Passed
Push — master ( f29488...0d4bed )
by smiley
02:25
created
src/Node/PrototypeElementTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\PrototypeDOM\Node;
14 14
 
15
-trait PrototypeElementTrait{
15
+trait PrototypeElementTrait {
16 16
 	use PrototypeTraversalTrait;
17 17
 
18 18
 	/**
@@ -52,28 +52,28 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function insert($content):PrototypeElement{
54 54
 
55
-		if(!\is_array($content)){
55
+		if (!\is_array($content)) {
56 56
 
57
-			foreach($this->ownerDocument->toNodeList($content) as $node){
57
+			foreach ($this->ownerDocument->toNodeList($content) as $node) {
58 58
 				$this->insert_bottom($node);
59 59
 			}
60 60
 
61 61
 			return $this;
62 62
 		}
63 63
 
64
-		foreach(['before', 'after', 'top', 'bottom'] as $pos){
64
+		foreach (['before', 'after', 'top', 'bottom'] as $pos) {
65 65
 
66
-			if(!\array_key_exists($pos, $content)){
66
+			if (!\array_key_exists($pos, $content)) {
67 67
 				continue;
68 68
 			}
69 69
 
70 70
 			$nodes = $this->ownerDocument->toNodeList($content[$pos]);
71 71
 
72
-			if($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling){
72
+			if ($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling) {
73 73
 				$nodes->reverse();
74 74
 			}
75 75
 
76
-			foreach($nodes as $node){
76
+			foreach ($nodes as $node) {
77 77
 				\call_user_func_array([$this, 'insert_'.$pos], [$node]);
78 78
 			}
79 79
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function insert_before(PrototypeElement $node, PrototypeElement $refNode = null):PrototypeElement{
92 92
 
93
-		if($this->parentNode){
93
+		if ($this->parentNode) {
94 94
 			$this->parentNode->insertBefore($this->importNode($node), $refNode ?? $this);
95 95
 		}
96 96
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function insert_after(PrototypeElement $node):PrototypeElement{
106 106
 
107
-		if(!$this->nextSibling && $this->parentNode){
107
+		if (!$this->nextSibling && $this->parentNode) {
108 108
 			return $this->parentNode->insert_bottom($node); // @codeCoverageIgnore
109 109
 		}
110 110
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function insert_top(PrototypeElement $node):PrototypeElement{
120 120
 
121
-		if($this->hasChildNodes()){
121
+		if ($this->hasChildNodes()) {
122 122
 			return $this->firstChild->insert_before($node, $this->firstChild);
123 123
 		}
124 124
 
Please login to merge, or discard this patch.
src/Node/PrototypeHTMLElementTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  * @property string $src
22 22
  * @property string $innerHTML
23 23
  */
24
-trait PrototypeHTMLElementTrait{
24
+trait PrototypeHTMLElementTrait {
25 25
 	use Magic, 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,17 +84,17 @@  discard block
 block discarded – undo
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
 			$classname = \trim($classname);
96 96
 
97
-			if(!empty($classname)){
97
+			if (!empty($classname)) {
98 98
 				$currentClassnames[] = $classname;
99 99
 			}
100 100
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Node/Element.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use DOMElement;
16 16
 
17
-class Element extends DOMElement implements PrototypeHTMLElement{
17
+class Element extends DOMElement implements PrototypeHTMLElement {
18 18
 	use PrototypeHTMLElementTrait;
19 19
 
20 20
 	/**
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	public function getAttributes():array{
24 24
 		$attributes = [];
25 25
 
26
-		foreach($this->attributes as $attribute){
26
+		foreach ($this->attributes as $attribute) {
27 27
 			$attributes[$attribute->nodeName] = $attribute->nodeValue;
28 28
 		}
29 29
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function setAttributes(array $attributes):PrototypeHTMLElement{
39 39
 
40
-		foreach($attributes as $name => $value){
40
+		foreach ($attributes as $name => $value) {
41 41
 			$this->setAttribute($name, $value);
42 42
 		}
43 43
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function removeAttributes(array $attributes):PrototypeHTMLElement{
53 53
 
54
-		foreach($attributes as $name){
54
+		foreach ($attributes as $name) {
55 55
 			$this->removeAttribute($name);
56 56
 		}
57 57
 
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	public function addClassNames(array $classnames):PrototypeHTMLElement{
67 67
 		$currentClassnames = $this->classNames();
68 68
 
69
-		foreach($classnames as $classname){
69
+		foreach ($classnames as $classname) {
70 70
 
71
-			if(!\in_array($classname, $currentClassnames, true)){
71
+			if (!\in_array($classname, $currentClassnames, true)) {
72 72
 				$currentClassnames[] = $classname;
73 73
 			}
74 74
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	public function removeClassNames(array $classnames):PrototypeHTMLElement{
88 88
 		$currentClassnames = $this->classNames();
89 89
 
90
-		foreach($classnames as $classname){
90
+		foreach ($classnames as $classname) {
91 91
 			$keys = \array_keys($currentClassnames, $classname);
92 92
 
93
-			foreach($keys as $key){
93
+			foreach ($keys as $key) {
94 94
 				unset($currentClassnames[$key]);
95 95
 			}
96 96
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function getStyles():array{
108 108
 
109
-		if(!$this->hasAttributes()){
109
+		if (!$this->hasAttributes()) {
110 110
 			return [];
111 111
 		}
112 112
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$currentStyle = [];
116 116
 
117
-		foreach($styles as $style){
117
+		foreach ($styles as $style) {
118 118
 			$s = \explode(':', $style);
119 119
 
120
-			if(\count($s) === 2){
120
+			if (\count($s) === 2) {
121 121
 				$currentStyle[\strtolower(\trim($s[0]))] = \trim($s[1]);
122 122
 			}
123 123
 
Please login to merge, or discard this patch.
src/Node/PrototypeTraversalTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		$nodeType = $nodeType ?? \XML_ELEMENT_NODE;
135 135
 		$children = new NodeList;
136 136
 
137
-		if(!$this->hasChildNodes()){
137
+		if (!$this->hasChildNodes()) {
138 138
 			return $children;
139 139
 		}
140 140
 
141
-		foreach($this->childNodes as $child){
141
+		foreach ($this->childNodes as $child) {
142 142
 
143
-			if($child->nodeType === $nodeType){
143
+			if ($child->nodeType === $nodeType) {
144 144
 				$children[] = $child;
145 145
 			}
146 146
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
194 194
 	 */
195
-	public function firstDescendant():?PrototypeTraversal{
195
+	public function firstDescendant(): ?PrototypeTraversal{
196 196
 		return $this->descendants()->first();
197 197
 	}
198 198
 
Please login to merge, or discard this patch.
src/Document.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	ProcessingInstruction,
27 27
 	PrototypeHTMLElement,
28 28
 	PrototypeNode,
29
-	Text,};
29
+	Text, };
30 30
 use chillerlan\Traits\Magic;
31 31
 use DOMDocument;
32 32
 use DOMException;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 /**
39 39
  * @property string $title
40 40
  */
41
-class Document extends DOMDocument{
41
+class Document extends DOMDocument {
42 42
 	use Magic;
43 43
 
44 44
 	protected const NODE_CLASSES = [
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		'DOMText'                  => Text::class,
58 58
 	];
59 59
 
60
-	protected const LOAD_OPTIONS = \LIBXML_COMPACT|\LIBXML_NONET|\LIBXML_HTML_NODEFDTD|\LIBXML_HTML_NOIMPLIED|\LIBXML_NOERROR;
60
+	protected const LOAD_OPTIONS = \LIBXML_COMPACT | \LIBXML_NONET | \LIBXML_HTML_NODEFDTD | \LIBXML_HTML_NOIMPLIED | \LIBXML_NOERROR;
61 61
 
62 62
 	/**
63 63
 	 * @var \Symfony\Component\CssSelector\CssSelectorConverter
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 	 * @param string|null                                                $version
73 73
 	 * @param string|null                                                $encoding
74 74
 	 */
75
-	public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null){
75
+	public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null) {
76 76
 		parent::__construct($version ?? '1.0', $encoding ?? 'UTF-8');
77 77
 
78
-		foreach($this::NODE_CLASSES as $baseClass => $extendedClass){
78
+		foreach ($this::NODE_CLASSES as $baseClass => $extendedClass) {
79 79
 			$this->registerNodeClass($baseClass, $extendedClass);
80 80
 		}
81 81
 
82
-		if($content !== null){
82
+		if ($content !== null) {
83 83
 			$this->loadDocument($content, $xml);
84 84
 		}
85 85
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * magic *
92 92
 	 *********/
93 93
 
94
-	public function magic_get_title():?string{
94
+	public function magic_get_title(): ?string{
95 95
 		return $this->select(['head > title'])->item(0)->nodeValue ?? null;
96 96
 	}
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	public function magic_set_title(string $title):void{
104 104
 		$currentTitle = $this->select(['head > title'])->item(0);
105 105
 
106
-		if($currentTitle instanceof Element){
106
+		if ($currentTitle instanceof Element) {
107 107
 			$currentTitle->update($title);
108 108
 			return;
109 109
 		}
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 		$head         = $this->select(['head'])->item(0);
112 112
 		$currentTitle = $this->newElement('title')->update($title);
113 113
 
114
-		if(!$head){
114
+		if (!$head) {
115 115
 			$html = $this->select(['html'])->first();
116 116
 
117
-			if(!$html instanceof PrototypeHTMLElement){
117
+			if (!$html instanceof PrototypeHTMLElement) {
118 118
 				throw new DOMException('<html> header missing');
119 119
 			}
120 120
 
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
 
136 136
 	public function loadDocument($content, bool $xml = null):Document{
137 137
 
138
-		if($content instanceof NodeList){
138
+		if ($content instanceof NodeList) {
139 139
 			return $this->insertNodeList($content);
140 140
 		}
141 141
 
142
-		if($content instanceof DOMNodeList){
142
+		if ($content instanceof DOMNodeList) {
143 143
 			return $this->insertNodeList(new NodeList($content));
144 144
 		}
145 145
 
146
-		if(!\is_string($content)){
146
+		if (!\is_string($content)) {
147 147
 			throw new DOMException('invalid document content');
148 148
 		}
149 149
 
150
-		if(\is_file($content) && \is_readable($content)){
150
+		if (\is_file($content) && \is_readable($content)) {
151 151
 			return $this->loadDocumentFile($content, $xml);
152 152
 		}
153 153
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			? $this->load($file, $options)
170 170
 			: $this->loadHTMLFile($file, $options);
171 171
 
172
-		if($result === false){
172
+		if ($result === false) {
173 173
 			throw new DOMException('failed to load document from file: '.$file); // @codeCoverageIgnore
174 174
 		}
175 175
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			? $this->loadXML($documentSource, $options)
192 192
 			: $this->loadHTML($documentSource, $options);
193 193
 
194
-		if($result === false){
194
+		if ($result === false) {
195 195
 			throw new DOMException('failed to load document from string'); // @codeCoverageIgnore
196 196
 		}
197 197
 
@@ -206,19 +206,19 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function toNodeList($content):NodeList{
208 208
 
209
-		if($content instanceof NodeList){
209
+		if ($content instanceof NodeList) {
210 210
 			return $content;
211 211
 		}
212 212
 
213
-		if($content instanceof DOMNode || $content instanceof PrototypeNode){
213
+		if ($content instanceof DOMNode || $content instanceof PrototypeNode) {
214 214
 			return new NodeList([$content]);
215 215
 		}
216 216
 
217
-		if($content instanceof DOMNodeList || \is_iterable($content)){
217
+		if ($content instanceof DOMNodeList || \is_iterable($content)) {
218 218
 			return new NodeList($content);
219 219
 		}
220 220
 
221
-		if(\is_string($content)){
221
+		if (\is_string($content)) {
222 222
 			$document = new self;
223 223
 			$document->loadHTML('<html><body id="-import-content">'.$content.'</body></html>');
224 224
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return \chillerlan\PrototypeDOM\NodeList|null
250 250
 	 */
251
-	public function query(string $xpath, DOMNode $contextNode = null):?NodeList{
251
+	public function query(string $xpath, DOMNode $contextNode = null): ?NodeList{
252 252
 		$q = (new DOMXPath($this))->query($xpath, $contextNode);
253 253
 
254 254
 		return $q !== false ? new NodeList($q) : null;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return \chillerlan\PrototypeDOM\NodeList|null
263 263
 	 */
264
-	public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null):?NodeList{
264
+	public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null): ?NodeList{
265 265
 		return $this->query($this->cssSelectorConverter->toXPath($selector, $axis ?? 'descendant-or-self::'), $contextNode);
266 266
 	}
267 267
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 		/** @var \chillerlan\PrototypeDOM\NodeList $nodes */
277 277
 		$nodes = $this->select($selectors, $contextNode, $axis ?? 'descendant-or-self::');
278 278
 
279
-		if(\count($nodes) > 0){
279
+		if (\count($nodes) > 0) {
280 280
 
281
-			foreach($nodes as $node){
281
+			foreach ($nodes as $node) {
282 282
 				$node->remove();
283 283
 			}
284 284
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	public function insertNodeList(NodeList $nodeList):Document{
296 296
 
297 297
 		/** @var \DOMNode $node */
298
-		foreach($nodeList as $node){
298
+		foreach ($nodeList as $node) {
299 299
 			$this->appendChild($this->importNode($node->cloneNode(true), true));
300 300
 		}
301 301
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	public function inspect(DOMNode $context = null, bool $xml = null):string{
318 318
 
319
-		if($xml === true){
319
+		if ($xml === true) {
320 320
 			return $this->saveXML($context);
321 321
 		}
322 322
 
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 		$nodeType = $nodeType ?? \XML_ELEMENT_NODE;
338 338
 		$elements = new NodeList;
339 339
 
340
-		foreach($selectors ?? ['*'] as $selector){
340
+		foreach ($selectors ?? ['*'] as $selector) {
341 341
 
342
-			if(!\is_string($selector)){
342
+			if (!\is_string($selector)) {
343 343
 				continue;
344 344
 			}
345 345
 
346
-			foreach($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element){
346
+			foreach ($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element) {
347 347
 
348
-				if($element->nodeType === $nodeType){
348
+				if ($element->nodeType === $nodeType) {
349 349
 					$elements[] = $element;
350 350
 				}
351 351
 
@@ -371,15 +371,15 @@  discard block
 block discarded – undo
371 371
 		$maxLength = $maxLength ?? -1;
372 372
 		$nodes     = new NodeList;
373 373
 
374
-		if(\in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){
374
+		if (\in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) {
375 375
 
376
-			while($element = $element->{$property}){
376
+			while ($element = $element->{$property}) {
377 377
 
378
-				if($element->nodeType === $nodeType){
378
+				if ($element->nodeType === $nodeType) {
379 379
 					$nodes[] = $element;
380 380
 				}
381 381
 
382
-				if(\count($nodes) === $maxLength){
382
+				if (\count($nodes) === $maxLength) {
383 383
 					break;
384 384
 				}
385 385
 
@@ -399,16 +399,16 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return \DOMNode|null
401 401
 	 */
402
-	public function recursivelyFind(DOMNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null):?DOMNode{
402
+	public function recursivelyFind(DOMNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null): ?DOMNode{
403 403
 		$nodeType = $nodeType ?? \XML_ELEMENT_NODE;
404 404
 		$index    = $index ?? 0;
405 405
 
406
-		if(\in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){
406
+		if (\in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) {
407 407
 
408 408
 			/** @var \chillerlan\PrototypeDOM\Node\Element $element */
409
-			while($element = $element->{$property}){
409
+			while ($element = $element->{$property}) {
410 410
 
411
-				if($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0){
411
+				if ($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0) {
412 412
 					continue;
413 413
 				}
414 414
 
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 	public function match(DOMNode $element, string $selector):bool{
432 432
 
433 433
 		/** @var \chillerlan\PrototypeDOM\Node\Element $match */
434
-		foreach($this->select([$selector]) as $match){
434
+		foreach ($this->select([$selector]) as $match) {
435 435
 
436
-			if($element->isSameNode($match)){
436
+			if ($element->isSameNode($match)) {
437 437
 				return true;
438 438
 			}
439 439
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		/** @var \chillerlan\PrototypeDOM\Node\Element $element */
455 455
 		$element = $this->createElement($tag);
456 456
 
457
-		if($attributes !== null){
457
+		if ($attributes !== null) {
458 458
 			$element->setAttributes($attributes);
459 459
 		}
460 460
 
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	 * @return \DOMNode|null
468 468
 	 * @throws \DOMException
469 469
 	 */
470
-	public function getElementById($elementId):?DOMNode{
470
+	public function getElementById($elementId): ?DOMNode{
471 471
 
472
-		if(!\is_string($elementId)){
472
+		if (!\is_string($elementId)) {
473 473
 			throw new DOMException('invalid element id');
474 474
 		}
475 475
 
Please login to merge, or discard this patch.