Skip to content

Commit 1914b6c

Browse files
Solve deprecations
1 parent 5062b83 commit 1914b6c

12 files changed

+31
-50
lines changed

src/Analyser/MutatingScope.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,7 +4284,7 @@ public function assignInitializedProperty(Type $fetchedOnType, string $propertyN
42844284
return $this;
42854285
}
42864286

4287-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
4287+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
42884288
if ($propertyReflection === null) {
42894289
return $this;
42904290
}
@@ -6164,7 +6164,12 @@ public function getStaticPropertyReflection(Type $typeWithProperty, string $prop
61646164
*/
61656165
private function propertyFetchType(Type $fetchedOnType, string $propertyName, Expr $propertyFetch): ?Type
61666166
{
6167-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
6167+
if ($propertyFetch instanceof PropertyFetch) {
6168+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
6169+
} else {
6170+
$propertyReflection = $this->getStaticPropertyReflection($fetchedOnType, $propertyName);
6171+
}
6172+
61686173
if ($propertyReflection === null) {
61696174
return null;
61706175
}

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,7 @@ static function (): void {
30943094
} else {
30953095
$propertyName = $expr->name->toString();
30963096
$propertyHolderType = $scopeBeforeVar->getType($expr->var);
3097-
$propertyReflection = $scopeBeforeVar->getPropertyReflection($propertyHolderType, $propertyName);
3097+
$propertyReflection = $scopeBeforeVar->getInstancePropertyReflection($propertyHolderType, $propertyName);
30983098
if ($propertyReflection !== null && $this->phpVersion->supportsPropertyHooks()) {
30993099
$propertyDeclaringClass = $propertyReflection->getDeclaringClass();
31003100
if ($propertyDeclaringClass->hasNativeProperty($propertyName)) {
@@ -5640,8 +5640,8 @@ static function (): void {
56405640
}
56415641

56425642
$propertyHolderType = $scope->getType($var->var);
5643-
if ($propertyName !== null && $propertyHolderType->hasProperty($propertyName)->yes()) {
5644-
$propertyReflection = $propertyHolderType->getProperty($propertyName, $scope);
5643+
if ($propertyName !== null && $propertyHolderType->hasInstanceProperty($propertyName)->yes()) {
5644+
$propertyReflection = $propertyHolderType->getInstanceProperty($propertyName, $scope);
56455645
$assignedExprType = $scope->getType($assignedExpr);
56465646
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scopeBeforeAssignEval);
56475647
if ($propertyReflection->canChangeTypeAfterAssignment()) {
@@ -5731,7 +5731,7 @@ static function (): void {
57315731
$scope = $result->getScope();
57325732

57335733
if ($propertyName !== null) {
5734-
$propertyReflection = $scope->getPropertyReflection($propertyHolderType, $propertyName);
5734+
$propertyReflection = $scope->getStaticPropertyReflection($propertyHolderType, $propertyName);
57355735
$assignedExprType = $scope->getType($assignedExpr);
57365736
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scopeBeforeAssignEval);
57375737
if ($propertyReflection !== null && $propertyReflection->canChangeTypeAfterAssignment()) {

src/Node/ClassPropertiesNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function getUninitializedProperties(
201201
continue;
202202
}
203203

204-
$propertyReflection = $usageScope->getPropertyReflection($fetchedOnType, $propertyName);
204+
$propertyReflection = $usageScope->getInstancePropertyReflection($fetchedOnType, $propertyName);
205205
if ($propertyReflection === null) {
206206
continue;
207207
}

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
@@ -38,17 +38,14 @@ public function processNode(Node $node, Scope $scope): array
3838
}
3939

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

45-
$property = $classType->getProperty($propertyName, $scope);
45+
$property = $classType->getStaticProperty($propertyName, $scope);
4646
if (!$property->isPrivate()) {
4747
return [];
4848
}
49-
if (!$property->isStatic()) {
50-
return [];
51-
}
5249

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

src/Rules/Properties/AccessStaticPropertiesRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
246246
]);
247247
}
248248

249-
$property = $classType->getProperty($name, $scope);
249+
$property = $classType->getStaticProperty($name, $scope);
250250
if (!$scope->canReadProperty($property)) {
251251
return array_merge($messages, [
252252
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 & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
317317
) {
318318
$properties = [];
319319
foreach ($this->getEnumCases() as $enumCase) {
320-
$properties[] = $enumCase->getUnresolvedPropertyPrototype($propertyName, $scope);
320+
$properties[] = $enumCase->getUnresolvedInstancePropertyPrototype($propertyName, $scope);
321321
}
322322

323323
if (count($properties) > 0) {
@@ -431,27 +431,6 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
431431
);
432432
}
433433

434-
/**
435-
* @deprecated Not in use anymore.
436-
*/
437-
public function getPropertyWithoutTransformingStatic(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
438-
{
439-
$classReflection = $this->getNakedClassReflection();
440-
if ($classReflection === null) {
441-
throw new ClassNotFoundException($this->className);
442-
}
443-
444-
if (!$classReflection->hasProperty($propertyName)) {
445-
$classReflection = $this->getClassReflection();
446-
}
447-
448-
if ($classReflection === null) {
449-
throw new ClassNotFoundException($this->className);
450-
}
451-
452-
return $classReflection->getProperty($propertyName, $scope);
453-
}
454-
455434
public function getReferencedClasses(): array
456435
{
457436
return [$this->className];

src/Type/Php/ReflectionPropertyConstructorThrowTypeExtension.php

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

4343
$classReflection = $this->reflectionProvider->getClass($constantString->getValue());
4444
foreach ($propertyType->getConstantStrings() as $constantPropertyString) {
45-
if (!$classReflection->hasProperty($constantPropertyString->getValue())) {
45+
if (!$classReflection->hasInstanceProperty($constantPropertyString->getValue())) {
4646
return $methodReflection->getThrowType();
4747
}
4848
}

0 commit comments

Comments
 (0)