Skip to content

Commit 71b6b77

Browse files
committed
Add support for generating custom class constant and property attributes in stubs
1 parent 97d4e4f commit 71b6b77

File tree

8 files changed

+214
-74
lines changed

8 files changed

+214
-74
lines changed

build/gen_stub.php

Lines changed: 167 additions & 59 deletions
Large diffs are not rendered by default.

ext/dom/php_dom_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pdo/pdo_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/soap/soap_arginfo.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/user_filters_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public function returnsThrowable(): Exception {}
4848
}
4949

5050
trait _ZendTestTrait {
51+
/** @var int */
52+
#[ZendTestAttribute]
53+
public const TEST_CONST = 1;
54+
5155
/** @var mixed */
56+
#[ZendTestAttribute]
5257
public $testProp;
5358

5459
#[ZendTestAttribute]

ext/zend_test/test_arginfo.h

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
gen_stub.php: Test that attributes are applied to methods
2+
gen_stub.php: Test that attributes are applied to constants, properties, and methods
33
--EXTENSIONS--
44
zend_test
55
--FILE--
@@ -9,10 +9,20 @@ class Foo {
99
use _ZendTestTrait;
1010
}
1111

12-
$reflection = new ReflectionMethod(Foo::class, "testMethod");
12+
$reflectionConstant = new ReflectionClassConstant(Foo::class, "TEST_CONST");
13+
var_dump($reflectionConstant->getAttributes()[0]->newInstance());
1314

14-
var_dump($reflection->getAttributes()[0]->getName());
15+
$reflectionProperty = new ReflectionProperty(Foo::class, "testProp");
16+
var_dump($reflectionProperty->getAttributes()[0]->newInstance());
17+
18+
$reflectionMethod = new ReflectionMethod(Foo::class, "testMethod");
19+
var_dump($reflectionMethod->getAttributes()[0]->newInstance());
1520

1621
?>
1722
--EXPECTF--
18-
string(%d) "ZendTestAttribute"
23+
object(ZendTestAttribute)#%d (0) {
24+
}
25+
object(ZendTestAttribute)#%d (0) {
26+
}
27+
object(ZendTestAttribute)#%d (0) {
28+
}

0 commit comments

Comments
 (0)