@@ -15,7 +15,11 @@ |
||
| 15 | 15 | use chillerlan\PrototypeDOM\Node\{Element, PrototypeNode}; |
| 16 | 16 | use chillerlan\Traits\{Enumerable, Interfaces\ArrayAccessTrait, Magic}; |
| 17 | 17 | use chillerlan\Traits\SPL\{CountableTrait, SeekableIteratorTrait}; |
| 18 | -use ArrayAccess, Countable, DOMNode, DOMNodeList, SeekableIterator; |
|
| 18 | +use ArrayAccess; |
|
| 19 | +use Countable; |
|
| 20 | +use DOMNode; |
|
| 21 | +use DOMNodeList; |
|
| 22 | +use SeekableIterator; |
|
| 19 | 23 | |
| 20 | 24 | /** |
| 21 | 25 | * @property int $length |
@@ -51,11 +51,9 @@ |
||
| 51 | 51 | |
| 52 | 52 | if($nodes instanceof DOMNodeList){ |
| 53 | 53 | $this->array = \iterator_to_array($nodes); |
| 54 | - } |
|
| 55 | - elseif($nodes instanceof NodeList){ |
|
| 54 | + } elseif($nodes instanceof NodeList){ |
|
| 56 | 55 | $this->array = $nodes->toArray(); |
| 57 | - } |
|
| 58 | - elseif(\is_iterable($nodes)){ |
|
| 56 | + } elseif(\is_iterable($nodes)){ |
|
| 59 | 57 | foreach($nodes as $node){ |
| 60 | 58 | if($node instanceof DOMNode || $node instanceof PrototypeNode){ |
| 61 | 59 | $this->array[] = $node; |
@@ -47,17 +47,17 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @throws \Exception |
| 49 | 49 | */ |
| 50 | - public function __construct(iterable $nodes = null){ |
|
| 50 | + public function __construct(iterable $nodes = null) { |
|
| 51 | 51 | |
| 52 | - if($nodes instanceof DOMNodeList){ |
|
| 52 | + if ($nodes instanceof DOMNodeList) { |
|
| 53 | 53 | $this->array = \iterator_to_array($nodes); |
| 54 | 54 | } |
| 55 | - elseif($nodes instanceof NodeList){ |
|
| 55 | + elseif ($nodes instanceof NodeList) { |
|
| 56 | 56 | $this->array = $nodes->toArray(); |
| 57 | 57 | } |
| 58 | - elseif(\is_iterable($nodes)){ |
|
| 59 | - foreach($nodes as $node){ |
|
| 60 | - if($node instanceof DOMNode || $node instanceof PrototypeNode){ |
|
| 58 | + elseif (\is_iterable($nodes)) { |
|
| 59 | + foreach ($nodes as $node) { |
|
| 60 | + if ($node instanceof DOMNode || $node instanceof PrototypeNode) { |
|
| 61 | 61 | $this->array[] = $node; |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function match(DOMNode $node):bool{ |
| 90 | 90 | /** @var \chillerlan\PrototypeDOM\Node\Element $element */ |
| 91 | - foreach($this->array as $element){ |
|
| 91 | + foreach ($this->array as $element) { |
|
| 92 | 92 | |
| 93 | - if($element->isSameNode($node)){ |
|
| 93 | + if ($element->isSameNode($node)) { |
|
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null |
| 106 | 106 | */ |
| 107 | - public function item(int $offset):?DOMNode{ |
|
| 107 | + public function item(int $offset): ?DOMNode{ |
|
| 108 | 108 | return $this->array[$offset] ?? null; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function offsetSet($offset, $value):void{ |
| 142 | 142 | |
| 143 | - if($value instanceof DOMNode){ |
|
| 143 | + if ($value instanceof DOMNode) { |
|
| 144 | 144 | |
| 145 | 145 | \is_int($offset) |
| 146 | 146 | ? $this->array[$offset] = $value |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null |
| 157 | 157 | */ |
| 158 | - public function first():?DOMNode{ |
|
| 158 | + public function first(): ?DOMNode{ |
|
| 159 | 159 | return $this->__first(); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null |
| 166 | 166 | */ |
| 167 | - public function last():?DOMNode{ |
|
| 167 | + public function last(): ?DOMNode{ |
|
| 168 | 168 | return $this->__last(); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * @property bool $schemaTypeInfo |
| 17 | 17 | * @property string $tagName |
| 18 | 18 | */ |
| 19 | -interface PrototypeElement extends PrototypeTraversal{ |
|
| 19 | +interface PrototypeElement extends PrototypeTraversal { |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * @link http://api.prototypejs.org/dom/Element/wrap/ |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @property string $href |
| 20 | 20 | * @property string $src |
| 21 | 21 | */ |
| 22 | -interface PrototypeHTMLElement extends PrototypeElement{ |
|
| 22 | +interface PrototypeHTMLElement extends PrototypeElement { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * http://api.prototypejs.org/dom/Element/identify/ |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return null|string |
| 82 | 82 | */ |
| 83 | - public function getStyle(string $property):?string; |
|
| 83 | + public function getStyle(string $property): ?string; |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @link http://api.prototypejs.org/dom/Element/setStyle/ |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | * @property string $baseURI |
| 33 | 33 | * @property string $textContent |
| 34 | 34 | */ |
| 35 | -interface PrototypeNode{ |
|
| 35 | +interface PrototypeNode { |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @link http://api.prototypejs.org/dom/Element/recursivelyCollect/ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @param string|array|\DOMNode|\DOMNodeList $content |
| 52 | 52 | * |
| 53 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeElement |
|
| 53 | + * @return PrototypeElementTrait |
|
| 54 | 54 | */ |
| 55 | 55 | public function insert($content):PrototypeElement{ |
| 56 | 56 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param \chillerlan\PrototypeDOM\Node\PrototypeElement $node |
| 89 | 89 | * @param \chillerlan\PrototypeDOM\Node\PrototypeElement|null $refNode |
| 90 | 90 | * |
| 91 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeElement |
|
| 91 | + * @return PrototypeElementTrait |
|
| 92 | 92 | */ |
| 93 | 93 | public function insert_before(PrototypeElement $node, PrototypeElement $refNode = null):PrototypeElement{ |
| 94 | 94 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * @param \chillerlan\PrototypeDOM\Node\PrototypeElement $node |
| 132 | 132 | * |
| 133 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeElement |
|
| 133 | + * @return PrototypeElementTrait |
|
| 134 | 134 | */ |
| 135 | 135 | public function insert_bottom(PrototypeElement $node):PrototypeElement{ |
| 136 | 136 | $this->appendChild($this->importNode($node)); |
@@ -12,8 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\PrototypeDOM\Node; |
| 14 | 14 | |
| 15 | -use chillerlan\PrototypeDOM\NodeList; |
|
| 16 | - |
|
| 17 | 15 | trait PrototypeElementTrait{ |
| 18 | 16 | use PrototypeTraversalTrait; |
| 19 | 17 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\PrototypeDOM\NodeList; |
| 16 | 16 | |
| 17 | -trait PrototypeElementTrait{ |
|
| 17 | +trait PrototypeElementTrait { |
|
| 18 | 18 | use PrototypeTraversalTrait; |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -54,28 +54,28 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function insert($content):PrototypeElement{ |
| 56 | 56 | |
| 57 | - if(!\is_array($content)){ |
|
| 57 | + if (!\is_array($content)) { |
|
| 58 | 58 | |
| 59 | - foreach($this->ownerDocument->toNodeList($content) as $node){ |
|
| 59 | + foreach ($this->ownerDocument->toNodeList($content) as $node) { |
|
| 60 | 60 | $this->insert_bottom($node); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | return $this; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - foreach(['before', 'after', 'top', 'bottom'] as $pos){ |
|
| 66 | + foreach (['before', 'after', 'top', 'bottom'] as $pos) { |
|
| 67 | 67 | |
| 68 | - if(!\array_key_exists($pos, $content)){ |
|
| 68 | + if (!\array_key_exists($pos, $content)) { |
|
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $nodes = $this->ownerDocument->toNodeList($content[$pos]); |
| 73 | 73 | |
| 74 | - if($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling){ |
|
| 74 | + if ($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling) { |
|
| 75 | 75 | $nodes->reverse(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - foreach($nodes as $node){ |
|
| 78 | + foreach ($nodes as $node) { |
|
| 79 | 79 | \call_user_func_array([$this, 'insert_'.$pos], [$node]); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function insert_before(PrototypeElement $node, PrototypeElement $refNode = null):PrototypeElement{ |
| 94 | 94 | |
| 95 | - if($this->parentNode){ |
|
| 95 | + if ($this->parentNode) { |
|
| 96 | 96 | $this->parentNode->insertBefore($this->importNode($node), $refNode ?? $this); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function insert_after(PrototypeElement $node):PrototypeElement{ |
| 108 | 108 | |
| 109 | - if(!$this->nextSibling && $this->parentNode){ |
|
| 109 | + if (!$this->nextSibling && $this->parentNode) { |
|
| 110 | 110 | return $this->parentNode->insert_bottom($node); // @codeCoverageIgnore |
| 111 | 111 | } |
| 112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function insert_top(PrototypeElement $node):PrototypeElement{ |
| 122 | 122 | |
| 123 | - if($this->hasChildNodes()){ |
|
| 123 | + if ($this->hasChildNodes()) { |
|
| 124 | 124 | return $this->firstChild->insert_before($node, $this->firstChild); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -175,7 +175,7 @@ |
||
| 175 | 175 | * @param array $style |
| 176 | 176 | * @param bool $replace |
| 177 | 177 | * |
| 178 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
|
| 178 | + * @return PrototypeHTMLElementTrait |
|
| 179 | 179 | */ |
| 180 | 180 | public function setStyle(array $style, bool $replace = null):PrototypeHTMLElement{ |
| 181 | 181 | $currentStyle = $this->getStyles(); |
@@ -12,8 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\PrototypeDOM\Node; |
| 14 | 14 | |
| 15 | -use chillerlan\Traits\Magic; |
|
| 16 | - |
|
| 17 | 15 | /** |
| 18 | 16 | * @property string $id |
| 19 | 17 | * @property string $class |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * @property string $src |
| 22 | 22 | * @property string $innerHTML |
| 23 | 23 | */ |
| 24 | -trait PrototypeHTMLElementTrait{ |
|
| 24 | +trait PrototypeHTMLElementTrait { |
|
| 25 | 25 | use PrototypeElementTrait; |
| 26 | 26 | |
| 27 | 27 | protected function magic_get_id():string{ |
| 28 | 28 | return \trim($this->getAttribute('id')); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - protected function magic_set_id(string $id){ |
|
| 31 | + protected function magic_set_id(string $id) { |
|
| 32 | 32 | return $this->setAttribute('id', $id); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return \trim($this->getAttribute('class')); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - protected function magic_set_class(string $class){ |
|
| 39 | + protected function magic_set_class(string $class) { |
|
| 40 | 40 | return $this->setAttribute('class', $class); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return \trim($this->getAttribute('href')); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - protected function magic_set_href(string $href){ |
|
| 47 | + protected function magic_set_href(string $href) { |
|
| 48 | 48 | return $this->setAttribute('href', $href); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return \trim($this->getAttribute('src')); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function magic_set_src(string $src){ |
|
| 55 | + protected function magic_set_src(string $src) { |
|
| 56 | 56 | return $this->setAttribute('src', $src); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function identify(string $newID = null):string{ |
| 71 | 71 | $oldID = $this->id; |
| 72 | 72 | |
| 73 | - if($newID !== null){ |
|
| 73 | + if ($newID !== null) { |
|
| 74 | 74 | $this->id = $newID; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function classNames():array{ |
| 86 | 86 | |
| 87 | - if(!$this->hasAttributes()){ |
|
| 87 | + if (!$this->hasAttributes()) { |
|
| 88 | 88 | return []; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $classnames = \explode(' ', $this->class); |
| 92 | 92 | $currentClassnames = []; |
| 93 | 93 | |
| 94 | - foreach($classnames as $classname){ |
|
| 94 | + foreach ($classnames as $classname) { |
|
| 95 | 95 | |
| 96 | - if(empty($classname)){ |
|
| 96 | + if (empty($classname)) { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function toggleClassName(string $classname):PrototypeHTMLElement{ |
| 147 | 147 | |
| 148 | - if($this->hasClassName($classname)){ |
|
| 148 | + if ($this->hasClassName($classname)) { |
|
| 149 | 149 | return $this->removeClassName($classname); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return null|string |
| 161 | 161 | */ |
| 162 | - public function getStyle(string $property):?string{ |
|
| 162 | + public function getStyle(string $property): ?string{ |
|
| 163 | 163 | $currentStyle = $this->getStyles(); |
| 164 | 164 | |
| 165 | - if(\array_key_exists(\strtolower($property), $currentStyle)){ |
|
| 165 | + if (\array_key_exists(\strtolower($property), $currentStyle)) { |
|
| 166 | 166 | return $currentStyle[$property]; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | public function setStyle(array $style, bool $replace = null):PrototypeHTMLElement{ |
| 181 | 181 | $currentStyle = $this->getStyles(); |
| 182 | 182 | |
| 183 | - if($replace !== true){ |
|
| 183 | + if ($replace !== true) { |
|
| 184 | 184 | $style = \array_merge($currentStyle, $style); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - foreach($style as $property => $value){ |
|
| 187 | + foreach ($style as $property => $value) { |
|
| 188 | 188 | $style[$property] = $property.': '.$value.';'; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeNode |
|
| 101 | + * @return PrototypeNodeTrait |
|
| 102 | 102 | */ |
| 103 | 103 | public function purge():PrototypeNode{ |
| 104 | 104 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | /** |
| 113 | 113 | * @link http://api.prototypejs.org/dom/Element/cleanWhitespace/ |
| 114 | 114 | * |
| 115 | - * @return \chillerlan\PrototypeDOM\Node\PrototypeNode |
|
| 115 | + * @return PrototypeNodeTrait |
|
| 116 | 116 | */ |
| 117 | 117 | public function cleanWhitespace():PrototypeNode{ |
| 118 | 118 | $node = $this->firstChild; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @property string $baseURI |
| 33 | 33 | * @property string $textContent |
| 34 | 34 | */ |
| 35 | -trait PrototypeNodeTrait{ |
|
| 35 | +trait PrototypeNodeTrait { |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @link http://api.prototypejs.org/dom/Element/recursivelyCollect/ |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function remove():PrototypeNode{ |
| 76 | 76 | |
| 77 | - if(!$this->parentNode){ |
|
| 77 | + if (!$this->parentNode) { |
|
| 78 | 78 | return $this; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function replace(PrototypeNode $newnode):PrototypeNode{ |
| 92 | 92 | |
| 93 | - if(!$this->parentNode){ |
|
| 93 | + if (!$this->parentNode) { |
|
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function purge():PrototypeNode{ |
| 104 | 104 | |
| 105 | - while($this->hasChildNodes()){ |
|
| 105 | + while ($this->hasChildNodes()) { |
|
| 106 | 106 | $this->firstChild->remove(); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | public function cleanWhitespace():PrototypeNode{ |
| 118 | 118 | $node = $this->firstChild; |
| 119 | 119 | |
| 120 | - while($node){ |
|
| 120 | + while ($node) { |
|
| 121 | 121 | $nextNode = $node->nextSibling; |
| 122 | 122 | |
| 123 | - if($node->nodeType === \XML_TEXT_NODE && $node->empty()){ |
|
| 123 | + if ($node->nodeType === \XML_TEXT_NODE && $node->empty()) { |
|
| 124 | 124 | $node->remove(); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | use PrototypeNodeTrait; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @param $selector |
|
| 25 | + * @param string|null $selector |
|
| 26 | 26 | * @param $index |
| 27 | 27 | * @param string $property |
| 28 | 28 | * @param int $nodeType https://secure.php.net/manual/dom.constants.php |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @property \chillerlan\PrototypeDOM\Document $ownerDocument |
| 20 | 20 | */ |
| 21 | -trait PrototypeTraversalTrait{ |
|
| 21 | +trait PrototypeTraversalTrait { |
|
| 22 | 22 | use PrototypeNodeTrait; |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|\DOMNode|null |
| 31 | 31 | */ |
| 32 | - public function recursivelyFind($selector, int $index = null, string $property = null, int $nodeType = \XML_ELEMENT_NODE):?PrototypeTraversal{ |
|
| 32 | + public function recursivelyFind($selector, int $index = null, string $property = null, int $nodeType = \XML_ELEMENT_NODE): ?PrototypeTraversal{ |
|
| 33 | 33 | |
| 34 | - if(\is_numeric($selector)){ |
|
| 34 | + if (\is_numeric($selector)) { |
|
| 35 | 35 | return $this->ownerDocument->recursivelyFind($this, $property, null, $selector, $nodeType); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null |
| 70 | 70 | */ |
| 71 | - public function down($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 71 | + public function down($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 72 | 72 | |
| 73 | - if($expression === null && $index === null){ |
|
| 73 | + if ($expression === null && $index === null) { |
|
| 74 | 74 | return $this->firstDescendant(); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $index = $index ?? 0; |
| 78 | 78 | |
| 79 | - if(\is_int($expression)){ |
|
| 79 | + if (\is_int($expression)) { |
|
| 80 | 80 | return $this->select(['*'])->item($expression); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if(\is_array($expression)){ |
|
| 83 | + if (\is_array($expression)) { |
|
| 84 | 84 | return $this->select($expression)->item($index); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null |
| 97 | 97 | */ |
| 98 | - public function up($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 98 | + public function up($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 99 | 99 | return $this->recursivelyFind($expression, $index, 'parentNode'); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null |
| 109 | 109 | */ |
| 110 | - public function previous($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 110 | + public function previous($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 111 | 111 | return $this->recursivelyFind($expression, $index, 'previousSibling'); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null |
| 121 | 121 | */ |
| 122 | - public function next($expression = null, int $index = null):?PrototypeTraversal{ |
|
| 122 | + public function next($expression = null, int $index = null): ?PrototypeTraversal{ |
|
| 123 | 123 | return $this->recursivelyFind($expression, $index, 'nextSibling'); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | public function childElements(int $nodeType = \XML_ELEMENT_NODE):NodeList{ |
| 134 | 134 | $children = new NodeList; |
| 135 | 135 | |
| 136 | - if(!$this->hasChildNodes()){ |
|
| 136 | + if (!$this->hasChildNodes()) { |
|
| 137 | 137 | return $children; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - foreach($this->childNodes as $child){ |
|
| 140 | + foreach ($this->childNodes as $child) { |
|
| 141 | 141 | |
| 142 | - if($child->nodeType === $nodeType){ |
|
| 142 | + if ($child->nodeType === $nodeType) { |
|
| 143 | 143 | $children[] = $child; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null |
| 193 | 193 | */ |
| 194 | - public function firstDescendant():?PrototypeTraversal{ |
|
| 194 | + public function firstDescendant(): ?PrototypeTraversal{ |
|
| 195 | 195 | return $this->descendants()->first(); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\PrototypeDOM\Node; |
| 14 | 14 | |
| 15 | -class CharacterData extends \DOMCharacterData implements PrototypeElement{ |
|
| 15 | +class CharacterData extends \DOMCharacterData implements PrototypeElement { |
|
| 16 | 16 | use PrototypeElementTrait; |
| 17 | 17 | } |