-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from romm/fix/anonymous-class-attribute
Handle anonymous class attribute
- Loading branch information
Showing
5 changed files
with
68 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Attribute declared in anonymous class | ||
|
||
--SKIPIF-- | ||
<?php version_compare(PHP_VERSION, "8.0", ">=") | ||
or die("skip because attributes are only available since PHP 8.0") ?> | ||
|
||
--FILE-- | ||
<?php | ||
|
||
error_reporting(E_ALL | E_STRICT); | ||
|
||
require __DIR__ . "/../Patchwork.php"; | ||
require __DIR__ . "/includes/AnonymousClassAttribute.php"; | ||
|
||
?> | ||
===DONE=== | ||
|
||
--EXPECT-- | ||
===DONE=== |
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,18 @@ | ||
<?php | ||
|
||
#[\Attribute] | ||
class SomeAttribute { | ||
public function __construct($value) {} | ||
} | ||
|
||
// Simple attribute | ||
new #[SomeAttribute('foo')] class {}; | ||
|
||
// Several attributes | ||
new #[SomeAttribute('foo')] #[SomeAttribute('bar')] class {}; | ||
|
||
// Attribute with argument on several lines | ||
new #[SomeAttribute([ | ||
'foo', | ||
'bar', | ||
])] class {}; |
22 changes: 22 additions & 0 deletions
22
tests/redefinition-new-anonymous-class-with-attribute.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,22 @@ | ||
--TEST-- | ||
Redefinition of new in anonymous class with attribute | ||
|
||
--SKIPIF-- | ||
<?php version_compare(PHP_VERSION, "8.0", ">=") | ||
or die("skip because attributes are only available since PHP 8.0") ?> | ||
|
||
--FILE-- | ||
<?php | ||
|
||
error_reporting(E_ALL | E_STRICT); | ||
|
||
$_SERVER['PHP_SELF'] = __FILE__; | ||
|
||
require __DIR__ . "/../Patchwork.php"; | ||
require __DIR__ . "/includes/AnonymousClassAttribute.php"; | ||
|
||
?> | ||
===DONE=== | ||
|
||
--EXPECT-- | ||
===DONE=== |