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
Push — master ( c77df9...3520b8 )
by Der Mundschenk
02:59
created
src/class-php-typography.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	const SPACING_POST_WORDS = 40;
54 54
 	const HTML_INSERTION     = 50;
55 55
 
56
-	const GROUPS = [ self::CHARACTERS, self::SPACING_PRE_WORDS, self::PROCESS_WORDS, self::SPACING_POST_WORDS, self::HTML_INSERTION ];
56
+	const GROUPS = [self::CHARACTERS, self::SPACING_PRE_WORDS, self::PROCESS_WORDS, self::SPACING_POST_WORDS, self::HTML_INSERTION];
57 57
 
58 58
 	/**
59 59
 	 * A DOM-based HTML5 parser.
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @var string
116 116
 	 */
117
-	const INIT_NOW  = 'now';
117
+	const INIT_NOW = 'now';
118 118
 
119 119
 	/**
120 120
 	 * Constant for signalling lazy (manual) initialization to the constructor.
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @param string $init Optional. Flag to control initialization. Valid inputs are INIT_NOW and INIT_LAZY. Default INIT_NOW.
130 130
 	 */
131
-	public function __construct( $init = self::INIT_NOW ) {
132
-		if ( self::INIT_NOW === $init ) {
131
+	public function __construct($init = self::INIT_NOW) {
132
+		if (self::INIT_NOW === $init) {
133 133
 			$this->init();
134 134
 		}
135 135
 	}
@@ -141,46 +141,46 @@  discard block
 block discarded – undo
141 141
 		$this->process_words_fix = new Node_Fixes\Process_Words_Fix();
142 142
 
143 143
 		// Nodify anything that requires adjacent text awareness here.
144
-		$this->register_node_fix( new Node_Fixes\Smart_Maths_Fix(),          self::CHARACTERS );
145
-		$this->register_node_fix( new Node_Fixes\Smart_Diacritics_Fix(),     self::CHARACTERS );
146
-		$this->register_node_fix( new Node_Fixes\Smart_Quotes_Fix( true ),   self::CHARACTERS );
147
-		$this->register_node_fix( new Node_Fixes\Smart_Dashes_Fix( true ),   self::CHARACTERS );
148
-		$this->register_node_fix( new Node_Fixes\Smart_Ellipses_Fix( true ), self::CHARACTERS );
149
-		$this->register_node_fix( new Node_Fixes\Smart_Marks_Fix( true ),    self::CHARACTERS );
144
+		$this->register_node_fix(new Node_Fixes\Smart_Maths_Fix(), self::CHARACTERS);
145
+		$this->register_node_fix(new Node_Fixes\Smart_Diacritics_Fix(), self::CHARACTERS);
146
+		$this->register_node_fix(new Node_Fixes\Smart_Quotes_Fix(true), self::CHARACTERS);
147
+		$this->register_node_fix(new Node_Fixes\Smart_Dashes_Fix(true), self::CHARACTERS);
148
+		$this->register_node_fix(new Node_Fixes\Smart_Ellipses_Fix(true), self::CHARACTERS);
149
+		$this->register_node_fix(new Node_Fixes\Smart_Marks_Fix(true), self::CHARACTERS);
150 150
 
151 151
 		// Keep spacing after smart character replacement.
152
-		$this->register_node_fix( new Node_Fixes\Single_Character_Word_Spacing_Fix(), self::SPACING_PRE_WORDS );
153
-		$this->register_node_fix( new Node_Fixes\Dash_Spacing_Fix(),                  self::SPACING_PRE_WORDS );
154
-		$this->register_node_fix( new Node_Fixes\Unit_Spacing_Fix(),                  self::SPACING_PRE_WORDS );
155
-		$this->register_node_fix( new Node_Fixes\Numbered_Abbreviation_Spacing_Fix(), self::SPACING_PRE_WORDS );
156
-		$this->register_node_fix( new Node_Fixes\French_Punctuation_Spacing_Fix(),    self::SPACING_PRE_WORDS );
152
+		$this->register_node_fix(new Node_Fixes\Single_Character_Word_Spacing_Fix(), self::SPACING_PRE_WORDS);
153
+		$this->register_node_fix(new Node_Fixes\Dash_Spacing_Fix(), self::SPACING_PRE_WORDS);
154
+		$this->register_node_fix(new Node_Fixes\Unit_Spacing_Fix(), self::SPACING_PRE_WORDS);
155
+		$this->register_node_fix(new Node_Fixes\Numbered_Abbreviation_Spacing_Fix(), self::SPACING_PRE_WORDS);
156
+		$this->register_node_fix(new Node_Fixes\French_Punctuation_Spacing_Fix(), self::SPACING_PRE_WORDS);
157 157
 
158 158
 		// Parse and process individual words.
159
-		$this->register_node_fix( $this->process_words_fix, self::PROCESS_WORDS );
159
+		$this->register_node_fix($this->process_words_fix, self::PROCESS_WORDS);
160 160
 
161 161
 		// Some final space manipulation.
162
-		$this->register_node_fix( new Node_Fixes\Dewidow_Fix(),        self::SPACING_POST_WORDS );
163
-		$this->register_node_fix( new Node_Fixes\Space_Collapse_Fix(), self::SPACING_POST_WORDS );
162
+		$this->register_node_fix(new Node_Fixes\Dewidow_Fix(), self::SPACING_POST_WORDS);
163
+		$this->register_node_fix(new Node_Fixes\Space_Collapse_Fix(), self::SPACING_POST_WORDS);
164 164
 
165 165
 		// Everything that requires HTML injection occurs here (functions above assume tag-free content)
166 166
 		// pay careful attention to functions below for tolerance of injected tags.
167
-		$this->register_node_fix( new Node_Fixes\Smart_Ordinal_Suffix_Fix( $this->css_classes['ordinal'] ),                                 self::HTML_INSERTION ); // call before "style_numbers" and "smart_fractions".
168
-		$this->register_node_fix( new Node_Fixes\Smart_Exponents_Fix(),                                                                     self::HTML_INSERTION ); // call before "style_numbers".
169
-		$this->register_node_fix( new Node_Fixes\Smart_Fractions_Fix( $this->css_classes['numerator'], $this->css_classes['denominator'] ), self::HTML_INSERTION ); // call before "style_numbers" and after "smart_ordinal_suffix".
170
-		$this->register_node_fix( new Node_Fixes\Style_Caps_Fix( $this->css_classes['caps'] ),                                              self::HTML_INSERTION ); // Call before "style_numbers".
171
-		$this->register_node_fix( new Node_Fixes\Style_Numbers_Fix( $this->css_classes['numbers'] ),                                        self::HTML_INSERTION ); // Call after "smart_ordinal_suffix", "smart_exponents", "smart_fractions", and "style_caps".
172
-		$this->register_node_fix( new Node_Fixes\Style_Ampersands_Fix( $this->css_classes['amp'] ),                                         self::HTML_INSERTION );
173
-		$this->register_node_fix( new Node_Fixes\Style_Initial_Quotes_Fix( $this->css_classes['quo'], $this->css_classes['dquo'] ),         self::HTML_INSERTION );
174
-		$this->register_node_fix( new Node_Fixes\Style_Hanging_Punctuation_Fix( $this->css_classes['push-single'], $this->css_classes['push-double'], $this->css_classes['pull-single'], $this->css_classes['pull-double'] ), self::HTML_INSERTION );
167
+		$this->register_node_fix(new Node_Fixes\Smart_Ordinal_Suffix_Fix($this->css_classes['ordinal']), self::HTML_INSERTION); // call before "style_numbers" and "smart_fractions".
168
+		$this->register_node_fix(new Node_Fixes\Smart_Exponents_Fix(), self::HTML_INSERTION); // call before "style_numbers".
169
+		$this->register_node_fix(new Node_Fixes\Smart_Fractions_Fix($this->css_classes['numerator'], $this->css_classes['denominator']), self::HTML_INSERTION); // call before "style_numbers" and after "smart_ordinal_suffix".
170
+		$this->register_node_fix(new Node_Fixes\Style_Caps_Fix($this->css_classes['caps']), self::HTML_INSERTION); // Call before "style_numbers".
171
+		$this->register_node_fix(new Node_Fixes\Style_Numbers_Fix($this->css_classes['numbers']), self::HTML_INSERTION); // Call after "smart_ordinal_suffix", "smart_exponents", "smart_fractions", and "style_caps".
172
+		$this->register_node_fix(new Node_Fixes\Style_Ampersands_Fix($this->css_classes['amp']), self::HTML_INSERTION);
173
+		$this->register_node_fix(new Node_Fixes\Style_Initial_Quotes_Fix($this->css_classes['quo'], $this->css_classes['dquo']), self::HTML_INSERTION);
174
+		$this->register_node_fix(new Node_Fixes\Style_Hanging_Punctuation_Fix($this->css_classes['push-single'], $this->css_classes['push-double'], $this->css_classes['pull-single'], $this->css_classes['pull-double']), self::HTML_INSERTION);
175 175
 
176 176
 		// Register token fixes.
177 177
 		$cache = $this->get_hyphenator_cache();
178 178
 
179
-		$this->register_token_fix( new Token_Fixes\Wrap_Hard_Hyphens_Fix() );
180
-		$this->register_token_fix( new Token_Fixes\Hyphenate_Compounds_Fix( $cache ) );
181
-		$this->register_token_fix( new Token_Fixes\Hyphenate_Fix( $cache ) );
182
-		$this->register_token_fix( new Token_Fixes\Wrap_URLs_Fix( $cache ) );
183
-		$this->register_token_fix( new Token_Fixes\Wrap_Emails_Fix() );
179
+		$this->register_token_fix(new Token_Fixes\Wrap_Hard_Hyphens_Fix());
180
+		$this->register_token_fix(new Token_Fixes\Hyphenate_Compounds_Fix($cache));
181
+		$this->register_token_fix(new Token_Fixes\Hyphenate_Fix($cache));
182
+		$this->register_token_fix(new Token_Fixes\Wrap_URLs_Fix($cache));
183
+		$this->register_token_fix(new Token_Fixes\Wrap_Emails_Fix());
184 184
 	}
185 185
 
186 186
 	/**
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return string The processed $html.
194 194
 	 */
195
-	public function process( $html, Settings $settings, $is_title = false ) {
196
-		return $this->process_textnodes( $html, [ $this, 'apply_fixes_to_html_node' ], $settings, $is_title );
195
+	public function process($html, Settings $settings, $is_title = false) {
196
+		return $this->process_textnodes($html, [$this, 'apply_fixes_to_html_node'], $settings, $is_title);
197 197
 	}
198 198
 
199 199
 	/**
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return string The processed $html.
208 208
 	 */
209
-	public function process_feed( $html, Settings $settings, $is_title = false ) {
210
-		return $this->process_textnodes( $html, [ $this, 'apply_fixes_to_feed_node' ], $settings, $is_title );
209
+	public function process_feed($html, Settings $settings, $is_title = false) {
210
+		return $this->process_textnodes($html, [$this, 'apply_fixes_to_feed_node'], $settings, $is_title);
211 211
 	}
212 212
 
213 213
 	/**
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string The processed $html.
222 222
 	 */
223
-	public function process_textnodes( $html, $fixer, Settings $settings, $is_title = false ) {
223
+	public function process_textnodes($html, $fixer, Settings $settings, $is_title = false) {
224 224
 		// Don't do aynthing if there is no valid callback.
225
-		if ( ! is_callable( $fixer ) ) {
226
-			trigger_error( 'PHP_Typography::process_textnodes called without a valid callback.', E_USER_WARNING ); // @codingStandardsIgnoreLine
225
+		if ( ! is_callable($fixer)) {
226
+			trigger_error('PHP_Typography::process_textnodes called without a valid callback.', E_USER_WARNING); // @codingStandardsIgnoreLine
227 227
 			return $html;
228 228
 		}
229 229
 
230
-		if ( isset( $settings['ignoreTags'] ) && $is_title && ( in_array( 'h1', $settings['ignoreTags'], true ) || in_array( 'h2', $settings['ignoreTags'], true ) ) ) {
230
+		if (isset($settings['ignoreTags']) && $is_title && (in_array('h1', $settings['ignoreTags'], true) || in_array('h2', $settings['ignoreTags'], true))) {
231 231
 			return $html;
232 232
 		}
233 233
 
@@ -235,41 +235,41 @@  discard block
 block discarded – undo
235 235
 		$html5_parser = $this->get_html5_parser();
236 236
 
237 237
 		// Parse the HTML.
238
-		$dom = $this->parse_html( $html5_parser, $html, $settings );
238
+		$dom = $this->parse_html($html5_parser, $html, $settings);
239 239
 
240 240
 		// Abort if there were parsing errors.
241
-		if ( empty( $dom ) ) {
241
+		if (empty($dom)) {
242 242
 			return $html;
243 243
 		}
244 244
 
245 245
 		// Query some nodes in the DOM.
246
-		$xpath = new \DOMXPath( $dom );
247
-		$body_node = $xpath->query( '/html/body' )->item( 0 );
248
-		$all_textnodes = $xpath->query( '//text()', $body_node );
249
-		$tags_to_ignore = $this->query_tags_to_ignore( $xpath, $body_node, $settings );
246
+		$xpath = new \DOMXPath($dom);
247
+		$body_node = $xpath->query('/html/body')->item(0);
248
+		$all_textnodes = $xpath->query('//text()', $body_node);
249
+		$tags_to_ignore = $this->query_tags_to_ignore($xpath, $body_node, $settings);
250 250
 
251 251
 		// Start processing.
252
-		foreach ( $all_textnodes as $textnode ) {
253
-			if ( self::arrays_intersect( DOM::get_ancestors( $textnode ), $tags_to_ignore ) ) {
252
+		foreach ($all_textnodes as $textnode) {
253
+			if (self::arrays_intersect(DOM::get_ancestors($textnode), $tags_to_ignore)) {
254 254
 				continue;
255 255
 			}
256 256
 
257 257
 			// We won't be doing anything with spaces, so we can jump ship if that is all we have.
258
-			if ( $textnode->isWhitespaceInElementContent() ) {
258
+			if ($textnode->isWhitespaceInElementContent()) {
259 259
 				continue;
260 260
 			}
261 261
 
262 262
 			// Decode all characters except < > &.
263
-			$textnode->data = htmlspecialchars( $textnode->data, ENT_NOQUOTES, 'UTF-8' ); // returns < > & to encoded HTML characters (&lt; &gt; and &amp; respectively).
263
+			$textnode->data = htmlspecialchars($textnode->data, ENT_NOQUOTES, 'UTF-8'); // returns < > & to encoded HTML characters (&lt; &gt; and &amp; respectively).
264 264
 
265 265
 			// Apply fixes.
266
-			call_user_func( $fixer, $textnode, $settings, $is_title );
266
+			call_user_func($fixer, $textnode, $settings, $is_title);
267 267
 
268 268
 			// Until now, we've only been working on a textnode: HTMLify result.
269
-			$this->replace_node_with_html( $textnode, $textnode->data );
269
+			$this->replace_node_with_html($textnode, $textnode->data);
270 270
 		}
271 271
 
272
-		return $html5_parser->saveHTML( $body_node->childNodes );
272
+		return $html5_parser->saveHTML($body_node->childNodes);
273 273
 	}
274 274
 
275 275
 	/**
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return boolean
283 283
 	 */
284
-	protected static function arrays_intersect( array $array1, array $array2 ) {
285
-		foreach ( $array1 as $value ) {
286
-			if ( isset( $array2[ spl_object_hash( $value ) ] ) ) {
284
+	protected static function arrays_intersect(array $array1, array $array2) {
285
+		foreach ($array1 as $value) {
286
+			if (isset($array2[spl_object_hash($value)])) {
287 287
 				return true;
288 288
 			}
289 289
 		}
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	 * @param Settings $settings The settings to apply.
299 299
 	 * @param bool     $is_title Optional. Default false.
300 300
 	 */
301
-	protected function apply_fixes_to_html_node( \DOMText $textnode, Settings $settings, $is_title = false ) {
302
-		foreach ( self::GROUPS as $group ) {
303
-			foreach ( $this->node_fixes[ $group ] as $fix ) {
304
-				$fix->apply( $textnode, $settings, $is_title );
301
+	protected function apply_fixes_to_html_node(\DOMText $textnode, Settings $settings, $is_title = false) {
302
+		foreach (self::GROUPS as $group) {
303
+			foreach ($this->node_fixes[$group] as $fix) {
304
+				$fix->apply($textnode, $settings, $is_title);
305 305
 			}
306 306
 		}
307 307
 	}
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 	 * @param Settings $settings The settings to apply.
314 314
 	 * @param bool     $is_title Optional. Default false.
315 315
 	 */
316
-	protected function apply_fixes_to_feed_node( \DOMText $textnode, Settings $settings, $is_title = false ) {
317
-		foreach ( self::GROUPS as $group ) {
318
-			foreach ( $this->node_fixes[ $group ] as $fix ) {
319
-				if ( $fix->feed_compatible() ) {
320
-					$fix->apply( $textnode, $settings, $is_title );
316
+	protected function apply_fixes_to_feed_node(\DOMText $textnode, Settings $settings, $is_title = false) {
317
+		foreach (self::GROUPS as $group) {
318
+			foreach ($this->node_fixes[$group] as $fix) {
319
+				if ($fix->feed_compatible()) {
320
+					$fix->apply($textnode, $settings, $is_title);
321 321
 				}
322 322
 			}
323 323
 		}
@@ -332,28 +332,28 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return \DOMDocument|null The encoding has already been set to UTF-8. Returns null if there were parsing errors.
334 334
 	 */
335
-	public function parse_html( \Masterminds\HTML5 $parser, $html, Settings $settings ) {
335
+	public function parse_html(\Masterminds\HTML5 $parser, $html, Settings $settings) {
336 336
 		// Silence some parsing errors for invalid HTML.
337
-		set_error_handler( [ $this, 'handle_parsing_errors' ] ); // @codingStandardsIgnoreLine
338
-		$xml_error_handling = libxml_use_internal_errors( true );
337
+		set_error_handler([$this, 'handle_parsing_errors']); // @codingStandardsIgnoreLine
338
+		$xml_error_handling = libxml_use_internal_errors(true);
339 339
 
340 340
 		// Do the actual parsing.
341
-		$dom = $parser->loadHTML( '<!DOCTYPE html><html><body>' . $html . '</body></html>' );
341
+		$dom = $parser->loadHTML('<!DOCTYPE html><html><body>' . $html . '</body></html>');
342 342
 		$dom->encoding = 'UTF-8';
343 343
 
344 344
 		// Restore original error handling.
345 345
 		libxml_clear_errors();
346
-		libxml_use_internal_errors( $xml_error_handling );
346
+		libxml_use_internal_errors($xml_error_handling);
347 347
 		restore_error_handler();
348 348
 
349 349
 		// Handle any parser errors.
350 350
 		$errors = $parser->getErrors();
351
-		if ( ! empty( $settings['parserErrorsHandler'] ) && ! empty( $errors ) ) {
352
-			$errors = call_user_func( $settings['parserErrorsHandler'], $errors );
351
+		if ( ! empty($settings['parserErrorsHandler']) && ! empty($errors)) {
352
+			$errors = call_user_func($settings['parserErrorsHandler'], $errors);
353 353
 		}
354 354
 
355 355
 		// Return null if there are still unhandled parsing errors.
356
-		if ( ! empty( $errors ) && ! $settings['parserErrorsIgnore'] ) {
356
+		if ( ! empty($errors) && ! $settings['parserErrorsIgnore']) {
357 357
 			$dom = null;
358 358
 		}
359 359
 
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return boolean Returns true if the error was handled, false otherwise.
373 373
 	 */
374
-	public function handle_parsing_errors( $errno, $errstr, $errfile, $errline, array $errcontext ) {
375
-		if ( ! ( error_reporting() & $errno ) ) { // @codingStandardsIgnoreLine.
374
+	public function handle_parsing_errors($errno, $errstr, $errfile, $errline, array $errcontext) {
375
+		if ( ! (error_reporting() & $errno)) { // @codingStandardsIgnoreLine.
376 376
 			return true; // not interesting.
377 377
 		}
378 378
 
379 379
 		// Ignore warnings from parser & let PHP handle the rest.
380
-		return $errno & E_USER_WARNING && 0 === substr_compare( $errfile, 'DOMTreeBuilder.php', -18 );
380
+		return $errno & E_USER_WARNING && 0 === substr_compare($errfile, 'DOMTreeBuilder.php', -18);
381 381
 	}
382 382
 
383 383
 	/**
@@ -389,25 +389,25 @@  discard block
 block discarded – undo
389 389
 	 *
390 390
 	 * @return array An array of \DOMNode (can be empty).
391 391
 	 */
392
-	public function query_tags_to_ignore( \DOMXPath $xpath, \DOMNode $initial_node, Settings $settings ) {
392
+	public function query_tags_to_ignore(\DOMXPath $xpath, \DOMNode $initial_node, Settings $settings) {
393 393
 		$elements = [];
394 394
 		$query_parts = [];
395
-		if ( ! empty( $settings['ignoreTags'] ) ) {
396
-			$query_parts[] = '//' . implode( ' | //', $settings['ignoreTags'] );
395
+		if ( ! empty($settings['ignoreTags'])) {
396
+			$query_parts[] = '//' . implode(' | //', $settings['ignoreTags']);
397 397
 		}
398
-		if ( ! empty( $settings['ignoreClasses'] ) ) {
399
-			$query_parts[] = "//*[contains(concat(' ', @class, ' '), ' " . implode( " ') or contains(concat(' ', @class, ' '), ' ", $settings['ignoreClasses'] ) . " ')]";
398
+		if ( ! empty($settings['ignoreClasses'])) {
399
+			$query_parts[] = "//*[contains(concat(' ', @class, ' '), ' " . implode(" ') or contains(concat(' ', @class, ' '), ' ", $settings['ignoreClasses']) . " ')]";
400 400
 		}
401
-		if ( ! empty( $settings['ignoreIDs'] ) ) {
402
-			$query_parts[] = '//*[@id=\'' . implode( '\' or @id=\'', $settings['ignoreIDs'] ) . '\']';
401
+		if ( ! empty($settings['ignoreIDs'])) {
402
+			$query_parts[] = '//*[@id=\'' . implode('\' or @id=\'', $settings['ignoreIDs']) . '\']';
403 403
 		}
404 404
 
405
-		if ( ! empty( $query_parts ) ) {
406
-			$ignore_query = implode( ' | ', $query_parts );
405
+		if ( ! empty($query_parts)) {
406
+			$ignore_query = implode(' | ', $query_parts);
407 407
 
408
-			$nodelist = $xpath->query( $ignore_query, $initial_node );
409
-			if ( false !== $nodelist ) {
410
-				$elements = DOM::nodelist_to_array( $nodelist );
408
+			$nodelist = $xpath->query($ignore_query, $initial_node);
409
+			if (false !== $nodelist) {
410
+				$elements = DOM::nodelist_to_array($nodelist);
411 411
 			}
412 412
 		}
413 413
 
@@ -422,25 +422,25 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @return \DOMNode|array An array of \DOMNode containing the new nodes or the old \DOMNode if the replacement failed.
424 424
 	 */
425
-	public function replace_node_with_html( \DOMNode $node, $content ) {
425
+	public function replace_node_with_html(\DOMNode $node, $content) {
426 426
 		$result = $node;
427 427
 
428 428
 		$parent = $node->parentNode;
429
-		if ( empty( $parent ) ) {
429
+		if (empty($parent)) {
430 430
 			return $node; // abort early to save cycles.
431 431
 		}
432 432
 
433
-		set_error_handler( [ $this, 'handle_parsing_errors' ] ); // @codingStandardsIgnoreLine.
433
+		set_error_handler([$this, 'handle_parsing_errors']); // @codingStandardsIgnoreLine.
434 434
 
435
-		$html_fragment = $this->get_html5_parser()->loadHTMLFragment( $content );
436
-		if ( ! empty( $html_fragment ) ) {
437
-			$imported_fragment = $node->ownerDocument->importNode( $html_fragment, true );
435
+		$html_fragment = $this->get_html5_parser()->loadHTMLFragment($content);
436
+		if ( ! empty($html_fragment)) {
437
+			$imported_fragment = $node->ownerDocument->importNode($html_fragment, true);
438 438
 
439
-			if ( ! empty( $imported_fragment ) ) {
439
+			if ( ! empty($imported_fragment)) {
440 440
 				// Save the children of the imported DOMDocumentFragment before replacement.
441
-				$children = DOM::nodelist_to_array( $imported_fragment->childNodes );
441
+				$children = DOM::nodelist_to_array($imported_fragment->childNodes);
442 442
 
443
-				if ( false !== $parent->replaceChild( $imported_fragment, $node ) ) {
443
+				if (false !== $parent->replaceChild($imported_fragment, $node)) {
444 444
 					// Success! We return the saved array of DOMNodes as
445 445
 					// $imported_fragment is just an empty DOMDocumentFragment now.
446 446
 					$result = $children;
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
 	 */
461 461
 	public function get_html5_parser() {
462 462
 		// Lazy-load HTML5 parser.
463
-		if ( ! isset( $this->html5_parser ) ) {
464
-			$this->html5_parser = new \Masterminds\HTML5( [
463
+		if ( ! isset($this->html5_parser)) {
464
+			$this->html5_parser = new \Masterminds\HTML5([
465 465
 				'disable_html_ns' => true,
466
-			] );
466
+			]);
467 467
 		}
468 468
 
469 469
 		return $this->html5_parser;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 * @return Hyphenator_Cache
476 476
 	 */
477 477
 	public function get_hyphenator_cache() {
478
-		if ( ! isset( $this->hyphenator_cache ) ) {
478
+		if ( ! isset($this->hyphenator_cache)) {
479 479
 			$this->hyphenator_cache = new Hyphenator_Cache();
480 480
 		}
481 481
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 *
488 488
 	 * @param Hyphenator_Cache $cache A hyphenator cache instance.
489 489
 	 */
490
-	public function set_hyphenator_cache( Hyphenator_Cache $cache ) {
490
+	public function set_hyphenator_cache(Hyphenator_Cache $cache) {
491 491
 		$this->hyphenator_cache = $cache;
492 492
 	}
493 493
 
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @throws \InvalidArgumentException Group is invalid.
503 503
 	 */
504
-	public function register_node_fix( Node_Fix $fix, $group ) {
505
-		switch ( $group ) {
504
+	public function register_node_fix(Node_Fix $fix, $group) {
505
+		switch ($group) {
506 506
 			case self::CHARACTERS:
507 507
 			case self::SPACING_PRE_WORDS:
508 508
 			case self::PROCESS_WORDS: // Used internally.
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 				break;
512 512
 
513 513
 			default:
514
-				throw new \InvalidArgumentException( "Invalid fixer group $group." );
514
+				throw new \InvalidArgumentException("Invalid fixer group $group.");
515 515
 		}
516 516
 
517
-		$this->node_fixes[ $group ][] = $fix;
517
+		$this->node_fixes[$group][] = $fix;
518 518
 	}
519 519
 
520 520
 	/**
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	 *
525 525
 	 * @param Token_Fix $fix Required.
526 526
 	 */
527
-	public function register_token_fix( Token_Fix $fix ) {
528
-		$this->process_words_fix->register_token_fix( $fix );
527
+	public function register_token_fix(Token_Fix $fix) {
528
+		$this->process_words_fix->register_token_fix($fix);
529 529
 	}
530 530
 
531 531
 	/**
@@ -535,27 +535,27 @@  discard block
 block discarded – undo
535 535
 	 *
536 536
 	 * @return array An array in the form ( $language_code => $language_name ).
537 537
 	 */
538
-	private static function get_language_plugin_list( $path ) {
538
+	private static function get_language_plugin_list($path) {
539 539
 		$language_name_pattern = '/"language"\s*:\s*((".+")|(\'.+\'))\s*,/';
540 540
 		$languages = [];
541
-		$handler = opendir( $path );
541
+		$handler = opendir($path);
542 542
 
543 543
 		// Read all files in directory.
544
-		while ( $file = readdir( $handler ) ) {
544
+		while ($file = readdir($handler)) {
545 545
 			// We only want the JSON files.
546
-			if ( '.json' === substr( $file, -5 ) ) {
547
-				$file_content = file_get_contents( $path . $file );
548
-				if ( preg_match( $language_name_pattern, $file_content, $matches ) ) {
549
-					$language_name = substr( $matches[1], 1, -1 );
550
-					$language_code = substr( $file, 0, -5 );
551
-					$languages[ $language_code ] = $language_name;
546
+			if ('.json' === substr($file, -5)) {
547
+				$file_content = file_get_contents($path . $file);
548
+				if (preg_match($language_name_pattern, $file_content, $matches)) {
549
+					$language_name = substr($matches[1], 1, -1);
550
+					$language_code = substr($file, 0, -5);
551
+					$languages[$language_code] = $language_name;
552 552
 				}
553 553
 			}
554 554
 		}
555
-		closedir( $handler );
555
+		closedir($handler);
556 556
 
557 557
 		// Sort translated language names according to current locale.
558
-		asort( $languages );
558
+		asort($languages);
559 559
 
560 560
 		return $languages;
561 561
 	}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @return array An array in the form of ( LANG_CODE => LANGUAGE ).
569 569
 	 */
570 570
 	public static function get_hyphenation_languages() {
571
-		return self::get_language_plugin_list( __DIR__ . '/lang/' );
571
+		return self::get_language_plugin_list(__DIR__ . '/lang/');
572 572
 	}
573 573
 
574 574
 	/**
@@ -579,6 +579,6 @@  discard block
 block discarded – undo
579 579
 	 * @return array An array in the form of ( LANG_CODE => LANGUAGE ).
580 580
 	 */
581 581
 	public static function get_diacritic_languages() {
582
-		return self::get_language_plugin_list( __DIR__ . '/diacritics/' );
582
+		return self::get_language_plugin_list(__DIR__ . '/diacritics/');
583 583
 	}
584 584
 }
Please login to merge, or discard this patch.