These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types = 1); |
||
4 | |||
5 | namespace HDNET\Autoloader\Annotation; |
||
6 | |||
7 | /** |
||
8 | * @Annotation |
||
9 | * @Target({"CLASS"}) |
||
10 | */ |
||
11 | class DatabaseTable |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | public $tableName; |
||
17 | |||
18 | /** |
||
19 | * @throws \InvalidArgumentException |
||
20 | */ |
||
21 | public function __construct(array $values) |
||
22 | { |
||
23 | if (isset($values['value'])) { |
||
24 | $this->argumentName = $values['value']; |
||
0 ignored issues
–
show
|
|||
25 | } elseif (isset($values['argumentName'])) { |
||
26 | $this->argumentName = $values['argumentName']; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | public function __toString() |
||
31 | { |
||
32 | return (string)$this->tableName; |
||
33 | } |
||
34 | } |
||
35 |
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: