Skip to content

Commit ab4fa10

Browse files
Review
1 parent 622b5f8 commit ab4fa10

File tree

6 files changed

+15
-26
lines changed

6 files changed

+15
-26
lines changed

src/Dependency/DependencyResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function resolveDependencies(Node $node, Scope $scope): NodeDependencies
378378
if ($this->reflectionProvider->hasClass($className)) {
379379
$propertyClassReflection = $this->reflectionProvider->getClass($className);
380380
if ($propertyClassReflection->hasStaticProperty($node->name->toString())) {
381-
$propertyReflection = $propertyClassReflection->getStaticProperty($node->name->toString(), $scope);
381+
$propertyReflection = $propertyClassReflection->getStaticProperty($node->name->toString());
382382
$this->addClassToDependencies($propertyReflection->getDeclaringClass()->getName(), $dependenciesReflections);
383383
}
384384
}

src/Reflection/ClassReflection.php

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -816,35 +816,24 @@ public function getInstanceProperty(string $propertyName, ClassMemberAccessAnswe
816816
return $this->instanceProperties[$key];
817817
}
818818

819-
public function getStaticProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
819+
public function getStaticProperty(string $propertyName): ExtendedPropertyReflection
820820
{
821821
$key = $propertyName;
822-
if ($scope->isInClass()) {
823-
$key = sprintf('%s-%s', $key, $scope->getClassReflection()->getCacheKey());
824-
}
825-
826-
if (!isset($this->staticProperties[$key])) {
827-
if ($this->getPhpExtension()->hasStaticProperty($this, $propertyName)) {
828-
$property = $this->wrapExtendedProperty($this->getPhpExtension()->getStaticProperty($this, $propertyName));
829-
if ($scope->canReadProperty($property)) {
830-
return $this->staticProperties[$key] = $property;
831-
}
832-
$this->staticProperties[$key] = $property;
833-
}
822+
if (isset($this->staticProperties[$key])) {
823+
return $this->staticProperties[$key];
834824
}
835825

836-
if (!isset($this->staticProperties[$key])) {
837-
if ($this->requireExtendsPropertiesClassReflectionExtension->hasStaticProperty($this, $propertyName)) {
838-
$property = $this->requireExtendsPropertiesClassReflectionExtension->getStaticProperty($this, $propertyName);
839-
$this->staticProperties[$key] = $property;
840-
}
826+
if ($this->getPhpExtension()->hasStaticProperty($this, $propertyName)) {
827+
$property = $this->wrapExtendedProperty($this->getPhpExtension()->getStaticProperty($this, $propertyName));
828+
return $this->staticProperties[$key] = $property;
841829
}
842830

843-
if (!isset($this->staticProperties[$key])) {
844-
throw new MissingPropertyFromReflectionException($this->getName(), $propertyName);
831+
if ($this->requireExtendsPropertiesClassReflectionExtension->hasStaticProperty($this, $propertyName)) {
832+
$property = $this->requireExtendsPropertiesClassReflectionExtension->getStaticProperty($this, $propertyName);
833+
return $this->staticProperties[$key] = $property;
845834
}
846835

847-
return $this->staticProperties[$key];
836+
throw new MissingPropertyFromReflectionException($this->getName(), $propertyName);
848837
}
849838

850839
public function hasNativeProperty(string $propertyName): bool

src/Rules/Properties/AccessStaticPropertiesRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
204204

205205
while ($parentClassReflection !== null) {
206206
if ($parentClassReflection->hasStaticProperty($name)) {
207-
if ($scope->canReadProperty($parentClassReflection->getStaticProperty($name, $scope))) {
207+
if ($scope->canReadProperty($parentClassReflection->getStaticProperty($name))) {
208208
return [];
209209
}
210210
return [

src/Type/ObjectType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
395395
throw new ClassNotFoundException($this->className);
396396
}
397397

398-
$property = $nakedClassReflection->getStaticProperty($propertyName, $scope);
398+
$property = $nakedClassReflection->getStaticProperty($propertyName);
399399

400400
$ancestor = $this->getAncestorWithClassName($property->getDeclaringClass()->getName());
401401
$resolvedClassReflection = null;

tests/PHPStan/Reflection/Annotations/DeprecatedAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testDeprecatedAnnotations(bool $deprecated, string $className, ?
124124
}
125125

126126
foreach ($deprecatedAnnotations['staticProperty'] ?? [] as $propertyName => $deprecatedMessage) {
127-
$propertyAnnotation = $class->getStaticProperty($propertyName, $scope);
127+
$propertyAnnotation = $class->getStaticProperty($propertyName);
128128
$this->assertSame($deprecated, $propertyAnnotation->isDeprecated()->yes());
129129
$this->assertSame($deprecatedMessage, $propertyAnnotation->getDeprecatedDescription());
130130
}

tests/PHPStan/Reflection/Annotations/InternalAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function testInternalAnnotations(bool $internal, string $className, array
146146
}
147147

148148
foreach ($internalAnnotations['staticProperty'] ?? [] as $propertyName) {
149-
$propertyAnnotation = $class->getStaticProperty($propertyName, $scope);
149+
$propertyAnnotation = $class->getStaticProperty($propertyName);
150150
$this->assertSame($internal, $propertyAnnotation->isInternal()->yes());
151151
}
152152

0 commit comments

Comments
 (0)