Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to PHPStan ^2.1.8 and change deprecated ClassReflection::isSubClassOf() to ClassReflection::is() #6775

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"require": {
"php": "^7.4|^8.0",
"phpstan/phpstan": "^2.1.7"
"phpstan/phpstan": "^2.1.8"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ocramius/package-versions": "^2.9",
"ondram/ci-detector": "^4.2",
"phpstan/phpdoc-parser": "^2.0.2",
"phpstan/phpstan": "^2.1.7",
"phpstan/phpstan": "^2.1.8",
"react/event-loop": "^1.5",
"react/promise": "^3.2",
"react/socket": "^1.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __invoke(
): ?string {
$fullyQualifiedClassName = (string) $nodeNameResolver->getName($class);
$classReflection = $reflectionProvider->getClass($fullyQualifiedClassName);
if (! $classReflection->isSubclassOf(Exception::class)) {
if (! $classReflection->is(Exception::class)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function collectTestMethodsUsesPrivateDataProvider(
Class_ $class,
array $classMethods
): array {
if (! $classReflection->isSubClassOf('PHPUnit\Framework\TestCase')) {
if (! $classReflection->is('PHPUnit\Framework\TestCase')) {
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function refactor(Node $node): ?Node
$classReflection = $scope->getClassReflection();

// skip PHPUnit calls, as they accept both self:: and $this-> formats
if ($classReflection->isSubclassOf('PHPUnit\Framework\TestCase')) {
if ($classReflection->is('PHPUnit\Framework\TestCase')) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private function shouldSkip(string $methodName, string $className, StaticCall $s
}

$reflection = $scope->getClassReflection();
if ($reflection instanceof ClassReflection && $reflection->isSubclassOf($className)) {
if ($reflection instanceof ClassReflection && $reflection->is($className)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function refactor(Node $node): ?Node
}

$currentClassReflection = $this->reflectionResolver->resolveClassReflection($node);
$isPDO = $currentClassReflection instanceof ClassReflection && $currentClassReflection->isSubclassOf('PDO');
$isPDO = $currentClassReflection instanceof ClassReflection && $currentClassReflection->is('PDO');

// It relies on phpstorm stubs that define 2 kind of query method for both php 7.4 and php 8.0
// @see https://github.com/JetBrains/phpstorm-stubs/blob/e2e898a29929d2f520fe95bdb2109d8fa895ba4a/PDO/PDO.php#L1096-L1126
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function refactor(Node $node): ?Node
}

$classReflection = $this->reflectionProvider->getClass($className);
if (! $classReflection->isSubclassOf('PHPUnit\Framework\TestCase')) {
if (! $classReflection->is('PHPUnit\Framework\TestCase')) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function refactor(Node $node): ?Node
}

foreach ($this->returnTypeChangedClassMethodReferences as $returnTypeChangedClassMethodReference) {
if (! $classReflection->isSubclassOf($returnTypeChangedClassMethodReference->getClass())) {
if (! $classReflection->is($returnTypeChangedClassMethodReference->getClass())) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ private function isInsideTestCaseClass(Scope $scope): bool
}

// is phpunit test case?
return $classReflection->isSubclassOf(ClassName::TEST_CASE_CLASS);
return $classReflection->is(ClassName::TEST_CASE_CLASS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ private function isClassReflectionType(ClassReflection $classReflection, string
return true;
}

return $classReflection->isSubclassOf($type);
return $classReflection->is($type);
}
}
2 changes: 1 addition & 1 deletion src/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function isMethodStaticCallOrClassMethodObjectType(Node $node, ObjectType
return true;
}

return $classReflection->isSubclassOf($objectType->getClassName());
return $classReflection->is($objectType->getClassName());
}

/**
Expand Down