Skip to content

Commit

Permalink
[BCB] Type::getProperty() now returns ExtendedPropertyReflection
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 30, 2024
1 parent 392f090 commit d1d7d4a
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 33 deletions.
1 change: 1 addition & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,4 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
* Remove `ConstantType` interface, use [`Type::isConstantValue()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isConstantValue) instead
* `acceptsNamedArguments()` in `FunctionReflection`, `ExtendedMethodReflection` and `CallableParametersAcceptor` interfaces returns `TrinaryLogic` instead of `bool`
* Remove `FunctionReflection::isFinal()`
* [`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)
4 changes: 2 additions & 2 deletions src/Type/ClosureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Native\NativeParameterReflection;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\Reflection\PassedByReference;
use PHPStan\Reflection\Php\ClosureCallUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Php\DummyParameter;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\TrinaryLogic;
Expand Down Expand Up @@ -307,7 +307,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return $this->objectType->hasProperty($propertyName);
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->objectType->getProperty($propertyName, $scope);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Generic/GenericObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
Expand Down Expand Up @@ -228,7 +228,7 @@ public function getClassReflection(): ?ClassReflection
->withVariances($this->variances);
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/IntersectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\InitializerExprTypeResolver;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\TrivialParametersAcceptor;
use PHPStan\Reflection\Type\IntersectionTypeUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\IntersectionTypeUnresolvedPropertyPrototypeReflection;
Expand Down Expand Up @@ -466,7 +466,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return $this->intersectResults(static fn (Type $type): TrinaryLogic => $type->hasProperty($propertyName));
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/MixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use PHPStan\Reflection\Dummy\DummyMethodReflection;
use PHPStan\Reflection\Dummy\DummyPropertyReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\TrivialParametersAcceptor;
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
Expand Down Expand Up @@ -381,7 +381,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createYes();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/NeverType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\ShouldNotHappenException;
Expand Down Expand Up @@ -141,7 +141,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
throw new ShouldNotHappenException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/NonexistentParentClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\ShouldNotHappenException;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
throw new ShouldNotHappenException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/ObjectShapeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
use PHPStan\PhpDocParser\Ast\Type\ObjectShapeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\MissingPropertyFromReflectionException;
use PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
Expand Down Expand Up @@ -102,7 +102,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createYes();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Type/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
Expand Down Expand Up @@ -160,7 +161,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/StaticType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
Expand Down Expand Up @@ -219,7 +219,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return $this->getStaticObjectType()->hasProperty($propertyName);
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/StrictMixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\ShouldNotHappenException;
Expand Down Expand Up @@ -135,7 +135,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
throw new ShouldNotHappenException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Traits/LateResolvableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\TrinaryLogic;
Expand Down Expand Up @@ -107,7 +107,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return $this->resolve()->hasProperty($propertyName);
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->resolve()->getProperty($propertyName, $scope);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Traits/MaybeObjectTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPStan\Reflection\Dummy\DummyMethodReflection;
use PHPStan\Reflection\Dummy\DummyPropertyReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
Expand Down Expand Up @@ -45,7 +45,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Traits/NonObjectTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\ShouldNotHappenException;
Expand Down Expand Up @@ -36,7 +36,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
throw new ShouldNotHappenException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Traits/ObjectTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPStan\Reflection\Dummy\DummyMethodReflection;
use PHPStan\Reflection\Dummy\DummyPropertyReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\CallbackUnresolvedPropertyPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Type/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ public function canAccessProperties(): TrinaryLogic;

public function hasProperty(string $propertyName): TrinaryLogic;

/**
* @return ExtendedPropertyReflection
*/
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection;
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection;

public function getUnresolvedPropertyPrototype(string $propertyName, ClassMemberAccessAnswerer $scope): UnresolvedPropertyPrototypeReflection;

Expand Down
4 changes: 2 additions & 2 deletions src/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\ExtendedPropertyReflection;
use PHPStan\Reflection\InitializerExprTypeResolver;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\Type\UnionTypeUnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnionTypeUnresolvedPropertyPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
Expand Down Expand Up @@ -435,7 +435,7 @@ public function hasProperty(string $propertyName): TrinaryLogic
return $this->unionResults(static fn (Type $type): TrinaryLogic => $type->hasProperty($propertyName));
}

public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): ExtendedPropertyReflection
{
return $this->getUnresolvedPropertyPrototype($propertyName, $scope)->getTransformedProperty();
}
Expand Down

0 comments on commit d1d7d4a

Please sign in to comment.