1 | <?php |
||
35 | class Requires |
||
36 | { |
||
37 | /** |
||
38 | * The annotation which identifies this annotation class |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | const ANNOTATION = 'Requires'; |
||
43 | |||
44 | /** |
||
45 | * The assertion type to use. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $type; |
||
50 | |||
51 | /** |
||
52 | * The constraint to use for assertion. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $constraint; |
||
57 | |||
58 | /** |
||
59 | * The constructor the initializes the instance with the |
||
60 | * data passed with the token. |
||
61 | * |
||
62 | * @param array $values The annotation values |
||
63 | */ |
||
64 | public function __construct(array $values = array()) |
||
77 | |||
78 | /** |
||
79 | * This method returns the class name as a string |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | public static function __getClass() |
||
87 | |||
88 | /** |
||
89 | * Returns the value of the name attribute. |
||
90 | * |
||
91 | * @return string|null The annotations name attribute |
||
92 | */ |
||
93 | public function getType() |
||
97 | |||
98 | /** |
||
99 | * Returns the value of the constraint attribute. |
||
100 | * |
||
101 | * @return string|null The annotations constraint attribute |
||
102 | */ |
||
103 | public function getConstraint() |
||
107 | } |
||
108 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: