diff --git a/bin/gen_stub.php b/bin/gen_stub.php index fda459b4..9f8ba4a7 100755 --- a/bin/gen_stub.php +++ b/bin/gen_stub.php @@ -228,7 +228,7 @@ class SimpleType { } if ($node->toLowerString() === 'self') { - throw new Exception('The exact class name must be used instead of "self"'); + return new SimpleType(ClassInfo::$currentClassName, false); } assert($node->isFullyQualified()); @@ -3455,6 +3455,7 @@ class AttributeInfo { class ClassInfo { static public ?self $currentClass = null; + static public ?string $currentClassName = null; public /* readonly */ Name $name; private int $flags; public string $type; @@ -4444,6 +4445,7 @@ class FileInfo { if ($stmt instanceof Stmt\ClassLike) { $className = $stmt->namespacedName; + ClassInfo::$currentClassName = $className->toString(); $constInfos = []; $propertyInfos = []; $methodInfos = []; diff --git a/tests/aot/closure-002.phpt b/tests/aot/closure-002.phpt new file mode 100644 index 00000000..a934cf0b --- /dev/null +++ b/tests/aot/closure-002.phpt @@ -0,0 +1,38 @@ +--TEST-- +closure 001 +--FILE-- + +--EXPECT-- +int(100) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +int(1000) +array(3) { + [0]=> + int(4) + [1]=> + int(5) + [2]=> + int(6) +} + diff --git a/tests/aot/func-self-type.phpt b/tests/aot/func-self-type.phpt new file mode 100644 index 00000000..cb25a448 --- /dev/null +++ b/tests/aot/func-self-type.phpt @@ -0,0 +1,23 @@ +--TEST-- +static calls +--FILE-- +pipe($stream2); + } +} +?> +--EXPECT-- +string(10) "Foo\Stream" \ No newline at end of file