Skip to content

Commit f677975

Browse files
committed
rebase
1 parent 4ddefa8 commit f677975

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Analyser/MutatingScope.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,21 @@ public function rememberConstructorScope(): self
369369
);
370370
}
371371

372-
private function isReadonlyPropertyFetchOnThis(PropertyFetch $expr): bool
372+
private function isReadonlyPropertyFetch(PropertyFetch $expr, bool $allowOnlyOnThis): bool
373373
{
374+
if (!$this->phpVersion->supportsReadOnlyProperties()) {
375+
return false;
376+
}
377+
374378
while ($expr instanceof PropertyFetch) {
375379
if ($expr->var instanceof Variable) {
376380
if (
377-
! $expr->name instanceof Node\Identifier
378-
|| !is_string($expr->var->name)
379-
|| $expr->var->name !== 'this'
381+
$allowOnlyOnThis
382+
&& (
383+
! $expr->name instanceof Node\Identifier
384+
|| !is_string($expr->var->name)
385+
|| $expr->var->name !== 'this'
386+
)
380387
) {
381388
return false;
382389
}
@@ -3774,7 +3781,7 @@ private function enterAnonymousFunctionWithoutReflection(
37743781
continue;
37753782
}
37763783

3777-
if (!$this->isReadonlyPropertyFetchOnThis($expr)) {
3784+
if (!$this->isReadonlyPropertyFetch($expr, true)) {
37783785
continue;
37793786
}
37803787

0 commit comments

Comments
 (0)