TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
636 B
35 lines
636 B
--TEST--
|
|
Anonymous Classes - Runtime class definition
|
|
--FILE--
|
|
<?php
|
|
|
|
namespace TestApp {
|
|
class Greeter {
|
|
protected string $greeting;
|
|
|
|
public function __construct(string $greeting) {
|
|
$this->greeting = $greeting;
|
|
}
|
|
|
|
public function greet() {
|
|
return $this->greeting;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
namespace {
|
|
use TestApp\Greeter;
|
|
function main() {
|
|
$class = new class("Hello") extends Greeter {
|
|
public function greet() {
|
|
return "{$this->greeting} from anonymous class";
|
|
}
|
|
};
|
|
echo $class->greet(), "\n";
|
|
}
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Hello from anonymous class
|
|
|