Skip to content

Commit ed32b19

Browse files
authored
Bump PHPStan 2.1.26 and fixes phpstan notice (rectorphp#7296)
* Bump PHPStan 2.1.26 and fixes phpstan notice * Fix on PropertyFetchTypeResolver: on PropertyFetch, use hasInstanceProperty() and hasInstanceProperty() * Fix to use hasStaticProperty() on ConvertStaticToSelfRector * Fix to use hasInstanceProperty() on MissingPropertiesResolver as locate property fetch name * Fix
1 parent b5e58fe commit ed32b19

8 files changed

Lines changed: 10 additions & 10 deletions

File tree

build/target-repository/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"require": {
1111
"php": "^7.4|^8.0",
12-
"phpstan/phpstan": "^2.1.18"
12+
"phpstan/phpstan": "^2.1.26"
1313
},
1414
"autoload": {
1515
"files": [

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"ocramius/package-versions": "^2.10",
2525
"ondram/ci-detector": "^4.2",
2626
"phpstan/phpdoc-parser": "^2.2",
27-
"phpstan/phpstan": "^2.1.18",
27+
"phpstan/phpstan": "^2.1.26",
2828
"react/event-loop": "^1.5",
2929
"react/promise": "^3.2",
3030
"react/socket": "^1.16",

rules/CodeQuality/NodeAnalyzer/MissingPropertiesResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function resolve(Class_ $class, ClassReflection $classReflection, array $
3434
}
3535

3636
// 2. is part of class docblock or another magic, skip it
37-
if ($classReflection->hasProperty($definedPropertyWithType->getName())) {
37+
if ($classReflection->hasInstanceProperty($definedPropertyWithType->getName())) {
3838
continue;
3939
}
4040

rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function shouldSkip(
143143
// native members.
144144
$hasMember = match (true) {
145145
$node instanceof StaticPropertyFetch => $isFinal
146-
? $classReflection->hasProperty($name)
146+
? $classReflection->hasStaticProperty($name)
147147
: $classReflection->hasNativeProperty($name),
148148
$node instanceof StaticCall => $isFinal
149149
? $classReflection->hasMethod($name)
@@ -157,7 +157,7 @@ private function shouldSkip(
157157

158158
$reflection = match (true) {
159159
$node instanceof StaticPropertyFetch => $isFinal
160-
? $classReflection->getProperty($name, $scope)
160+
? $classReflection->getStaticProperty($name)
161161
: $classReflection->getNativeProperty($name),
162162
$node instanceof StaticCall => $isFinal
163163
? $classReflection->getMethod($name, $scope)

rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function refactor(Node $node): ?Node
131131
continue;
132132
}
133133

134-
if (! $classReflection->hasProperty($propertyFetchName) || $classReflection->isBuiltin()) {
134+
if (! $classReflection->hasInstanceProperty($propertyFetchName) || $classReflection->isBuiltin()) {
135135
$newNodes[] = $this->replaceToPropertyExistsWithNullCheck(
136136
$issetExpr->var,
137137
$propertyFetchName,

rules/Privatization/Guard/ParentPropertyLookupGuard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function isFoundInMethodStmts(array $stmts, string $propertyName, string
128128
private function isGuardedByParents(array $parentClassReflections, string $propertyName, string $className): bool
129129
{
130130
foreach ($parentClassReflections as $parentClassReflection) {
131-
if ($parentClassReflection->hasProperty($propertyName)) {
131+
if ($parentClassReflection->hasInstanceProperty($propertyName) || $parentClassReflection->hasStaticProperty($propertyName)) {
132132
return false;
133133
}
134134

src/NodeManipulator/PropertyManipulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function isUsedByTrait(ClassReflection $classReflection, string $property
155155
public function hasTraitWithSamePropertyOrWritten(ClassReflection $classReflection, string $propertyName): bool
156156
{
157157
foreach ($classReflection->getTraits() as $traitUse) {
158-
if ($traitUse->hasProperty($propertyName)) {
158+
if ($traitUse->hasInstanceProperty($propertyName) || $traitUse->hasStaticProperty($propertyName)) {
159159
return true;
160160
}
161161

src/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function getVendorPropertyFetchType(PropertyFetch $propertyFetch): Type
8282
}
8383

8484
$classReflection = $this->reflectionProvider->getClass($varType->getClassName());
85-
if (! $classReflection->hasProperty($propertyName)) {
85+
if (! $classReflection->hasInstanceProperty($propertyName)) {
8686
return new MixedType();
8787
}
8888

@@ -91,7 +91,7 @@ private function getVendorPropertyFetchType(PropertyFetch $propertyFetch): Type
9191
return new MixedType();
9292
}
9393

94-
$extendedPropertyReflection = $classReflection->getProperty($propertyName, $propertyFetchScope);
94+
$extendedPropertyReflection = $classReflection->getInstanceProperty($propertyName, $propertyFetchScope);
9595

9696
return $extendedPropertyReflection->getReadableType();
9797
}

0 commit comments

Comments
 (0)