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 ( 18b4f0...c37768 )
by Der Mundschenk
56s queued 49s
created
src/bin/update-patterns.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,31 +31,31 @@
 block discarded – undo
31 31
 /**
32 32
  * Autoload parser classes
33 33
  */
34
-$autoload = dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php';
35
-if ( file_exists( $autoload ) ) {
34
+$autoload = dirname(dirname(__DIR__)) . '/vendor/autoload.php';
35
+if (file_exists($autoload)) {
36 36
 	require_once $autoload;
37 37
 } else {
38 38
 	// We are a dependency of another project.
39
-	require_once dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/autoload.php';
39
+	require_once dirname(dirname(dirname(dirname(__DIR__)))) . '/autoload.php';
40 40
 }
41 41
 
42
-$target_directory = dirname( __DIR__ ) . '/lang';
43
-$patterns_list    = json_decode( file_get_contents( __DIR__ . '/patterns.json' ), true );
42
+$target_directory = dirname(__DIR__) . '/lang';
43
+$patterns_list    = json_decode(file_get_contents(__DIR__ . '/patterns.json'), true);
44 44
 
45
-foreach ( $patterns_list['list'] as $pattern ) {
45
+foreach ($patterns_list['list'] as $pattern) {
46 46
 	$language = $pattern['name'];
47 47
 	$url      = $pattern['url'];
48 48
 	$filename = $pattern['short'] . '.json';
49 49
 
50
-	$converter = new Pattern_Converter( $url, $language );
50
+	$converter = new Pattern_Converter($url, $language);
51 51
 
52 52
 	echo "Parsing $language TeX file and converting it to lang/$filename ..."; // phpcs: XSS ok.
53 53
 
54 54
 	try {
55 55
 		$json_pattern = $converter->convert();
56
-		file_put_contents( $target_directory . '/' . $filename, $json_pattern );
56
+		file_put_contents($target_directory . '/' . $filename, $json_pattern);
57 57
 		echo " done\n";
58
-	} catch ( \Exception $e ) {
58
+	} catch (\Exception $e) {
59 59
 		echo " error, skipping\n";
60 60
 	}
61 61
 }
Please login to merge, or discard this patch.
src/class-settings.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @param bool $set_defaults If true, set default values for various properties. Defaults to true.
100 100
 	 */
101
-	public function __construct( $set_defaults = true ) {
102
-		$this->init( $set_defaults );
101
+	public function __construct($set_defaults = true) {
102
+		$this->init($set_defaults);
103 103
 	}
104 104
 
105 105
 	/**
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return mixed
111 111
 	 */
112
-	public function &__get( $key ) {
113
-		return $this->data[ $key ];
112
+	public function &__get($key) {
113
+		return $this->data[$key];
114 114
 	}
115 115
 
116 116
 	/**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param string $key   The settings key.
120 120
 	 * @param mixed  $value The settings value.
121 121
 	 */
122
-	public function __set( $key, $value ) {
123
-		$this->data[ $key ] = $value;
122
+	public function __set($key, $value) {
123
+		$this->data[$key] = $value;
124 124
 	}
125 125
 
126 126
 	/**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @param string $key The settings key.
130 130
 	 */
131
-	public function __isset( $key ) {
132
-		return isset( $this->data[ $key ] );
131
+	public function __isset($key) {
132
+		return isset($this->data[$key]);
133 133
 	}
134 134
 
135 135
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @param string $key The settings key.
139 139
 	 */
140
-	public function __unset( $key ) {
141
-		unset( $this->data[ $key ] );
140
+	public function __unset($key) {
141
+		unset($this->data[$key]);
142 142
 	}
143 143
 
144 144
 	/**
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @param string $offset The settings key.
148 148
 	 * @param mixed  $value  The settings value.
149 149
 	 */
150
-	public function offsetSet( $offset, $value ) {
151
-		if ( is_null( $offset ) ) {
150
+	public function offsetSet($offset, $value) {
151
+		if (is_null($offset)) {
152 152
 			$this->data[] = $value;
153 153
 		} else {
154
-			$this->data[ $offset ] = $value;
154
+			$this->data[$offset] = $value;
155 155
 		}
156 156
 	}
157 157
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param string $offset The settings key.
162 162
 	 */
163
-	public function offsetExists( $offset ) {
164
-		return isset( $this->data[ $offset ] );
163
+	public function offsetExists($offset) {
164
+		return isset($this->data[$offset]);
165 165
 	}
166 166
 
167 167
 	/**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param string $offset The settings key.
171 171
 	 */
172
-	public function offsetUnset( $offset ) {
173
-		unset( $this->data[ $offset ] );
172
+	public function offsetUnset($offset) {
173
+		unset($this->data[$offset]);
174 174
 	}
175 175
 
176 176
 	/**
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return mixed
182 182
 	 */
183
-	public function offsetGet( $offset ) {
184
-		return isset( $this->data[ $offset ] ) ? $this->data[ $offset ] : null;
183
+	public function offsetGet($offset) {
184
+		return isset($this->data[$offset]) ? $this->data[$offset] : null;
185 185
 	}
186 186
 
187 187
 	/**
@@ -235,21 +235,21 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @param bool $set_defaults If true, set default values for various properties. Defaults to true.
237 237
 	 */
238
-	private function init( $set_defaults = true ) {
239
-		$this->no_break_narrow_space = U::NO_BREAK_SPACE;  // used in unit spacing - can be changed to 8239 via set_true_no_break_narrow_space.
238
+	private function init($set_defaults = true) {
239
+		$this->no_break_narrow_space = U::NO_BREAK_SPACE; // used in unit spacing - can be changed to 8239 via set_true_no_break_narrow_space.
240 240
 
241
-		$this->dash_style = new Settings\Simple_Dashes( U::EM_DASH, U::THIN_SPACE, U::EN_DASH, U::THIN_SPACE );
241
+		$this->dash_style = new Settings\Simple_Dashes(U::EM_DASH, U::THIN_SPACE, U::EN_DASH, U::THIN_SPACE);
242 242
 
243
-		$this->primary_quote_style   = new Settings\Simple_Quotes( U::DOUBLE_QUOTE_OPEN, U::DOUBLE_QUOTE_CLOSE );
244
-		$this->secondary_quote_style = new Settings\Simple_Quotes( U::SINGLE_QUOTE_OPEN, U::SINGLE_QUOTE_CLOSE );
243
+		$this->primary_quote_style   = new Settings\Simple_Quotes(U::DOUBLE_QUOTE_OPEN, U::DOUBLE_QUOTE_CLOSE);
244
+		$this->secondary_quote_style = new Settings\Simple_Quotes(U::SINGLE_QUOTE_OPEN, U::SINGLE_QUOTE_CLOSE);
245 245
 
246 246
 		// Set up some arrays for quick HTML5 introspection.
247
-		$this->self_closing_tags = array_filter( array_keys( \Masterminds\HTML5\Elements::$html5 ), function( $tag ) {
248
-			return \Masterminds\HTML5\Elements::isA( $tag, \Masterminds\HTML5\Elements::VOID_TAG );
247
+		$this->self_closing_tags = array_filter(array_keys(\Masterminds\HTML5\Elements::$html5), function($tag) {
248
+			return \Masterminds\HTML5\Elements::isA($tag, \Masterminds\HTML5\Elements::VOID_TAG);
249 249
 		} );
250
-		$this->inappropriate_tags = [ 'iframe', 'textarea', 'button', 'select', 'optgroup', 'option', 'map', 'style', 'head', 'title', 'script', 'applet', 'object', 'param' ];
250
+		$this->inappropriate_tags = ['iframe', 'textarea', 'button', 'select', 'optgroup', 'option', 'map', 'style', 'head', 'title', 'script', 'applet', 'object', 'param'];
251 251
 
252
-		if ( $set_defaults ) {
252
+		if ($set_defaults) {
253 253
 			$this->set_defaults();
254 254
 		}
255 255
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @param bool $on Optional. Default false.
327 327
 	 */
328
-	public function set_ignore_parser_errors( $on = false ) {
328
+	public function set_ignore_parser_errors($on = false) {
329 329
 		$this->data['parserErrorsIgnore'] = $on;
330 330
 	}
331 331
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @param callable|null $handler Optional. A callable that takes an array of error strings as its parameter. Default null.
336 336
 	 */
337
-	public function set_parser_errors_handler( $handler = null ) {
338
-		if ( ! empty( $handler ) && ! is_callable( $handler ) ) {
337
+	public function set_parser_errors_handler($handler = null) {
338
+		if ( ! empty($handler) && ! is_callable($handler)) {
339 339
 			return; // Invalid handler, abort.
340 340
 		}
341 341
 
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @param bool $on Optional. Default false.
349 349
 	 */
350
-	public function set_true_no_break_narrow_space( $on = false ) {
350
+	public function set_true_no_break_narrow_space($on = false) {
351 351
 
352
-		if ( $on ) {
352
+		if ($on) {
353 353
 			$this->no_break_narrow_space = U::NO_BREAK_NARROW_SPACE;
354 354
 		} else {
355 355
 			$this->no_break_narrow_space = U::NO_BREAK_SPACE;
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @param string|array $tags A comma separated list or an array of tag names.
363 363
 	 */
364
-	public function set_tags_to_ignore( $tags = [ 'code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math' ] ) {
364
+	public function set_tags_to_ignore($tags = ['code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math']) {
365 365
 		// Ensure that we pass only lower-case tag names to XPath.
366
-		$tags = array_filter( array_map( 'strtolower', Strings::maybe_split_parameters( $tags ) ), 'ctype_alnum' );
366
+		$tags = array_filter(array_map('strtolower', Strings::maybe_split_parameters($tags)), 'ctype_alnum');
367 367
 
368 368
 		// Self closing tags shouldn't be in $tags.
369
-		$this->data['ignoreTags'] = array_unique( array_merge( array_diff( $tags, $this->self_closing_tags ), $this->inappropriate_tags ) );
369
+		$this->data['ignoreTags'] = array_unique(array_merge(array_diff($tags, $this->self_closing_tags), $this->inappropriate_tags));
370 370
 	}
371 371
 
372 372
 	/**
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @param string|array $classes A comma separated list or an array of class names.
376 376
 	 */
377
-	public function set_classes_to_ignore( $classes = [ 'vcard', 'noTypo' ] ) {
378
-		$this->data['ignoreClasses'] = Strings::maybe_split_parameters( $classes );
377
+	public function set_classes_to_ignore($classes = ['vcard', 'noTypo']) {
378
+		$this->data['ignoreClasses'] = Strings::maybe_split_parameters($classes);
379 379
 	}
380 380
 
381 381
 	/**
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @param string|array $ids A comma separated list or an array of tag names.
385 385
 	 */
386
-	public function set_ids_to_ignore( $ids = [] ) {
387
-		$this->data['ignoreIDs'] = Strings::maybe_split_parameters( $ids );
386
+	public function set_ids_to_ignore($ids = []) {
387
+		$this->data['ignoreIDs'] = Strings::maybe_split_parameters($ids);
388 388
 	}
389 389
 
390 390
 	/**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @param bool $on Optional. Default true.
394 394
 	 */
395
-	public function set_smart_quotes( $on = true ) {
395
+	public function set_smart_quotes($on = true) {
396 396
 		$this->data['smartQuotes'] = $on;
397 397
 	}
398 398
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 *
421 421
 	 * @throws \DomainException Thrown if $style constant is invalid.
422 422
 	 */
423
-	public function set_smart_quotes_primary( $style = Quote_Style::DOUBLE_CURLED ) {
424
-		$this->primary_quote_style = $this->get_quote_style( $style );
423
+	public function set_smart_quotes_primary($style = Quote_Style::DOUBLE_CURLED) {
424
+		$this->primary_quote_style = $this->get_quote_style($style);
425 425
 	}
426 426
 
427 427
 	/**
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @throws \DomainException Thrown if $style constant is invalid.
450 450
 	 */
451
-	public function set_smart_quotes_secondary( $style = Quote_Style::SINGLE_CURLED ) {
452
-		$this->secondary_quote_style = $this->get_quote_style( $style );
451
+	public function set_smart_quotes_secondary($style = Quote_Style::SINGLE_CURLED) {
452
+		$this->secondary_quote_style = $this->get_quote_style($style);
453 453
 	}
454 454
 
455 455
 	/**
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return Settings\Quotes
463 463
 	 */
464
-	protected function get_quote_style( $style ) {
465
-		return $this->get_style( $style, Settings\Quotes::class, [ Quote_Style::class, 'get_styled_quotes' ], 'quote' );
464
+	protected function get_quote_style($style) {
465
+		return $this->get_style($style, Settings\Quotes::class, [Quote_Style::class, 'get_styled_quotes'], 'quote');
466 466
 	}
467 467
 
468 468
 	/**
@@ -477,15 +477,15 @@  discard block
 block discarded – undo
477 477
 	 *
478 478
 	 * @return object An instance of $expected_class.
479 479
 	 */
480
-	protected function get_style( $style, $expected_class, callable $get_style, $description ) {
481
-		if ( $style instanceof $expected_class ) {
480
+	protected function get_style($style, $expected_class, callable $get_style, $description) {
481
+		if ($style instanceof $expected_class) {
482 482
 			$object = $style;
483 483
 		} else {
484
-			$object = $get_style( $style, $this );
484
+			$object = $get_style($style, $this);
485 485
 		}
486 486
 
487
-		if ( empty( $object ) ) {
488
-			throw new \DomainException( "Invalid $description style $style." );
487
+		if (empty($object)) {
488
+			throw new \DomainException("Invalid $description style $style.");
489 489
 		}
490 490
 
491 491
 		return $object;
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @param bool $on Optional. Default true.
498 498
 	 */
499
-	public function set_smart_dashes( $on = true ) {
499
+	public function set_smart_dashes($on = true) {
500 500
 		$this->data['smartDashes'] = $on;
501 501
 	}
502 502
 
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @throws \DomainException Thrown if $style constant is invalid.
513 513
 	 */
514
-	public function set_smart_dashes_style( $style = Dash_Style::TRADITIONAL_US ) {
515
-		$this->dash_style = $this->get_style( $style, Settings\Dashes::class, [ Dash_Style::class, 'get_styled_dashes' ], 'dash' );
514
+	public function set_smart_dashes_style($style = Dash_Style::TRADITIONAL_US) {
515
+		$this->dash_style = $this->get_style($style, Settings\Dashes::class, [Dash_Style::class, 'get_styled_dashes'], 'dash');
516 516
 	}
517 517
 
518 518
 	/**
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	 *
521 521
 	 * @param bool $on Optional. Default true.
522 522
 	 */
523
-	public function set_smart_ellipses( $on = true ) {
523
+	public function set_smart_ellipses($on = true) {
524 524
 		$this->data['smartEllipses'] = $on;
525 525
 	}
526 526
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @param bool $on Optional. Default true.
531 531
 	 */
532
-	public function set_smart_diacritics( $on = true ) {
532
+	public function set_smart_diacritics($on = true) {
533 533
 		$this->data['smartDiacritics'] = $on;
534 534
 	}
535 535
 
@@ -538,19 +538,19 @@  discard block
 block discarded – undo
538 538
 	 *
539 539
 	 * @param string $lang Has to correspond to a filename in 'diacritics'. Optional. Default 'en-US'.
540 540
 	 */
541
-	public function set_diacritic_language( $lang = 'en-US' ) {
542
-		if ( isset( $this->data['diacriticLanguage'] ) && $this->data['diacriticLanguage'] === $lang ) {
541
+	public function set_diacritic_language($lang = 'en-US') {
542
+		if (isset($this->data['diacriticLanguage']) && $this->data['diacriticLanguage'] === $lang) {
543 543
 			return;
544 544
 		}
545 545
 
546 546
 		$this->data['diacriticLanguage'] = $lang;
547
-		$language_file_name = dirname( __FILE__ ) . '/diacritics/' . $lang . '.json';
547
+		$language_file_name = dirname(__FILE__) . '/diacritics/' . $lang . '.json';
548 548
 
549
-		if ( file_exists( $language_file_name ) ) {
550
-			$diacritics_file = json_decode( file_get_contents( $language_file_name ), true );
549
+		if (file_exists($language_file_name)) {
550
+			$diacritics_file = json_decode(file_get_contents($language_file_name), true);
551 551
 			$this->data['diacriticWords'] = $diacritics_file['diacritic_words'];
552 552
 		} else {
553
-			unset( $this->data['diacriticWords'] );
553
+			unset($this->data['diacriticWords']);
554 554
 		}
555 555
 
556 556
 		$this->update_diacritics_replacement_arrays();
@@ -562,21 +562,21 @@  discard block
 block discarded – undo
562 562
 	 * @param string|array $custom_replacements An array formatted [needle=>replacement, needle=>replacement...],
563 563
 	 *                                          or a string formatted `"needle"=>"replacement","needle"=>"replacement",...
564 564
 	 */
565
-	public function set_diacritic_custom_replacements( $custom_replacements = [] ) {
566
-		if ( ! is_array( $custom_replacements ) ) {
567
-			$custom_replacements = $this->parse_diacritics_replacement_string( $custom_replacements );
565
+	public function set_diacritic_custom_replacements($custom_replacements = []) {
566
+		if ( ! is_array($custom_replacements)) {
567
+			$custom_replacements = $this->parse_diacritics_replacement_string($custom_replacements);
568 568
 		}
569 569
 
570
-		$this->data['diacriticCustomReplacements'] = Arrays::array_map_assoc( function( $key, $replacement ) {
571
-			$key         = strip_tags( trim( $key ) );
572
-			$replacement = strip_tags( trim( $replacement ) );
570
+		$this->data['diacriticCustomReplacements'] = Arrays::array_map_assoc(function($key, $replacement) {
571
+			$key         = strip_tags(trim($key));
572
+			$replacement = strip_tags(trim($replacement));
573 573
 
574
-			if ( ! empty( $key ) && ! empty( $replacement ) ) {
575
-				return [ $key, $replacement ];
574
+			if ( ! empty($key) && ! empty($replacement)) {
575
+				return [$key, $replacement];
576 576
 			} else {
577 577
 				return [];
578 578
 			}
579
-		}, $custom_replacements );
579
+		}, $custom_replacements);
580 580
 
581 581
 		$this->update_diacritics_replacement_arrays();
582 582
 	}
@@ -588,21 +588,21 @@  discard block
 block discarded – undo
588 588
 	 *
589 589
 	 * @return array
590 590
 	 */
591
-	private function parse_diacritics_replacement_string( $custom_replacements ) {
592
-		return Arrays::array_map_assoc( function( $key, $replacement ) {
591
+	private function parse_diacritics_replacement_string($custom_replacements) {
592
+		return Arrays::array_map_assoc(function($key, $replacement) {
593 593
 
594 594
 			// Account for single and double quotes in keys ...
595
-			if ( preg_match( '/("|\')((?:(?!\1).)+)(?:\1\s*=>)/', $replacement, $match ) ) {
595
+			if (preg_match('/("|\')((?:(?!\1).)+)(?:\1\s*=>)/', $replacement, $match)) {
596 596
 				$key = $match[2];
597 597
 			}
598 598
 
599 599
 			// ... and values.
600
-			if ( preg_match( '/(?:=>\s*("|\'))((?:(?!\1).)+)(?:\1)/', $replacement, $match ) ) {
600
+			if (preg_match('/(?:=>\s*("|\'))((?:(?!\1).)+)(?:\1)/', $replacement, $match)) {
601 601
 				$replacement = $match[2];
602 602
 			}
603 603
 
604
-			return [ $key, $replacement ];
605
-		}, preg_split( '/,/', $custom_replacements, -1, PREG_SPLIT_NO_EMPTY ) );
604
+			return [$key, $replacement];
605
+		}, preg_split('/,/', $custom_replacements, -1, PREG_SPLIT_NO_EMPTY));
606 606
 	}
607 607
 
608 608
 	/**
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 		$patterns = [];
616 616
 		$replacements = [];
617 617
 
618
-		if ( ! empty( $this->data['diacriticCustomReplacements'] ) ) {
619
-			$this->parse_diacritics_rules( $this->data['diacriticCustomReplacements'], $patterns, $replacements );
618
+		if ( ! empty($this->data['diacriticCustomReplacements'])) {
619
+			$this->parse_diacritics_rules($this->data['diacriticCustomReplacements'], $patterns, $replacements);
620 620
 		}
621
-		if ( ! empty( $this->data['diacriticWords'] ) ) {
622
-			$this->parse_diacritics_rules( $this->data['diacriticWords'], $patterns, $replacements );
621
+		if ( ! empty($this->data['diacriticWords'])) {
622
+			$this->parse_diacritics_rules($this->data['diacriticWords'], $patterns, $replacements);
623 623
 		}
624 624
 
625 625
 		$this->data['diacriticReplacement'] = [
@@ -635,11 +635,11 @@  discard block
 block discarded – undo
635 635
 	 * @param array $patterns         Resulting patterns. Passed by reference.
636 636
 	 * @param array $replacements     Resulting replacements. Passed by reference.
637 637
 	 */
638
-	private function parse_diacritics_rules( array $diacritics_rules, array &$patterns, array &$replacements ) {
638
+	private function parse_diacritics_rules(array $diacritics_rules, array &$patterns, array &$replacements) {
639 639
 
640
-		foreach ( $diacritics_rules as $needle => $replacement ) {
640
+		foreach ($diacritics_rules as $needle => $replacement) {
641 641
 			$patterns[] = '/\b(?<!\w[' . U::NO_BREAK_SPACE . U::SOFT_HYPHEN . '])' . $needle . '\b(?![' . U::NO_BREAK_SPACE . U::SOFT_HYPHEN . ']\w)/u';
642
-			$replacements[ $needle ] = $replacement;
642
+			$replacements[$needle] = $replacement;
643 643
 		}
644 644
 	}
645 645
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 *
649 649
 	 * @param bool $on Optional. Default true.
650 650
 	 */
651
-	public function set_smart_marks( $on = true ) {
651
+	public function set_smart_marks($on = true) {
652 652
 		$this->data['smartMarks'] = $on;
653 653
 	}
654 654
 
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	 *
658 658
 	 * @param bool $on Optional. Default true.
659 659
 	 */
660
-	public function set_smart_math( $on = true ) {
660
+	public function set_smart_math($on = true) {
661 661
 		$this->data['smartMath'] = $on;
662 662
 	}
663 663
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @param bool $on Optional. Default true.
668 668
 	 */
669
-	public function set_smart_exponents( $on = true ) {
669
+	public function set_smart_exponents($on = true) {
670 670
 		$this->data['smartExponents'] = $on;
671 671
 	}
672 672
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	 *
676 676
 	 * @param bool $on Optional. Default true.
677 677
 	 */
678
-	public function set_smart_fractions( $on = true ) {
678
+	public function set_smart_fractions($on = true) {
679 679
 		$this->data['smartFractions'] = $on;
680 680
 	}
681 681
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 *
685 685
 	 * @param bool $on Optional. Default true.
686 686
 	 */
687
-	public function set_smart_ordinal_suffix( $on = true ) {
687
+	public function set_smart_ordinal_suffix($on = true) {
688 688
 		$this->data['smartOrdinalSuffix'] = $on;
689 689
 	}
690 690
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 *
694 694
 	 * @param bool $on Optional. Default true.
695 695
 	 */
696
-	public function set_single_character_word_spacing( $on = true ) {
696
+	public function set_single_character_word_spacing($on = true) {
697 697
 		$this->data['singleCharacterWordSpacing'] = $on;
698 698
 	}
699 699
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 *
703 703
 	 * @param bool $on Optional. Default true.
704 704
 	 */
705
-	public function set_fraction_spacing( $on = true ) {
705
+	public function set_fraction_spacing($on = true) {
706 706
 		$this->data['fractionSpacing'] = $on;
707 707
 	}
708 708
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 *
712 712
 	 * @param bool $on Optional. Default true.
713 713
 	 */
714
-	public function set_unit_spacing( $on = true ) {
714
+	public function set_unit_spacing($on = true) {
715 715
 		$this->data['unitSpacing'] = $on;
716 716
 	}
717 717
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	 *
721 721
 	 * @param bool $on Optional. Default true.
722 722
 	 */
723
-	public function set_numbered_abbreviation_spacing( $on = true ) {
723
+	public function set_numbered_abbreviation_spacing($on = true) {
724 724
 		$this->data['numberedAbbreviationSpacing'] = $on;
725 725
 	}
726 726
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	 *
730 730
 	 * @param bool $on Optional. Default true.
731 731
 	 */
732
-	public function set_french_punctuation_spacing( $on = true ) {
732
+	public function set_french_punctuation_spacing($on = true) {
733 733
 		$this->data['frenchPunctuationSpacing'] = $on;
734 734
 	}
735 735
 
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 	 *
739 739
 	 * @param string|array $units A comma separated list or an array of units.
740 740
 	 */
741
-	public function set_units( $units = [] ) {
742
-		$this->data['units'] = Strings::maybe_split_parameters( $units );
743
-		$this->update_unit_pattern( $this->data['units'] );
741
+	public function set_units($units = []) {
742
+		$this->data['units'] = Strings::maybe_split_parameters($units);
743
+		$this->update_unit_pattern($this->data['units']);
744 744
 	}
745 745
 
746 746
 	/**
@@ -748,14 +748,14 @@  discard block
 block discarded – undo
748 748
 	 *
749 749
 	 * @param array $units An array of unit names.
750 750
 	 */
751
-	private function update_unit_pattern( array $units ) {
751
+	private function update_unit_pattern(array $units) {
752 752
 		// Update components & regex pattern.
753
-		foreach ( $units as $index => $unit ) {
753
+		foreach ($units as $index => $unit) {
754 754
 			// Escape special chars.
755
-			$units[ $index ] = preg_replace( '#([\[\\\^\$\.\|\?\*\+\(\)\{\}])#', '\\\\$1', $unit );
755
+			$units[$index] = preg_replace('#([\[\\\^\$\.\|\?\*\+\(\)\{\}])#', '\\\\$1', $unit);
756 756
 		}
757
-		$this->custom_units = implode( '|', $units );
758
-		$this->custom_units .= ( $this->custom_units ) ? '|' : '';
757
+		$this->custom_units = implode('|', $units);
758
+		$this->custom_units .= ($this->custom_units) ? '|' : '';
759 759
 	}
760 760
 
761 761
 	/**
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 	 *
764 764
 	 * @param bool $on Optional. Default true.
765 765
 	 */
766
-	public function set_dash_spacing( $on = true ) {
766
+	public function set_dash_spacing($on = true) {
767 767
 		$this->data['dashSpacing'] = $on;
768 768
 	}
769 769
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	 *
773 773
 	 * @param bool $on Optional. Default true.
774 774
 	 */
775
-	public function set_space_collapse( $on = true ) {
775
+	public function set_space_collapse($on = true) {
776 776
 		$this->data['spaceCollapse'] = $on;
777 777
 	}
778 778
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @param bool $on Optional. Default true.
783 783
 	 */
784
-	public function set_dewidow( $on = true ) {
784
+	public function set_dewidow($on = true) {
785 785
 		$this->data['dewidow'] = $on;
786 786
 	}
787 787
 
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 	 *
791 791
 	 * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default.
792 792
 	 */
793
-	public function set_max_dewidow_length( $length = 5 ) {
794
-		$length = ( $length > 1 ) ? $length : 5;
793
+	public function set_max_dewidow_length($length = 5) {
794
+		$length = ($length > 1) ? $length : 5;
795 795
 
796 796
 		$this->data['dewidowMaxLength'] = $length;
797 797
 	}
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
 	 *
802 802
 	 * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default.
803 803
 	 */
804
-	public function set_max_dewidow_pull( $length = 5 ) {
805
-		$length = ( $length > 1 ) ? $length : 5;
804
+	public function set_max_dewidow_pull($length = 5) {
805
+		$length = ($length > 1) ? $length : 5;
806 806
 
807 807
 		$this->data['dewidowMaxPull'] = $length;
808 808
 	}
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 	 *
813 813
 	 * @param bool $on Optional. Default true.
814 814
 	 */
815
-	public function set_wrap_hard_hyphens( $on = true ) {
815
+	public function set_wrap_hard_hyphens($on = true) {
816 816
 		$this->data['hyphenHardWrap'] = $on;
817 817
 	}
818 818
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 *
822 822
 	 * @param bool $on Optional. Default true.
823 823
 	 */
824
-	public function set_url_wrap( $on = true ) {
824
+	public function set_url_wrap($on = true) {
825 825
 		$this->data['urlWrap'] = $on;
826 826
 	}
827 827
 
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @param bool $on Optional. Default true.
832 832
 	 */
833
-	public function set_email_wrap( $on = true ) {
833
+	public function set_email_wrap($on = true) {
834 834
 		$this->data['emailWrap'] = $on;
835 835
 	}
836 836
 
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	 *
840 840
 	 * @param int $length Defaults to 5. Trying to set the value to less than 1 resets the length to the default.
841 841
 	 */
842
-	public function set_min_after_url_wrap( $length = 5 ) {
843
-		$length = ( $length > 0 ) ? $length : 5;
842
+	public function set_min_after_url_wrap($length = 5) {
843
+		$length = ($length > 0) ? $length : 5;
844 844
 
845 845
 		$this->data['urlMinAfterWrap'] = $length;
846 846
 	}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @param bool $on Optional. Default true.
852 852
 	 */
853
-	public function set_style_ampersands( $on = true ) {
853
+	public function set_style_ampersands($on = true) {
854 854
 		$this->data['styleAmpersands'] = $on;
855 855
 	}
856 856
 
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 	 *
860 860
 	 * @param bool $on Optional. Default true.
861 861
 	 */
862
-	public function set_style_caps( $on = true ) {
862
+	public function set_style_caps($on = true) {
863 863
 		$this->data['styleCaps'] = $on;
864 864
 	}
865 865
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 	 *
869 869
 	 * @param bool $on Optional. Default true.
870 870
 	 */
871
-	public function set_style_initial_quotes( $on = true ) {
871
+	public function set_style_initial_quotes($on = true) {
872 872
 		$this->data['styleInitialQuotes'] = $on;
873 873
 	}
874 874
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 	 *
878 878
 	 * @param bool $on Optional. Default true.
879 879
 	 */
880
-	public function set_style_numbers( $on = true ) {
880
+	public function set_style_numbers($on = true) {
881 881
 		$this->data['styleNumbers'] = $on;
882 882
 	}
883 883
 
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 	 *
887 887
 	 * @param bool $on Optional. Default true.
888 888
 	 */
889
-	public function set_style_hanging_punctuation( $on = true ) {
889
+	public function set_style_hanging_punctuation($on = true) {
890 890
 		$this->data['styleHangingPunctuation'] = $on;
891 891
 	}
892 892
 
@@ -895,14 +895,14 @@  discard block
 block discarded – undo
895 895
 	 *
896 896
 	 * @param string|array $tags A comma separated list or an array of tag names.
897 897
 	 */
898
-	public function set_initial_quote_tags( $tags = [ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'li', 'dd', 'dt' ] ) {
898
+	public function set_initial_quote_tags($tags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'li', 'dd', 'dt']) {
899 899
 		// Make array if handed a list of tags as a string.
900
-		if ( ! is_array( $tags ) ) {
901
-			$tags = preg_split( '/[^a-z0-9]+/', $tags, -1, PREG_SPLIT_NO_EMPTY );
900
+		if ( ! is_array($tags)) {
901
+			$tags = preg_split('/[^a-z0-9]+/', $tags, -1, PREG_SPLIT_NO_EMPTY);
902 902
 		}
903 903
 
904 904
 		// Store the tag array inverted (with the tagName as its index for faster lookup).
905
-		$this->data['initialQuoteTags'] = array_change_key_case( array_flip( $tags ), CASE_LOWER );
905
+		$this->data['initialQuoteTags'] = array_change_key_case(array_flip($tags), CASE_LOWER);
906 906
 	}
907 907
 
908 908
 	/**
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 	 *
911 911
 	 * @param bool $on Optional. Default true.
912 912
 	 */
913
-	public function set_hyphenation( $on = true ) {
913
+	public function set_hyphenation($on = true) {
914 914
 		$this->data['hyphenation'] = $on;
915 915
 	}
916 916
 
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 	 *
920 920
 	 * @param string $lang Has to correspond to a filename in 'lang'. Optional. Default 'en-US'.
921 921
 	 */
922
-	public function set_hyphenation_language( $lang = 'en-US' ) {
923
-		if ( isset( $this->data['hyphenLanguage'] ) && $this->data['hyphenLanguage'] === $lang ) {
922
+	public function set_hyphenation_language($lang = 'en-US') {
923
+		if (isset($this->data['hyphenLanguage']) && $this->data['hyphenLanguage'] === $lang) {
924 924
 			return; // Bail out, no need to do anything.
925 925
 		}
926 926
 
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 	 *
933 933
 	 * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default.
934 934
 	 */
935
-	public function set_min_length_hyphenation( $length = 5 ) {
936
-		$length = ( $length > 1 ) ? $length : 5;
935
+	public function set_min_length_hyphenation($length = 5) {
936
+		$length = ($length > 1) ? $length : 5;
937 937
 
938 938
 		$this->data['hyphenMinLength'] = $length;
939 939
 	}
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 	 *
944 944
 	 * @param int $length Defaults to 3. Trying to set the value to less than 1 resets the length to the default.
945 945
 	 */
946
-	public function set_min_before_hyphenation( $length = 3 ) {
947
-		$length = ( $length > 0 ) ? $length : 3;
946
+	public function set_min_before_hyphenation($length = 3) {
947
+		$length = ($length > 0) ? $length : 3;
948 948
 
949 949
 		$this->data['hyphenMinBefore'] = $length;
950 950
 	}
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 	 *
955 955
 	 * @param int $length Defaults to 2. Trying to set the value to less than 1 resets the length to the default.
956 956
 	 */
957
-	public function set_min_after_hyphenation( $length = 2 ) {
958
-		$length = ( $length > 0 ) ? $length : 2;
957
+	public function set_min_after_hyphenation($length = 2) {
958
+		$length = ($length > 0) ? $length : 2;
959 959
 
960 960
 		$this->data['hyphenMinAfter'] = $length;
961 961
 	}
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 	 *
966 966
 	 * @param bool $on Optional. Default true.
967 967
 	 */
968
-	public function set_hyphenate_headings( $on = true ) {
968
+	public function set_hyphenate_headings($on = true) {
969 969
 		$this->data['hyphenateTitle'] = $on;
970 970
 	}
971 971
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	 *
975 975
 	 * @param bool $on Optional. Default true.
976 976
 	 */
977
-	public function set_hyphenate_all_caps( $on = true ) {
977
+	public function set_hyphenate_all_caps($on = true) {
978 978
 		$this->data['hyphenateAllCaps'] = $on;
979 979
 	}
980 980
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 	 *
984 984
 	 * @param bool $on Optional. Default true.
985 985
 	 */
986
-	public function set_hyphenate_title_case( $on = true ) {
986
+	public function set_hyphenate_title_case($on = true) {
987 987
 		$this->data['hyphenateTitleCase'] = $on;
988 988
 	}
989 989
 
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	 *
993 993
 	 * @param bool $on Optional. Default true.
994 994
 	 */
995
-	public function set_hyphenate_compounds( $on = true ) {
995
+	public function set_hyphenate_compounds($on = true) {
996 996
 		$this->data['hyphenateCompounds'] = $on;
997 997
 	}
998 998
 
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 	 * @param string|array $exceptions An array of words with all hyphenation points marked with a hard hyphen (or a string list of such words).
1003 1003
 	 *        In the latter case, only alphanumeric characters and hyphens are recognized. The default is empty.
1004 1004
 	 */
1005
-	public function set_hyphenation_exceptions( $exceptions = [] ) {
1006
-		$this->data['hyphenationCustomExceptions'] = Strings::maybe_split_parameters( $exceptions );
1005
+	public function set_hyphenation_exceptions($exceptions = []) {
1006
+		$this->data['hyphenationCustomExceptions'] = Strings::maybe_split_parameters($exceptions);
1007 1007
 	}
1008 1008
 
1009 1009
 	/**
@@ -1013,11 +1013,11 @@  discard block
 block discarded – undo
1013 1013
 	 *
1014 1014
 	 * @return string A binary hash value for the current settings limited to $max_length.
1015 1015
 	 */
1016
-	public function get_hash( $max_length = 16 ) {
1017
-		$hash = md5( json_encode( $this->data ), true );
1016
+	public function get_hash($max_length = 16) {
1017
+		$hash = md5(json_encode($this->data), true);
1018 1018
 
1019
-		if ( $max_length < strlen( $hash ) ) {
1020
-			$hash = substr( $hash, 0, $max_length );
1019
+		if ($max_length < strlen($hash)) {
1020
+			$hash = substr($hash, 0, $max_length);
1021 1021
 		}
1022 1022
 
1023 1023
 		return $hash;
Please login to merge, or discard this patch.
src/fixes/node-fixes/class-process-words-fix.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
 	 * @param Settings $settings Required.
68 68
 	 * @param bool     $is_title Optional. Default false.
69 69
 	 */
70
-	public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) {
70
+	public function apply(\DOMText $textnode, Settings $settings, $is_title = false) {
71 71
 		// Lazy-load text parser.
72
-		$text_parser  = $this->get_text_parser();
72
+		$text_parser = $this->get_text_parser();
73 73
 		$tokens = [];
74 74
 
75 75
 		// Set up parameters for word categories.
76
-		$mixed_caps       = empty( $settings['hyphenateAllCaps'] ) ? Text_Parser::ALLOW_ALL_CAPS : Text_Parser::NO_ALL_CAPS;
77
-		$letter_caps      = empty( $settings['hyphenateAllCaps'] ) ? Text_Parser::NO_ALL_CAPS : Text_Parser::ALLOW_ALL_CAPS;
78
-		$mixed_compounds  = empty( $settings['hyphenateCompounds'] ) ? Text_Parser::ALLOW_COMPOUNDS : Text_Parser::NO_COMPOUNDS;
79
-		$letter_compounds = empty( $settings['hyphenateCompounds'] ) ? Text_Parser::NO_COMPOUNDS : Text_Parser::ALLOW_COMPOUNDS;
76
+		$mixed_caps       = empty($settings['hyphenateAllCaps']) ? Text_Parser::ALLOW_ALL_CAPS : Text_Parser::NO_ALL_CAPS;
77
+		$letter_caps      = empty($settings['hyphenateAllCaps']) ? Text_Parser::NO_ALL_CAPS : Text_Parser::ALLOW_ALL_CAPS;
78
+		$mixed_compounds  = empty($settings['hyphenateCompounds']) ? Text_Parser::ALLOW_COMPOUNDS : Text_Parser::NO_COMPOUNDS;
79
+		$letter_compounds = empty($settings['hyphenateCompounds']) ? Text_Parser::NO_COMPOUNDS : Text_Parser::ALLOW_COMPOUNDS;
80 80
 
81 81
 		// Break text down for a bit more granularity.
82
-		$text_parser->load( $textnode->data );
83
-		$tokens[ Token_Fix::MIXED_WORDS ]    = $text_parser->get_words( Text_Parser::NO_ALL_LETTERS, $mixed_caps, $mixed_compounds );  // prohibit letter-only words, allow caps, allow compounds (or not).
84
-		$tokens[ Token_Fix::COMPOUND_WORDS ] = ! empty( $settings['hyphenateCompounds'] ) ? $text_parser->get_words( Text_Parser::NO_ALL_LETTERS, $letter_caps, Text_Parser::REQUIRE_COMPOUNDS ) : [];
85
-		$tokens[ Token_Fix::WORDS ]          = $text_parser->get_words( Text_Parser::REQUIRE_ALL_LETTERS, $letter_caps, $letter_compounds ); // require letter-only words allow/prohibit caps & compounds vice-versa.
86
-		$tokens[ Token_Fix::OTHER ]          = $text_parser->get_other();
82
+		$text_parser->load($textnode->data);
83
+		$tokens[Token_Fix::MIXED_WORDS]    = $text_parser->get_words(Text_Parser::NO_ALL_LETTERS, $mixed_caps, $mixed_compounds); // prohibit letter-only words, allow caps, allow compounds (or not).
84
+		$tokens[Token_Fix::COMPOUND_WORDS] = ! empty($settings['hyphenateCompounds']) ? $text_parser->get_words(Text_Parser::NO_ALL_LETTERS, $letter_caps, Text_Parser::REQUIRE_COMPOUNDS) : [];
85
+		$tokens[Token_Fix::WORDS]          = $text_parser->get_words(Text_Parser::REQUIRE_ALL_LETTERS, $letter_caps, $letter_compounds); // require letter-only words allow/prohibit caps & compounds vice-versa.
86
+		$tokens[Token_Fix::OTHER]          = $text_parser->get_other();
87 87
 
88 88
 		// Process individual text parts here.
89
-		foreach ( $this->token_fixes as $fix ) {
89
+		foreach ($this->token_fixes as $fix) {
90 90
 			$t = $fix->target();
91 91
 
92
-			$tokens[ $t ] = $fix->apply( $tokens[ $t ], $settings, $is_title, $textnode );
92
+			$tokens[$t] = $fix->apply($tokens[$t], $settings, $is_title, $textnode);
93 93
 		}
94 94
 
95 95
 		// Apply updates to our text.
96
-		$text_parser->update( $tokens[ Token_Fix::MIXED_WORDS ] + $tokens[ Token_Fix::COMPOUND_WORDS ] + $tokens[ Token_Fix::WORDS ] + $tokens[ Token_Fix::OTHER ] );
96
+		$text_parser->update($tokens[Token_Fix::MIXED_WORDS] + $tokens[Token_Fix::COMPOUND_WORDS] + $tokens[Token_Fix::WORDS] + $tokens[Token_Fix::OTHER]);
97 97
 		$textnode->data = $text_parser->unload();
98 98
 	}
99 99
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function get_text_parser() {
106 106
 		// Lazy-load text parser.
107
-		if ( ! isset( $this->text_parser ) ) {
107
+		if ( ! isset($this->text_parser)) {
108 108
 			$this->text_parser = new Text_Parser();
109 109
 		}
110 110
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param Token_Fix $fix Required.
118 118
 	 */
119
-	public function register_token_fix( Token_Fix $fix ) {
119
+	public function register_token_fix(Token_Fix $fix) {
120 120
 		$this->token_fixes[] = $fix;
121 121
 	}
122 122
 }
Please login to merge, or discard this patch.
src/fixes/node-fixes/class-dash-spacing-fix.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -103,22 +103,22 @@  discard block
 block discarded – undo
103 103
 	 * @param Settings $settings Required.
104 104
 	 * @param bool     $is_title Optional. Default false.
105 105
 	 */
106
-	public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) {
107
-		if ( empty( $settings['dashSpacing'] ) ) {
106
+	public function apply(\DOMText $textnode, Settings $settings, $is_title = false) {
107
+		if (empty($settings['dashSpacing'])) {
108 108
 			return;
109 109
 		}
110 110
 
111 111
 		// Various special characters and regular expressions.
112 112
 		$s = $settings->dash_style();
113 113
 
114
-		if ( $s != $this->cached_dash_style ) { // WPCS: loose comparison ok.
115
-			$this->update_dash_spacing_regex( $s->parenthetical_dash(), $s->parenthetical_space(), $s->interval_dash(), $s->interval_space() );
114
+		if ($s != $this->cached_dash_style) { // WPCS: loose comparison ok.
115
+			$this->update_dash_spacing_regex($s->parenthetical_dash(), $s->parenthetical_space(), $s->interval_dash(), $s->interval_space());
116 116
 			$this->cached_dash_style = $s;
117 117
 		}
118 118
 
119
-		$textnode->data = preg_replace( self::EM_DASH_SPACING,             $this->em_dash_replacement,            $textnode->data );
120
-		$textnode->data = preg_replace( $this->parenthetical_dash_spacing, $this->parenthetical_dash_replacement, $textnode->data );
121
-		$textnode->data = preg_replace( $this->interval_dash_spacing,      $this->interval_dash_replacement,      $textnode->data );
119
+		$textnode->data = preg_replace(self::EM_DASH_SPACING, $this->em_dash_replacement, $textnode->data);
120
+		$textnode->data = preg_replace($this->parenthetical_dash_spacing, $this->parenthetical_dash_replacement, $textnode->data);
121
+		$textnode->data = preg_replace($this->interval_dash_spacing, $this->interval_dash_replacement, $textnode->data);
122 122
 	}
123 123
 
124 124
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @param string $interval            The dash character used for interval dashes.
130 130
 	 * @param string $interval_space      The space character used around interval dashes.
131 131
 	 */
132
-	private function update_dash_spacing_regex( $parenthetical, $parenthetical_space, $interval, $interval_space ) {
132
+	private function update_dash_spacing_regex($parenthetical, $parenthetical_space, $interval, $interval_space) {
133 133
 		$this->parenthetical_dash_spacing = "/
134 134
 			(?:
135 135
 				\s
Please login to merge, or discard this patch.
src/fixes/node-fixes/class-smart-quotes-fix.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param bool $feed_compatible Optional. Default false.
128 128
 	 */
129
-	public function __construct( $feed_compatible = false ) {
130
-		parent::__construct( $feed_compatible );
129
+	public function __construct($feed_compatible = false) {
130
+		parent::__construct($feed_compatible);
131 131
 
132
-		$this->apostrophe_exception_matches      = array_keys( self::APOSTROPHE_EXCEPTIONS );
133
-		$this->apostrophe_exception_replacements = array_values( self::APOSTROPHE_EXCEPTIONS );
132
+		$this->apostrophe_exception_matches      = array_keys(self::APOSTROPHE_EXCEPTIONS);
133
+		$this->apostrophe_exception_replacements = array_values(self::APOSTROPHE_EXCEPTIONS);
134 134
 	}
135 135
 
136 136
 	/**
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 	 * @param Settings $settings Required.
141 141
 	 * @param bool     $is_title Optional. Default false.
142 142
 	 */
143
-	public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) {
144
-		if ( empty( $settings['smartQuotes'] ) ) {
143
+	public function apply(\DOMText $textnode, Settings $settings, $is_title = false) {
144
+		if (empty($settings['smartQuotes'])) {
145 145
 			return;
146 146
 		}
147 147
 
148 148
 		// Need to get context of adjacent characters outside adjacent inline tags or HTML comment
149 149
 		// if we have adjacent characters add them to the text.
150
-		$previous_character = DOM::get_prev_chr( $textnode );
151
-		if ( '' !== $previous_character ) {
150
+		$previous_character = DOM::get_prev_chr($textnode);
151
+		if ('' !== $previous_character) {
152 152
 			$textnode->data = $previous_character . $textnode->data;
153 153
 		}
154
-		$next_character = DOM::get_next_chr( $textnode );
155
-		if ( '' !== $next_character ) {
154
+		$next_character = DOM::get_next_chr($textnode);
155
+		if ('' !== $next_character) {
156 156
 			$textnode->data = $textnode->data . $next_character;
157 157
 		}
158 158
 
@@ -165,63 +165,63 @@  discard block
 block discarded – undo
165 165
 		$single_open  = $single->open();
166 166
 		$single_close = $single->close();
167 167
 
168
-		if ( $double != $this->cached_primary_quotes || $single != $this->cached_secondary_quotes ) { // WPCS: loose comparison ok.
169
-			$this->update_smart_quotes_brackets( $double_open, $double_close, $single_open, $single_close );
168
+		if ($double != $this->cached_primary_quotes || $single != $this->cached_secondary_quotes) { // WPCS: loose comparison ok.
169
+			$this->update_smart_quotes_brackets($double_open, $double_close, $single_open, $single_close);
170 170
 			$this->cached_primary_quotes   = $double;
171 171
 			$this->cached_secondary_quotes = $single;
172 172
 		}
173 173
 
174 174
 		// Before primes, handle quoted numbers (and quotes ending in numbers).
175
-		$textnode->data = preg_replace( self::SINGLE_QUOTED_NUMBERS, "{$single_open}\$1{$single_close}", $textnode->data );
176
-		$textnode->data = preg_replace( self::DOUBLE_QUOTED_NUMBERS, "{$double_open}\$1{$double_close}", $textnode->data );
175
+		$textnode->data = preg_replace(self::SINGLE_QUOTED_NUMBERS, "{$single_open}\$1{$single_close}", $textnode->data);
176
+		$textnode->data = preg_replace(self::DOUBLE_QUOTED_NUMBERS, "{$double_open}\$1{$double_close}", $textnode->data);
177 177
 
178 178
 		// Guillemets.
179
-		$textnode->data = str_replace( '<<',       U::GUILLEMET_OPEN,  $textnode->data );
180
-		$textnode->data = str_replace( '&lt;&lt;', U::GUILLEMET_OPEN,  $textnode->data );
181
-		$textnode->data = str_replace( '>>',       U::GUILLEMET_CLOSE, $textnode->data );
182
-		$textnode->data = str_replace( '&gt;&gt;', U::GUILLEMET_CLOSE, $textnode->data );
179
+		$textnode->data = str_replace('<<', U::GUILLEMET_OPEN, $textnode->data);
180
+		$textnode->data = str_replace('&lt;&lt;', U::GUILLEMET_OPEN, $textnode->data);
181
+		$textnode->data = str_replace('>>', U::GUILLEMET_CLOSE, $textnode->data);
182
+		$textnode->data = str_replace('&gt;&gt;', U::GUILLEMET_CLOSE, $textnode->data);
183 183
 
184 184
 		// Primes.
185
-		$textnode->data = preg_replace( self::SINGLE_DOUBLE_PRIME,           '$1' . U::SINGLE_PRIME . '$2$3' . U::DOUBLE_PRIME, $textnode->data );
186
-		$textnode->data = preg_replace( self::SINGLE_DOUBLE_PRIME_1_GLYPH,   '$1' . U::SINGLE_PRIME . '$2$3' . U::DOUBLE_PRIME, $textnode->data );
187
-		$textnode->data = preg_replace( self::DOUBLE_PRIME,                  '$1' . U::DOUBLE_PRIME,                            $textnode->data ); // should not interfere with regular quote matching.
188
-		$textnode->data = preg_replace( self::SINGLE_PRIME,                  '$1' . U::SINGLE_PRIME,                            $textnode->data );
189
-		$textnode->data = preg_replace( self::SINGLE_PRIME_COMPOUND,         '$1' . U::SINGLE_PRIME,                            $textnode->data );
190
-		$textnode->data = preg_replace( self::DOUBLE_PRIME_COMPOUND,         '$1' . U::DOUBLE_PRIME,                            $textnode->data );
191
-		$textnode->data = preg_replace( self::DOUBLE_PRIME_1_GLYPH,          '$1' . U::DOUBLE_PRIME,                            $textnode->data ); // should not interfere with regular quote matching.
192
-		$textnode->data = preg_replace( self::DOUBLE_PRIME_1_GLYPH_COMPOUND, '$1' . U::DOUBLE_PRIME,                            $textnode->data );
185
+		$textnode->data = preg_replace(self::SINGLE_DOUBLE_PRIME, '$1' . U::SINGLE_PRIME . '$2$3' . U::DOUBLE_PRIME, $textnode->data);
186
+		$textnode->data = preg_replace(self::SINGLE_DOUBLE_PRIME_1_GLYPH, '$1' . U::SINGLE_PRIME . '$2$3' . U::DOUBLE_PRIME, $textnode->data);
187
+		$textnode->data = preg_replace(self::DOUBLE_PRIME, '$1' . U::DOUBLE_PRIME, $textnode->data); // should not interfere with regular quote matching.
188
+		$textnode->data = preg_replace(self::SINGLE_PRIME, '$1' . U::SINGLE_PRIME, $textnode->data);
189
+		$textnode->data = preg_replace(self::SINGLE_PRIME_COMPOUND, '$1' . U::SINGLE_PRIME, $textnode->data);
190
+		$textnode->data = preg_replace(self::DOUBLE_PRIME_COMPOUND, '$1' . U::DOUBLE_PRIME, $textnode->data);
191
+		$textnode->data = preg_replace(self::DOUBLE_PRIME_1_GLYPH, '$1' . U::DOUBLE_PRIME, $textnode->data); // should not interfere with regular quote matching.
192
+		$textnode->data = preg_replace(self::DOUBLE_PRIME_1_GLYPH_COMPOUND, '$1' . U::DOUBLE_PRIME, $textnode->data);
193 193
 
194 194
 		// Backticks.
195
-		$textnode->data = str_replace( '``', $double_open,  $textnode->data );
196
-		$textnode->data = str_replace( '`',  $single_open,  $textnode->data );
197
-		$textnode->data = str_replace( "''", $double_close, $textnode->data );
195
+		$textnode->data = str_replace('``', $double_open, $textnode->data);
196
+		$textnode->data = str_replace('`', $single_open, $textnode->data);
197
+		$textnode->data = str_replace("''", $double_close, $textnode->data);
198 198
 
199 199
 		// Comma quotes.
200
-		$textnode->data = str_replace( ',,', U::DOUBLE_LOW_9_QUOTE, $textnode->data );
201
-		$textnode->data = preg_replace( self::COMMA_QUOTE, U::SINGLE_LOW_9_QUOTE, $textnode->data ); // like _,¿hola?'_.
200
+		$textnode->data = str_replace(',,', U::DOUBLE_LOW_9_QUOTE, $textnode->data);
201
+		$textnode->data = preg_replace(self::COMMA_QUOTE, U::SINGLE_LOW_9_QUOTE, $textnode->data); // like _,¿hola?'_.
202 202
 
203 203
 		// Apostrophes.
204
-		$textnode->data = preg_replace( self::APOSTROPHE_WORDS,   U::APOSTROPHE,        $textnode->data );
205
-		$textnode->data = preg_replace( self::APOSTROPHE_DECADES, U::APOSTROPHE . '$1', $textnode->data ); // decades: '98.
206
-		$textnode->data = str_replace( $this->apostrophe_exception_matches, $this->apostrophe_exception_replacements, $textnode->data );
204
+		$textnode->data = preg_replace(self::APOSTROPHE_WORDS, U::APOSTROPHE, $textnode->data);
205
+		$textnode->data = preg_replace(self::APOSTROPHE_DECADES, U::APOSTROPHE . '$1', $textnode->data); // decades: '98.
206
+		$textnode->data = str_replace($this->apostrophe_exception_matches, $this->apostrophe_exception_replacements, $textnode->data);
207 207
 
208 208
 		// Quotes.
209
-		$textnode->data = str_replace( $this->brackets_matches, $this->brackets_replacements, $textnode->data );
210
-		$textnode->data = preg_replace( self::SINGLE_QUOTE_OPEN,          $single_open,  $textnode->data );
211
-		$textnode->data = preg_replace( self::SINGLE_QUOTE_CLOSE,         $single_close, $textnode->data );
212
-		$textnode->data = preg_replace( self::SINGLE_QUOTE_OPEN_SPECIAL,  $single_open,  $textnode->data ); // like _'¿hola?'_.
213
-		$textnode->data = preg_replace( self::SINGLE_QUOTE_CLOSE_SPECIAL, $single_close, $textnode->data );
214
-		$textnode->data = preg_replace( self::DOUBLE_QUOTE_OPEN,          $double_open,  $textnode->data );
215
-		$textnode->data = preg_replace( self::DOUBLE_QUOTE_CLOSE,         $double_close, $textnode->data );
216
-		$textnode->data = preg_replace( self::DOUBLE_QUOTE_OPEN_SPECIAL,  $double_open,  $textnode->data );
217
-		$textnode->data = preg_replace( self::DOUBLE_QUOTE_CLOSE_SPECIAL, $double_close, $textnode->data );
209
+		$textnode->data = str_replace($this->brackets_matches, $this->brackets_replacements, $textnode->data);
210
+		$textnode->data = preg_replace(self::SINGLE_QUOTE_OPEN, $single_open, $textnode->data);
211
+		$textnode->data = preg_replace(self::SINGLE_QUOTE_CLOSE, $single_close, $textnode->data);
212
+		$textnode->data = preg_replace(self::SINGLE_QUOTE_OPEN_SPECIAL, $single_open, $textnode->data); // like _'¿hola?'_.
213
+		$textnode->data = preg_replace(self::SINGLE_QUOTE_CLOSE_SPECIAL, $single_close, $textnode->data);
214
+		$textnode->data = preg_replace(self::DOUBLE_QUOTE_OPEN, $double_open, $textnode->data);
215
+		$textnode->data = preg_replace(self::DOUBLE_QUOTE_CLOSE, $double_close, $textnode->data);
216
+		$textnode->data = preg_replace(self::DOUBLE_QUOTE_OPEN_SPECIAL, $double_open, $textnode->data);
217
+		$textnode->data = preg_replace(self::DOUBLE_QUOTE_CLOSE_SPECIAL, $double_close, $textnode->data);
218 218
 
219 219
 		// Quote catch-alls - assume left over quotes are closing - as this is often the most complicated position, thus most likely to be missed.
220
-		$textnode->data = str_replace( "'", $single_close, $textnode->data );
221
-		$textnode->data = str_replace( '"', $double_close, $textnode->data );
220
+		$textnode->data = str_replace("'", $single_close, $textnode->data);
221
+		$textnode->data = str_replace('"', $double_close, $textnode->data);
222 222
 
223 223
 		// If we have adjacent characters remove them from the text.
224
-		$textnode->data = self::remove_adjacent_characters( $textnode->data, $previous_character, $next_character );
224
+		$textnode->data = self::remove_adjacent_characters($textnode->data, $previous_character, $next_character);
225 225
 	}
226 226
 
227 227
 	/**
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @param  string $secondary_open  Secondary quote style open.
233 233
 	 * @param  string $secondary_close Secondary quote style close.
234 234
 	 */
235
-	private function update_smart_quotes_brackets( $primary_open, $primary_close, $secondary_open, $secondary_close ) {
235
+	private function update_smart_quotes_brackets($primary_open, $primary_close, $secondary_open, $secondary_close) {
236 236
 		$brackets = [
237 237
 			// Single quotes.
238 238
 			"['"  => '[' . $secondary_open,
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			"'\"" => $secondary_close . $primary_close,
256 256
 		];
257 257
 
258
-		$this->brackets_matches      = array_keys( $brackets );
259
-		$this->brackets_replacements = array_values( $brackets );
258
+		$this->brackets_matches      = array_keys($brackets);
259
+		$this->brackets_replacements = array_values($brackets);
260 260
 	}
261 261
 }
Please login to merge, or discard this patch.
src/bin/class-file-operations.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@
 block discarded – undo
39 39
 	 *
40 40
 	 * @return int
41 41
 	 */
42
-	public static function get_http_response_code( $url ) {
42
+	public static function get_http_response_code($url) {
43 43
 
44 44
 		$curl = curl_init();
45
-		curl_setopt_array( $curl, [
45
+		curl_setopt_array($curl, [
46 46
 			CURLOPT_RETURNTRANSFER => true,
47 47
 			CURLOPT_URL            => $url,
48
-		] );
49
-		curl_exec( $curl );
50
-		$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
51
-		curl_close( $curl );
48
+		]);
49
+		curl_exec($curl);
50
+		$response_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
51
+		curl_close($curl);
52 52
 
53 53
 		return $response_code;
54 54
 	}
Please login to merge, or discard this patch.
src/bin/class-pattern-converter.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 	 * @param string $url      The TeX pattern file URL.
64 64
 	 * @param string $language A human-readable language name.
65 65
 	 */
66
-	public function __construct( $url, $language ) {
66
+	public function __construct($url, $language) {
67 67
 		$this->url      = $url;
68 68
 		$this->language = $language;
69 69
 
70
-		$this->word_characters = join( [
70
+		$this->word_characters = join([
71 71
 			"\w.'ʼ᾽ʼ᾿’",
72
-			Strings::uchr( 8205, 8204, 768, 769, 771, 772, 775, 776, 784, 803, 805, 814, 817 ),
73
-			'\p{Devanagari}' . Strings::uchr( 2385, 2386 ),
72
+			Strings::uchr(8205, 8204, 768, 769, 771, 772, 775, 776, 784, 803, 805, 814, 817),
73
+			'\p{Devanagari}' . Strings::uchr(2385, 2386),
74 74
 			'\p{Bengali}',
75 75
 			'\p{Gujarati}',
76 76
 			'\p{Gurmukhi}',
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			'\p{Malayalam}',
82 82
 			'\p{Thai}',
83 83
 			'-',
84
-		] );
84
+		]);
85 85
 	}
86 86
 
87 87
 	/**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 	 * @param string $pattern TeX hyphenation pattern.
91 91
 	 * @return string
92 92
 	 */
93
-	protected function get_segment( $pattern ) {
94
-		return preg_replace( '/[0-9]/', '', str_replace( '.', '_', $pattern ) );
93
+	protected function get_segment($pattern) {
94
+		return preg_replace('/[0-9]/', '', str_replace('.', '_', $pattern));
95 95
 	}
96 96
 
97 97
 	/**
@@ -103,31 +103,31 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string
105 105
 	 */
106
-	protected function get_sequence( $pattern ) {
107
-		$characters = Strings::mb_str_split( str_replace( '.', '_', $pattern ) );
106
+	protected function get_sequence($pattern) {
107
+		$characters = Strings::mb_str_split(str_replace('.', '_', $pattern));
108 108
 		$result = [];
109 109
 
110
-		foreach ( $characters as $index => $chr ) {
111
-			if ( ctype_digit( $chr ) ) {
110
+		foreach ($characters as $index => $chr) {
111
+			if (ctype_digit($chr)) {
112 112
 				$result[] = $chr;
113 113
 			} else {
114
-				if ( ! isset( $characters[ $index - 1 ] ) || ! ctype_digit( $characters[ $index - 1 ] ) ) {
114
+				if ( ! isset($characters[$index - 1]) || ! ctype_digit($characters[$index - 1])) {
115 115
 					$result[] = '0';
116 116
 				}
117 117
 
118
-				if ( ! isset( $characters[ $index + 1 ] ) && ! ctype_digit( $characters[ $index ] ) ) {
118
+				if ( ! isset($characters[$index + 1]) && ! ctype_digit($characters[$index])) {
119 119
 					$result[] = '0';
120 120
 				}
121 121
 			}
122 122
 		}
123 123
 
124 124
 		// Do some error checking.
125
-		$count = count( $result );
126
-		$count_seg = mb_strlen( $this->get_segment( $pattern ) );
127
-		$sequence = implode( $result );
125
+		$count = count($result);
126
+		$count_seg = mb_strlen($this->get_segment($pattern));
127
+		$sequence = implode($result);
128 128
 
129
-		if ( $count !== $count_seg + 1 ) {
130
-			throw new \RangeException( "Invalid segment length $count for pattern $pattern (result sequence $sequence)." );
129
+		if ($count !== $count_seg + 1) {
130
+			throw new \RangeException("Invalid segment length $count for pattern $pattern (result sequence $sequence).");
131 131
 		}
132 132
 
133 133
 		return $sequence;
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	protected function format_results( array $patterns, array $exceptions, array $comments ) {
149
+	protected function format_results(array $patterns, array $exceptions, array $comments) {
150 150
 		$pattern_mapping = [];
151 151
 
152
-		foreach ( $patterns as $pattern ) {
153
-			$segment = $this->get_segment( $pattern );
152
+		foreach ($patterns as $pattern) {
153
+			$segment = $this->get_segment($pattern);
154 154
 
155
-			if ( ! isset( $pattern_mapping[ $segment ] ) ) {
156
-				$pattern_mapping[ $segment ] = $this->get_sequence( $pattern );
155
+			if ( ! isset($pattern_mapping[$segment])) {
156
+				$pattern_mapping[$segment] = $this->get_sequence($pattern);
157 157
 			}
158 158
 		}
159 159
 
160 160
 		// Produce a nice exceptions mapping.
161 161
 		$json_exceptions = [];
162
-		foreach ( $exceptions as $exception ) {
163
-			$json_exceptions[ mb_strtolower( str_replace( '-', '', $exception ) ) ] = mb_strtolower( $exception );
162
+		foreach ($exceptions as $exception) {
163
+			$json_exceptions[mb_strtolower(str_replace('-', '', $exception))] = mb_strtolower($exception);
164 164
 		}
165 165
 
166 166
 		$json_results = [
167 167
 			'language'         => $this->language,
168 168
 			'source_url'       => $this->url,
169
-			'copyright'        => array_map( 'rtrim', $comments ),
169
+			'copyright'        => array_map('rtrim', $comments),
170 170
 			'exceptions'       => $json_exceptions,
171 171
 			'patterns'         => $pattern_mapping,
172 172
 		];
173 173
 
174
-		return json_encode( $json_results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
174
+		return json_encode($json_results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
175 175
 	}
176 176
 
177 177
 	/**
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return bool
190 190
 	 */
191
-	protected function match_exceptions( $line, array &$exceptions ) {
192
-		if ( preg_match( '/^\s*([\w-]+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) {
191
+	protected function match_exceptions($line, array &$exceptions) {
192
+		if (preg_match('/^\s*([\w-]+)\s*}\s*(?:%.*)?$/u', $line, $matches)) {
193 193
 			$exceptions[] = $matches[1];
194 194
 			return false;
195
-		} if ( preg_match( '/^\s*((?:[\w-]+\s*)+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) {
196
-			$this->match_exceptions( $matches[1], $exceptions );
195
+		} if (preg_match('/^\s*((?:[\w-]+\s*)+)\s*}\s*(?:%.*)?$/u', $line, $matches)) {
196
+			$this->match_exceptions($matches[1], $exceptions);
197 197
 			return false;
198
-		} elseif ( preg_match( '/^\s*}\s*(?:%.*)?$/u', $line, $matches ) ) {
198
+		} elseif (preg_match('/^\s*}\s*(?:%.*)?$/u', $line, $matches)) {
199 199
 			return false;
200
-		} elseif ( preg_match( '/^\s*([\w-]+)\s*(?:%.*)?$/u',  $line, $matches ) ) {
200
+		} elseif (preg_match('/^\s*([\w-]+)\s*(?:%.*)?$/u', $line, $matches)) {
201 201
 			$exceptions[] = $matches[1];
202
-		} elseif ( preg_match( '/^\s*((?:[\w-]+\s*)+)(?:%.*)?$/u',  $line, $matches ) ) {
202
+		} elseif (preg_match('/^\s*((?:[\w-]+\s*)+)(?:%.*)?$/u', $line, $matches)) {
203 203
 			// Sometimes there are multiple exceptions on a single line.
204
-			foreach ( self::split_at_whitespace( $matches[1] ) as $match ) {
204
+			foreach (self::split_at_whitespace($matches[1]) as $match) {
205 205
 				$exceptions[] = $match;
206 206
 			}
207
-		} elseif ( preg_match( '/^\s*(?:%.*)?$/u', $line, $matches ) ) {
207
+		} elseif (preg_match('/^\s*(?:%.*)?$/u', $line, $matches)) {
208 208
 			// Ignore comments and whitespace in exceptions.
209 209
 			return true;
210 210
 		} else {
211
-			throw new \RangeException( "Error: unknown exception line $line\n" );
211
+			throw new \RangeException("Error: unknown exception line $line\n");
212 212
 		}
213 213
 
214 214
 		return true;
@@ -224,24 +224,24 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @return bool
226 226
 	 */
227
-	protected function match_patterns( $line, array &$patterns ) {
228
-		if ( preg_match( '/^\s*([' . $this->word_characters . ']+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) {
227
+	protected function match_patterns($line, array &$patterns) {
228
+		if (preg_match('/^\s*([' . $this->word_characters . ']+)\s*}\s*(?:%.*)?$/u', $line, $matches)) {
229 229
 			$patterns[] = $matches[1];
230 230
 			return false;
231
-		} elseif ( preg_match( '/^\s*}\s*(?:%.*)?$/u', $line, $matches ) ) {
231
+		} elseif (preg_match('/^\s*}\s*(?:%.*)?$/u', $line, $matches)) {
232 232
 			return false;
233
-		} elseif ( preg_match( '/^\s*([' . $this->word_characters . ']+)\s*(?:%.*)?$/u',  $line, $matches ) ) {
233
+		} elseif (preg_match('/^\s*([' . $this->word_characters . ']+)\s*(?:%.*)?$/u', $line, $matches)) {
234 234
 			$patterns[] = $matches[1];
235
-		} elseif ( preg_match( '/^\s*((?:[' . $this->word_characters . ']+\s*)+)(?:%.*)?$/u',  $line, $matches ) ) {
235
+		} elseif (preg_match('/^\s*((?:[' . $this->word_characters . ']+\s*)+)(?:%.*)?$/u', $line, $matches)) {
236 236
 			// Sometimes there are multiple patterns on a single line.
237
-			foreach ( self::split_at_whitespace( $matches[1] ) as $match ) {
237
+			foreach (self::split_at_whitespace($matches[1]) as $match) {
238 238
 				$patterns[] = $match;
239 239
 			}
240
-		} elseif ( preg_match( '/^\s*(?:%.*)?$/u', $line, $matches ) ) {
240
+		} elseif (preg_match('/^\s*(?:%.*)?$/u', $line, $matches)) {
241 241
 			// Ignore comments and whitespace in patterns.
242 242
 			return true;
243 243
 		} else {
244
-			throw new \RangeException( 'Error: unknown pattern line ' . htmlentities( $line, ENT_NOQUOTES | ENT_HTML5 ) . "\n" );
244
+			throw new \RangeException('Error: unknown pattern line ' . htmlentities($line, ENT_NOQUOTES | ENT_HTML5) . "\n");
245 245
 		}
246 246
 
247 247
 		return true;
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return array
256 256
 	 */
257
-	private static function split_at_whitespace( $line ) {
258
-		return preg_split( '/\s+/Su', $line, -1, PREG_SPLIT_NO_EMPTY );
257
+	private static function split_at_whitespace($line) {
258
+		return preg_split('/\s+/Su', $line, -1, PREG_SPLIT_NO_EMPTY);
259 259
 	}
260 260
 
261 261
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @return string
268 268
 	 */
269 269
 	public function convert() {
270
-		if ( ! file_exists( $this->url ) && 404 === File_Operations::get_http_response_code( $this->url ) ) {
271
-			throw new \RuntimeException( "Error: unknown pattern file '{$this->url}'\n" );
270
+		if ( ! file_exists($this->url) && 404 === File_Operations::get_http_response_code($this->url)) {
271
+			throw new \RuntimeException("Error: unknown pattern file '{$this->url}'\n");
272 272
 		}
273 273
 
274 274
 		// Results.
@@ -280,36 +280,36 @@  discard block
 block discarded – undo
280 280
 		$reading_patterns   = false;
281 281
 		$reading_exceptions = false;
282 282
 
283
-		$file = new \SplFileObject( $this->url );
284
-		while ( ! $file->eof() ) {
283
+		$file = new \SplFileObject($this->url);
284
+		while ( ! $file->eof()) {
285 285
 			$line = $file->fgets();
286 286
 
287
-			if ( $reading_patterns ) {
288
-				$reading_patterns = $this->match_patterns( $line, $patterns );
289
-			} elseif ( $reading_exceptions ) {
290
-				$reading_exceptions = $this->match_exceptions( $line, $exceptions );
287
+			if ($reading_patterns) {
288
+				$reading_patterns = $this->match_patterns($line, $patterns);
289
+			} elseif ($reading_exceptions) {
290
+				$reading_exceptions = $this->match_exceptions($line, $exceptions);
291 291
 			} else {
292 292
 				// Not a pattern & not an exception.
293
-				if ( preg_match( '/^\s*%.*$/u', $line, $matches ) ) {
293
+				if (preg_match('/^\s*%.*$/u', $line, $matches)) {
294 294
 					$comments[] = $line;
295
-				} elseif ( preg_match( '/^\s*\\\patterns\s*\{\s*(.*)$/u', $line, $matches ) ) {
296
-					$reading_patterns = $this->match_patterns( $matches[1], $patterns );
297
-				} elseif ( preg_match( '/^\s*\\\hyphenation\s*{\s*(.*)$/u', $line, $matches ) ) {
298
-					$reading_exceptions = $this->match_exceptions( $matches[1], $exceptions );
299
-				} elseif ( preg_match( '/^\s*\\\endinput.*$/u', $line, $matches ) ) {
295
+				} elseif (preg_match('/^\s*\\\patterns\s*\{\s*(.*)$/u', $line, $matches)) {
296
+					$reading_patterns = $this->match_patterns($matches[1], $patterns);
297
+				} elseif (preg_match('/^\s*\\\hyphenation\s*{\s*(.*)$/u', $line, $matches)) {
298
+					$reading_exceptions = $this->match_exceptions($matches[1], $exceptions);
299
+				} elseif (preg_match('/^\s*\\\endinput.*$/u', $line, $matches)) {
300 300
 					// Ignore this line completely.
301 301
 					continue;
302
-				} elseif ( preg_match( '/^\s*\\\[\w]+.*$/u', $line, $matches ) ) {
302
+				} elseif (preg_match('/^\s*\\\[\w]+.*$/u', $line, $matches)) {
303 303
 					// Treat other commands as comments unless we are matching exceptions or patterns.
304 304
 					$comments[] = $line;
305
-				} elseif ( preg_match( '/^\s*$/u', $line, $matches ) ) {
305
+				} elseif (preg_match('/^\s*$/u', $line, $matches)) {
306 306
 					continue; // Do nothing.
307 307
 				} else {
308
-					throw new \RangeException( "Error: unknown line $line\n" );
308
+					throw new \RangeException("Error: unknown line $line\n");
309 309
 				}
310 310
 			}
311 311
 		}
312 312
 
313
-		return $this->format_results( $patterns, $exceptions, $comments );
313
+		return $this->format_results($patterns, $exceptions, $comments);
314 314
 	}
315 315
 }
Please login to merge, or discard this patch.
src/bin/update-iana.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
 /**
32 32
  * Autoload parser classes
33 33
  */
34
-$autoload = dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php';
35
-if ( file_exists( $autoload ) ) {
34
+$autoload = dirname(dirname(__DIR__)) . '/vendor/autoload.php';
35
+if (file_exists($autoload)) {
36 36
 	require_once $autoload;
37 37
 } else {
38 38
 	// We are a dependency of another project.
39
-	require_once dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/autoload.php';
39
+	require_once dirname(dirname(dirname(dirname(__DIR__)))) . '/autoload.php';
40 40
 }
41 41
 
42 42
 $source_file = 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt';
43
-$target_file = dirname( __DIR__ ) . '/IANA/tlds-alpha-by-domain.txt';
43
+$target_file = dirname(__DIR__) . '/IANA/tlds-alpha-by-domain.txt';
44 44
 
45
-if ( ! file_exists( $source_file ) ) {
46
-	if ( 404 === File_Operations::get_http_response_code( $source_file ) ) {
45
+if ( ! file_exists($source_file)) {
46
+	if (404 === File_Operations::get_http_response_code($source_file)) {
47 47
 		echo "Error: unknown TLD file '{$source_file}'\n";
48 48
 		die( -3 );
49 49
 	}
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
 
52 52
 try {
53 53
 	echo 'Trying to update IANA top-level domain list ...';
54
-	$domain_list = file_get_contents( $source_file );
54
+	$domain_list = file_get_contents($source_file);
55 55
 
56 56
 	// Ensure directory exists.
57
-	if ( ! is_dir( dirname( $target_file ) ) ) {
58
-		mkdir( dirname( $target_file ), 0755, true );
57
+	if ( ! is_dir(dirname($target_file))) {
58
+		mkdir(dirname($target_file), 0755, true);
59 59
 	}
60 60
 
61
-	$file = new \SplFileObject( $target_file, 'w' );
62
-	if ( 0 === $file->fwrite( $domain_list ) ) {
61
+	$file = new \SplFileObject($target_file, 'w');
62
+	if (0 === $file->fwrite($domain_list)) {
63 63
 		echo " error writing file\n";
64 64
 	} else {
65 65
 		echo " done\n";
66 66
 	}
67
-} catch ( \Exception $e ) {
67
+} catch (\Exception $e) {
68 68
 	echo " error\n";
69 69
 }
Please login to merge, or discard this patch.