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.
Completed
Pull Request — master (#11)
by Der Mundschenk
02:42
created
src/class-dom.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,8 +160,8 @@
 block discarded – undo
160 160
 	 * Retrieves a character from the given \DOMNode.
161 161
 	 *
162 162
 	 * @param  \DOMNode $node         Required.
163
-	 * @param  [type]   $position     The position parameter for `substr`.
164
-	 * @param  [type]   $length       The length parameter for `substr`.
163
+	 * @param  integer   $position     The position parameter for `substr`.
164
+	 * @param  integer   $length       The length parameter for `substr`.
165 165
 	 * @param  callable $get_textnode A function to retrieve the \DOMText from the node.
166 166
 	 *
167 167
 	 * @return string The character or an empty string.
Please login to merge, or discard this 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
 	/**
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return string The character or an empty string.
168 168
 	 */
169
-	private static function get_adjacent_chr( \DOMNode $node, $position, $length, callable $get_textnode ) {
170
-		$textnode = $get_textnode( $node );
169
+	private static function get_adjacent_chr(\DOMNode $node, $position, $length, callable $get_textnode) {
170
+		$textnode = $get_textnode($node);
171 171
 
172
-		if ( isset( $textnode ) && isset( $textnode->data ) ) {
172
+		if (isset($textnode) && isset($textnode->data)) {
173 173
 			// Determine encoding.
174
-			$func = Strings::functions( $textnode->data );
174
+			$func = Strings::functions($textnode->data);
175 175
 
176
-			if ( ! empty( $func ) ) {
177
-				return preg_replace( '/\p{C}/Su', '', $func['substr']( $textnode->data, $position, $length ) );
176
+			if ( ! empty($func)) {
177
+				return preg_replace('/\p{C}/Su', '', $func['substr']($textnode->data, $position, $length));
178 178
 			}
179 179
 		}
180 180
 
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
190 190
 	 */
191
-	public static function get_previous_textnode( \DOMNode $element = null ) {
192
-		return self::get_adjacent_textnode( function( &$node = null ) {
191
+	public static function get_previous_textnode(\DOMNode $element = null) {
192
+		return self::get_adjacent_textnode(function(&$node = null) {
193 193
 			$node = $node->previousSibling;
194
-			return self::get_last_textnode( $node );
195
-		}, __METHOD__, $element );
194
+			return self::get_last_textnode($node);
195
+		}, __METHOD__, $element);
196 196
 	}
197 197
 
198 198
 	/**
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	 *
203 203
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
204 204
 	 */
205
-	public static function get_next_textnode( \DOMNode $element = null ) {
206
-		return self::get_adjacent_textnode( function( &$node = null ) {
205
+	public static function get_next_textnode(\DOMNode $element = null) {
206
+		return self::get_adjacent_textnode(function(&$node = null) {
207 207
 			$node = $node->nextSibling;
208
-			return self::get_first_textnode( $node );
209
-		}, __METHOD__, $element );
208
+			return self::get_first_textnode($node);
209
+		}, __METHOD__, $element);
210 210
 	}
211 211
 
212 212
 	/**
@@ -218,22 +218,22 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
220 220
 	 */
221
-	private static function get_adjacent_textnode( callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null ) {
222
-		if ( ! isset( $element ) ) {
221
+	private static function get_adjacent_textnode(callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null) {
222
+		if ( ! isset($element)) {
223 223
 			return null;
224
-		} elseif ( $element instanceof \DOMElement && isset( self::$block_tags[ $element->tagName ] ) ) {
224
+		} elseif ($element instanceof \DOMElement && isset(self::$block_tags[$element->tagName])) {
225 225
 			return null;
226 226
 		}
227 227
 
228 228
 		$adjacent = null;
229 229
 		$node     = $element;
230 230
 
231
-		while ( ! empty( $node ) && empty( $adjacent ) ) {
232
-			$adjacent = $iterate( $node );
231
+		while ( ! empty($node) && empty($adjacent)) {
232
+			$adjacent = $iterate($node);
233 233
 		}
234 234
 
235
-		if ( empty( $adjacent ) ) {
236
-			$adjacent = $get_adjacent_parent( $element->parentNode );
235
+		if (empty($adjacent)) {
236
+			$adjacent = $get_adjacent_parent($element->parentNode);
237 237
 		}
238 238
 
239 239
 		return $adjacent;
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return \DOMText|null The first child of type \DOMText, the element itself if it is of type \DOMText or null.
249 249
 	 */
250
-	public static function get_first_textnode( \DOMNode $element = null, $recursive = false ) {
251
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$first_textnode = null ) {
250
+	public static function get_first_textnode(\DOMNode $element = null, $recursive = false) {
251
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $first_textnode = null) {
252 252
 			$i = 0;
253 253
 
254
-			while ( $i < $children->length && empty( $first_textnode ) ) {
255
-				$first_textnode = self::get_first_textnode( $children->item( $i ), true );
254
+			while ($i < $children->length && empty($first_textnode)) {
255
+				$first_textnode = self::get_first_textnode($children->item($i), true);
256 256
 				$i++;
257 257
 			}
258
-		}, $element, $recursive );
258
+		}, $element, $recursive);
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
268 268
 	 */
269
-	public static function get_last_textnode( \DOMNode $element = null, $recursive = false ) {
270
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$last_textnode = null ) {
269
+	public static function get_last_textnode(\DOMNode $element = null, $recursive = false) {
270
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $last_textnode = null) {
271 271
 			$i = $children->length - 1;
272 272
 
273
-			while ( $i >= 0 && empty( $last_textnode ) ) {
274
-				$last_textnode = self::get_last_textnode( $children->item( $i ), true );
273
+			while ($i >= 0 && empty($last_textnode)) {
274
+				$last_textnode = self::get_last_textnode($children->item($i), true);
275 275
 				$i--;
276 276
 			}
277
-		}, $element, $recursive );
277
+		}, $element, $recursive);
278 278
 	}
279 279
 
280 280
 	/**
@@ -288,24 +288,24 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
290 290
 	 */
291
-	private static function get_edge_textnode( callable $iteration, \DOMNode $element = null, $recursive = false ) {
292
-		if ( ! isset( $element ) ) {
291
+	private static function get_edge_textnode(callable $iteration, \DOMNode $element = null, $recursive = false) {
292
+		if ( ! isset($element)) {
293 293
 			return null;
294 294
 		}
295 295
 
296
-		if ( $element instanceof \DOMText ) {
296
+		if ($element instanceof \DOMText) {
297 297
 			return $element;
298
-		} elseif ( ! $element instanceof \DOMElement ) {
298
+		} elseif ( ! $element instanceof \DOMElement) {
299 299
 			// Return null if $element is neither \DOMText nor \DOMElement.
300 300
 			return null;
301
-		} elseif ( $recursive && isset( self::$block_tags[ $element->tagName ] ) ) {
301
+		} elseif ($recursive && isset(self::$block_tags[$element->tagName])) {
302 302
 			return null;
303 303
 		}
304 304
 
305 305
 		$edge_textnode = null;
306 306
 
307
-		if ( $element->hasChildNodes() ) {
308
-			$iteration( $element->childNodes, $edge_textnode );
307
+		if ($element->hasChildNodes()) {
308
+			$iteration($element->childNodes, $edge_textnode);
309 309
 		}
310 310
 
311 311
 		return $edge_textnode;
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @return \DOMElement|null
320 320
 	 */
321
-	public static function get_block_parent( \DOMNode $element ) {
321
+	public static function get_block_parent(\DOMNode $element) {
322 322
 		$parent = $element->parentNode;
323
-		if ( ! $parent instanceof \DOMElement ) {
323
+		if ( ! $parent instanceof \DOMElement) {
324 324
 			return null;
325 325
 		}
326 326
 
327
-		while ( ! isset( self::$block_tags[ $parent->tagName ] ) && ! empty( $parent->parentNode ) && $parent->parentNode instanceof \DOMElement ) {
327
+		while ( ! isset(self::$block_tags[$parent->tagName]) && ! empty($parent->parentNode) && $parent->parentNode instanceof \DOMElement) {
328 328
 			$parent = $parent->parentNode;
329 329
 		}
330 330
 
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 
339 339
 	 * @return string The tag name (or the empty string).
340 340
 	 */
341
-	public static function get_block_parent_name( \DOMNode $element ) {
342
-		$parent = self::get_block_parent( $element );
341
+	public static function get_block_parent_name(\DOMNode $element) {
342
+		$parent = self::get_block_parent($element);
343 343
 
344
-		if ( ! empty( $parent ) ) {
344
+		if ( ! empty($parent)) {
345 345
 			return $parent->tagName;
346 346
 		} else {
347 347
 			return '';
Please login to merge, or discard this patch.