Skip to content

Commit ad034a9

Browse files
Solve deprecations
1 parent 4445a52 commit ad034a9

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
@@ -4316,7 +4316,7 @@ public function assignInitializedProperty(Type $fetchedOnType, string $propertyN
43164316
return $this;
43174317
}
43184318

4319-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
4319+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
43204320
if ($propertyReflection === null) {
43214321
return $this;
43224322
}
@@ -6196,7 +6196,12 @@ public function getStaticPropertyReflection(Type $typeWithProperty, string $prop
61966196
*/
61976197
private function propertyFetchType(Type $fetchedOnType, string $propertyName, Expr $propertyFetch): ?Type
61986198
{
6199-
$propertyReflection = $this->getPropertyReflection($fetchedOnType, $propertyName);
6199+
if ($propertyFetch instanceof PropertyFetch) {
6200+
$propertyReflection = $this->getInstancePropertyReflection($fetchedOnType, $propertyName);
6201+
} else {
6202+
$propertyReflection = $this->getStaticPropertyReflection($fetchedOnType, $propertyName);
6203+
}
6204+
62006205
if ($propertyReflection === null) {
62016206
return null;
62026207
}

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,7 +3097,7 @@ static function (): void {
30973097
} else {
30983098
$propertyName = $expr->name->toString();
30993099
$propertyHolderType = $scopeBeforeVar->getType($expr->var);
3100-
$propertyReflection = $scopeBeforeVar->getPropertyReflection($propertyHolderType, $propertyName);
3100+
$propertyReflection = $scopeBeforeVar->getInstancePropertyReflection($propertyHolderType, $propertyName);
31013101
if ($propertyReflection !== null && $this->phpVersion->supportsPropertyHooks()) {
31023102
$propertyDeclaringClass = $propertyReflection->getDeclaringClass();
31033103
if ($propertyDeclaringClass->hasNativeProperty($propertyName)) {
@@ -5643,8 +5643,8 @@ static function (): void {
56435643
}
56445644

56455645
$propertyHolderType = $scope->getType($var->var);
5646-
if ($propertyName !== null && $propertyHolderType->hasProperty($propertyName)->yes()) {
5647-
$propertyReflection = $propertyHolderType->getProperty($propertyName, $scope);
5646+
if ($propertyName !== null && $propertyHolderType->hasInstanceProperty($propertyName)->yes()) {
5647+
$propertyReflection = $propertyHolderType->getInstanceProperty($propertyName, $scope);
56485648
$assignedExprType = $scope->getType($assignedExpr);
56495649
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scopeBeforeAssignEval);
56505650
if ($propertyReflection->canChangeTypeAfterAssignment()) {
@@ -5734,7 +5734,7 @@ static function (): void {
57345734
$scope = $result->getScope();
57355735

57365736
if ($propertyName !== null) {
5737-
$propertyReflection = $scope->getPropertyReflection($propertyHolderType, $propertyName);
5737+
$propertyReflection = $scope->getStaticPropertyReflection($propertyHolderType, $propertyName);
57385738
$assignedExprType = $scope->getType($assignedExpr);
57395739
$nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scopeBeforeAssignEval);
57405740
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
@@ -304,7 +304,7 @@ public function getUnresolvedInstancePropertyPrototype(string $propertyName, Cla
304304
) {
305305
$properties = [];
306306
foreach ($this->getEnumCases() as $enumCase) {
307-
$properties[] = $enumCase->getUnresolvedPropertyPrototype($propertyName, $scope);
307+
$properties[] = $enumCase->getUnresolvedInstancePropertyPrototype($propertyName, $scope);
308308
}
309309

310310
if (count($properties) > 0) {
@@ -418,27 +418,6 @@ public function getUnresolvedStaticPropertyPrototype(string $propertyName, Class
418418
);
419419
}
420420

421-
/**
422-
* @deprecated Not in use anymore.
423-
*/
424-
public function getPropertyWithoutTransformingStatic(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection
425-
{
426-
$classReflection = $this->getNakedClassReflection();
427-
if ($classReflection === null) {
428-
throw new ClassNotFoundException($this->className);
429-
}
430-
431-
if (!$classReflection->hasProperty($propertyName)) {
432-
$classReflection = $this->getClassReflection();
433-
}
434-
435-
if ($classReflection === null) {
436-
throw new ClassNotFoundException($this->className);
437-
}
438-
439-
return $classReflection->getProperty($propertyName, $scope);
440-
}
441-
442421
public function getReferencedClasses(): array
443422
{
444423
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)