-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for properties, class constants, params, enums
- Loading branch information
Showing
7 changed files
with
242 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Attributes; | ||
|
||
#[AttributeClass] | ||
enum EnumWithAttributes | ||
{ | ||
|
||
#[AttributeClass] | ||
public const ENUM_CONST = true; | ||
|
||
#[AttributeClass] | ||
case Foo; | ||
|
||
} | ||
|
||
|
||
#[AttributeClass] | ||
trait TraitWithAttributes | ||
{ | ||
|
||
#[AttributeClass] | ||
private const TRAIT_CONST = true; | ||
|
||
#[AttributeClass] | ||
private $bar; | ||
|
||
|
||
#[AttributeClass] | ||
public function traitMethod( | ||
#[AttributeClass] | ||
bool $param | ||
): void { | ||
} | ||
|
||
} | ||
|
||
// https://phpstan.org/blog/how-phpstan-analyses-traits | ||
class ClassWithTraitWithAttributes | ||
{ | ||
|
||
use TraitWithAttributes; | ||
|
||
} | ||
|
||
|
||
#[AttributeClass] | ||
interface InterfaceWithAttributes | ||
{ | ||
|
||
#[AttributeClass] | ||
public function interfaceMethod( | ||
#[AttributeClass] | ||
bool $param | ||
): void; | ||
|
||
} | ||
|
||
|
||
#[AttributeClass] | ||
function functionWithAttributes( | ||
#[AttributeClass] | ||
int $param | ||
): void { | ||
} | ||
|
||
|
||
$anonymousFunction = #[AttributeClass] function ( | ||
#[AttributeClass] | ||
int $param | ||
): void { | ||
}; | ||
|
||
|
||
$arrowFunction = #[AttributeClass] fn( | ||
#[AttributeClass] | ||
int $param | ||
) => 1; |
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