diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c15006..7222968 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: ['8.0','8.1'] steps: - name: "Checkout" @@ -44,7 +44,7 @@ jobs: strategy: matrix: - php: ['7.3', '7.4', '8.0'] + php: ['8.0','8.1'] steps: - name: "Checkout" diff --git a/Makefile b/Makefile index 022c819..a0cee93 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:8.3-cli-alpine php -d error_reporting=-1 -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:8.3-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:8.3-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:8.3-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:8.3-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 ed9a136..222d15b 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ } ], "require": { - "php": ">=7.3|^8.0", - "phpstan/phpstan": "^1.0" + "php": ">=7.4|^8.0", + "phpstan/phpstan": "^2.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -19,7 +19,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": "dev-upgrade-to-phpstan2" }, "config": { "bin-dir": "bin", diff --git a/phpstan.neon b/phpstan.neon index 90931bc..82eb315 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,10 @@ includes: - extension.neon - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: + ignoreErrors: + - + identifier: phpstanApi.instanceofType + - '~Method .* should return class-string but returns string.~' reportUnmatchedIgnoredErrors: true level: 9 paths: diff --git a/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php b/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php index 913e840..017713f 100644 --- a/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php +++ b/src/Bonami/Collection/Phpstan/GroupByMethodReturnTypeExtension.php @@ -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/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);