We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * @param string|null $css_class Optional. Default null. |
55 | 55 | * @param bool $feed_compatible Optional. Default false. |
56 | 56 | */ |
57 | - public function __construct( $css_class = null, $feed_compatible = false ) { |
|
58 | - parent::__construct( $feed_compatible ); |
|
57 | + public function __construct($css_class = null, $feed_compatible = false) { |
|
58 | + parent::__construct($feed_compatible); |
|
59 | 59 | |
60 | - $ordinal_class = empty( $css_class ) ? '' : ' class="' . $css_class . '"'; |
|
60 | + $ordinal_class = empty($css_class) ? '' : ' class="' . $css_class . '"'; |
|
61 | 61 | $this->replacement = "\$1<sup{$ordinal_class}>\$2</sup>"; |
62 | 62 | } |
63 | 63 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | * @param Settings $settings Required. |
69 | 69 | * @param bool $is_title Optional. Default false. |
70 | 70 | */ |
71 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
72 | - if ( empty( $settings['smartOrdinalSuffix'] ) ) { |
|
71 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
72 | + if (empty($settings['smartOrdinalSuffix'])) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | - $textnode->data = preg_replace( "/\b(\d+)(st|nd|rd|th)\b/", $this->replacement, $textnode->data ); |
|
76 | + $textnode->data = preg_replace("/\b(\d+)(st|nd|rd|th)\b/", $this->replacement, $textnode->data); |
|
77 | 77 | } |
78 | 78 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param bool $feed_compatible Optional. Default false. |
79 | 79 | */ |
80 | - public function __construct( $feed_compatible = false ) { |
|
81 | - parent::__construct( self::REGEX, self::REPLACEMENT, self::SETTING, $feed_compatible ); |
|
80 | + public function __construct($feed_compatible = false) { |
|
81 | + parent::__construct(self::REGEX, self::REPLACEMENT, self::SETTING, $feed_compatible); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * @param Settings $settings Required. |
89 | 89 | * @param bool $is_title Optional. Default false. |
90 | 90 | */ |
91 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
91 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
92 | 92 | // Update replacement with current non-breaking narrow space. |
93 | 93 | $this->replacement = "\$1{$settings->no_break_narrow_space()}\$2"; |
94 | 94 | |
95 | 95 | // Update regex with custom units. |
96 | 96 | $this->regex = "/(\d\.?)\s({$settings->custom_units()}" . self::_STANDARD_UNITS . ')\b/x'; |
97 | 97 | |
98 | - parent::apply( $textnode, $settings, $is_title ); |
|
98 | + parent::apply($textnode, $settings, $is_title); |
|
99 | 99 | } |
100 | 100 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param Settings $settings Required. |
59 | 59 | * @param bool $is_title Optional. Default false. |
60 | 60 | */ |
61 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
62 | - if ( empty( $settings['frenchPunctuationSpacing'] ) ) { |
|
61 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
62 | + if (empty($settings['frenchPunctuationSpacing'])) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
@@ -68,25 +68,25 @@ discard block |
||
68 | 68 | |
69 | 69 | // Need to get context of adjacent characters outside adjacent inline tags or HTML comment |
70 | 70 | // if we have adjacent characters add them to the text. |
71 | - $previous_character = DOM::get_prev_chr( $textnode ); |
|
72 | - if ( '' !== $previous_character ) { |
|
71 | + $previous_character = DOM::get_prev_chr($textnode); |
|
72 | + if ('' !== $previous_character) { |
|
73 | 73 | $textnode->data = $previous_character . $textnode->data; |
74 | 74 | } |
75 | 75 | |
76 | - $textnode->data = preg_replace( self::INSERT_SPACE_BEFORE_CLOSING_QUOTE, '$1' . $no_break_narrow_space . '$3$4', $textnode->data ); |
|
77 | - $textnode->data = preg_replace( self::INSERT_NARROW_SPACE, '$1' . $no_break_narrow_space . '$3$4', $textnode->data ); |
|
78 | - $textnode->data = preg_replace( self::INSERT_FULL_SPACE, '$1' . U::NO_BREAK_SPACE . '$3$4', $textnode->data ); |
|
79 | - $textnode->data = preg_replace( self::INSERT_SPACE_BEFORE_SEMICOLON, '$1' . $no_break_narrow_space . '$3$4', $textnode->data ); |
|
76 | + $textnode->data = preg_replace(self::INSERT_SPACE_BEFORE_CLOSING_QUOTE, '$1' . $no_break_narrow_space . '$3$4', $textnode->data); |
|
77 | + $textnode->data = preg_replace(self::INSERT_NARROW_SPACE, '$1' . $no_break_narrow_space . '$3$4', $textnode->data); |
|
78 | + $textnode->data = preg_replace(self::INSERT_FULL_SPACE, '$1' . U::NO_BREAK_SPACE . '$3$4', $textnode->data); |
|
79 | + $textnode->data = preg_replace(self::INSERT_SPACE_BEFORE_SEMICOLON, '$1' . $no_break_narrow_space . '$3$4', $textnode->data); |
|
80 | 80 | |
81 | 81 | // The next rule depends on the following characters as well. |
82 | - $next_character = DOM::get_next_chr( $textnode ); |
|
83 | - if ( '' !== $next_character ) { |
|
82 | + $next_character = DOM::get_next_chr($textnode); |
|
83 | + if ('' !== $next_character) { |
|
84 | 84 | $textnode->data = $textnode->data . $next_character; |
85 | 85 | } |
86 | 86 | |
87 | - $textnode->data = preg_replace( self::INSERT_SPACE_AFTER_OPENING_QUOTE, '$1$2' . $no_break_narrow_space . '$4', $textnode->data ); |
|
87 | + $textnode->data = preg_replace(self::INSERT_SPACE_AFTER_OPENING_QUOTE, '$1$2' . $no_break_narrow_space . '$4', $textnode->data); |
|
88 | 88 | |
89 | 89 | // If we have adjacent characters remove them from the text. |
90 | - $textnode->data = self::remove_adjacent_characters( $textnode->data, $previous_character, $next_character ); |
|
90 | + $textnode->data = self::remove_adjacent_characters($textnode->data, $previous_character, $next_character); |
|
91 | 91 | } |
92 | 92 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | // Standard dashes. |
45 | 45 | const PARENTHETICAL_DOUBLE_DASH = '/(\s|' . RE::HTML_SPACES . ')--(\s|' . RE::HTML_SPACES . ')/xui'; // ' -- '. |
46 | - const PARENTHETICAL_SINGLE_DASH = '/(\s|' . RE::HTML_SPACES . ')-(\s|' . RE::HTML_SPACES . ')/xui'; // ' - '. |
|
46 | + const PARENTHETICAL_SINGLE_DASH = '/(\s|' . RE::HTML_SPACES . ')-(\s|' . RE::HTML_SPACES . ')/xui'; // ' - '. |
|
47 | 47 | const EN_DASH_WORDS = '/([\w])\-(' . U::THIN_SPACE . '|' . U::HAIR_SPACE . '|' . U::NO_BREAK_NARROW_SPACE . '|' . U::NO_BREAK_SPACE . ')/u'; |
48 | 48 | const EN_DASH_NUMBERS = "/(\b\d+(\.?))\-(\d+\\2)/"; |
49 | 49 | const EN_DASH_PHONE_NUMBERS = "/(\b\d{3})" . U::EN_DASH . "(\d{4}\b)/"; |
@@ -119,30 +119,30 @@ discard block |
||
119 | 119 | * @param Settings $settings Required. |
120 | 120 | * @param bool $is_title Optional. Default false. |
121 | 121 | */ |
122 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
123 | - if ( empty( $settings['smartDashes'] ) ) { |
|
122 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
123 | + if (empty($settings['smartDashes'])) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Various special characters and regular expressions. |
128 | 128 | $s = $settings->dash_style(); |
129 | 129 | |
130 | - $textnode->data = str_replace( '---', U::EM_DASH, $textnode->data ); |
|
131 | - $textnode->data = preg_replace( self::PARENTHETICAL_DOUBLE_DASH, "\$1{$s->parenthetical_dash()}\$2", $textnode->data ); |
|
132 | - $textnode->data = str_replace( '--', U::EN_DASH, $textnode->data ); |
|
133 | - $textnode->data = preg_replace( self::PARENTHETICAL_SINGLE_DASH, "\$1{$s->parenthetical_dash()}\$2", $textnode->data ); |
|
130 | + $textnode->data = str_replace('---', U::EM_DASH, $textnode->data); |
|
131 | + $textnode->data = preg_replace(self::PARENTHETICAL_DOUBLE_DASH, "\$1{$s->parenthetical_dash()}\$2", $textnode->data); |
|
132 | + $textnode->data = str_replace('--', U::EN_DASH, $textnode->data); |
|
133 | + $textnode->data = preg_replace(self::PARENTHETICAL_SINGLE_DASH, "\$1{$s->parenthetical_dash()}\$2", $textnode->data); |
|
134 | 134 | |
135 | - $textnode->data = preg_replace( self::EN_DASH_WORDS , '$1' . U::EN_DASH . '$2', $textnode->data ); |
|
136 | - $textnode->data = preg_replace( self::EN_DASH_NUMBERS, "\$1{$s->interval_dash()}\$3", $textnode->data ); |
|
137 | - $textnode->data = preg_replace( self::EN_DASH_PHONE_NUMBERS, '$1' . U::NO_BREAK_HYPHEN . '$2', $textnode->data ); // phone numbers. |
|
138 | - $textnode->data = str_replace( 'xn' . U::EN_DASH, 'xn--', $textnode->data ); // revert messed-up punycode. |
|
135 | + $textnode->data = preg_replace(self::EN_DASH_WORDS, '$1' . U::EN_DASH . '$2', $textnode->data); |
|
136 | + $textnode->data = preg_replace(self::EN_DASH_NUMBERS, "\$1{$s->interval_dash()}\$3", $textnode->data); |
|
137 | + $textnode->data = preg_replace(self::EN_DASH_PHONE_NUMBERS, '$1' . U::NO_BREAK_HYPHEN . '$2', $textnode->data); // phone numbers. |
|
138 | + $textnode->data = str_replace('xn' . U::EN_DASH, 'xn--', $textnode->data); // revert messed-up punycode. |
|
139 | 139 | |
140 | 140 | // Revert dates back to original formats |
141 | 141 | // YYYY-MM-DD. |
142 | - $textnode->data = preg_replace( self::DATE_YYYY_MM_DD, '$1-$2-$3', $textnode->data ); |
|
142 | + $textnode->data = preg_replace(self::DATE_YYYY_MM_DD, '$1-$2-$3', $textnode->data); |
|
143 | 143 | // MM-DD-YYYY or DD-MM-YYYY. |
144 | - $textnode->data = preg_replace( self::DATE_MM_DD_YYYY, '$1$3-$2$4-$5', $textnode->data ); |
|
144 | + $textnode->data = preg_replace(self::DATE_MM_DD_YYYY, '$1$3-$2$4-$5', $textnode->data); |
|
145 | 145 | // YYYY-MM or YYYY-DDDD next. |
146 | - $textnode->data = preg_replace( self::DATE_YYYY_MM, '$1-$2', $textnode->data ); |
|
146 | + $textnode->data = preg_replace(self::DATE_YYYY_MM, '$1-$2', $textnode->data); |
|
147 | 147 | } |
148 | 148 | } |
@@ -45,24 +45,24 @@ |
||
45 | 45 | * @param Settings $settings Required. |
46 | 46 | * @param bool $is_title Optional. Default false. |
47 | 47 | */ |
48 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
49 | - if ( empty( $settings['smartDiacritics'] ) ) { |
|
48 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
49 | + if (empty($settings['smartDiacritics'])) { |
|
50 | 50 | return; // abort. |
51 | 51 | } |
52 | 52 | |
53 | - if ( ! empty( $settings['diacriticReplacement'] ) && |
|
54 | - ! empty( $settings['diacriticReplacement']['patterns'] ) && |
|
55 | - ! empty( $settings['diacriticReplacement']['replacements'] ) ) { |
|
53 | + if ( ! empty($settings['diacriticReplacement']) && |
|
54 | + ! empty($settings['diacriticReplacement']['patterns']) && |
|
55 | + ! empty($settings['diacriticReplacement']['replacements'])) { |
|
56 | 56 | |
57 | 57 | // Uses "word" => "replacement" pairs from an array to make fast preg_* replacements. |
58 | 58 | $replacements = $settings['diacriticReplacement']['replacements']; |
59 | - $textnode->data = preg_replace_callback( $settings['diacriticReplacement']['patterns'], function( $match ) use ( $replacements ) { |
|
60 | - if ( isset( $replacements[ $match[0] ] ) ) { |
|
61 | - return $replacements[ $match[0] ]; |
|
59 | + $textnode->data = preg_replace_callback($settings['diacriticReplacement']['patterns'], function($match) use ($replacements) { |
|
60 | + if (isset($replacements[$match[0]])) { |
|
61 | + return $replacements[$match[0]]; |
|
62 | 62 | } else { |
63 | 63 | return $match[0]; |
64 | 64 | } |
65 | - }, $textnode->data ); |
|
65 | + }, $textnode->data); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param bool $feed_compatible Optional. Default false. |
53 | 53 | */ |
54 | - public function __construct( $feed_compatible = false ) { |
|
54 | + public function __construct($feed_compatible = false) { |
|
55 | 55 | $this->feed_compatible = $feed_compatible; |
56 | 56 | } |
57 | 57 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - abstract public function apply( \DOMText $textnode, Settings $settings, $is_title = false ); |
|
67 | + abstract public function apply(\DOMText $textnode, Settings $settings, $is_title = false); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Determines whether the fix should be applied to (RSS) feeds. |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return string The string without `$prev_char` and `$next_char`. |
88 | 88 | */ |
89 | - protected static function remove_adjacent_characters( $string, $prev_char = '', $next_char = '' ) { |
|
89 | + protected static function remove_adjacent_characters($string, $prev_char = '', $next_char = '') { |
|
90 | 90 | // Use the most efficient string functions. |
91 | - $func = Strings::functions( $string ); |
|
91 | + $func = Strings::functions($string); |
|
92 | 92 | |
93 | 93 | // Remove previous character. |
94 | - if ( '' !== $prev_char ) { |
|
95 | - $string = $func['substr']( $string, 1, $func['strlen']( $string ) ); |
|
94 | + if ('' !== $prev_char) { |
|
95 | + $string = $func['substr']($string, 1, $func['strlen']($string)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Remove next character. |
99 | - if ( '' !== $next_char ) { |
|
100 | - $string = $func['substr']( $string, 0, $func['strlen']( $string ) - 1 ); |
|
99 | + if ('' !== $next_char) { |
|
100 | + $string = $func['substr']($string, 0, $func['strlen']($string) - 1); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | return $string; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * @param string $css_class HTML class used in markup. |
54 | 54 | * @param bool $feed_compatible Optional. Default false. |
55 | 55 | */ |
56 | - public function __construct( $css_class, $feed_compatible = false ) { |
|
57 | - parent::__construct( self::REGEX, self::SETTINGS_SWITCH, $css_class, $feed_compatible ); |
|
56 | + public function __construct($css_class, $feed_compatible = false) { |
|
57 | + parent::__construct(self::REGEX, self::SETTINGS_SWITCH, $css_class, $feed_compatible); |
|
58 | 58 | } |
59 | 59 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param string $settings_switch On/off switch for fix. |
70 | 70 | * @param bool $feed_compatible Optional. Default false. |
71 | 71 | */ |
72 | - public function __construct( $regex, $replacement, $settings_switch, $feed_compatible = false ) { |
|
73 | - parent::__construct( $feed_compatible ); |
|
72 | + public function __construct($regex, $replacement, $settings_switch, $feed_compatible = false) { |
|
73 | + parent::__construct($feed_compatible); |
|
74 | 74 | |
75 | 75 | $this->regex = $regex; |
76 | 76 | $this->settings_switch = $settings_switch; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | * @param Settings $settings Required. |
85 | 85 | * @param bool $is_title Optional. Default false. |
86 | 86 | */ |
87 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
88 | - if ( empty( $settings[ $this->settings_switch ] ) ) { |
|
87 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
88 | + if (empty($settings[$this->settings_switch])) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $textnode->data = preg_replace( $this->regex, $this->replacement, $textnode->data ); |
|
92 | + $textnode->data = preg_replace($this->regex, $this->replacement, $textnode->data); |
|
93 | 93 | } |
94 | 94 | } |
@@ -49,22 +49,22 @@ |
||
49 | 49 | * @param Settings $settings Required. |
50 | 50 | * @param bool $is_title Optional. Default false. |
51 | 51 | */ |
52 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
53 | - if ( empty( $settings['smartMarks'] ) ) { |
|
52 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
53 | + if (empty($settings['smartMarks'])) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Escape usage of "501(c)(1...29)" (US non-profit). |
58 | - $textnode->data = preg_replace( self::ESCAPE_501C, '$1' . RE::ESCAPE_MARKER . '$2' . RE::ESCAPE_MARKER . '$3', $textnode->data ); |
|
58 | + $textnode->data = preg_replace(self::ESCAPE_501C, '$1' . RE::ESCAPE_MARKER . '$2' . RE::ESCAPE_MARKER . '$3', $textnode->data); |
|
59 | 59 | |
60 | 60 | // Replace marks. |
61 | - $textnode->data = str_replace( [ '(c)', '(C)' ], U::COPYRIGHT, $textnode->data ); |
|
62 | - $textnode->data = str_replace( [ '(r)', '(R)' ], U::REGISTERED_MARK, $textnode->data ); |
|
63 | - $textnode->data = str_replace( [ '(p)', '(P)' ], U::SOUND_COPY_MARK, $textnode->data ); |
|
64 | - $textnode->data = str_replace( [ '(sm)', '(SM)' ], U::SERVICE_MARK, $textnode->data ); |
|
65 | - $textnode->data = str_replace( [ '(tm)', '(TM)' ], U::TRADE_MARK, $textnode->data ); |
|
61 | + $textnode->data = str_replace(['(c)', '(C)'], U::COPYRIGHT, $textnode->data); |
|
62 | + $textnode->data = str_replace(['(r)', '(R)'], U::REGISTERED_MARK, $textnode->data); |
|
63 | + $textnode->data = str_replace(['(p)', '(P)'], U::SOUND_COPY_MARK, $textnode->data); |
|
64 | + $textnode->data = str_replace(['(sm)', '(SM)'], U::SERVICE_MARK, $textnode->data); |
|
65 | + $textnode->data = str_replace(['(tm)', '(TM)'], U::TRADE_MARK, $textnode->data); |
|
66 | 66 | |
67 | 67 | // Un-escape escaped sequences. |
68 | - $textnode->data = str_replace( RE::ESCAPE_MARKER, '', $textnode->data ); |
|
68 | + $textnode->data = str_replace(RE::ESCAPE_MARKER, '', $textnode->data); |
|
69 | 69 | } |
70 | 70 | } |