Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 95ed67...d1d2d9 )
by Der Mundschenk
02:46
created
src/class-dom.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return array
50 50
 	 */
51
-	public static function block_tags( $reset = false ) {
52
-		if ( empty( self::$block_tags ) || $reset ) {
51
+	public static function block_tags($reset = false) {
52
+		if (empty(self::$block_tags) || $reset) {
53 53
 			self::$block_tags = array_merge(
54
-				array_flip( array_filter( array_keys( \Masterminds\HTML5\Elements::$html5 ), function( $tag ) {
55
-					return \Masterminds\HTML5\Elements::isA( $tag, \Masterminds\HTML5\Elements::BLOCK_TAG );
56
-				} ) ),
57
-				array_flip( [ 'li', 'td', 'dt' ] ) // not included as "block tags" in current HTML5-PHP version.
54
+				array_flip(array_filter(array_keys(\Masterminds\HTML5\Elements::$html5), function($tag) {
55
+					return \Masterminds\HTML5\Elements::isA($tag, \Masterminds\HTML5\Elements::BLOCK_TAG);
56
+				} )),
57
+				array_flip(['li', 'td', 'dt']) // not included as "block tags" in current HTML5-PHP version.
58 58
 			);
59 59
 		}
60 60
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return array An associative array in the form ( $spl_object_hash => $node ).
71 71
 	 */
72
-	public static function nodelist_to_array( \DOMNodeList $list ) {
72
+	public static function nodelist_to_array(\DOMNodeList $list) {
73 73
 		$out = [];
74 74
 
75
-		foreach ( $list as $node ) {
76
-			$out[ spl_object_hash( $node ) ] = $node;
75
+		foreach ($list as $node) {
76
+			$out[spl_object_hash($node)] = $node;
77 77
 		}
78 78
 
79 79
 		return $out;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return array An array of \DOMNode.
89 89
 	 */
90
-	public static function get_ancestors( \DOMNode $node ) {
90
+	public static function get_ancestors(\DOMNode $node) {
91 91
 		$result = [];
92 92
 
93
-		while ( ( $node = $node->parentNode ) && ( $node instanceof \DOMElement ) ) { // @codingStandardsIgnoreLine.
93
+		while (($node = $node->parentNode) && ($node instanceof \DOMElement)) { // @codingStandardsIgnoreLine.
94 94
 			$result[] = $node;
95 95
 		}
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return boolean True if the element has any of the given class(es).
108 108
 	 */
109
-	public static function has_class( \DOMNode $tag, $classnames ) {
110
-		if ( $tag instanceof \DOMText ) {
109
+	public static function has_class(\DOMNode $tag, $classnames) {
110
+		if ($tag instanceof \DOMText) {
111 111
 			$tag = $tag->parentNode; // @codingStandardsIgnoreLine.
112 112
 		}
113 113
 
114 114
 		// Bail if we are not working with a tag or if there is no classname.
115
-		if ( ! ( $tag instanceof \DOMElement ) || empty( $classnames ) ) {
115
+		if ( ! ($tag instanceof \DOMElement) || empty($classnames)) {
116 116
 			return false;
117 117
 		}
118 118
 
119 119
 		// Ensure we always have an array of classnames.
120
-		if ( ! is_array( $classnames ) ) {
121
-			$classnames = [ $classnames ];
120
+		if ( ! is_array($classnames)) {
121
+			$classnames = [$classnames];
122 122
 		}
123 123
 
124
-		if ( $tag->hasAttribute( 'class' ) ) {
125
-			$tag_classes = array_flip( explode( ' ', $tag->getAttribute( 'class' ) ) );
124
+		if ($tag->hasAttribute('class')) {
125
+			$tag_classes = array_flip(explode(' ', $tag->getAttribute('class')));
126 126
 
127
-			foreach ( $classnames as $classname ) {
128
-				if ( isset( $tag_classes[ $classname ] ) ) {
127
+			foreach ($classnames as $classname) {
128
+				if (isset($tag_classes[$classname])) {
129 129
 					return true;
130 130
 				}
131 131
 			}
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return string A single character (or the empty string).
143 143
 	 */
144
-	public static function get_prev_chr( \DOMNode $element ) {
145
-		return self::get_adjacent_chr( $element, -1, 1, [ __CLASS__, 'get_previous_textnode' ] );
144
+	public static function get_prev_chr(\DOMNode $element) {
145
+		return self::get_adjacent_chr($element, -1, 1, [__CLASS__, 'get_previous_textnode']);
146 146
 	}
147 147
 
148 148
 	/**
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return string A single character (or the empty string).
154 154
 	 */
155
-	public static function get_next_chr( \DOMNode $element ) {
156
-		return self::get_adjacent_chr( $element, 0, 1, [ __CLASS__, 'get_next_textnode' ] );
155
+	public static function get_next_chr(\DOMNode $element) {
156
+		return self::get_adjacent_chr($element, 0, 1, [__CLASS__, 'get_next_textnode']);
157 157
 	}
158 158
 
159 159
 	/**
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return string The character or an empty string.
170 170
 	 */
171
-	private static function get_adjacent_chr( \DOMNode $node, $position, $length, callable $get_textnode ) {
172
-		$textnode = $get_textnode( $node );
171
+	private static function get_adjacent_chr(\DOMNode $node, $position, $length, callable $get_textnode) {
172
+		$textnode = $get_textnode($node);
173 173
 
174
-		if ( isset( $textnode ) && isset( $textnode->data ) ) {
174
+		if (isset($textnode) && isset($textnode->data)) {
175 175
 			// Determine encoding.
176
-			$func = Strings::functions( $textnode->data );
176
+			$func = Strings::functions($textnode->data);
177 177
 
178
-			if ( ! empty( $func ) ) {
179
-				return preg_replace( '/\p{C}/Su', '', $func['substr']( $textnode->data, $position, $length ) );
178
+			if ( ! empty($func)) {
179
+				return preg_replace('/\p{C}/Su', '', $func['substr']($textnode->data, $position, $length));
180 180
 			}
181 181
 		}
182 182
 
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
192 192
 	 */
193
-	public static function get_previous_textnode( \DOMNode $element = null ) {
194
-		return self::get_adjacent_textnode( function( &$node = null ) {
193
+	public static function get_previous_textnode(\DOMNode $element = null) {
194
+		return self::get_adjacent_textnode(function(&$node = null) {
195 195
 			$node = $node->previousSibling;
196
-			return self::get_last_textnode( $node );
197
-		}, __METHOD__, $element );
196
+			return self::get_last_textnode($node);
197
+		}, __METHOD__, $element);
198 198
 	}
199 199
 
200 200
 	/**
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
206 206
 	 */
207
-	public static function get_next_textnode( \DOMNode $element = null ) {
208
-		return self::get_adjacent_textnode( function( &$node = null ) {
207
+	public static function get_next_textnode(\DOMNode $element = null) {
208
+		return self::get_adjacent_textnode(function(&$node = null) {
209 209
 			$node = $node->nextSibling;
210
-			return self::get_first_textnode( $node );
211
-		}, __METHOD__, $element );
210
+			return self::get_first_textnode($node);
211
+		}, __METHOD__, $element);
212 212
 	}
213 213
 
214 214
 	/**
@@ -222,22 +222,22 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
224 224
 	 */
225
-	private static function get_adjacent_textnode( callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null ) {
226
-		if ( ! isset( $element ) ) {
225
+	private static function get_adjacent_textnode(callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null) {
226
+		if ( ! isset($element)) {
227 227
 			return null;
228
-		} elseif ( $element instanceof \DOMElement && isset( self::$block_tags[ $element->tagName ] ) ) {
228
+		} elseif ($element instanceof \DOMElement && isset(self::$block_tags[$element->tagName])) {
229 229
 			return null;
230 230
 		}
231 231
 
232 232
 		$adjacent = null;
233 233
 		$node     = $element;
234 234
 
235
-		while ( ! empty( $node ) && empty( $adjacent ) ) {
236
-			$adjacent = $iterate( $node );
235
+		while ( ! empty($node) && empty($adjacent)) {
236
+			$adjacent = $iterate($node);
237 237
 		}
238 238
 
239
-		if ( empty( $adjacent ) ) {
240
-			$adjacent = $get_adjacent_parent( $element->parentNode );
239
+		if (empty($adjacent)) {
240
+			$adjacent = $get_adjacent_parent($element->parentNode);
241 241
 		}
242 242
 
243 243
 		return $adjacent;
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return \DOMText|null The first child of type \DOMText, the element itself if it is of type \DOMText or null.
253 253
 	 */
254
-	public static function get_first_textnode( \DOMNode $element = null, $recursive = false ) {
255
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$first_textnode = null ) {
254
+	public static function get_first_textnode(\DOMNode $element = null, $recursive = false) {
255
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $first_textnode = null) {
256 256
 			$i = 0;
257 257
 
258
-			while ( $i < $children->length && empty( $first_textnode ) ) {
259
-				$first_textnode = self::get_first_textnode( $children->item( $i ), true );
258
+			while ($i < $children->length && empty($first_textnode)) {
259
+				$first_textnode = self::get_first_textnode($children->item($i), true);
260 260
 				$i++;
261 261
 			}
262
-		}, $element, $recursive );
262
+		}, $element, $recursive);
263 263
 	}
264 264
 
265 265
 	/**
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
272 272
 	 */
273
-	public static function get_last_textnode( \DOMNode $element = null, $recursive = false ) {
274
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$last_textnode = null ) {
273
+	public static function get_last_textnode(\DOMNode $element = null, $recursive = false) {
274
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $last_textnode = null) {
275 275
 			$i = $children->length - 1;
276 276
 
277
-			while ( $i >= 0 && empty( $last_textnode ) ) {
278
-				$last_textnode = self::get_last_textnode( $children->item( $i ), true );
277
+			while ($i >= 0 && empty($last_textnode)) {
278
+				$last_textnode = self::get_last_textnode($children->item($i), true);
279 279
 				$i--;
280 280
 			}
281
-		}, $element, $recursive );
281
+		}, $element, $recursive);
282 282
 
283 283
 		// xxx
284 284
 	}
@@ -296,24 +296,24 @@  discard block
 block discarded – undo
296 296
 	 *
297 297
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
298 298
 	 */
299
-	private static function get_edge_textnode( callable $iteration, \DOMNode $element = null, $recursive = false ) {
300
-		if ( ! isset( $element ) ) {
299
+	private static function get_edge_textnode(callable $iteration, \DOMNode $element = null, $recursive = false) {
300
+		if ( ! isset($element)) {
301 301
 			return null;
302 302
 		}
303 303
 
304
-		if ( $element instanceof \DOMText ) {
304
+		if ($element instanceof \DOMText) {
305 305
 			return $element;
306
-		} elseif ( ! $element instanceof \DOMElement ) {
306
+		} elseif ( ! $element instanceof \DOMElement) {
307 307
 			// Return null if $element is neither \DOMText nor \DOMElement.
308 308
 			return null;
309
-		} elseif ( $recursive && isset( self::$block_tags[ $element->tagName ] ) ) {
309
+		} elseif ($recursive && isset(self::$block_tags[$element->tagName])) {
310 310
 			return null;
311 311
 		}
312 312
 
313 313
 		$edge_textnode = null;
314 314
 
315
-		if ( $element->hasChildNodes() ) {
316
-			$iteration( $element->childNodes, $edge_textnode );
315
+		if ($element->hasChildNodes()) {
316
+			$iteration($element->childNodes, $edge_textnode);
317 317
 		}
318 318
 
319 319
 		return $edge_textnode;
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @return \DOMElement|null
328 328
 	 */
329
-	public static function get_block_parent( \DOMNode $element ) {
329
+	public static function get_block_parent(\DOMNode $element) {
330 330
 		$parent = $element->parentNode;
331
-		if ( ! $parent instanceof \DOMElement ) {
331
+		if ( ! $parent instanceof \DOMElement) {
332 332
 			return null;
333 333
 		}
334 334
 
335
-		while ( ! isset( self::$block_tags[ $parent->tagName ] ) && ! empty( $parent->parentNode ) && $parent->parentNode instanceof \DOMElement ) {
335
+		while ( ! isset(self::$block_tags[$parent->tagName]) && ! empty($parent->parentNode) && $parent->parentNode instanceof \DOMElement) {
336 336
 			$parent = $parent->parentNode;
337 337
 		}
338 338
 
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 
347 347
 	 * @return string The tag name (or the empty string).
348 348
 	 */
349
-	public static function get_block_parent_name( \DOMNode $element ) {
350
-		$parent = self::get_block_parent( $element );
349
+	public static function get_block_parent_name(\DOMNode $element) {
350
+		$parent = self::get_block_parent($element);
351 351
 
352
-		if ( ! empty( $parent ) ) {
352
+		if ( ! empty($parent)) {
353 353
 			return $parent->tagName;
354 354
 		} else {
355 355
 			return '';
Please login to merge, or discard this patch.