-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly deal with internal attributes used on promoted properties.
Closes GH-9661
- Loading branch information
Showing
7 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
ext/zend_test/tests/attribute-promotion-parameter-only.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--TEST-- | ||
Attribute on promoted property may only target parameter | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
class AttrTest | ||
{ | ||
public function __construct( | ||
#[ZendTestParameterAttribute('foo')] public $param | ||
) {} | ||
} | ||
|
||
$ref = new ReflectionClass(AttrTest::class); | ||
$attr = $ref->getConstructor()->getParameters()[0]->getAttributes(); | ||
|
||
var_dump(count($attr)); | ||
var_dump($attr[0]->getName()); | ||
var_dump($attr[0]->newInstance()->parameter); | ||
|
||
$attr = $ref->getProperty('param')->getAttributes(); | ||
|
||
var_dump(count($attr)); | ||
|
||
?> | ||
--EXPECTF-- | ||
int(1) | ||
string(26) "ZendTestParameterAttribute" | ||
string(3) "foo" | ||
int(0) |
31 changes: 31 additions & 0 deletions
31
ext/zend_test/tests/attribute-promotion-property-only.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--TEST-- | ||
Attribute on promoted property may only target property | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
class AttrTest | ||
{ | ||
public function __construct( | ||
#[ZendTestPropertyAttribute('foo')] public $param | ||
) {} | ||
} | ||
|
||
$ref = new ReflectionClass(AttrTest::class); | ||
$attr = $ref->getConstructor()->getParameters()[0]->getAttributes(); | ||
|
||
var_dump(count($attr)); | ||
|
||
$attr = $ref->getProperty('param')->getAttributes(); | ||
|
||
var_dump(count($attr)); | ||
var_dump($attr[0]->getName()); | ||
var_dump($attr[0]->newInstance()->parameter); | ||
|
||
?> | ||
--EXPECTF-- | ||
int(0) | ||
int(1) | ||
string(25) "ZendTestPropertyAttribute" | ||
string(3) "foo" |