diff --git a/build/phpstan.neon b/build/phpstan.neon index 33eb00a154..4454a9d73c 100644 --- a/build/phpstan.neon +++ b/build/phpstan.neon @@ -75,7 +75,6 @@ parameters: - '#^Dynamic call to static method PHPUnit\\Framework\\\S+\(\)\.$#' - '#should be contravariant with parameter \$node \(PhpParser\\Node\) of method PHPStan\\Rules\\Rule::processNode\(\)$#' - '#Variable property access on PhpParser\\Node#' - - '#Test::data[a-zA-Z0-9_]+\(\) return type has no value type specified in iterable type#' - identifier: shipmonk.deadMethod message: '#^Unused .*?Factory::create#' # likely used in DIC diff --git a/composer.json b/composer.json index cd308d1bff..8e4e11ea51 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "php-parallel-lint/php-parallel-lint": "^1.2.0", "phpstan/phpstan-deprecation-rules": "^2.0.2", "phpstan/phpstan-nette": "^2.0", - "phpstan/phpstan-phpunit": "^2.0.7", + "phpstan/phpstan-phpunit": "^2.0.8", "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^11.5.23", "shipmonk/composer-dependency-analyser": "^1.5", diff --git a/composer.lock b/composer.lock index c5e0f72e21..2ae210b81f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "287b52923d083c465ffea8ba6a6441fb", + "content-hash": "7a8129b9f491fdfb4736ccea93ce4b01", "packages": [ { "name": "clue/ndjson-react", @@ -4777,17 +4777,17 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "9a9b161baee88a5f5c58d816943cff354ff233dc" + "reference": "033f6906f7abc5acbe3c81b642ad9e363e1bb4a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/9a9b161baee88a5f5c58d816943cff354ff233dc", - "reference": "9a9b161baee88a5f5c58d816943cff354ff233dc", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/033f6906f7abc5acbe3c81b642ad9e363e1bb4a0", + "reference": "033f6906f7abc5acbe3c81b642ad9e363e1bb4a0", "shasum": "" }, "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.18" + "phpstan/phpstan": "^2.1.32" }, "conflict": { "phpunit/phpunit": "<7.0" @@ -4823,7 +4823,7 @@ "issues": "https://github.com/phpstan/phpstan-phpunit/issues", "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.x" }, - "time": "2025-07-13T11:31:46+00:00" + "time": "2025-10-29T08:37:09+00:00" }, { "name": "phpstan/phpstan-strict-rules", diff --git a/src/Type/ClosureTypeFactory.php b/src/Type/ClosureTypeFactory.php index ef4d81be75..a702909072 100644 --- a/src/Type/ClosureTypeFactory.php +++ b/src/Type/ClosureTypeFactory.php @@ -46,7 +46,7 @@ public function __construct( } /** - * @param Closure(): mixed $closure + * @param Closure(mixed): mixed $closure */ public function fromClosureObject(Closure $closure): ClosureType { diff --git a/tests/PHPStan/Command/CommandHelperTest.php b/tests/PHPStan/Command/CommandHelperTest.php index 5ecf380ddb..9b3813e054 100644 --- a/tests/PHPStan/Command/CommandHelperTest.php +++ b/tests/PHPStan/Command/CommandHelperTest.php @@ -285,7 +285,7 @@ public static function dataParameters(): array } /** - * @param array $expectedParameters + * @param array $expectedParameters * @throws InceptionNotSuccessfulException */ #[DataProvider('dataParameters')] diff --git a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php index 488d2ebcd6..4e697459e8 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php @@ -19,7 +19,6 @@ public static function dataFormatterOutputProvider(): iterable 0, 0, '', - '', ]; yield [ diff --git a/tests/PHPStan/Reflection/BetterReflection/SourceLocator/OptimizedSingleFileSourceLocatorTest.php b/tests/PHPStan/Reflection/BetterReflection/SourceLocator/OptimizedSingleFileSourceLocatorTest.php index f8c0875f69..add5a684b7 100644 --- a/tests/PHPStan/Reflection/BetterReflection/SourceLocator/OptimizedSingleFileSourceLocatorTest.php +++ b/tests/PHPStan/Reflection/BetterReflection/SourceLocator/OptimizedSingleFileSourceLocatorTest.php @@ -235,7 +235,7 @@ public function testConstUnknown(string $constantName): void } /** - * @param class-string[] $expectedIdentifiers + * @param array $expectedIdentifiers */ #[DataProvider('dataForIdenifiersByType')] public function testLocateIdentifiersByType( diff --git a/tests/PHPStan/Reflection/ClassReflectionPropertyHooksTest.php b/tests/PHPStan/Reflection/ClassReflectionPropertyHooksTest.php index 80c75e06cf..3003fad564 100644 --- a/tests/PHPStan/Reflection/ClassReflectionPropertyHooksTest.php +++ b/tests/PHPStan/Reflection/ClassReflectionPropertyHooksTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Reflection; +use PHPStan\ShouldNotHappenException; use PHPStan\Testing\PHPStanTestCase; use PHPStan\Type\Generic\GenericObjectType; use PHPStan\Type\IntegerType; @@ -226,6 +227,9 @@ public static function dataPropertyHooks(): iterable ]; $specificFooGenerics = (new GenericObjectType('PropertyHooksTypes\\FooGenerics', [new IntegerType()]))->getClassReflection(); + if ($specificFooGenerics === null) { + throw new ShouldNotHappenException(); + } yield [ $specificFooGenerics, @@ -291,6 +295,9 @@ public static function dataPropertyHooks(): iterable ]; $specificFooGenericsConstructor = (new GenericObjectType('PropertyHooksTypes\\FooGenericsConstructor', [new IntegerType()]))->getClassReflection(); + if ($specificFooGenericsConstructor === null) { + throw new ShouldNotHappenException(); + } yield [ $specificFooGenericsConstructor, diff --git a/tests/PHPStan/Type/ClosureTypeFactoryTest.php b/tests/PHPStan/Type/ClosureTypeFactoryTest.php index 64ebdddb2f..e492febefc 100644 --- a/tests/PHPStan/Type/ClosureTypeFactoryTest.php +++ b/tests/PHPStan/Type/ClosureTypeFactoryTest.php @@ -63,7 +63,7 @@ public static function dataFromClosureObjectParameter(): array } /** - * @param Closure(): mixed $closure + * @param Closure(mixed): mixed $closure */ #[DataProvider('dataFromClosureObjectParameter')] public function testFromClosureObjectParameter(Closure $closure, int $index, string $type): void @@ -75,7 +75,7 @@ public function testFromClosureObjectParameter(Closure $closure, int $index, str } /** - * @param Closure(): mixed $closure + * @param Closure(mixed): mixed $closure */ private function getClosureType(Closure $closure): ClosureType { diff --git a/tests/PHPStan/Type/StringTypeTest.php b/tests/PHPStan/Type/StringTypeTest.php index a5630c1a30..3be9e03240 100644 --- a/tests/PHPStan/Type/StringTypeTest.php +++ b/tests/PHPStan/Type/StringTypeTest.php @@ -96,13 +96,15 @@ public static function dataIsSuperTypeOf(): array } #[DataProvider('dataIsSuperTypeOf')] - public function testIsSuperTypeOf(StringType $type, Type $otherType, TrinaryLogic $expectedResult): void + public function testIsSuperTypeOf(Type $stringType, Type $otherType, TrinaryLogic $expectedResult): void { - $actualResult = $type->isSuperTypeOf($otherType); + $this->assertInstanceOf(StringType::class, $stringType); + + $actualResult = $stringType->isSuperTypeOf($otherType); $this->assertSame( $expectedResult->describe(), $actualResult->describe(), - sprintf('%s -> isSuperTypeOf(%s)', $type->describe(VerbosityLevel::precise()), $otherType->describe(VerbosityLevel::precise())), + sprintf('%s -> isSuperTypeOf(%s)', $stringType->describe(VerbosityLevel::precise()), $otherType->describe(VerbosityLevel::precise())), ); } @@ -174,13 +176,15 @@ public static function dataAccepts(): iterable } #[DataProvider('dataAccepts')] - public function testAccepts(StringType $type, Type $otherType, TrinaryLogic $expectedResult): void + public function testAccepts(Type $stringType, Type $otherType, TrinaryLogic $expectedResult): void { - $actualResult = $type->accepts($otherType, true)->result; + $this->assertInstanceOf(StringType::class, $stringType); + + $actualResult = $stringType->accepts($otherType, true)->result; $this->assertSame( $expectedResult->describe(), $actualResult->describe(), - sprintf('%s -> accepts(%s)', $type->describe(VerbosityLevel::precise()), $otherType->describe(VerbosityLevel::precise())), + sprintf('%s -> accepts(%s)', $stringType->describe(VerbosityLevel::precise()), $otherType->describe(VerbosityLevel::precise())), ); } diff --git a/tests/PHPStan/Type/UnionTypeTest.php b/tests/PHPStan/Type/UnionTypeTest.php index d0ec27f619..f140f4ccfe 100644 --- a/tests/PHPStan/Type/UnionTypeTest.php +++ b/tests/PHPStan/Type/UnionTypeTest.php @@ -77,13 +77,15 @@ public static function dataIsCallable(): array } #[DataProvider('dataIsCallable')] - public function testIsCallable(UnionType $type, TrinaryLogic $expectedResult): void + public function testIsCallable(Type $unionType, TrinaryLogic $expectedResult): void { - $actualResult = $type->isCallable(); + $this->assertInstanceOf(UnionType::class, $unionType); + + $actualResult = $unionType->isCallable(); $this->assertSame( $expectedResult->describe(), $actualResult->describe(), - sprintf('%s -> isCallable()', $type->describe(VerbosityLevel::precise())), + sprintf('%s -> isCallable()', $unionType->describe(VerbosityLevel::precise())), ); } @@ -699,13 +701,15 @@ public static function dataIsScalar(): array } #[DataProvider('dataIsScalar')] - public function testIsScalar(UnionType $type, TrinaryLogic $expectedResult): void + public function testIsScalar(Type $unionType, TrinaryLogic $expectedResult): void { - $actualResult = $type->isScalar(); + $this->assertInstanceOf(UnionType::class, $unionType); + + $actualResult = $unionType->isScalar(); $this->assertSame( $expectedResult->describe(), $actualResult->describe(), - sprintf('%s -> isScalar()', $type->describe(VerbosityLevel::precise())), + sprintf('%s -> isScalar()', $unionType->describe(VerbosityLevel::precise())), ); }