We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -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 | } |
@@ -40,7 +40,6 @@ |
||
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * The setting string used to enable/disable the fix (e.g. 'styleAmpersands'). |
| 43 | - |
|
| 44 | 43 | * @var string |
| 45 | 44 | */ |
| 46 | 45 | protected $settings_switch; |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | * @param string $css_class HTML class used in markup. |
| 70 | 70 | * @param bool $feed_compatible Optional. Default false. |
| 71 | 71 | */ |
| 72 | - public function __construct( $regex, $settings_switch, $css_class, $feed_compatible = false ) { |
|
| 73 | - parent::__construct( $css_class, $feed_compatible ); |
|
| 72 | + public function __construct($regex, $settings_switch, $css_class, $feed_compatible = false) { |
|
| 73 | + parent::__construct($css_class, $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_internal( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
| 88 | - if ( empty( $settings[ $this->settings_switch ] ) ) { |
|
| 87 | + public function apply_internal(\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, '<span class="' . $this->css_class . '">$1</span>', $textnode->data ); |
|
| 92 | + $textnode->data = preg_replace($this->regex, '<span class="' . $this->css_class . '">$1</span>', $textnode->data); |
|
| 93 | 93 | } |
| 94 | 94 | } |
@@ -103,22 +103,22 @@ discard block |
||
| 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 ) { |
|
| 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) { |
|
| 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 |
||
| 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 |
@@ -53,23 +53,23 @@ |
||
| 53 | 53 | * @param Settings $settings Required. |
| 54 | 54 | * @param bool $is_title Optional. Default false. |
| 55 | 55 | */ |
| 56 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
| 57 | - if ( empty( $settings['spaceCollapse'] ) ) { |
|
| 56 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
| 57 | + if (empty($settings['spaceCollapse'])) { |
|
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Normal spacing. |
| 62 | - $textnode->data = preg_replace( self::COLLAPSE_NORMAL_SPACES, ' ', $textnode->data ); |
|
| 62 | + $textnode->data = preg_replace(self::COLLAPSE_NORMAL_SPACES, ' ', $textnode->data); |
|
| 63 | 63 | |
| 64 | 64 | // Non-breakable space get's priority. If non-breakable space exists in a string of spaces, it collapses to a single non-breakable space. |
| 65 | - $textnode->data = preg_replace( self::COLLAPSE_NON_BREAKABLE_SPACES, U::NO_BREAK_SPACE, $textnode->data ); |
|
| 65 | + $textnode->data = preg_replace(self::COLLAPSE_NON_BREAKABLE_SPACES, U::NO_BREAK_SPACE, $textnode->data); |
|
| 66 | 66 | |
| 67 | 67 | // For any other spaceing, replace with the first occurance of an unusual space character. |
| 68 | - $textnode->data = preg_replace( self::COLLAPSE_OTHER_SPACES, '$1', $textnode->data ); |
|
| 68 | + $textnode->data = preg_replace(self::COLLAPSE_OTHER_SPACES, '$1', $textnode->data); |
|
| 69 | 69 | |
| 70 | 70 | // Remove all spacing at beginning of block level elements. |
| 71 | - if ( '' === DOM::get_prev_chr( $textnode ) ) { // we have the first text in a block level element. |
|
| 72 | - $textnode->data = preg_replace( self::COLLAPSE_SPACES_AT_START_OF_BLOCK, '', $textnode->data ); |
|
| 71 | + if ('' === DOM::get_prev_chr($textnode)) { // we have the first text in a block level element. |
|
| 72 | + $textnode->data = preg_replace(self::COLLAPSE_SPACES_AT_START_OF_BLOCK, '', $textnode->data); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -46,12 +46,12 @@ |
||
| 46 | 46 | * @param Settings $settings Required. |
| 47 | 47 | * @param bool $is_title Optional. Default false. |
| 48 | 48 | */ |
| 49 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
| 50 | - if ( empty( $settings['smartEllipses'] ) ) { |
|
| 49 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
| 50 | + if (empty($settings['smartEllipses'])) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $textnode->data = str_replace( [ '....', '. . . .' ], '.' . U::ELLIPSIS, $textnode->data ); |
|
| 55 | - $textnode->data = str_replace( [ '...', '. . .' ], U::ELLIPSIS, $textnode->data ); |
|
| 54 | + $textnode->data = str_replace(['....', '. . . .'], '.' . U::ELLIPSIS, $textnode->data); |
|
| 55 | + $textnode->data = str_replace(['...', '. . .'], U::ELLIPSIS, $textnode->data); |
|
| 56 | 56 | } |
| 57 | 57 | } |
@@ -126,11 +126,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 ) { |
|
| 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) { |
|
| 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( '<<', U::GUILLEMET_OPEN, $textnode->data ); |
|
| 181 | - $textnode->data = str_replace( '>>', U::GUILLEMET_CLOSE, $textnode->data ); |
|
| 182 | - $textnode->data = str_replace( '>>', U::GUILLEMET_CLOSE, $textnode->data ); |
|
| 179 | + $textnode->data = str_replace('<<', U::GUILLEMET_OPEN, $textnode->data); |
|
| 180 | + $textnode->data = str_replace('<<', U::GUILLEMET_OPEN, $textnode->data); |
|
| 181 | + $textnode->data = str_replace('>>', U::GUILLEMET_CLOSE, $textnode->data); |
|
| 182 | + $textnode->data = str_replace('>>', 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 |
||
| 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 |
||
| 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 | } |
@@ -73,40 +73,40 @@ discard block |
||
| 73 | 73 | * @param Settings $settings Required. |
| 74 | 74 | * @param bool $is_title Optional. Default false. |
| 75 | 75 | */ |
| 76 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
| 76 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
| 77 | 77 | // Intervening inline tags may interfere with widow identification, but that is a sacrifice of using the parser. |
| 78 | 78 | // Intervening tags will only interfere if they separate the widow from previous or preceding whitespace. |
| 79 | - if ( empty( $settings['dewidow'] ) || empty( $settings['dewidowMaxPull'] ) || empty( $settings['dewidowMaxLength'] ) ) { |
|
| 79 | + if (empty($settings['dewidow']) || empty($settings['dewidowMaxPull']) || empty($settings['dewidowMaxLength'])) { |
|
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( '' === DOM::get_next_chr( $textnode ) ) { |
|
| 83 | + if ('' === DOM::get_next_chr($textnode)) { |
|
| 84 | 84 | // We have the last type "text" child of a block level element. |
| 85 | - $textnode->data = preg_replace_callback( self::REGEX, function( array $widow ) use ( $settings ) { |
|
| 86 | - $func = Strings::functions( $widow[0] ); |
|
| 85 | + $textnode->data = preg_replace_callback(self::REGEX, function(array $widow) use ($settings) { |
|
| 86 | + $func = Strings::functions($widow[0]); |
|
| 87 | 87 | |
| 88 | 88 | // If we are here, we know that widows are being protected in some fashion |
| 89 | 89 | // with that, we will assert that widows should never be hyphenated or wrapped |
| 90 | 90 | // as such, we will strip soft hyphens and zero-width-spaces. |
| 91 | - $widow['widow'] = str_replace( U::ZERO_WIDTH_SPACE, '', $widow['widow'] ); // TODO: check if this can match here. |
|
| 92 | - $widow['widow'] = str_replace( U::SOFT_HYPHEN, '', $widow['widow'] ); // TODO: check if this can match here. |
|
| 93 | - $widow['trailing'] = preg_replace( "/\s+/{$func['u']}", U::NO_BREAK_SPACE, $widow['trailing'] ); |
|
| 94 | - $widow['trailing'] = str_replace( U::ZERO_WIDTH_SPACE, '', $widow['trailing'] ); |
|
| 95 | - $widow['trailing'] = str_replace( U::SOFT_HYPHEN, '', $widow['trailing'] ); |
|
| 91 | + $widow['widow'] = str_replace(U::ZERO_WIDTH_SPACE, '', $widow['widow']); // TODO: check if this can match here. |
|
| 92 | + $widow['widow'] = str_replace(U::SOFT_HYPHEN, '', $widow['widow']); // TODO: check if this can match here. |
|
| 93 | + $widow['trailing'] = preg_replace("/\s+/{$func['u']}", U::NO_BREAK_SPACE, $widow['trailing']); |
|
| 94 | + $widow['trailing'] = str_replace(U::ZERO_WIDTH_SPACE, '', $widow['trailing']); |
|
| 95 | + $widow['trailing'] = str_replace(U::SOFT_HYPHEN, '', $widow['trailing']); |
|
| 96 | 96 | |
| 97 | 97 | // Eject if widows neighbor is proceeded by a no break space (the pulled text would be too long). |
| 98 | - if ( '' === $widow['space_before'] || strstr( U::NO_BREAK_SPACE, $widow['space_before'] ) ) { |
|
| 98 | + if ('' === $widow['space_before'] || strstr(U::NO_BREAK_SPACE, $widow['space_before'])) { |
|
| 99 | 99 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Eject if widows neighbor length exceeds the max allowed or widow length exceeds max allowed. |
| 103 | - if ( $func['strlen']( $widow['neighbor'] ) > $settings['dewidowMaxPull'] || |
|
| 104 | - $func['strlen']( $widow['widow'] ) > $settings['dewidowMaxLength'] ) { |
|
| 103 | + if ($func['strlen']($widow['neighbor']) > $settings['dewidowMaxPull'] || |
|
| 104 | + $func['strlen']($widow['widow']) > $settings['dewidowMaxLength']) { |
|
| 105 | 105 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Never replace thin and hair spaces with . |
| 109 | - switch ( $widow['space_between'] ) { |
|
| 109 | + switch ($widow['space_between']) { |
|
| 110 | 110 | case U::THIN_SPACE: |
| 111 | 111 | case U::HAIR_SPACE: |
| 112 | 112 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | // Let's protect some widows! |
| 116 | 116 | return $widow['space_before'] . $widow['neighbor'] . U::NO_BREAK_SPACE . $widow['widow'] . $widow['trailing']; |
| 117 | - }, $textnode->data ); |
|
| 117 | + }, $textnode->data); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |