Skip to content

Commit c53df3c

Browse files
Solve deprecations
1 parent 4169e78 commit c53df3c

12 files changed

+31
-47
lines changed

src/Analyser/MutatingScope.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,7 @@ public function assignInitializedProperty(Type $fetchedOnType, string $propertyN
42874287
return $this;
42884288
}
42894289

4290-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
4290+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
42914291
if ($propertyReflection === null) {
42924292
return $this;
42934293
}
@@ -6174,7 +6174,12 @@ public function getStaticPropertyReflection(Type $typeWithProperty, string $prop
61746174
*/
61756175
private function propertyFetchType(Type $fetchedOnType, string $propertyName, Expr $propertyFetch): ?Type
61766176
{
6177-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
6177+
if ($propertyFetch instanceof PropertyFetch) {
6178+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
6179+
} else {
6180+
$propertyReflection = $this->getStaticPropertyReflection($fetchedOnType, $propertyName);
6181+
}
6182+
61786183
if ($propertyReflection === null) {
61796184
return null;
61806185
}

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,7 +3084,7 @@ static function (): void {
30843084
} else {
30853085
$propertyName = $expr->name->toString();
30863086
$propertyHolderType = $scopeBeforeVar->getType($expr->var);
3087-
$propertyReflection = $scopeBeforeVar->getPropertyReflection($propertyHolderType, $propertyName);
3087+
$propertyReflection = $scopeBeforeVar->getInstancePropertyReflection($propertyHolderType, $propertyName);
30883088
if ($propertyReflection !== null && $this->phpVersion->supportsPropertyHooks()) {
30893089
$propertyDeclaringClass = $propertyReflection->getDeclaringClass();
30903090
if ($propertyDeclaringClass->hasNativeProperty($propertyName)) {
@@ -5627,8 +5627,8 @@ static function (): void {
56275627
}
56285628

56295629
$propertyHolderType = $scope->getType($var->var);
5630-
if ($propertyName !== null && $propertyHolderType->hasProperty($propertyName)->yes()) {
5631-
$propertyReflection = $propertyHolderType->getProperty($propertyName, $scope);
5630+
if ($propertyName !== null && $propertyHolderType->hasInstanceProperty($propertyName)->yes()) {
5631+
$propertyReflection = $propertyHolderType->getInstanceProperty($propertyName, $scope);
56325632
$assignedExprType = $scope->getType($assignedExpr);
56335633
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scope);
56345634
if ($propertyReflection->canChangeTypeAfterAssignment()) {
@@ -5716,7 +5716,7 @@ static function (): void {
57165716
$scope = $result->getScope();
57175717

57185718
if ($propertyName !== null) {
5719-
$propertyReflection = $scope->getPropertyReflection($propertyHolderType, $propertyName);
5719+
$propertyReflection = $scope->getStaticPropertyReflection($propertyHolderType, $propertyName);
57205720
$assignedExprType = $scope->getType($assignedExpr);
57215721
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scope);
57225722
if ($propertyReflection !== null && $propertyReflection->canChangeTypeAfterAssignment()) {

src/Node/ClassPropertiesNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function getUninitializedProperties(
198198
continue;
199199
}
200200

201-
$propertyReflection = $usageScope->getPropertyReflection($fetchedOnType, $propertyName);
201+
$propertyReflection = $usageScope->getInstancePropertyReflection($fetchedOnType, $propertyName);
202202
if ($propertyReflection === null) {
203203
continue;
204204
}

src/Reflection/Mixin/MixinPropertiesClassReflectionExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ private function findProperty(ClassReflection $classReflection, string $property
5454

5555
$this->inProcess[$typeDescription][$propertyName] = true;
5656

57-
if (!$type->hasProperty($propertyName)->yes()) {
57+
if (!$type->hasInstanceProperty($propertyName)->yes()) {
5858
unset($this->inProcess[$typeDescription][$propertyName]);
5959
continue;
6060
}
6161

62-
$property = $type->getProperty($propertyName, new OutOfClassScope());
62+
$property = $type->getInstanceProperty($propertyName, new OutOfClassScope());
6363
unset($this->inProcess[$typeDescription][$propertyName]);
6464

6565
return $property;

src/Rules/Properties/AccessPrivatePropertyThroughStaticRule.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@ public function processNode(Node $node, Scope $scope): array
3636
}
3737

3838
$classType = $scope->resolveTypeByName($className);
39-
if (!$classType->hasProperty($propertyName)->yes()) {
39+
if (!$classType->hasStaticProperty($propertyName)->yes()) {
4040
return [];
4141
}
4242

43-
$property = $classType->getProperty($propertyName, $scope);
43+
$property = $classType->getStaticProperty($propertyName, $scope);
4444
if (!$property->isPrivate()) {
4545
return [];
4646
}
47-
if (!$property->isStatic()) {
48-
return [];
49-
}
5047

5148
if ($scope->isInClass() && $scope->getClassReflection()->isFinal()) {
5249
return [];

src/Rules/Properties/AccessStaticPropertiesRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
231231
]);
232232
}
233233

234-
$property = $classType->getProperty($name, $scope);
234+
$property = $classType->getStaticProperty($name, $scope);
235235
if (!$scope->canReadProperty($property)) {
236236
return array_merge($messages, [
237237
RuleErrorBuilder::message(sprintf(

src/Type/IntersectionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
547547
{
548548
$propertyPrototypes = [];
549549
foreach ($this->types as $type) {
550-
if (!$type->hasProperty($propertyName)->yes()) {
550+
if (!$type->hasInstanceProperty($propertyName)->yes()) {
551551
continue;
552552
}
553553

src/Type/ObjectShapeType.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function accepts(Type $type, bool $strictTypes): AcceptsResult
158158
$result = AcceptsResult::createYes();
159159
$scope = new OutOfClassScope();
160160
foreach ($this->properties as $propertyName => $propertyType) {
161-
$typeHasProperty = $type->hasProperty($propertyName);
161+
$typeHasProperty = $type->hasInstanceProperty($propertyName);
162162
$hasProperty = new AcceptsResult(
163163
$typeHasProperty,
164164
$typeHasProperty->yes() ? [] : [
@@ -183,7 +183,7 @@ public function accepts(Type $type, bool $strictTypes): AcceptsResult
183183
$result = $result->and($hasProperty);
184184

185185
try {
186-
$otherProperty = $type->getProperty($propertyName, $scope);
186+
$otherProperty = $type->getInstanceProperty($propertyName, $scope);
187187
} catch (MissingPropertyFromReflectionException) {
188188
return new AcceptsResult(
189189
$result->result,
@@ -270,7 +270,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
270270
$result = IsSuperTypeOfResult::createYes();
271271
$scope = new OutOfClassScope();
272272
foreach ($this->properties as $propertyName => $propertyType) {
273-
$hasProperty = new IsSuperTypeOfResult($type->hasProperty($propertyName), []);
273+
$hasProperty = new IsSuperTypeOfResult($type->hasInstanceProperty($propertyName), []);
274274
if ($hasProperty->no()) {
275275
if (in_array($propertyName, $this->optionalProperties, true)) {
276276
continue;
@@ -284,7 +284,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
284284
$result = $result->and($hasProperty);
285285

286286
try {
287-
$otherProperty = $type->getProperty($propertyName, $scope);
287+
$otherProperty = $type->getInstanceProperty($propertyName, $scope);
288288
} catch (MissingPropertyFromReflectionException) {
289289
return $result;
290290
}
@@ -381,12 +381,12 @@ public function inferTemplateTypes(Type $receivedType): TemplateTypeMap
381381
$typeMap = TemplateTypeMap::createEmpty();
382382
$scope = new OutOfClassScope();
383383
foreach ($this->properties as $name => $propertyType) {
384-
if ($receivedType->hasProperty($name)->no()) {
384+
if ($receivedType->hasInstanceProperty($name)->no()) {
385385
continue;
386386
}
387387

388388
try {
389-
$receivedProperty = $receivedType->getProperty($name, $scope);
389+
$receivedProperty = $receivedType->getInstanceProperty($name, $scope);
390390
} catch (MissingPropertyFromReflectionException) {
391391
continue;
392392
}
@@ -477,10 +477,10 @@ public function traverseSimultaneously(Type $right, callable $cb): Type
477477

478478
$scope = new OutOfClassScope();
479479
foreach ($this->properties as $name => $propertyType) {
480-
if (!$right->hasProperty($name)->yes()) {
480+
if (!$right->hasInstanceProperty($name)->yes()) {
481481
return $this;
482482
}
483-
$transformed = $cb($propertyType, $right->getProperty($name, $scope)->getReadableType());
483+
$transformed = $cb($propertyType, $right->getInstanceProperty($name, $scope)->getReadableType());
484484
if ($transformed !== $propertyType) {
485485
$stillOriginal = false;
486486
}

src/Type/ObjectType.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
306306
) {
307307
$properties = [];
308308
foreach ($this->getEnumCases() as $enumCase) {
309-
$properties[] = $enumCase->getUnresolvedPropertyPrototype($propertyName, $scope);
309+
$properties[] = $enumCase->getUnresolvedInstancePropertyPrototype($propertyName, $scope);
310310
}
311311

312312
if (count($properties) > 0) {
@@ -420,24 +420,6 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
420420
);
421421
}
422422

423-
public function getPropertyWithoutTransformingStatic(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
424-
{
425-
$classReflection = $this->getNakedClassReflection();
426-
if ($classReflection === null) {
427-
throw new ClassNotFoundException($this->className);
428-
}
429-
430-
if (!$classReflection->hasProperty($propertyName)) {
431-
$classReflection = $this->getClassReflection();
432-
}
433-
434-
if ($classReflection === null) {
435-
throw new ClassNotFoundException($this->className);
436-
}
437-
438-
return $classReflection->getProperty($propertyName, $scope);
439-
}
440-
441423
public function getReferencedClasses(): array
442424
{
443425
return [$this->className];

src/Type/Php/ReflectionPropertyConstructorThrowTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getThrowTypeFromStaticMethodCall(MethodReflection $methodReflect
4040

4141
$classReflection = $this->reflectionProvider->getClass($constantString->getValue());
4242
foreach ($propertyType->getConstantStrings() as $constantPropertyString) {
43-
if (!$classReflection->hasProperty($constantPropertyString->getValue())) {
43+
if (!$classReflection->hasInstanceProperty($constantPropertyString->getValue())) {
4444
return $methodReflection->getThrowType();
4545
}
4646
}

0 commit comments

Comments
 (0)