diff --git a/bin/compiler.php b/bin/compiler.php index 45ec141d..93dabdc4 100755 --- a/bin/compiler.php +++ b/bin/compiler.php @@ -1,6 +1,7 @@ #!/usr/bin/env php isVarExpr($expr->var) and $this->isIdExpr($expr->name)) { + $this->parsePropertyFetch($expr); + if ($expr->getAttribute('nativePropertyVar')) { + $propVar = $expr->getAttribute('nativePropertyVar'); + $info = $this->context->objectProps[$propVar]; + return $info['type']; + } + } + break; case 'Expr_New': return self::TYPE_OBJECT; case 'Expr_Assign': @@ -3465,6 +3475,7 @@ class CompilerBase extends \PhpAot\Core\Translator 'getter' => $getProperty, ]; } + $expr->setAttribute('nativePropertyVar', $propVar); return $propVar; } } diff --git a/tests/aot/object_property/003.phpt b/tests/aot/object_property/003.phpt new file mode 100644 index 00000000..0e605843 --- /dev/null +++ b/tests/aot/object_property/003.phpt @@ -0,0 +1,25 @@ +--TEST-- +default array property +--FILE-- +x; + $x += 23; + $this->x += 12; + var_dump($x, $this->x); + } +} + +function main() { + $obj = new Test; + $obj->bar(); +} +?> +--EXPECT-- +int(123) +int(112) \ No newline at end of file