LegacyPropertyHelper
class LegacyPropertyHelper
Reads configuration property declarations and the class attributes that can replace them, for the rules recommending attributes over legacy model and queue properties.
Values are PHP constants, with an enum case held as its PHPStan type.
Methods
Create a new legacy property helper instance.
Get the class's own fixed declarations of the given properties, and those of the traits it uses directly.
Get the default a property has without the class's own declaration: its parent's, with the class declaring it there and whether it is public. Null when that default is not one constant.
Get the given attributes on the class and each parent below the base class, nearest first, as the runtime reads them: each class's own, then those of the traits it uses directly, in order.
Find the nearest of the levels' attributes of a class: a class's own, then its traits' in order.
Track the files a class's property defaults, constructors and read attribute arguments come from.
Determine whether two values are the same, comparing enum cases by their case.
Write a value as PHP code.
Write a declared default as written, when an attribute on the same class takes its value.
Details
at line 44
__construct(ReflectionProvider $reflectionProvider, InitializerExprTypeResolver $initializerExprTypeResolver, ConstructorParser $constructorParser)
Create a new legacy property helper instance.
at line 66
array
declarations(ClassReflection $classReflection, ClassLike $class, array $properties, array $setters)
Get the class's own fixed declarations of the given properties, and those of the traits it uses directly.
A property with no default, one the constructor may change, or one whose default is not a single constant holds per-instance state or cannot move to an attribute, so it is left out. A trait's declaration is included when the class uses that trait directly, no other direct trait declares the property, and its default means the same in the trait, since attribute lookup reads no nested traits and an attribute on the trait reads its arguments there. Its line is in the trait's file.
at line 131
array|null
inheritedDefault(ClassReflection $classReflection, string $name)
Get the default a property has without the class's own declaration: its parent's, with the class declaring it there and whether it is public. Null when that default is not one constant.
at line 165
array
attributeLevels(ClassReflection $classReflection, array $attributeClasses, string|null $baseClass)
Get the given attributes on the class and each parent below the base class, nearest first, as the runtime reads them: each class's own, then those of the traits it uses directly, in order.
Each attribute holds its constructor arguments by parameter name, a variadic parameter's as a list. The attributes whose arguments are not all single constants are listed apart, wherever they are.
at line 210
array|null
nearestAttribute(array $levels, string $attributeClass)
Find the nearest of the levels' attributes of a class: a class's own, then its traits' in order.
at line 231
void
trackSources(ClassReflection $classReflection, array $attributeClasses, string|null $baseClass, Scope $scope)
Track the files a class's property defaults, constructors and read attribute arguments come from.
They are not declarations, whose changes alone reanalyze the class's file.
at line 257
bool
same(mixed $first, mixed $second)
Determine whether two values are the same, comparing enum cases by their case.
at line 269
string
render(mixed $value)
Write a value as PHP code.
at line 294
string
printExpression(Expr $expression)
Write a declared default as written, when an attribute on the same class takes its value.