Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2375,8 +2375,8 @@ protected function getTypeCode(string $variableLikeName, string &$code): string
$code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->num_types = $classTypeCount;\n";

foreach ($arginfoType->classTypes as $k => $classType) {
$escapedClassName = $classType->toEscapedName();
$code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->types[$k] = (zend_type) ZEND_TYPE_INIT_CLASS({$variableLikeType}_{$variableLikeName}_class_{$escapedClassName}, 0, 0);\n";
$varEscapedClassName = $classType->toVarEscapedName();
$code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->types[$k] = (zend_type) ZEND_TYPE_INIT_CLASS({$variableLikeType}_{$variableLikeName}_class_{$varEscapedClassName}, 0, 0);\n";
}

$typeMaskCode = $this->type->toArginfoType()->toTypeMask();
Expand Down Expand Up @@ -4261,6 +4261,11 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
continue;
}

if ($stmt instanceof Stmt\Use_ || $stmt instanceof Stmt\GroupUse) {
// use statements are resolved by NameResolver before this point
continue;
}

if ($stmt instanceof Stmt\Const_) {
foreach ($stmt->consts as $const) {
$this->constInfos[] = parseConstLike(
Expand Down
2 changes: 2 additions & 0 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static zend_class_entry *zend_test_forbid_dynamic_call;
static zend_class_entry *zend_test_ns_foo_class;
static zend_class_entry *zend_test_ns_unlikely_compile_error_class;
static zend_class_entry *zend_test_ns_not_unlikely_compile_error_class;
static zend_class_entry *zend_test_ns_bar_class;
static zend_class_entry *zend_test_ns2_foo_class;
static zend_class_entry *zend_test_ns2_ns_foo_class;
static zend_class_entry *zend_test_unit_enum;
Expand Down Expand Up @@ -1567,6 +1568,7 @@ PHP_MINIT_FUNCTION(zend_test)
zend_test_ns_foo_class = register_class_ZendTestNS_Foo();
zend_test_ns_unlikely_compile_error_class = register_class_ZendTestNS_UnlikelyCompileError();
zend_test_ns_not_unlikely_compile_error_class = register_class_ZendTestNS_NotUnlikelyCompileError();
zend_test_ns_bar_class = register_class_ZendTestNS_Bar();
zend_test_ns2_foo_class = register_class_ZendTestNS2_Foo();
zend_test_ns2_ns_foo_class = register_class_ZendTestNS2_ZendSubNS_Foo();

Expand Down
11 changes: 11 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ class Foo {
public function method(): int {}
}

interface Bar {}

class UnlikelyCompileError {
/* This method signature would create a compile error due to the string
* "ZendTestNS\UnlikelyCompileError" in the generated macro call */
Expand All @@ -378,11 +380,20 @@ public function method(): ?NotUnlikelyCompileError {}

namespace ZendTestNS2 {

use ZendTestNS\Foo as FooAlias;
use ZendTestNS\UnlikelyCompileError;
use ZendTestNS\{NotUnlikelyCompileError};

/** @var string */
const ZEND_CONSTANT_A = "namespaced";

class Foo {
public ZendSubNS\Foo $foo;
public ZendSubNS\Foo&\ZendTestNS\Bar $intersectionProp;
public ZendSubNS\Foo|\ZendTestNS\Bar $unionProp;
public FooAlias $fooAlias;
public UnlikelyCompileError $unlProp;
public NotUnlikelyCompileError $notUnlProp;

public function method(): void {}
}
Expand Down
59 changes: 58 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ext/zend_test/test_decl.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 41 additions & 1 deletion ext/zend_test/test_legacy_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions ext/zend_test/tests/gen_stub_test_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,31 @@ var_dump($foo);
object(ZendTestNS2\Foo)#%d (%d) {
["foo"]=>
uninitialized(ZendTestNS2\ZendSubNS\Foo)
["intersectionProp"]=>
uninitialized(ZendTestNS2\ZendSubNS\Foo&ZendTestNS\Bar)
["unionProp"]=>
uninitialized(ZendTestNS2\ZendSubNS\Foo|ZendTestNS\Bar)
["fooAlias"]=>
uninitialized(ZendTestNS\Foo)
["unlProp"]=>
uninitialized(ZendTestNS\UnlikelyCompileError)
["notUnlProp"]=>
uninitialized(ZendTestNS\NotUnlikelyCompileError)
}
object(ZendTestNS2\Foo)#%d (%d) {
["foo"]=>
object(ZendTestNS2\ZendSubNS\Foo)#%d (%d) {
}
["intersectionProp"]=>
uninitialized(ZendTestNS2\ZendSubNS\Foo&ZendTestNS\Bar)
["unionProp"]=>
uninitialized(ZendTestNS2\ZendSubNS\Foo|ZendTestNS\Bar)
["fooAlias"]=>
uninitialized(ZendTestNS\Foo)
["unlProp"]=>
uninitialized(ZendTestNS\UnlikelyCompileError)
["notUnlProp"]=>
uninitialized(ZendTestNS\NotUnlikelyCompileError)
}
object(ZendTestNS\UnlikelyCompileError)#%d (%d) {
}
Expand Down