1 | <?php |
||
58 | class ParseIpAddrOutput |
||
59 | { |
||
60 | /** |
||
61 | * parse the output of the 'ip addr show' command |
||
62 | * |
||
63 | * @param mixed $output |
||
64 | * the output to parse |
||
65 | * @return array<NetInterface> |
||
66 | * a list of the network interfaces extracted from the given |
||
67 | * command output |
||
68 | */ |
||
69 | public function __invoke($output) |
||
73 | |||
74 | /** |
||
75 | * parse the output of the 'ip addr show' command |
||
76 | * |
||
77 | * @param mixed $output |
||
78 | * the output to parse |
||
79 | * @return array<NetInterface> |
||
80 | * a list of the network interfaces extracted from the given |
||
81 | * command output |
||
82 | */ |
||
83 | public static function from($output) |
||
88 | |||
89 | /** |
||
90 | * parse the output of the 'ip addr show' command |
||
91 | * |
||
92 | * @param Traversable $output |
||
93 | * the output to parse |
||
94 | * @return array<NetInterface> |
||
95 | * a list of the network interfaces extracted from the given |
||
96 | * command output |
||
97 | */ |
||
98 | private static function fromTraversable($output) |
||
122 | |||
123 | /** |
||
124 | * convert the output of the 'ip addr show' command into smaller groups |
||
125 | * that are easier to parse |
||
126 | * |
||
127 | * @param array|Traversable $lines |
||
128 | * the output to group |
||
129 | * @return array |
||
130 | * the grouped output |
||
131 | */ |
||
132 | private static function groupOutputIntoInterfaces($lines) |
||
157 | |||
158 | /** |
||
159 | * parse the output of the 'ip addr show' command |
||
160 | * |
||
161 | * @param string $output |
||
162 | * the output to parse |
||
163 | * @return array<NetInterface> |
||
164 | * a list of the network interfaces extracted from the given |
||
165 | * command output |
||
166 | */ |
||
167 | private static function fromString($output) |
||
172 | |||
173 | /** |
||
174 | * called when we've been given a data type that we do not support |
||
175 | * |
||
176 | * @param mixed $output |
||
177 | * the unsupported data |
||
178 | * @return void |
||
179 | * @throws E4xx_UnsupportedType |
||
180 | */ |
||
181 | private static function nothingMatchesTheInputType($output) |
||
185 | |||
186 | /** |
||
187 | * a map of which method to use for which type of data we're asked to |
||
188 | * process |
||
189 | * |
||
190 | * @var array |
||
191 | */ |
||
192 | private static $dispatchMap = [ |
||
193 | 'Traversable' => 'fromTraversable', |
||
194 | 'String' => 'fromString', |
||
195 | ]; |
||
196 | } |
||
197 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: