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.
Test Setup Failed
Branch master (2d2662)
by Der Mundschenk
01:59
created
src/class-dom.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -332,7 +332,6 @@
 block discarded – undo
332 332
 	 * Retrieves the tag name of the nearest block-level parent.
333 333
 	 *
334 334
 	 * @param \DOMNode $element A node.
335
-
336 335
 	 * @return string The tag name (or the empty string).
337 336
 	 */
338 337
 	public static function get_block_parent_name( \DOMNode $element ) {
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 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,15 +141,15 @@  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
-		$previous_textnode = self::get_previous_textnode( $element );
144
+	public static function get_prev_chr(\DOMNode $element) {
145
+		$previous_textnode = self::get_previous_textnode($element);
146 146
 
147
-		if ( isset( $previous_textnode ) && isset( $previous_textnode->data ) ) {
147
+		if (isset($previous_textnode) && isset($previous_textnode->data)) {
148 148
 			// First determine encoding.
149
-			$func = Strings::functions( $previous_textnode->data );
149
+			$func = Strings::functions($previous_textnode->data);
150 150
 
151
-			if ( ! empty( $func ) ) {
152
-				return preg_replace( '/\p{C}/Su', '', $func['substr']( $previous_textnode->data, - 1 ) );
151
+			if ( ! empty($func)) {
152
+				return preg_replace('/\p{C}/Su', '', $func['substr']($previous_textnode->data, - 1));
153 153
 			}
154 154
 		} // @codeCoverageIgnore
155 155
 
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return string A single character (or the empty string).
165 165
 	 */
166
-	public static function get_next_chr( \DOMNode $element ) {
167
-		$next_textnode = self::get_next_textnode( $element );
166
+	public static function get_next_chr(\DOMNode $element) {
167
+		$next_textnode = self::get_next_textnode($element);
168 168
 
169
-		if ( isset( $next_textnode ) && isset( $next_textnode->data ) ) {
169
+		if (isset($next_textnode) && isset($next_textnode->data)) {
170 170
 			// First determine encoding.
171
-			$func = Strings::functions( $next_textnode->data );
171
+			$func = Strings::functions($next_textnode->data);
172 172
 
173
-			if ( ! empty( $func ) ) {
174
-				return preg_replace( '/\p{C}/Su', '', $func['substr']( $next_textnode->data, 0, 1 ) );
173
+			if ( ! empty($func)) {
174
+				return preg_replace('/\p{C}/Su', '', $func['substr']($next_textnode->data, 0, 1));
175 175
 			}
176 176
 		} // @codeCoverageIgnore
177 177
 
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
187 187
 	 */
188
-	public static function get_previous_textnode( \DOMNode $element = null ) {
189
-		return self::get_adjacent_textnode( function( &$node = null ) {
188
+	public static function get_previous_textnode(\DOMNode $element = null) {
189
+		return self::get_adjacent_textnode(function(&$node = null) {
190 190
 			$node = $node->previousSibling;
191
-			return self::get_last_textnode( $node );
192
-		}, __METHOD__, $element );
191
+			return self::get_last_textnode($node);
192
+		}, __METHOD__, $element);
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
201 201
 	 */
202
-	public static function get_next_textnode( \DOMNode $element = null ) {
203
-		return self::get_adjacent_textnode( function( &$node = null ) {
202
+	public static function get_next_textnode(\DOMNode $element = null) {
203
+		return self::get_adjacent_textnode(function(&$node = null) {
204 204
 			$node = $node->nextSibling;
205
-			return self::get_first_textnode( $node );
206
-		}, __METHOD__, $element );
205
+			return self::get_first_textnode($node);
206
+		}, __METHOD__, $element);
207 207
 	}
208 208
 
209 209
 	/**
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return \DOMText|null Null if $element is a block-level element or no text sibling exists.
217 217
 	 */
218
-	private static function get_adjacent_textnode( callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null ) {
219
-		if ( ! isset( $element ) ) {
218
+	private static function get_adjacent_textnode(callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null) {
219
+		if ( ! isset($element)) {
220 220
 			return null;
221
-		} elseif ( $element instanceof \DOMElement && isset( self::$block_tags[ $element->tagName ] ) ) {
221
+		} elseif ($element instanceof \DOMElement && isset(self::$block_tags[$element->tagName])) {
222 222
 			return null;
223 223
 		}
224 224
 
225 225
 		$adjacent = null;
226 226
 		$node     = $element;
227 227
 
228
-		while ( ! empty( $node ) && empty( $adjacent ) ) {
229
-			$adjacent = $iterate( $node );
228
+		while ( ! empty($node) && empty($adjacent)) {
229
+			$adjacent = $iterate($node);
230 230
 		}
231 231
 
232
-		if ( empty( $adjacent ) ) {
233
-			$adjacent = $get_adjacent_parent( $element->parentNode );
232
+		if (empty($adjacent)) {
233
+			$adjacent = $get_adjacent_parent($element->parentNode);
234 234
 		}
235 235
 
236 236
 		return $adjacent;
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @return \DOMText|null The first child of type \DOMText, the element itself if it is of type \DOMText or null.
246 246
 	 */
247
-	public static function get_first_textnode( \DOMNode $element = null, $recursive = false ) {
248
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$first_textnode = null ) {
247
+	public static function get_first_textnode(\DOMNode $element = null, $recursive = false) {
248
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $first_textnode = null) {
249 249
 			$i = 0;
250 250
 
251
-			while ( $i < $children->length && empty( $first_textnode ) ) {
252
-				$first_textnode = self::get_first_textnode( $children->item( $i ), true );
251
+			while ($i < $children->length && empty($first_textnode)) {
252
+				$first_textnode = self::get_first_textnode($children->item($i), true);
253 253
 				$i++;
254 254
 			}
255
-		}, $element, $recursive );
255
+		}, $element, $recursive);
256 256
 	}
257 257
 
258 258
 	/**
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
265 265
 	 */
266
-	public static function get_last_textnode( \DOMNode $element = null, $recursive = false ) {
267
-		return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$last_textnode = null ) {
266
+	public static function get_last_textnode(\DOMNode $element = null, $recursive = false) {
267
+		return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $last_textnode = null) {
268 268
 			$i = $children->length - 1;
269 269
 
270
-			while ( $i >= 0 && empty( $last_textnode ) ) {
271
-				$last_textnode = self::get_last_textnode( $children->item( $i ), true );
270
+			while ($i >= 0 && empty($last_textnode)) {
271
+				$last_textnode = self::get_last_textnode($children->item($i), true);
272 272
 				$i--;
273 273
 			}
274
-		}, $element, $recursive );
274
+		}, $element, $recursive);
275 275
 	}
276 276
 
277 277
 	/**
@@ -285,24 +285,24 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null.
287 287
 	 */
288
-	private static function get_edge_textnode( callable $iteration, \DOMNode $element = null, $recursive = false ) {
289
-		if ( ! isset( $element ) ) {
288
+	private static function get_edge_textnode(callable $iteration, \DOMNode $element = null, $recursive = false) {
289
+		if ( ! isset($element)) {
290 290
 			return null;
291 291
 		}
292 292
 
293
-		if ( $element instanceof \DOMText ) {
293
+		if ($element instanceof \DOMText) {
294 294
 			return $element;
295
-		} elseif ( ! $element instanceof \DOMElement ) {
295
+		} elseif ( ! $element instanceof \DOMElement) {
296 296
 			// Return null if $element is neither \DOMText nor \DOMElement.
297 297
 			return null;
298
-		} elseif ( $recursive && isset( self::$block_tags[ $element->tagName ] ) ) {
298
+		} elseif ($recursive && isset(self::$block_tags[$element->tagName])) {
299 299
 			return null;
300 300
 		}
301 301
 
302 302
 		$edge_textnode = null;
303 303
 
304
-		if ( $element->hasChildNodes() ) {
305
-			$iteration( $element->childNodes, $edge_textnode );
304
+		if ($element->hasChildNodes()) {
305
+			$iteration($element->childNodes, $edge_textnode);
306 306
 		}
307 307
 
308 308
 		return $edge_textnode;
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return \DOMElement|null
317 317
 	 */
318
-	public static function get_block_parent( \DOMNode $element ) {
318
+	public static function get_block_parent(\DOMNode $element) {
319 319
 		$parent = $element->parentNode;
320
-		if ( ! $parent instanceof \DOMElement ) {
320
+		if ( ! $parent instanceof \DOMElement) {
321 321
 			return null;
322 322
 		}
323 323
 
324
-		while ( ! isset( self::$block_tags[ $parent->tagName ] ) && ! empty( $parent->parentNode ) && $parent->parentNode instanceof \DOMElement ) {
324
+		while ( ! isset(self::$block_tags[$parent->tagName]) && ! empty($parent->parentNode) && $parent->parentNode instanceof \DOMElement) {
325 325
 			$parent = $parent->parentNode;
326 326
 		}
327 327
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 
336 336
 	 * @return string The tag name (or the empty string).
337 337
 	 */
338
-	public static function get_block_parent_name( \DOMNode $element ) {
339
-		$parent = self::get_block_parent( $element );
338
+	public static function get_block_parent_name(\DOMNode $element) {
339
+		$parent = self::get_block_parent($element);
340 340
 
341
-		if ( ! empty( $parent ) ) {
341
+		if ( ! empty($parent)) {
342 342
 			return $parent->tagName;
343 343
 		} else {
344 344
 			return '';
Please login to merge, or discard this patch.
src/class-text-parser.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -299,28 +299,28 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return bool Returns `true` on successful completion, `false` otherwise.
301 301
 	 */
302
-	public function load( $raw_text ) {
303
-		if ( ! is_string( $raw_text ) ) {
302
+	public function load($raw_text) {
303
+		if ( ! is_string($raw_text)) {
304 304
 			return false; // we have an error, abort.
305 305
 		}
306 306
 
307 307
 		// Abort if a simple string exceeds 500 characters (security concern).
308
-		if ( preg_match( self::_RE_MAX_STRING_LENGTH, $raw_text ) ) {
308
+		if (preg_match(self::_RE_MAX_STRING_LENGTH, $raw_text)) {
309 309
 			return false;
310 310
 		}
311 311
 
312 312
 		// Detect encoding.
313
-		$str_functions = Strings::functions( $raw_text );
314
-		if ( empty( $str_functions ) ) {
313
+		$str_functions = Strings::functions($raw_text);
314
+		if (empty($str_functions)) {
315 315
 			return false; // unknown encoding.
316 316
 		}
317 317
 		$this->current_strtoupper = $str_functions['strtoupper'];
318 318
 
319 319
 		// Tokenize the raw text parts.
320
-		$this->text = self::tokenize( preg_split( self::_RE_ANY_TEXT, $raw_text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) );
320
+		$this->text = self::tokenize(preg_split(self::_RE_ANY_TEXT, $raw_text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
321 321
 
322 322
 		// The token array should never be empty.
323
-		return ! empty( $this->text );
323
+		return ! empty($this->text);
324 324
 	}
325 325
 
326 326
 	/**
@@ -334,23 +334,23 @@  discard block
 block discarded – undo
334 334
 	 *         @type Token $index A token may combine several input parts.
335 335
 	 * }
336 336
 	 */
337
-	protected static function tokenize( array $parts ) {
337
+	protected static function tokenize(array $parts) {
338 338
 		$tokens = [];
339 339
 		$index  = 0;
340 340
 
341
-		foreach ( $parts as $part ) {
342
-			if ( preg_match( self::_RE_SPACE, $part ) ) {
343
-				$tokens[ $index ] = new Token( $part, Token::SPACE );
344
-			} elseif ( preg_match( self::_RE_PUNCTUATION, $part ) ) {
345
-				$tokens[ $index ] = new Token( $part, Token::PUNCTUATION );
346
-			} elseif ( preg_match( self::_RE_WORD, $part ) ) {
341
+		foreach ($parts as $part) {
342
+			if (preg_match(self::_RE_SPACE, $part)) {
343
+				$tokens[$index] = new Token($part, Token::SPACE);
344
+			} elseif (preg_match(self::_RE_PUNCTUATION, $part)) {
345
+				$tokens[$index] = new Token($part, Token::PUNCTUATION);
346
+			} elseif (preg_match(self::_RE_WORD, $part)) {
347 347
 				// Make sure that things like email addresses and URLs are not broken up
348 348
 				// into words and punctuation not preceeded by an 'other'.
349
-				self::parse_ambiguous_token( Token::WORD, $part, $tokens, $index );
349
+				self::parse_ambiguous_token(Token::WORD, $part, $tokens, $index);
350 350
 			} else {
351 351
 				// Make sure that things like email addresses and URLs are not broken up into words
352 352
 				// and punctuation not preceeded by an 'other' or 'word'.
353
-				self::parse_ambiguous_token( Token::OTHER, $part, $tokens, $index );
353
+				self::parse_ambiguous_token(Token::OTHER, $part, $tokens, $index);
354 354
 			}
355 355
 
356 356
 			$index++;
@@ -367,25 +367,25 @@  discard block
 block discarded – undo
367 367
 	 * @param array  $tokens        The token array. Passed by reference.
368 368
 	 * @param int    $index         The current index. Passed by reference.
369 369
 	 */
370
-	protected static function parse_ambiguous_token( $expected_type, $part, array &$tokens, &$index ) {
370
+	protected static function parse_ambiguous_token($expected_type, $part, array &$tokens, &$index) {
371 371
 
372 372
 		// Make sure that things like email addresses and URLs are not broken up incorrectly.
373
-		if ( self::is_preceeded_by( Token::OTHER, $tokens, $index ) || ( Token::OTHER === $expected_type && self::is_preceeded_by( Token::WORD, $tokens, $index ) ) ) {
373
+		if (self::is_preceeded_by(Token::OTHER, $tokens, $index) || (Token::OTHER === $expected_type && self::is_preceeded_by(Token::WORD, $tokens, $index))) {
374 374
 			$index--;
375
-			$old_part = $tokens[ $index ]->value;
376
-			$tokens[ $index ] = new Token( $old_part . $part, Token::OTHER );
375
+			$old_part = $tokens[$index]->value;
376
+			$tokens[$index] = new Token($old_part . $part, Token::OTHER);
377 377
 
378 378
 		// Not preceeded by a non-space + punctuation.
379
-		} elseif ( self::is_preceeded_by( Token::PUNCTUATION, $tokens, $index ) && self::is_not_preceeded_by( Token::SPACE, $tokens, $index, 2 ) ) {
380
-			$old_part   = $tokens[ $index - 1 ]->value;
381
-			$older_part = $tokens[ $index - 2 ]->value;
382
-			$tokens[ $index - 2 ] = new Token( $older_part . $old_part . $part, Token::OTHER );
383
-			unset( $tokens[ $index - 1 ] );
379
+		} elseif (self::is_preceeded_by(Token::PUNCTUATION, $tokens, $index) && self::is_not_preceeded_by(Token::SPACE, $tokens, $index, 2)) {
380
+			$old_part   = $tokens[$index - 1]->value;
381
+			$older_part = $tokens[$index - 2]->value;
382
+			$tokens[$index - 2] = new Token($older_part . $old_part . $part, Token::OTHER);
383
+			unset($tokens[$index - 1]);
384 384
 			$index = $index - 2;
385 385
 
386 386
 		// All good.
387 387
 		} else {
388
-			$tokens[ $index ] = new Token( $part, $expected_type );
388
+			$tokens[$index] = new Token($part, $expected_type);
389 389
 		}
390 390
 	}
391 391
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return bool
401 401
 	 */
402
-	protected static function is_preceeded_by( $type, array $tokens, $index, $steps = 1 ) {
403
-		return $index - $steps >= 0 && $type === $tokens[ $index - $steps ]->type;
402
+	protected static function is_preceeded_by($type, array $tokens, $index, $steps = 1) {
403
+		return $index - $steps >= 0 && $type === $tokens[$index - $steps]->type;
404 404
 	}
405 405
 
406 406
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return bool
415 415
 	 */
416
-	protected static function is_not_preceeded_by( $type, array $tokens, $index, $steps = 1 ) {
417
-		return $index - $steps >= 0 && $type !== $tokens[ $index - $steps ]->type;
416
+	protected static function is_not_preceeded_by($type, array $tokens, $index, $steps = 1) {
417
+		return $index - $steps >= 0 && $type !== $tokens[$index - $steps]->type;
418 418
 	}
419 419
 
420 420
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @return bool Returns true on successful completion.
427 427
 	 */
428 428
 	public function reload() {
429
-		return $this->load( $this->unload() );
429
+		return $this->load($this->unload());
430 430
 	}
431 431
 
432 432
 	/**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	public function unload() {
438 438
 		$reassembled_text = '';
439 439
 
440
-		foreach ( $this->text as $token ) {
440
+		foreach ($this->text as $token) {
441 441
 			$reassembled_text .= $token->value;
442 442
 		}
443 443
 
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 	 *      @type Text_Parser\Token $index
464 464
 	 * }
465 465
 	 */
466
-	public function update( $tokens ) {
467
-		foreach ( $tokens as $index => $token ) {
468
-			$this->text[ $index ] = $this->text[ $index ]->with_value( $token->value );
466
+	public function update($tokens) {
467
+		foreach ($tokens as $index => $token) {
468
+			$this->text[$index] = $this->text[$index]->with_value($token->value);
469 469
 		}
470 470
 	}
471 471
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * @return array    An array of Text_Parser\Token.
485 485
 	 */
486 486
 	public function get_spaces() {
487
-		return $this->get_type( Token::SPACE );
487
+		return $this->get_type(Token::SPACE);
488 488
 	}
489 489
 
490 490
 	/**
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 * @return array    An array of Text_Parser\Token.
494 494
 	 */
495 495
 	public function get_punctuation() {
496
-		return $this->get_type( Token::PUNCTUATION );
496
+		return $this->get_type(Token::PUNCTUATION);
497 497
 	}
498 498
 
499 499
 	/**
@@ -505,22 +505,22 @@  discard block
 block discarded – undo
505 505
 	 *
506 506
 	 * @return array    An array of Text_Parser\Token.
507 507
 	 */
508
-	public function get_words( $abc = self::ALLOW_ALL_LETTERS, $caps = self::ALLOW_ALL_CAPS, $comps = self::ALLOW_COMPOUNDS ) {
508
+	public function get_words($abc = self::ALLOW_ALL_LETTERS, $caps = self::ALLOW_ALL_CAPS, $comps = self::ALLOW_COMPOUNDS) {
509 509
 		// Return early if no text has been loaded.
510
-		if ( ! isset( $this->text ) || ! is_callable( $this->current_strtoupper ) ) {
510
+		if ( ! isset($this->text) || ! is_callable($this->current_strtoupper)) {
511 511
 			return []; // abort.
512 512
 		}
513 513
 
514 514
 		// Result set.
515 515
 		$tokens = [];
516 516
 
517
-		foreach ( $this->get_type( Token::WORD ) as $index => $token ) {
517
+		foreach ($this->get_type(Token::WORD) as $index => $token) {
518 518
 
519
-			if ( $this->conforms_to_letters_policy( $token, $abc ) &&
520
-				 $this->conforms_to_caps_policy( $token, $caps ) &&
521
-				 $this->conforms_to_compounds_policy( $token, $comps ) ) {
519
+			if ($this->conforms_to_letters_policy($token, $abc) &&
520
+				 $this->conforms_to_caps_policy($token, $caps) &&
521
+				 $this->conforms_to_compounds_policy($token, $comps)) {
522 522
 
523
-				$tokens[ $index ] = $token;
523
+				$tokens[$index] = $token;
524 524
 			}
525 525
 		}
526 526
 
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 	 *
536 536
 	 * @return bool
537 537
 	 */
538
-	protected function conforms_to_letters_policy( Token $token, $policy ) {
538
+	protected function conforms_to_letters_policy(Token $token, $policy) {
539 539
 
540 540
 		// Short circuit.
541
-		if ( self::ALLOW_ALL_LETTERS === $policy ) {
541
+		if (self::ALLOW_ALL_LETTERS === $policy) {
542 542
 			return true;
543 543
 		}
544 544
 
545
-		$lettered = preg_replace( self::_RE_HTML_LETTER_CONNECTORS, '', $token->value );
545
+		$lettered = preg_replace(self::_RE_HTML_LETTER_CONNECTORS, '', $token->value);
546 546
 
547 547
 		return
548
-			( self::REQUIRE_ALL_LETTERS === $policy && $lettered === $token->value ) ||
549
-			( self::NO_ALL_LETTERS === $policy && $lettered !== $token->value );
548
+			(self::REQUIRE_ALL_LETTERS === $policy && $lettered === $token->value) ||
549
+			(self::NO_ALL_LETTERS === $policy && $lettered !== $token->value);
550 550
 	}
551 551
 
552 552
 	/**
@@ -557,19 +557,19 @@  discard block
 block discarded – undo
557 557
 	 *
558 558
 	 * @return bool
559 559
 	 */
560
-	protected function conforms_to_caps_policy( Token $token, $policy ) {
560
+	protected function conforms_to_caps_policy(Token $token, $policy) {
561 561
 
562 562
 		// Short circuit.
563
-		if ( self::ALLOW_ALL_CAPS === $policy ) {
563
+		if (self::ALLOW_ALL_CAPS === $policy) {
564 564
 			return true;
565 565
 		}
566 566
 
567 567
 		// Token value in all-caps.
568
-		$capped = call_user_func( $this->current_strtoupper, $token->value );
568
+		$capped = call_user_func($this->current_strtoupper, $token->value);
569 569
 
570 570
 		return
571
-			( self::REQUIRE_ALL_CAPS === $policy && $capped === $token->value ) ||
572
-			( self::NO_ALL_CAPS === $policy && $capped !== $token->value );
571
+			(self::REQUIRE_ALL_CAPS === $policy && $capped === $token->value) ||
572
+			(self::NO_ALL_CAPS === $policy && $capped !== $token->value);
573 573
 	}
574 574
 
575 575
 	/**
@@ -580,18 +580,18 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return bool
582 582
 	 */
583
-	protected function conforms_to_compounds_policy( Token $token, $policy ) {
583
+	protected function conforms_to_compounds_policy(Token $token, $policy) {
584 584
 
585 585
 		// Short circuit.
586
-		if ( self::ALLOW_COMPOUNDS === $policy ) {
586
+		if (self::ALLOW_COMPOUNDS === $policy) {
587 587
 			return true;
588 588
 		}
589 589
 
590
-		$uncompound = preg_replace( '/-/S', '', $token->value );
590
+		$uncompound = preg_replace('/-/S', '', $token->value);
591 591
 
592 592
 		return
593
-			( self::REQUIRE_COMPOUNDS === $policy && $uncompound !== $token->value ) ||
594
-			( self::NO_COMPOUNDS === $policy && $uncompound === $token->value );
593
+			(self::REQUIRE_COMPOUNDS === $policy && $uncompound !== $token->value) ||
594
+			(self::NO_COMPOUNDS === $policy && $uncompound === $token->value);
595 595
 	}
596 596
 
597 597
 	/**
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @return array    An array of Text_Parser\Token.
601 601
 	 */
602 602
 	public function get_other() {
603
-		return $this->get_type( Token::OTHER );
603
+		return $this->get_type(Token::OTHER);
604 604
 	}
605 605
 
606 606
 	/**
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 	 *
611 611
 	 * @return array    An array of Text_Parser\Token.
612 612
 	 */
613
-	public function get_type( $type ) {
613
+	public function get_type($type) {
614 614
 		$tokens = [];
615 615
 
616
-		foreach ( $this->text as $index => $token ) {
617
-			if ( $token->type === $type ) {
618
-				$tokens[ $index ] = $token;
616
+		foreach ($this->text as $index => $token) {
617
+			if ($token->type === $type) {
618
+				$tokens[$index] = $token;
619 619
 			}
620 620
 		}
621 621
 
Please login to merge, or discard this patch.
src/class-re.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string A list of top-level domains concatenated with '|'.
105 105
 	 */
106
-	private static function get_top_level_domains_from_file( $path ) {
106
+	private static function get_top_level_domains_from_file($path) {
107 107
 		$domains = [];
108 108
 
109
-		if ( file_exists( $path ) ) {
110
-			$file = new \SplFileObject( $path );
109
+		if (file_exists($path)) {
110
+			$file = new \SplFileObject($path);
111 111
 
112
-			while ( ! $file->eof() ) {
112
+			while ( ! $file->eof()) {
113 113
 				$line = $file->fgets();
114 114
 
115
-				if ( preg_match( '#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches ) ) {
116
-					$domains[] = strtolower( $matches[0] );
115
+				if (preg_match('#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches)) {
116
+					$domains[] = strtolower($matches[0]);
117 117
 				}
118 118
 			}
119 119
 		}
120 120
 
121
-		if ( count( $domains ) > 0 ) {
122
-			return implode( '|', $domains );
121
+		if (count($domains) > 0) {
122
+			return implode('|', $domains);
123 123
 		} else {
124 124
 			return 'ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|com|coop|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw';
125 125
 		}
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * @return string
132 132
 	 */
133 133
 	public static function top_level_domains() {
134
-		if ( empty( self::$top_level_domains_pattern ) ) {
134
+		if (empty(self::$top_level_domains_pattern)) {
135 135
 			// Initialize valid top level domains from IANA list.
136
-			self::$top_level_domains_pattern = self::get_top_level_domains_from_file( __DIR__ . '/IANA/tlds-alpha-by-domain.txt' );
136
+			self::$top_level_domains_pattern = self::get_top_level_domains_from_file(__DIR__ . '/IANA/tlds-alpha-by-domain.txt');
137 137
 		}
138 138
 
139 139
 		return self::$top_level_domains_pattern;
Please login to merge, or discard this patch.
src/settings/class-simple-quotes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	 * @param string $open  Opening quote character(s).
56 56
 	 * @param string $close Closing quote character(s).
57 57
 	 */
58
-	public function __construct( $open, $close ) {
58
+	public function __construct($open, $close) {
59 59
 		$this->open  = $open;
60 60
 		$this->close = $close;
61 61
 	}
Please login to merge, or discard this patch.
src/settings/class-simple-dashes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 	 * @param string $interval            The dash character used for interval dashes.
72 72
 	 * @param string $interval_space      The space character used around interval dashes.
73 73
 	 */
74
-	public function __construct( $parenthetical, $parenthetical_space, $interval, $interval_space ) {
74
+	public function __construct($parenthetical, $parenthetical_space, $interval, $interval_space) {
75 75
 		$this->parenthetical_dash  = $parenthetical;
76 76
 		$this->parenthetical_space = $parenthetical_space;
77 77
 		$this->interval_dash       = $interval;
Please login to merge, or discard this patch.
src/settings/class-quote-style.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -149,15 +149,15 @@
 block discarded – undo
149 149
 	 *
150 150
 	 * @return Quotes|null Returns null in case of an invalid $style parameter.
151 151
 	 */
152
-	public static function get_styled_quotes( $style, Settings $settings ) {
153
-		if ( isset( self::$styles[ $style ] ) ) {
154
-			return new Simple_Quotes( self::$styles[ $style ][ self::_OPEN ], self::$styles[ $style ][ self::_CLOSE ] );
152
+	public static function get_styled_quotes($style, Settings $settings) {
153
+		if (isset(self::$styles[$style])) {
154
+			return new Simple_Quotes(self::$styles[$style][self::_OPEN], self::$styles[$style][self::_CLOSE]);
155 155
 		}
156 156
 
157
-		if ( self::DOUBLE_GUILLEMETS_FRENCH === $style ) {
157
+		if (self::DOUBLE_GUILLEMETS_FRENCH === $style) {
158 158
 			$space = $settings->no_break_narrow_space();
159 159
 
160
-			return new Simple_Quotes( U::GUILLEMET_OPEN . $space, $space . U::GUILLEMET_CLOSE );
160
+			return new Simple_Quotes(U::GUILLEMET_OPEN . $space, $space . U::GUILLEMET_CLOSE);
161 161
 		}
162 162
 
163 163
 		return null;
Please login to merge, or discard this patch.
src/class-hyphenator.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	 * @param string|null $language   Optional. Short-form language name. Default null.
93 93
 	 * @param array       $exceptions Optional. Custom hyphenation exceptions. Default empty array.
94 94
 	 */
95
-	public function __construct( $language = null, array $exceptions = [] ) {
95
+	public function __construct($language = null, array $exceptions = []) {
96 96
 
97
-		if ( ! empty( $language ) ) {
98
-			$this->set_language( $language );
97
+		if ( ! empty($language)) {
98
+			$this->set_language($language);
99 99
 		}
100 100
 
101
-		if ( ! empty( $exceptions ) ) {
102
-			$this->set_custom_exceptions( $exceptions );
101
+		if ( ! empty($exceptions)) {
102
+			$this->set_custom_exceptions($exceptions);
103 103
 		}
104 104
 	}
105 105
 
@@ -108,31 +108,31 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param array $exceptions Optional. An array of words with all hyphenation points marked with a hard hyphen. Default empty array.
110 110
 	 */
111
-	public function set_custom_exceptions( array $exceptions = [] ) {
112
-		if ( empty( $exceptions ) && empty( $this->custom_exceptions ) ) {
111
+	public function set_custom_exceptions(array $exceptions = []) {
112
+		if (empty($exceptions) && empty($this->custom_exceptions)) {
113 113
 			return; // Nothing to do at all.
114 114
 		}
115 115
 
116 116
 		// Calculate hash & check against previous exceptions.
117
-		$new_hash = self::get_object_hash( $exceptions );
118
-		if ( $this->custom_exceptions_hash === $new_hash ) {
117
+		$new_hash = self::get_object_hash($exceptions);
118
+		if ($this->custom_exceptions_hash === $new_hash) {
119 119
 			return; // No need to update exceptions.
120 120
 		}
121 121
 
122 122
 		// Do our thing.
123 123
 		$exception_keys = [];
124
-		foreach ( $exceptions as $exception ) {
125
-			$func = Strings::functions( $exception );
126
-			if ( empty( $func ) ) {
124
+		foreach ($exceptions as $exception) {
125
+			$func = Strings::functions($exception);
126
+			if (empty($func)) {
127 127
 				continue; // unknown encoding, abort.
128 128
 			}
129 129
 
130
-			$exception = $func['strtolower']( $exception );
131
-			$exception_keys[ $exception ] = preg_replace( "#-#{$func['u']}", '', $exception );
130
+			$exception = $func['strtolower']($exception);
131
+			$exception_keys[$exception] = preg_replace("#-#{$func['u']}", '', $exception);
132 132
 		}
133 133
 
134 134
 		// Update exceptions.
135
-		$this->custom_exceptions      = array_flip( $exception_keys );
135
+		$this->custom_exceptions      = array_flip($exception_keys);
136 136
 		$this->custom_exceptions_hash = $new_hash;
137 137
 
138 138
 		// Force remerging of patgen and custom exception patterns.
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	protected static function get_object_hash( $object ) {
150
-		return md5( json_encode( $object ), false );
149
+	protected static function get_object_hash($object) {
150
+		return md5(json_encode($object), false);
151 151
 	}
152 152
 
153 153
 	/**
@@ -157,23 +157,23 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @return bool Whether loading the pattern file was successful.
159 159
 	 */
160
-	public function set_language( $lang = 'en-US' ) {
161
-		if ( isset( $this->language ) && $this->language === $lang ) {
160
+	public function set_language($lang = 'en-US') {
161
+		if (isset($this->language) && $this->language === $lang) {
162 162
 			return true; // Bail out, no need to do anything.
163 163
 		}
164 164
 
165 165
 		$success = false;
166
-		$language_file_name = dirname( __FILE__ ) . '/lang/' . $lang . '.json';
166
+		$language_file_name = dirname(__FILE__) . '/lang/' . $lang . '.json';
167 167
 
168
-		if ( file_exists( $language_file_name ) ) {
169
-			$raw_language_file = file_get_contents( $language_file_name );
168
+		if (file_exists($language_file_name)) {
169
+			$raw_language_file = file_get_contents($language_file_name);
170 170
 
171
-			if ( false !== $raw_language_file ) {
172
-				$language_file = json_decode( $raw_language_file, true );
171
+			if (false !== $raw_language_file) {
172
+				$language_file = json_decode($raw_language_file, true);
173 173
 
174
-				if ( false !== $language_file ) {
174
+				if (false !== $language_file) {
175 175
 					$this->language           = $lang;
176
-					$this->pattern_trie       = Trie_Node::build_trie( $language_file['patterns'] );
176
+					$this->pattern_trie       = Trie_Node::build_trie($language_file['patterns']);
177 177
 					$this->pattern_exceptions = $language_file['exceptions'];
178 178
 
179 179
 					$success = true;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 
184 184
 		// Clean up.
185
-		if ( ! $success ) {
185
+		if ( ! $success) {
186 186
 			$this->language = null;
187 187
 			$this->pattern_trie = null;
188 188
 			$this->pattern_exceptions = [];
@@ -206,18 +206,18 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return array The modified text tokens.
208 208
 	 */
209
-	public function hyphenate( $parsed_text_tokens, $hyphen = '-', $hyphenate_title_case = false, $min_length = 2, $min_before = 2, $min_after = 2 ) {
210
-		if ( empty( $min_length ) || empty( $min_before ) || ! isset( $this->pattern_trie ) || ! isset( $this->pattern_exceptions ) ) {
209
+	public function hyphenate($parsed_text_tokens, $hyphen = '-', $hyphenate_title_case = false, $min_length = 2, $min_before = 2, $min_after = 2) {
210
+		if (empty($min_length) || empty($min_before) || ! isset($this->pattern_trie) || ! isset($this->pattern_exceptions)) {
211 211
 			return $parsed_text_tokens;
212 212
 		}
213 213
 
214 214
 		// Make sure we have full exceptions list.
215
-		if ( ! isset( $this->merged_exception_patterns ) ) {
215
+		if ( ! isset($this->merged_exception_patterns)) {
216 216
 			$this->merge_hyphenation_exceptions();
217 217
 		}
218 218
 
219
-		foreach ( $parsed_text_tokens as $key => $text_token ) {
220
-			$parsed_text_tokens[ $key ] = $text_token->with_value( $this->hyphenate_word( $text_token->value, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after ) );
219
+		foreach ($parsed_text_tokens as $key => $text_token) {
220
+			$parsed_text_tokens[$key] = $text_token->with_value($this->hyphenate_word($text_token->value, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after));
221 221
 		}
222 222
 
223 223
 		return $parsed_text_tokens;
@@ -235,48 +235,48 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @return string
237 237
 	 */
238
-	protected function hyphenate_word( $word, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after ) {
238
+	protected function hyphenate_word($word, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after) {
239 239
 		// Quickly reference string functions according to encoding.
240
-		$func = Strings::functions( $word );
241
-		if ( empty( $func ) ) {
240
+		$func = Strings::functions($word);
241
+		if (empty($func)) {
242 242
 			return $word; // unknown encoding, abort.
243 243
 		}
244 244
 
245 245
 		// Check word length.
246
-		$word_length = $func['strlen']( $word );
247
-		if ( $word_length < $min_length ) {
246
+		$word_length = $func['strlen']($word);
247
+		if ($word_length < $min_length) {
248 248
 			return $word;
249 249
 		}
250 250
 
251 251
 		// Trie lookup requires a lowercase search term.
252
-		$the_key = $func['strtolower']( $word );
252
+		$the_key = $func['strtolower']($word);
253 253
 
254 254
 		// If this is a capitalized word, and settings do not allow hyphenation of such, abort!
255 255
 		// Note: This is different than uppercase words, where we are looking for title case.
256
-		if ( ! $hyphenate_title_case && $func['substr']( $the_key, 0, 1 ) !== $func['substr']( $word, 0, 1 ) ) {
256
+		if ( ! $hyphenate_title_case && $func['substr']($the_key, 0, 1) !== $func['substr']($word, 0, 1)) {
257 257
 			return $word;
258 258
 		}
259 259
 
260 260
 		// Give exceptions preference.
261
-		if ( isset( $this->merged_exception_patterns[ $the_key ] ) ) {
262
-			$word_pattern = $this->merged_exception_patterns[ $the_key ];
261
+		if (isset($this->merged_exception_patterns[$the_key])) {
262
+			$word_pattern = $this->merged_exception_patterns[$the_key];
263 263
 		}
264 264
 
265 265
 		// Lookup word pattern if there is no exception.
266
-		if ( ! isset( $word_pattern ) ) {
267
-			$word_pattern = $this->lookup_word_pattern( $the_key, $func['strlen'], $func['str_split'] );
266
+		if ( ! isset($word_pattern)) {
267
+			$word_pattern = $this->lookup_word_pattern($the_key, $func['strlen'], $func['str_split']);
268 268
 		}
269 269
 
270 270
 		// Add hyphen character based on $word_pattern.
271
-		$word_parts      = $func['str_split']( $word, 1 );
271
+		$word_parts      = $func['str_split']($word, 1);
272 272
 		$hyphenated_word = '';
273 273
 
274
-		for ( $i = 0; $i < $word_length; $i++ ) {
275
-			if ( isset( $word_pattern[ $i ] ) && self::is_odd( $word_pattern[ $i ] ) && ( $i >= $min_before) && ( $i <= $word_length - $min_after ) ) {
274
+		for ($i = 0; $i < $word_length; $i++) {
275
+			if (isset($word_pattern[$i]) && self::is_odd($word_pattern[$i]) && ($i >= $min_before) && ($i <= $word_length - $min_after)) {
276 276
 				$hyphenated_word .= $hyphen;
277 277
 			}
278 278
 
279
-			$hyphenated_word .= $word_parts[ $i ];
279
+			$hyphenated_word .= $word_parts[$i];
280 280
 		}
281 281
 
282 282
 		return $hyphenated_word;
@@ -291,33 +291,33 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @return array The hyphenation pattern.
293 293
 	 */
294
-	protected function lookup_word_pattern( $key, callable $strlen, callable $str_split ) {
294
+	protected function lookup_word_pattern($key, callable $strlen, callable $str_split) {
295 295
 		// Add underscores to make out-of-index checks unnecessary,
296 296
 		// also hyphenation is done in lower case.
297 297
 		$search        = '_' . $key . '_';
298
-		$search_length = $strlen( $search );
299
-		$chars         = $str_split( $search );
298
+		$search_length = $strlen($search);
299
+		$chars         = $str_split($search);
300 300
 		$word_pattern  = [];
301 301
 
302
-		for ( $start = 0; $start < $search_length; ++$start ) {
302
+		for ($start = 0; $start < $search_length; ++$start) {
303 303
 			// Start from the trie root node.
304 304
 			$node = $this->pattern_trie;
305 305
 
306 306
 			// Walk through the trie while storing detected patterns.
307
-			for ( $step = $start; $step < $search_length; ++$step ) {
307
+			for ($step = $start; $step < $search_length; ++$step) {
308 308
 				// No further path in the trie.
309
-				if ( ! $node->exists( $chars[ $step ] ) ) {
309
+				if ( ! $node->exists($chars[$step])) {
310 310
 					break;
311 311
 				}
312 312
 
313 313
 				// Look for next character.
314
-				$node = $node->get_node( $chars[ $step ] );
314
+				$node = $node->get_node($chars[$step]);
315 315
 
316 316
 				// Merge different offset values and keep maximum.
317
-				foreach ( $node->offsets() as $pattern_offset ) {
317
+				foreach ($node->offsets() as $pattern_offset) {
318 318
 					$value  = $pattern_offset[0];
319 319
 					$offset = $pattern_offset[1] + $start - 1;
320
-					$word_pattern[ $offset ] = isset( $word_pattern[ $offset ] ) ? max( $word_pattern[ $offset ], $value ) : $value;
320
+					$word_pattern[$offset] = isset($word_pattern[$offset]) ? max($word_pattern[$offset], $value) : $value;
321 321
 				}
322 322
 			}
323 323
 		}
@@ -333,18 +333,18 @@  discard block
 block discarded – undo
333 333
 		$exceptions = [];
334 334
 
335 335
 		// Merge custom and language specific word hyphenations.
336
-		if ( ! empty( $this->pattern_exceptions ) && ! empty( $this->custom_exceptions ) ) {
337
-			$exceptions = array_merge( $this->custom_exceptions, $this->pattern_exceptions );
338
-		} elseif ( ! empty( $this->pattern_exceptions ) ) {
336
+		if ( ! empty($this->pattern_exceptions) && ! empty($this->custom_exceptions)) {
337
+			$exceptions = array_merge($this->custom_exceptions, $this->pattern_exceptions);
338
+		} elseif ( ! empty($this->pattern_exceptions)) {
339 339
 			$exceptions = $this->pattern_exceptions;
340
-		} elseif ( ! empty( $this->custom_exceptions ) ) {
340
+		} elseif ( ! empty($this->custom_exceptions)) {
341 341
 			$exceptions = $this->custom_exceptions;
342 342
 		}
343 343
 
344 344
 		// Update patterns as well.
345 345
 		$exception_patterns = [];
346
-		foreach ( $exceptions as $exception_key => $exception ) {
347
-			$exception_patterns[ $exception_key ] = self::convert_hyphenation_exception_to_pattern( $exception );
346
+		foreach ($exceptions as $exception_key => $exception) {
347
+			$exception_patterns[$exception_key] = self::convert_hyphenation_exception_to_pattern($exception);
348 348
 		}
349 349
 
350 350
 		$this->merged_exception_patterns = $exception_patterns;
@@ -357,22 +357,22 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @return array|null Returns the hyphenation pattern or null if `$exception` is using an invalid encoding.
359 359
 	 */
360
-	protected static function convert_hyphenation_exception_to_pattern( $exception ) {
361
-		$func = Strings::functions( $exception );
362
-		if ( empty( $func ) ) {
360
+	protected static function convert_hyphenation_exception_to_pattern($exception) {
361
+		$func = Strings::functions($exception);
362
+		if (empty($func)) {
363 363
 			return null; // unknown encoding, abort.
364 364
 		}
365 365
 
366 366
 		// Set the word_pattern - this method keeps any contextually important capitalization.
367
-		$lowercase_hyphened_word_parts  = $func['str_split']( $exception, 1 );
368
-		$lowercase_hyphened_word_length = $func['strlen']( $exception );
367
+		$lowercase_hyphened_word_parts  = $func['str_split']($exception, 1);
368
+		$lowercase_hyphened_word_length = $func['strlen']($exception);
369 369
 
370 370
 		$word_pattern = [];
371 371
 		$index = 0;
372 372
 
373
-		for ( $i = 0; $i < $lowercase_hyphened_word_length; $i++ ) {
374
-			if ( '-' === $lowercase_hyphened_word_parts[ $i ] ) {
375
-				$word_pattern[ $index ] = 9;
373
+		for ($i = 0; $i < $lowercase_hyphened_word_length; $i++) {
374
+			if ('-' === $lowercase_hyphened_word_parts[$i]) {
375
+				$word_pattern[$index] = 9;
376 376
 			} else {
377 377
 				$index++;
378 378
 			}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @return bool true if $number is odd, false if it is even.
390 390
 	 */
391
-	protected static function is_odd( $number ) {
392
-		return (bool) ( $number % 2 );
391
+	protected static function is_odd($number) {
392
+		return (bool) ($number % 2);
393 393
 	}
394 394
 }
Please login to merge, or discard this patch.
src/fixes/class-node-fix.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	 *
47 47
 	 * @return void
48 48
 	 */
49
-	public function apply( \DOMText $textnode, Settings $settings, $is_title = false );
49
+	public function apply(\DOMText $textnode, Settings $settings, $is_title = false);
50 50
 
51 51
 	/**
52 52
 	 * Determines whether the fix should be applied to (RSS) feeds.
Please login to merge, or discard this patch.
src/fixes/class-token-fix.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array An array of tokens.
54 54
 	 */
55
-	public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null );
55
+	public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null);
56 56
 
57 57
 	/**
58 58
 	 * Determines whether the fix should be applied to (RSS) feeds.
Please login to merge, or discard this patch.