Skip to content

Commit

Permalink
Upgrade phpstan (1.9) and remove psalm (#69)
Browse files Browse the repository at this point in the history
* Upgrade phpstan (1.9) and remove psalm

* Update readme
  • Loading branch information
akondas committed Dec 11, 2022
1 parent 4567ce0 commit 1c866a3
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 210 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ At the moment, in the experimental phase.

**[Documentation](https://munusphp.github.io/docs/start)**

Due to the lack of generic types, Munus achieves genericity with the help of [Psalm](https://github.com/vimeo/psalm) `template` annotation.
Due to the lack of generic types, Munus achieves genericity with the help of [PHPStan](https://phpstan.org/blog/generics-in-php-using-phpdocs) `template` annotation.

Stream example: find the sum of the first ten squares of even numbers
```php
Expand Down
7 changes: 1 addition & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.9",
"phpunit/phpunit": "^8.4",
"vimeo/psalm": "^4.9",
"phpstan/phpstan": "^0.12",
"psalm/plugin-phpunit": "^0.15"
"phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-4": {
Expand All @@ -44,9 +42,6 @@
"phpstan": [
"phpstan analyse src tests --level=4"
],
"psalm": [
"psalm --show-info=false"
],
"phpunit": [
"phpunit --color=always"
],
Expand Down
49 changes: 0 additions & 49 deletions psalm.baseline.xml

This file was deleted.

151 changes: 0 additions & 151 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Collection/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function reduce(callable $operation)
}

$accumulator = $this->next();
while ($this->hasNext()) {
while ($this->hasNext()) { // @phpstan-ignore-line
$accumulator = $operation($accumulator, $this->next());
}

Expand Down
5 changes: 4 additions & 1 deletion src/Collection/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public function get(): Option
}
$key = func_get_arg(0);

return isset($this->map[$key]) ? Option::some($this->map[$key]) : Option::none();
/** @var Option<V> $option */
$option = isset($this->map[$key]) ? Option::some($this->map[$key]) : Option::none();

return $option;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Control/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ abstract class Option extends Value
*/
public static function of($value): self
{
return $value === null ? self::none() : self::some($value);
/** @var Option<U> $option */
$option = $value === null ? self::none() : self::some($value);

return $option;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/Collection/IteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ public function testCompositeIterator(): void
self::assertEquals(4, $iterator->next());
self::assertFalse($iterator->hasNext());
}

public function testReduce(): void
{
$iterator = Iterator::of(1, 2, 3);

self::assertEquals(6, $iterator->reduce(fn (int $a, int $b) => $a + $b));
}
}

0 comments on commit 1c866a3

Please sign in to comment.