1 | <?php |
||
48 | class Item extends \Jkphl\Micrometa\Domain\Item\Item implements ItemInterface |
||
49 | { |
||
50 | /** |
||
51 | * Parser format |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | protected $format; |
||
56 | /** |
||
57 | * Item value |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $value; |
||
62 | /** |
||
63 | * Nested Items |
||
64 | * |
||
65 | * @var ItemInterface[] |
||
66 | */ |
||
67 | protected $children; |
||
68 | |||
69 | /** |
||
70 | * Item constructor |
||
71 | * |
||
72 | * @param int $format Parser format |
||
73 | * @param PropertyListFactoryInterface $propertyListFactory Property list factory |
||
74 | * @param string|array $type Item type(s) |
||
75 | * @param array[] $properties Item properties |
||
76 | * @param ItemInterface[] $children Nested items |
||
77 | * @param string|null $itemId Item id |
||
78 | * @param string|null $value Item value |
||
79 | */ |
||
80 | 17 | public function __construct( |
|
94 | |||
95 | /** |
||
96 | * Return the item value |
||
97 | * |
||
98 | * @return string Item value |
||
99 | */ |
||
100 | 1 | public function getValue() |
|
101 | { |
||
102 | 1 | return $this->value; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Export the object |
||
107 | * |
||
108 | * @return mixed |
||
109 | */ |
||
110 | 1 | public function export() |
|
111 | { |
||
112 | return (object)[ |
||
113 | 1 | 'format' => $this->getFormat(), |
|
114 | 1 | 'types' => array_map( |
|
115 | function ($type) { |
||
116 | 1 | return $type->profile.$type->name; |
|
117 | 1 | }, |
|
118 | 1 | $this->getType() |
|
119 | 1 | ), |
|
120 | 1 | 'properties' => $this->getProperties()->export(), |
|
121 | 1 | 'items' => array_map( |
|
122 | 1 | function (ItemInterface $item) { |
|
123 | 1 | return $item->export(); |
|
124 | 1 | }, |
|
125 | 1 | $this->getChildren() |
|
126 | 1 | ) |
|
127 | 1 | ]; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * Return the parser format |
||
132 | * |
||
133 | * @return int Parser format |
||
134 | */ |
||
135 | 5 | public function getFormat() |
|
139 | |||
140 | /** |
||
141 | * Return the nested children |
||
142 | * |
||
143 | * @return ItemInterface[] Nested children |
||
144 | */ |
||
145 | 11 | public function getChildren() |
|
149 | } |
||
150 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.