Skip to content

Commit b9bd212

Browse files
Review
1 parent dcb3b72 commit b9bd212

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
@@ -815,35 +815,24 @@ public function getInstanceProperty(string $propertyName, ClassMemberAccessAnswe
815815
return $this->instanceProperties[$key];
816816
}
817817

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

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

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

846-
return $this->staticProperties[$key];
835+
throw new MissingPropertyFromReflectionException($this->getName(), $propertyName);
847836
}
848837

849838
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
@@ -408,7 +408,7 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
408408
throw new ClassNotFoundException($this->className);
409409
}
410410

411-
$property = $nakedClassReflection->getStaticProperty($propertyName, $scope);
411+
$property = $nakedClassReflection->getStaticProperty($propertyName);
412412

413413
$ancestor = $this->getAncestorWithClassName($property->getDeclaringClass()->getName());
414414
$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)