-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44aa58c
commit e8f731b
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
Zend/tests/attributes/constants/not_repeatable-internal.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,12 @@ | ||
--TEST-- | ||
Validation of attribute repetition (not allowed; internal attribute) | ||
--FILE-- | ||
<?php | ||
|
||
#[Deprecated] | ||
#[Deprecated] | ||
const MY_CONST = true; | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Attribute "Deprecated" must not be repeated in %s on line %d |
36 changes: 36 additions & 0 deletions
36
Zend/tests/attributes/constants/not_repeatable-userland.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,36 @@ | ||
--TEST-- | ||
Validation of attribute repetition (not allowed; userland attribute) | ||
--FILE-- | ||
<?php | ||
|
||
#[Attribute] | ||
class MyAttribute {} | ||
|
||
#[MyAttribute] | ||
#[MyAttribute] | ||
const MY_CONST = true; | ||
|
||
$attributes = new ReflectionConstant( 'MY_CONST' )->getAttributes(); | ||
var_dump( $attributes ); | ||
$attributes[0]->newInstance(); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(2) { | ||
[0]=> | ||
object(ReflectionAttribute)#%d (1) { | ||
["name"]=> | ||
string(11) "MyAttribute" | ||
} | ||
[1]=> | ||
object(ReflectionAttribute)#%d (1) { | ||
["name"]=> | ||
string(11) "MyAttribute" | ||
} | ||
} | ||
|
||
Fatal error: Uncaught Error: Attribute "MyAttribute" must not be repeated in %s:%d | ||
Stack trace: | ||
#0 %s(%d): ReflectionAttribute->newInstance() | ||
#1 {main} | ||
thrown in %s on line %d |
16 changes: 16 additions & 0 deletions
16
Zend/tests/attributes/constants/yes_repeatable-internal.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,16 @@ | ||
--TEST-- | ||
Validation of attribute repetition (is allowed; internal attribute) | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
#[ZendTestRepeatableAttribute] | ||
#[ZendTestRepeatableAttribute] | ||
const MY_CONST = true; | ||
|
||
echo "Done\n"; | ||
|
||
?> | ||
--EXPECT-- | ||
Done |
30 changes: 30 additions & 0 deletions
30
Zend/tests/attributes/constants/yes_repeatable-userland.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,30 @@ | ||
--TEST-- | ||
Validation of attribute repetition (is allowed; userland attribute) | ||
--FILE-- | ||
<?php | ||
|
||
#[Attribute(Attribute::TARGET_ALL|Attribute::IS_REPEATABLE)] | ||
class MyAttribute {} | ||
|
||
#[MyAttribute] | ||
#[MyAttribute] | ||
const MY_CONST = true; | ||
|
||
$attributes = new ReflectionConstant( 'MY_CONST' )->getAttributes(); | ||
var_dump( $attributes ); | ||
$attributes[0]->newInstance(); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(2) { | ||
[0]=> | ||
object(ReflectionAttribute)#%d (1) { | ||
["name"]=> | ||
string(11) "MyAttribute" | ||
} | ||
[1]=> | ||
object(ReflectionAttribute)#%d (1) { | ||
["name"]=> | ||
string(11) "MyAttribute" | ||
} | ||
} |