Skip to content

Commit d1d7d4a

Browse files
committed
[BCB] Type::getProperty() now returns ExtendedPropertyReflection
1 parent 392f090 commit d1d7d4a

17 files changed

+32
-33
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,4 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
278278
* Remove `ConstantType` interface, use [`Type::isConstantValue()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isConstantValue) instead
279279
* `acceptsNamedArguments()` in `FunctionReflection`, `ExtendedMethodReflection` and `CallableParametersAcceptor` interfaces returns `TrinaryLogic` instead of `bool`
280280
* Remove `FunctionReflection::isFinal()`
281+
* [`Type::getProperty()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_getProperty) now returns [`ExtendedPropertyReflection`](https://apiref.phpstan.org/2.0.x/PHPStan.Reflection.ExtendedPropertyReflection.html)

src/Type/ClosureType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
use PHPStan\Reflection\ClassReflection;
2121
use PHPStan\Reflection\ConstantReflection;
2222
use PHPStan\Reflection\ExtendedMethodReflection;
23+
use PHPStan\Reflection\ExtendedPropertyReflection;
2324
use PHPStan\Reflection\Native\NativeParameterReflection;
2425
use PHPStan\Reflection\ParameterReflection;
2526
use PHPStan\Reflection\ParametersAcceptor;
2627
use PHPStan\Reflection\PassedByReference;
2728
use PHPStan\Reflection\Php\ClosureCallUnresolvedMethodPrototypeReflection;
2829
use PHPStan\Reflection\Php\DummyParameter;
29-
use PHPStan\Reflection\PropertyReflection;
3030
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
3131
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
3232
use PHPStan\TrinaryLogic;
@@ -307,7 +307,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
307307
return $this->objectType->hasProperty($propertyName);
308308
}
309309

310-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
310+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
311311
{
312312
return $this->objectType->getProperty($propertyName, $scope);
313313
}

src/Type/Generic/GenericObjectType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPStan\Reflection\ClassMemberAccessAnswerer;
99
use PHPStan\Reflection\ClassReflection;
1010
use PHPStan\Reflection\ExtendedMethodReflection;
11-
use PHPStan\Reflection\PropertyReflection;
11+
use PHPStan\Reflection\ExtendedPropertyReflection;
1212
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
1313
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
1414
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
@@ -228,7 +228,7 @@ public function getClassReflection(): ?ClassReflection
228228
->withVariances($this->variances);
229229
}
230230

231-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
231+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
232232
{
233233
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
234234
}

src/Type/IntersectionType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use PHPStan\Reflection\ClassMemberAccessAnswerer;
1111
use PHPStan\Reflection\ConstantReflection;
1212
use PHPStan\Reflection\ExtendedMethodReflection;
13+
use PHPStan\Reflection\ExtendedPropertyReflection;
1314
use PHPStan\Reflection\InitializerExprTypeResolver;
14-
use PHPStan\Reflection\PropertyReflection;
1515
use PHPStan\Reflection\TrivialParametersAcceptor;
1616
use PHPStan\Reflection\Type\IntersectionTypeUnresolvedMethodPrototypeReflection;
1717
use PHPStan\Reflection\Type\IntersectionTypeUnresolvedPropertyPrototypeReflection;
@@ -466,7 +466,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
466466
return $this->intersectResults(static fn (Type $type): TrinaryLogic => $type->hasProperty($propertyName));
467467
}
468468

469-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
469+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
470470
{
471471
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
472472
}

src/Type/MixedType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use PHPStan\Reflection\Dummy\DummyMethodReflection;
1313
use PHPStan\Reflection\Dummy\DummyPropertyReflection;
1414
use PHPStan\Reflection\ExtendedMethodReflection;
15-
use PHPStan\Reflection\PropertyReflection;
15+
use PHPStan\Reflection\ExtendedPropertyReflection;
1616
use PHPStan\Reflection\TrivialParametersAcceptor;
1717
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
1818
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
@@ -381,7 +381,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
381381
return TrinaryLogic::createYes();
382382
}
383383

384-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
384+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
385385
{
386386
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
387387
}

src/Type/NeverType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPStan\Reflection\ClassMemberAccessAnswerer;
99
use PHPStan\Reflection\ConstantReflection;
1010
use PHPStan\Reflection\ExtendedMethodReflection;
11-
use PHPStan\Reflection\PropertyReflection;
11+
use PHPStan\Reflection\ExtendedPropertyReflection;
1212
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
1313
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
1414
use PHPStan\ShouldNotHappenException;
@@ -141,7 +141,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
141141
return TrinaryLogic::createNo();
142142
}
143143

144-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
144+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
145145
{
146146
throw new ShouldNotHappenException();
147147
}

src/Type/NonexistentParentClassType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPStan\Reflection\ClassMemberAccessAnswerer;
99
use PHPStan\Reflection\ConstantReflection;
1010
use PHPStan\Reflection\ExtendedMethodReflection;
11-
use PHPStan\Reflection\PropertyReflection;
11+
use PHPStan\Reflection\ExtendedPropertyReflection;
1212
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
1313
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
1414
use PHPStan\ShouldNotHappenException;
@@ -67,7 +67,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
6767
return TrinaryLogic::createNo();
6868
}
6969

70-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
70+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
7171
{
7272
throw new ShouldNotHappenException();
7373
}

src/Type/ObjectShapeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use PHPStan\PhpDocParser\Ast\Type\ObjectShapeNode;
1111
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
1212
use PHPStan\Reflection\ClassMemberAccessAnswerer;
13+
use PHPStan\Reflection\ExtendedPropertyReflection;
1314
use PHPStan\Reflection\MissingPropertyFromReflectionException;
1415
use PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension;
15-
use PHPStan\Reflection\PropertyReflection;
1616
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
1717
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
1818
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
@@ -102,7 +102,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
102102
return TrinaryLogic::createYes();
103103
}
104104

105-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
105+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
106106
{
107107
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
108108
}

src/Type/ObjectType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use PHPStan\Reflection\ClassReflection;
2424
use PHPStan\Reflection\ConstantReflection;
2525
use PHPStan\Reflection\ExtendedMethodReflection;
26+
use PHPStan\Reflection\ExtendedPropertyReflection;
2627
use PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension;
2728
use PHPStan\Reflection\PropertyReflection;
2829
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
@@ -160,7 +161,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
160161
return TrinaryLogic::createNo();
161162
}
162163

163-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
164+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
164165
{
165166
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
166167
}

src/Type/StaticType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PHPStan\Reflection\ClassReflection;
1010
use PHPStan\Reflection\ConstantReflection;
1111
use PHPStan\Reflection\ExtendedMethodReflection;
12-
use PHPStan\Reflection\PropertyReflection;
12+
use PHPStan\Reflection\ExtendedPropertyReflection;
1313
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
1414
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
1515
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
@@ -219,7 +219,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
219219
return $this->getStaticObjectType()->hasProperty($propertyName);
220220
}
221221

222-
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
222+
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
223223
{
224224
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
225225
}

0 commit comments

Comments
 (0)