Skip to content

Commit 2151184

Browse files
Solve deprecations
1 parent 6843075 commit 2151184

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Rules/Properties/AccessPropertiesCheck.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ private function processSingleProperty(Scope $scope, PropertyFetch $node, string
6767
$scope,
6868
NullsafeOperatorHelper::getNullsafeShortcircuitedExprRespectingScope($scope, $node->var),
6969
sprintf('Access to property $%s on an unknown class %%s.', SprintfHelper::escapeFormatString($name)),
70+
// TODO use hasInstanceProperty
7071
static fn (Type $type): bool => $type->canAccessProperties()->yes() && $type->hasProperty($name)->yes(),
7172
);
7273
$type = $typeResult->getType();
@@ -93,6 +94,7 @@ private function processSingleProperty(Scope $scope, PropertyFetch $node, string
9394
];
9495
}
9596

97+
// TODO use hasInstanceProperty
9698
$has = $type->hasProperty($name);
9799
if (!$has->no() && $this->canAccessUndefinedProperties($scope, $node)) {
98100
return [];
@@ -124,12 +126,12 @@ private function processSingleProperty(Scope $scope, PropertyFetch $node, string
124126
$propertyClassReflection = $this->reflectionProvider->getClass($classNames[0]);
125127
$parentClassReflection = $propertyClassReflection->getParentClass();
126128
while ($parentClassReflection !== null) {
127-
if ($parentClassReflection->hasProperty($name)) {
129+
if ($parentClassReflection->hasInstanceProperty($name)) {
128130
if ($write) {
129-
if ($scope->canWriteProperty($parentClassReflection->getProperty($name, $scope))) {
131+
if ($scope->canWriteProperty($parentClassReflection->getInstanceProperty($name, $scope))) {
130132
return [];
131133
}
132-
} elseif ($scope->canReadProperty($parentClassReflection->getProperty($name, $scope))) {
134+
} elseif ($scope->canReadProperty($parentClassReflection->getInstanceProperty($name, $scope))) {
133135
return [];
134136
}
135137

@@ -173,6 +175,7 @@ private function processSingleProperty(Scope $scope, PropertyFetch $node, string
173175
];
174176
}
175177

178+
// TODO use getInstanceProperty
176179
$propertyReflection = $type->getProperty($name, $scope);
177180
if ($propertyReflection->isStatic()) {
178181
return [

src/Rules/Properties/AccessStaticPropertiesRule.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
135135
$scope,
136136
NullsafeOperatorHelper::getNullsafeShortcircuitedExprRespectingScope($scope, $node->class),
137137
sprintf('Access to static property $%s on an unknown class %%s.', SprintfHelper::escapeFormatString($name)),
138+
// TODO Use hasStaticProperty
138139
static fn (Type $type): bool => $type->canAccessProperties()->yes() && $type->hasProperty($name)->yes(),
139140
);
140141
$classType = $classTypeResult->getType();
@@ -167,6 +168,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
167168
]);
168169
}
169170

171+
// TODO Use hasStaticProperty
170172
$has = $classType->hasProperty($name);
171173
if (!$has->no() && $scope->isUndefinedExpressionAllowed($node)) {
172174
return [];
@@ -183,8 +185,8 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
183185
$parentClassReflection = $propertyClassReflection->getParentClass();
184186

185187
while ($parentClassReflection !== null) {
186-
if ($parentClassReflection->hasProperty($name)) {
187-
if ($scope->canReadProperty($parentClassReflection->getProperty($name, $scope))) {
188+
if ($parentClassReflection->hasStaticProperty($name)) {
189+
if ($scope->canReadProperty($parentClassReflection->getStaticProperty($name, $scope))) {
188190
return [];
189191
}
190192
return [
@@ -209,6 +211,7 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node,
209211
]);
210212
}
211213

214+
// TODO Use getStaticProperty and update the if
212215
$property = $classType->getProperty($name, $scope);
213216
if (!$property->isStatic()) {
214217
$hasPropertyTypes = TypeUtils::getHasPropertyTypes($classType);

0 commit comments

Comments
 (0)