Conditions | 8 |
Paths | 7 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types = 1); |
||
23 | public function __construct($data = null, bool $strict = false) |
||
24 | { |
||
25 | if (is_array($data) || is_object($data)) { |
||
26 | foreach ($data as $key => $value) { |
||
27 | $this->setField($key, $value, $strict); |
||
28 | } |
||
29 | } elseif ($data !== null) { |
||
30 | throw new InvalidArgumentException( |
||
31 | get_called_class() . |
||
32 | ' constructor expects array, object, or null' |
||
33 | ); |
||
34 | } |
||
35 | |||
36 | if ($this instanceof Resource && !count($this->type ?? [])) { |
||
|
|||
37 | $class = get_called_class(); |
||
38 | if (count($class::TYPES)) { |
||
39 | $this->type = new Listing([$class::TYPES[0]]); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.