From aa681c7c1fb6bf51f36c60b5c0a31ff2c4dbbf75 Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Wed, 17 Aug 2022 23:49:01 +0200 Subject: [PATCH 1/8] Change branch alias to 0.5.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ed9a136..5dba469 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.4.x-dev" + "dev-master": "0.5.x-dev" }, "phpstan": { "includes": [ From ca661fe6b9054b560300925527b16a3a3ae61fae Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Wed, 17 Aug 2022 23:49:45 +0200 Subject: [PATCH 2/8] Drop official support for php 7.3 --- .github/workflows/main.yml | 4 ++-- Makefile | 10 +++++----- composer.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c15006..6158b11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: ['7.3', '7.4', '8.0'] + php: ['7.4', '8.0'] steps: - name: "Checkout" @@ -44,7 +44,7 @@ jobs: strategy: matrix: - php: ['7.3', '7.4', '8.0'] + php: ['7.4', '8.0'] steps: - name: "Checkout" diff --git a/Makefile b/Makefile index 022c819..c9946f8 100644 --- a/Makefile +++ b/Makefile @@ -11,16 +11,16 @@ test: $(MAKE) fmt-check phpstan: - docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi analyse + docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d memory_limit=-1 bin/phpstan --ansi analyse phpstan-clear-cache: - docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache + docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache phpunit: - docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml + docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml fmt-check: - docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests + docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests fmt: - docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests + docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests diff --git a/composer.json b/composer.json index 5dba469..9d59ee1 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": ">=7.3|^8.0", + "php": ">=7.4|^8.0", "phpstan/phpstan": "^1.0" }, "require-dev": { From e04a913841917e5314033e84f37014daed352b0a Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Wed, 17 Aug 2022 23:50:22 +0200 Subject: [PATCH 3/8] Remove unused import --- tests/Bonami/Collection/Phpstan/LazyListTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Bonami/Collection/Phpstan/LazyListTest.php b/tests/Bonami/Collection/Phpstan/LazyListTest.php index 23789be..a8cd5a3 100644 --- a/tests/Bonami/Collection/Phpstan/LazyListTest.php +++ b/tests/Bonami/Collection/Phpstan/LazyListTest.php @@ -4,7 +4,6 @@ namespace Bonami\Collection\Phpstan; -use ArrayIterator; use Bonami\Collection\LazyList; use PHPUnit\Framework\TestCase; From 3e92b8de177635722b522bee846be28ee7c28811 Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Wed, 17 Aug 2022 23:50:32 +0200 Subject: [PATCH 4/8] Allow usage of arrow functions --- ruleset.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/ruleset.xml b/ruleset.xml index de69974..4e268e8 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -59,7 +59,6 @@ - From 31a40c85bdaf18d0ee2836ccfc944758b0c351fd Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Wed, 17 Aug 2022 23:52:19 +0200 Subject: [PATCH 5/8] Introduce support for type narrowing for filter --- extension.neon | 16 ++- src/Bonami/Collection/Phpstan/Helpers.php | 33 ++++++ .../IterableFilterTypeNarrowingExtension.php | 110 ++++++++++++++++++ .../Collection/Phpstan/ArrayListTest.php | 42 +++++++ .../Collection/Phpstan/LazyListTest.php | 19 +++ 5 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 src/Bonami/Collection/Phpstan/Helpers.php create mode 100644 src/Bonami/Collection/Phpstan/IterableFilterTypeNarrowingExtension.php diff --git a/extension.neon b/extension.neon index 591b3aa..633f63a 100644 --- a/extension.neon +++ b/extension.neon @@ -1,4 +1,16 @@ services: + - + class: Bonami\Collection\Phpstan\IterableFilterTypeNarrowingExtension + arguments: + - 'Bonami\Collection\ArrayList' + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - + class: Bonami\Collection\Phpstan\IterableFilterTypeNarrowingExtension + arguments: + - 'Bonami\Collection\LazyList' + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension - class: Bonami\Collection\Phpstan\ArrayListWithoutNullsReturnTypeExtension tags: @@ -10,7 +22,7 @@ services: - phpstan.broker.dynamicStaticMethodReturnTypeExtension - class: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension - factory: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension::forMethods('Bonami\Collection\ArrayList', ['uniqueBy', 'unique', 'union', 'filter', 'sort', 'take', 'slice', 'minus', 'minusOne', 'concat', 'intersect', 'reverse']) + factory: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension::forMethods('Bonami\Collection\ArrayList', ['uniqueBy', 'unique', 'union', 'sort', 'take', 'slice', 'minus', 'minusOne', 'concat', 'intersect', 'reverse']) tags: - phpstan.broker.dynamicMethodReturnTypeExtension - @@ -30,7 +42,7 @@ services: - phpstan.broker.dynamicStaticMethodReturnTypeExtension - class: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension - factory: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension::forMethods('Bonami\Collection\LazyList', ['take', 'filter', 'dropWhile', 'drop', 'concat', 'add', 'insertOnPosition']) + factory: Bonami\Collection\Phpstan\LateStaticBindingMethodReturnTypeExtension::forMethods('Bonami\Collection\LazyList', ['take', 'dropWhile', 'drop', 'concat', 'add', 'insertOnPosition']) tags: - phpstan.broker.dynamicMethodReturnTypeExtension - diff --git a/src/Bonami/Collection/Phpstan/Helpers.php b/src/Bonami/Collection/Phpstan/Helpers.php new file mode 100644 index 0000000..fcdcd97 --- /dev/null +++ b/src/Bonami/Collection/Phpstan/Helpers.php @@ -0,0 +1,33 @@ +expr; + } + + if (!($closure instanceof Expr\Closure)) { + return null; + } + + if (!isset($closure->stmts[0])) { + return null; + } + + if (!($closure->stmts[0] instanceof Return_)) { + return null; + } + + return $closure->stmts[0]->expr; + } +} diff --git a/src/Bonami/Collection/Phpstan/IterableFilterTypeNarrowingExtension.php b/src/Bonami/Collection/Phpstan/IterableFilterTypeNarrowingExtension.php new file mode 100644 index 0000000..92a9ded --- /dev/null +++ b/src/Bonami/Collection/Phpstan/IterableFilterTypeNarrowingExtension.php @@ -0,0 +1,110 @@ +class = $class; + } + + public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void + { + $this->typeSpecifier = $typeSpecifier; + } + + public function getClass(): string + { + return $this->class; + } + + public function isMethodSupported(MethodReflection $methodReflection): bool + { + return $methodReflection->getName() === 'filter'; + } + + public function getTypeFromMethodCall( + MethodReflection $methodReflection, + MethodCall $methodCall, + Scope $scope + ): ?Type { + $type = $scope->getType($methodCall->var); + + if (!$type instanceof GenericObjectType) { + return $type; + } + + $args = $methodCall->getArgs(); + if (!array_key_exists(0, $args)) { + return $type; + } + + $arg = $methodCall->getArgs()[0]->value; + if (!($arg instanceof Closure || $arg instanceof ArrowFunction)) { + return $type; + } + + $expr = Helpers::getSimpleClosureExpression($arg); + if ($expr !== null) { + $specifiedTypes = $this->typeSpecifier + ->specifyTypesInCondition($scope, $expr, TypeSpecifierContext::createTruthy()); + + if (count($specifiedTypes->getSureTypes()) !== 0) { + return new GenericObjectType( + $methodReflection->getDeclaringClass()->getName(), + array_values(array_map( + static function (array $pair) use ($type) { + return TypeCombinator::intersect($type->getIterableValueType(), $pair[1]); + }, + $specifiedTypes->getSureTypes(), + )) + ); + } + + if (count($specifiedTypes->getSureNotTypes()) !== 0) { + return new GenericObjectType( + $methodReflection->getDeclaringClass()->getName(), + array_values(array_map( + static function (array $pair) use ($type) { + return TypeCombinator::remove($type->getIterableValueType(), $pair[1]); + }, + $specifiedTypes->getSureNotTypes(), + )) + ); + } + return $type; + } + + return $type; + } +} diff --git a/tests/Bonami/Collection/Phpstan/ArrayListTest.php b/tests/Bonami/Collection/Phpstan/ArrayListTest.php index 939a627..95bd2c3 100644 --- a/tests/Bonami/Collection/Phpstan/ArrayListTest.php +++ b/tests/Bonami/Collection/Phpstan/ArrayListTest.php @@ -157,6 +157,33 @@ public function testWithoutNullsReturnType(): void self::assertInstanceOf(FooArrayList::class, $concreteList); } + public function testItShouldFilterNullsFromGenericType(): void + { + $withNulls = ArrayList::fromIterable([new Foo(), null]); + $withoutNulls = $withNulls->filter(static function (?Foo $foo): bool { + return $foo !== null; + }); + $this->requireArrayListOfFoo($withoutNulls); + $this->requireArrayListOfFoo($withNulls->filter(static function (?Foo $foo): bool { + return $foo !== null; + })); + $this->requireArrayListOfFoo($withNulls->filter(static fn (?Foo $foo): bool => $foo !== null)); + self::assertInstanceOf(ArrayList::class, $withoutNulls); + + $fooList = FooArrayList::fromIterable([new Foo(), null]) + ->filter(static fn (?Foo $foo) => $foo !== null); + + $this->requireFooList($fooList); + } + + public function testItShouldFilterTypesFromUnions(): void + { + $intsAndStrings = ArrayList::fromIterable([1, 'string']); + $this->requireIntsAndStrings($intsAndStrings); + $this->requireInts($intsAndStrings->filter(fn ($x) => is_int($x))); + $this->requireStrings($intsAndStrings->filter(fn ($x) => !is_int($x))); + } + public function testMinusReturnType(): void { $genericList = ArrayList::fromIterable([new Foo()])->minus([new Foo()]); @@ -250,4 +277,19 @@ public function requireMapArrayListByFoo(Map $list): void public function requireMapFooArrayListByFoo(Map $list): void { } + + /** @param ArrayList $intsAndStrings */ + private function requireIntsAndStrings(ArrayList $intsAndStrings): void + { + } + + /** @param ArrayList $intsAndStrings */ + private function requireInts(ArrayList $intsAndStrings): void + { + } + + /** @param ArrayList $intsAndStrings */ + private function requireStrings(ArrayList $intsAndStrings): void + { + } } diff --git a/tests/Bonami/Collection/Phpstan/LazyListTest.php b/tests/Bonami/Collection/Phpstan/LazyListTest.php index a8cd5a3..3a71bcb 100644 --- a/tests/Bonami/Collection/Phpstan/LazyListTest.php +++ b/tests/Bonami/Collection/Phpstan/LazyListTest.php @@ -79,6 +79,25 @@ public function testFilterReturnType(): void self::assertInstanceOf(FooLazyList::class, $concreteList); } + public function testItShouldNarrowTypesAfterFilter(): void + { + $withNulls = LazyList::fromIterable([new Foo(), null]); + $withoutNulls = $withNulls->filter(static function (?Foo $foo): bool { + return $foo !== null; + }); + $this->requireLazyListOfFoo($withoutNulls); + $this->requireLazyListOfFoo($withNulls->filter(static function (?Foo $foo): bool { + return $foo !== null; + })); + $this->requireLazyListOfFoo($withNulls->filter(static fn (?Foo $foo): bool => $foo !== null)); + self::assertInstanceOf(LazyList::class, $withoutNulls); + + $fooList = FooLazyList::fromIterable([new Foo(), null]) + ->filter(static fn (?Foo $foo) => $foo !== null); + + $this->requireFooList($fooList); + } + public function testDropWhileReturnType(): void { $tautology = static function () { From 1dbbf291060f7923bd41431d75212f7473dfcdcc Mon Sep 17 00:00:00 2001 From: Milan Donef Date: Tue, 11 Feb 2025 11:04:39 +0100 Subject: [PATCH 6/8] chore! drop support for php < 8.1 and upgrade to phpstan 2.0 --- .github/workflows/main.yml | 6 +++--- Makefile | 10 +++++----- composer.json | 7 ++++--- phpstan.neon | 2 ++ .../Phpstan/GroupByMethodReturnTypeExtension.php | 9 +++++---- .../LateStaticBindingMethodReturnTypeExtension.php | 10 +++++----- ...taticBindingStaticMethodReturnTypeExtension.php | 14 +++++++------- tests/Bonami/Collection/Phpstan/MapTest.php | 1 + 8 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6158b11..cd336ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: ['7.4', '8.0'] + php: ['8.1','8.2','8.3','8.4'] steps: - name: "Checkout" @@ -44,7 +44,7 @@ jobs: strategy: matrix: - php: ['7.4', '8.0'] + php: ['8.1','8.2','8.3','8.4'] steps: - name: "Checkout" @@ -75,7 +75,7 @@ jobs: strategy: matrix: - php: ['8.0'] + php: ['8.1'] steps: - name: "Checkout" diff --git a/Makefile b/Makefile index c9946f8..ab54308 100644 --- a/Makefile +++ b/Makefile @@ -11,16 +11,16 @@ test: $(MAKE) fmt-check phpstan: - docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d memory_limit=-1 bin/phpstan --ansi analyse + docker run -it --rm -v ${PWD}:/app -w /app php:8.4-cli-alpine php -d memory_limit=-1 bin/phpstan --ansi analyse phpstan-clear-cache: - docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache + docker run -it --rm -v ${PWD}:/app -w /app php:8.4-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache phpunit: - docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml + docker run -it --rm -v ${PWD}:/app -w /app php:8.4-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml fmt-check: - docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests + docker run -it --rm -v ${PWD}:/app -w /app php:8.4-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests fmt: - docker run -it --rm -v ${PWD}:/app -w /app php:7.4-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests + docker run -it --rm -v ${PWD}:/app -w /app php:8.4-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests diff --git a/composer.json b/composer.json index 9d59ee1..ef1d79a 100644 --- a/composer.json +++ b/composer.json @@ -1,4 +1,5 @@ { + "version": "0.5.0", "name": "bonami/phpstan-collections", "type": "phpstan-extension", "description": "Phpstan extension for bonami/collections library", @@ -10,8 +11,8 @@ } ], "require": { - "php": ">=7.4|^8.0", - "phpstan/phpstan": "^1.0" + "php": "^8.1", + "phpstan/phpstan": "^2.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -19,7 +20,7 @@ "phpunit/phpunit": "^9.4.2", "slevomat/coding-standard": "^6.4.1", "squizlabs/php_codesniffer": "^3.5.0", - "bonami/collections": "^0.4.5" + "bonami/collections": "0.6.0" }, "config": { "bin-dir": "bin", diff --git a/phpstan.neon b/phpstan.neon index 90931bc..0ee8d28 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,8 @@ includes: - extension.neon - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: + ignoreErrors: + - '~Doing instanceof PHPStan\\Type\\Generic\\GenericObjectType is error-prone and deprecated~' reportUnmatchedIgnoredErrors: true level: 9 paths: diff --git a/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php b/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php index 913e840..3c1a4c9 100644 --- a/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php +++ b/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php @@ -9,7 +9,6 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; -use PHPStan\Type\CallableType; use PHPStan\Type\ClosureType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Generic\GenericObjectType; @@ -18,9 +17,10 @@ class GroupByMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var string */ - private $class; + /** @var class-string */ + private string $class; + /** @param class-string $class */ public function __construct(string $class) { $this->class = $class; @@ -43,8 +43,9 @@ public function getTypeFromMethodCall( ): Type { $arg = $methodCall->args[0]; assert($arg instanceof Arg); + $closure = $scope->getType($arg->value); - assert($closure instanceof ClosureType || $closure instanceof CallableType); + assert($closure instanceof ClosureType); $listType = $scope->getType($methodCall->var); diff --git a/src/Bonami/Collection/Phpstan/LateStaticBindingMethodReturnTypeExtension.php b/src/Bonami/Collection/Phpstan/LateStaticBindingMethodReturnTypeExtension.php index 3162ce4..b575fb0 100644 --- a/src/Bonami/Collection/Phpstan/LateStaticBindingMethodReturnTypeExtension.php +++ b/src/Bonami/Collection/Phpstan/LateStaticBindingMethodReturnTypeExtension.php @@ -12,14 +12,14 @@ class LateStaticBindingMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var string */ - private $class; + /** @var class-string */ + private string $class; /** @var array */ - private $methods; + private array $methods; /** - * @param string $class + * @param class-string $class * @param array $methods */ private function __construct(string $class, array $methods) @@ -29,7 +29,7 @@ private function __construct(string $class, array $methods) } /** - * @param string $class + * @param class-string $class * @param array $methods */ public static function forMethods(string $class, array $methods): self diff --git a/src/Bonami/Collection/Phpstan/LateStaticBindingStaticMethodReturnTypeExtension.php b/src/Bonami/Collection/Phpstan/LateStaticBindingStaticMethodReturnTypeExtension.php index 9e50026..8b96ed3 100644 --- a/src/Bonami/Collection/Phpstan/LateStaticBindingStaticMethodReturnTypeExtension.php +++ b/src/Bonami/Collection/Phpstan/LateStaticBindingStaticMethodReturnTypeExtension.php @@ -17,14 +17,14 @@ class LateStaticBindingStaticMethodReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension { - /** @var string */ - private $class; + /** @var class-string */ + private string $class; /** @var array */ - private $methods; + private array $methods; /** - * @param string $class + * @param class-string $class * @param array $methods */ private function __construct(string $class, array $methods) @@ -34,7 +34,7 @@ private function __construct(string $class, array $methods) } /** - * @param string $class + * @param class-string $class * @param array $methods */ public static function forMethods(string $class, array $methods): self @@ -60,8 +60,8 @@ public function getTypeFromStaticMethodCall( $calledClassExpr = $methodCall->class; if ($calledClassExpr instanceof PropertyFetch) { $type = $scope->getType($calledClassExpr); - if ($type instanceof GenericClassStringType) { - return $type->getGenericType(); + if ($type->isClassString()->yes()) { + return $type->getClassStringObjectType(); } } diff --git a/tests/Bonami/Collection/Phpstan/MapTest.php b/tests/Bonami/Collection/Phpstan/MapTest.php index 04a8222..06b77d4 100644 --- a/tests/Bonami/Collection/Phpstan/MapTest.php +++ b/tests/Bonami/Collection/Phpstan/MapTest.php @@ -12,6 +12,7 @@ class MapTest extends TestCase public function testFromAssociativeArrayReturnType(): void { $genericList = Map::fromAssociativeArray([1 => new Foo()]); + // @phpstan-ignore-next-line $this->requireMapOfFoo($genericList); self::assertInstanceOf(Map::class, $genericList); From 1a2021a1ab22a0182c6386d0dc8aa62fd312082c Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Thu, 20 Mar 2025 19:25:53 +0100 Subject: [PATCH 7/8] refactor: use call site variance instead of supression --- tests/Bonami/Collection/Phpstan/MapTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Bonami/Collection/Phpstan/MapTest.php b/tests/Bonami/Collection/Phpstan/MapTest.php index 06b77d4..42125ba 100644 --- a/tests/Bonami/Collection/Phpstan/MapTest.php +++ b/tests/Bonami/Collection/Phpstan/MapTest.php @@ -12,7 +12,6 @@ class MapTest extends TestCase public function testFromAssociativeArrayReturnType(): void { $genericList = Map::fromAssociativeArray([1 => new Foo()]); - // @phpstan-ignore-next-line $this->requireMapOfFoo($genericList); self::assertInstanceOf(Map::class, $genericList); @@ -188,7 +187,7 @@ public function testSortValuesReturnType(): void self::assertInstanceOf(FooMap::class, $concreteList); } - /** @phpstan-param Map $list */ + /** @phpstan-param Map $list */ public function requireMapOfFoo(Map $list): void { } From 3985a3c1f35f6398d0a249eb9852809fd1963359 Mon Sep 17 00:00:00 2001 From: Jan Machala Date: Thu, 20 Mar 2025 19:30:26 +0100 Subject: [PATCH 8/8] chore: update GH pipeline --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd336ef..1e43cd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: extensions: "json, dom, mbstring" - name: "Cache dependencies" - uses: "actions/cache@v1.1.2" + uses: "actions/cache@v4" with: path: "~/.composer/cache" key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}" @@ -57,7 +57,7 @@ jobs: extensions: "json, dom, mbstring" - name: "Cache dependencies" - uses: "actions/cache@v1.1.2" + uses: "actions/cache@v4" with: path: "~/.composer/cache" key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}" @@ -91,7 +91,7 @@ jobs: run: "composer validate" - name: "Cache dependencies" - uses: "actions/cache@v1.1.2" + uses: "actions/cache@v4" with: path: "~/.composer/cache" key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}"