Skip to content

Commit 634c3a4

Browse files
committed
:octocat:
1 parent 95ad239 commit 634c3a4

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/Document.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getElementsBySelector(string $selector, DOMNode $contextNode = n
6969
* @param string $axis
7070
* @param int $nodeType
7171
*
72-
* @return array
72+
* @return \DOMNode[]
7373
*/
7474
public function select($selectors = null, DOMNode $contextNode = null, string $axis = 'descendant-or-self::', int $nodeType = XML_ELEMENT_NODE):array{
7575

@@ -166,7 +166,7 @@ public function _toDOMNodeList($content):DOMNodeList{
166166
* @param int $maxLength
167167
* @param int $nodeType
168168
*
169-
* @return array[\chillerlan\PrototypeDOM\Element]
169+
* @return \DOMNode[]
170170
*/
171171
public function recursivelyCollect(DOMNode $element, string $property, int $maxLength = -1, int $nodeType = XML_ELEMENT_NODE):array{
172172
$nodes = [];
@@ -197,16 +197,16 @@ public function recursivelyCollect(DOMNode $element, string $property, int $maxL
197197
* @param int $index
198198
* @param int $nodeType
199199
*
200-
* @return \chillerlan\PrototypeDOM\Element|\DOMNode|null
200+
* @return \DOMNode|null
201201
*/
202202
public function _recursivelyFind(DOMNode $element, string $property, string $selector = null, int $index = 0, int $nodeType = XML_ELEMENT_NODE){
203203

204204
if(in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){
205205

206+
/** @var \chillerlan\PrototypeDOM\Element $element */
206207
while($element = $element->{$property}){
207208

208-
/** @var \chillerlan\PrototypeDOM\Element $element */
209-
if($element->nodeType !== $nodeType || $selector && !$element->match($selector) || --$index >= 0){
209+
if($element->nodeType !== $nodeType || !is_null($selector) && !$element->match($selector) || --$index >= 0){
210210
continue;
211211
}
212212

src/Element.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace chillerlan\PrototypeDOM;
1414

15-
use DOMElement, DOMNode, DOMNodeList;
15+
use DOMElement;
1616

1717
class Element extends DOMElement{
1818
use NodeTraversalTrait, NodeManipulationTrait;
@@ -25,7 +25,7 @@ class Element extends DOMElement{
2525
public function id(string $newID = null):string {
2626
$oldID = $this->getAttribute('id');
2727

28-
if($newID){
28+
if(!is_null($newID)){
2929
$this->setAttribute('id', $newID);
3030
}
3131

@@ -146,7 +146,7 @@ public function toggleClassName(string $classname):Element{
146146
}
147147

148148
/**
149-
* @return array
149+
* @return string[]
150150
*/
151151
public function getStyle():array{
152152
$currentStyle = [];
@@ -210,7 +210,7 @@ public function setStyle(array $style, bool $replace = false):Element{
210210
}
211211

212212
/**
213-
* @return array
213+
* @return string[]
214214
*/
215215
public function getAttributes():array{
216216
$attributes = [];

src/NodeTraversalTrait.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace chillerlan\PrototypeDOM;
1414

15-
use DOMNode, DOMNodeList;
15+
use DOMNode;
1616

1717
/**
1818
* @extends \DOMNode
@@ -31,7 +31,7 @@ trait NodeTraversalTrait{
3131
* @param int $maxLength
3232
* @param int $nodeType
3333
*
34-
* @return array [\chillerlan\PrototypeDOM\Element]
34+
* @return \chillerlan\PrototypeDOM\Element[]
3535
*/
3636
public function recursivelyCollect(string $property, int $maxLength = -1, int $nodeType = XML_ELEMENT_NODE):array{
3737
/** @var \DOMNode $this */
@@ -138,7 +138,7 @@ public function next($expression = null, int $index = null){
138138
/**
139139
* @param int $nodeType
140140
*
141-
* @return array[\chillerlan\PrototypeDOM\Element]
141+
* @return \chillerlan\PrototypeDOM\Element[]
142142
*/
143143
public function childElements(int $nodeType = XML_ELEMENT_NODE):array{
144144
$children = [];
@@ -177,21 +177,21 @@ public function descendantOf(DOMNode $ancestor):bool{
177177
}
178178

179179
/**
180-
* @return array[\chillerlan\PrototypeDOM\Element]
180+
* @return \chillerlan\PrototypeDOM\Element[]
181181
*/
182182
public function ancestors():array{
183183
return $this->recursivelyCollect('parentNode');
184184
}
185185

186186
/**
187-
* @return array[\chillerlan\PrototypeDOM\Element]
187+
* @return \chillerlan\PrototypeDOM\Element[]
188188
*/
189189
public function siblings():array{
190190
return array_merge(array_reverse($this->previousSiblings()), $this->nextSiblings());
191191
}
192192

193193
/**
194-
* @return array[\chillerlan\PrototypeDOM\Element]
194+
* @return \chillerlan\PrototypeDOM\Element[]
195195
*/
196196
public function descendants():array{
197197
return $this->select();
@@ -205,14 +205,14 @@ public function firstDescendant(){
205205
}
206206

207207
/**
208-
* @return array[\chillerlan\PrototypeDOM\Element]
208+
* @return \chillerlan\PrototypeDOM\Element[]
209209
*/
210210
public function previousSiblings():array{
211211
return $this->recursivelyCollect('previousSibling');
212212
}
213213

214214
/**
215-
* @return array[\chillerlan\PrototypeDOM\Element]
215+
* @return \chillerlan\PrototypeDOM\Element[]
216216
*/
217217
public function nextSiblings():array{
218218
return $this->recursivelyCollect('nextSibling');

0 commit comments

Comments
 (0)