-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tokenizer: add support for php8 attributes
- Loading branch information
Showing
9 changed files
with
593 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/* testAttribute */ | ||
#[Attribute] | ||
class CustomAttribute {} | ||
|
||
/* testAttributeWithParams */ | ||
#[Attribute(Attribute::TARGET_CLASS)] | ||
class SecondCustomAttribute {} | ||
|
||
/* testAttributeWithNamedParam */ | ||
#[Attribute(flags: Attribute::TARGET_ALL)] | ||
class AttributeWithParams { | ||
public function __construct($foo, array $bar) {} | ||
} | ||
|
||
/* testAttributeOnFunction */ | ||
#[CustomAttribute] | ||
function attribute_on_function_test() {} | ||
|
||
/* testAttributeOnFunctionWithParams */ | ||
#[AttributeWithParams('foo', bar: ['bar' => 'foobar'])] | ||
function attribute_with_params_on_function_test() {} | ||
|
||
/* testTwoAttributeOnTheSameLine */ | ||
#[CustomAttribute] #[AttributeWithParams('foo')] | ||
function two_attribute_on_same_line_test() {} | ||
|
||
/* testAttributeAndCommentOnTheSameLine */ | ||
#[CustomAttribute] // This is a comment | ||
function attribute_and_line_comment_on_same_line_test() {} | ||
|
||
/* testAttributeGrouping */ | ||
#[CustomAttribute, AttributeWithParams('foo'), AttributeWithParams('foo', bar: ['bar' => 'foobar'])] | ||
function attribute_grouping_test() {} | ||
|
||
/* testAttributeMultiline */ | ||
#[ | ||
CustomAttribute, | ||
AttributeWithParams('foo'), | ||
AttributeWithParams('foo', bar: ['bar' => 'foobar']) | ||
] | ||
function attribute_multiline_test() {} | ||
|
||
/* testAttributeMultilineWithComment */ | ||
#[ | ||
CustomAttribute, // comment | ||
AttributeWithParams(/* another comment */ 'foo'), | ||
AttributeWithParams('foo', bar: ['bar' => 'foobar']) | ||
] | ||
function attribute_multiline_with_comment_test() {} | ||
|
||
/* testSingleAttributeOnParameter */ | ||
function single_attribute_on_parameter_test(#[ParamAttribute] int $param) {} | ||
|
||
/* testMultipleAttributesOnParameter */ | ||
function multiple_attributes_on_parameter_test(#[ParamAttribute, AttributeWithParams(/* another comment */ 'foo')] int $param) {} | ||
|
||
/* testMultilineAttributesOnParameter */ | ||
function multiline_attributes_on_parameter_test(#[ | ||
AttributeWithParams( | ||
'foo' | ||
) | ||
] int $param) {} | ||
|
||
/* testInvalidAttribute */ | ||
#[ThisIsNotAnAttribute | ||
function invalid_attribute_test() {} | ||
|
Oops, something went wrong.