diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index edf43899..31d12980 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4342,8 +4342,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->assertExprCanBeUsedAsValue($expr->expr, 'instanceof operand'); if ($this->isNameExpr($expr->class)) { $className = $this->getNamespacedClassName($this->parseIdentifier($expr->class)); - $className = $this->getClassEntryPtr($className); - return 'php::instanceOf(' . $this->parseExpr($expr->expr) . ', ' . $className . ')'; + return 'php::instanceOf(' . $this->parseExpr($expr->expr) . ', ' . $this->getLiteralString($className) . ')'; } else { return 'php::instanceOf(' . $this->parseExpr($expr->expr) . ', ' . $this->identifierToStr($expr->class) . ')'; } diff --git a/tests/aot/namespace/interface-across-ns.phpt b/tests/aot/namespace/interface-across-ns.phpt index b6217a68..e3e96d98 100644 --- a/tests/aot/namespace/interface-across-ns.phpt +++ b/tests/aot/namespace/interface-across-ns.phpt @@ -29,6 +29,24 @@ namespace Services\Payment { return $this->log; } } + + class StripeProcessor2 implements \Contracts\Payment\PaymentProcessor { + private array $log = []; + + public function pay(float $amount): bool { + $this->log[] = "paid:{$amount}"; + return true; + } + + public function refund(float $amount): bool { + $this->log[] = "refunded:{$amount}"; + return true; + } + + public function getLog(): array { + return $this->log; + } + } } namespace { @@ -41,6 +59,13 @@ namespace { var_dump($p->refund(50.0)); var_dump($p->getLog()); var_dump($p instanceof PaymentProcessor); + + $p2 = new Services\Payment\StripeProcessor2(); + var_dump($p2->pay(200.0)); + var_dump($p2->refund(150.0)); + var_dump($p2->getLog()); + var_dump($p2 instanceof PaymentProcessor2); + echo "done\n"; } } @@ -55,4 +80,13 @@ array(2) { string(11) "refunded:50" } bool(true) +bool(true) +bool(true) +array(2) { + [0]=> + string(8) "paid:200" + [1]=> + string(12) "refunded:150" +} +bool(false) done