These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace ByJG\AnyDataset\Dataset; |
||
4 | |||
5 | use ByJG\AnyDataset\Exception\DatasetException; |
||
6 | use ByJG\Util\XmlUtil; |
||
7 | use DOMDocument; |
||
8 | use InvalidArgumentException; |
||
9 | |||
10 | class XmlDataset |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * String |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | private $rowNode = null; |
||
19 | |||
20 | /** |
||
21 | * Enter description here... |
||
22 | * |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private $colNodes = null; |
||
26 | |||
27 | /** |
||
28 | * @var DOMDocument |
||
29 | */ |
||
30 | private $domDocument; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $registerNS; |
||
37 | |||
38 | /** |
||
39 | * @param DOMDocument|string $xml |
||
40 | * @param string $rowNode |
||
41 | * @param string[] $colNode |
||
42 | * @param array $registerNS |
||
43 | * @throws \ByJG\AnyDataset\Exception\DatasetException |
||
44 | * @throws \ByJG\Util\Exception\XmlUtilException |
||
45 | */ |
||
46 | 8 | public function __construct($xml, $rowNode, $colNode, $registerNS = null) |
|
47 | { |
||
48 | 8 | if (!is_array($colNode)) { |
|
49 | throw new DatasetException("XmlDataset constructor: Column nodes must be an array."); |
||
50 | } |
||
51 | |||
52 | 8 | if ($xml instanceof DOMDocument) { |
|
53 | $this->domDocument = $xml; |
||
54 | } else { |
||
55 | 8 | $this->domDocument = XmlUtil::createXmlDocumentFromStr($xml); |
|
56 | } |
||
57 | |||
58 | 7 | if (is_null($registerNS)) { |
|
59 | 6 | $registerNS = array(); |
|
60 | } |
||
61 | |||
62 | 7 | if (!is_array($registerNS)) { |
|
63 | throw new InvalidArgumentException('The parameter $registerNS must be an associative array'); |
||
64 | } |
||
65 | |||
66 | 7 | $this->registerNS = $registerNS; |
|
0 ignored issues
–
show
|
|||
67 | 7 | $this->rowNode = $rowNode; |
|
68 | 7 | $this->colNodes = $colNode; |
|
69 | 7 | } |
|
70 | |||
71 | /** |
||
72 | * @access public |
||
73 | * @return GenericIterator |
||
74 | * @throws \ByJG\Util\Exception\XmlUtilException |
||
75 | */ |
||
76 | 7 | public function getIterator() |
|
77 | { |
||
78 | 7 | $iterator = new XmlIterator( |
|
79 | 7 | XmlUtil::selectNodes( |
|
80 | 7 | $this->domDocument->documentElement, |
|
81 | 7 | $this->rowNode, |
|
82 | 7 | $this->registerNS |
|
0 ignored issues
–
show
$this->registerNS is of type string , but the function expects a array|null .
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: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
83 | ), |
||
84 | 7 | $this->colNodes, |
|
85 | 7 | $this->registerNS |
|
86 | ); |
||
87 | 7 | return $iterator; |
|
88 | } |
||
89 | } |
||
90 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..