File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments