We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param string $css_double Required. |
62 | 62 | * @param bool $feed_compatible Optional. Default false. |
63 | 63 | */ |
64 | - public function __construct( $css_single, $css_double, $feed_compatible = false ) { |
|
65 | - parent::__construct( [ $css_single, $css_double ], $feed_compatible ); |
|
64 | + public function __construct($css_single, $css_double, $feed_compatible = false) { |
|
65 | + parent::__construct([$css_single, $css_double], $feed_compatible); |
|
66 | 66 | |
67 | 67 | $this->single_quote_class = $css_single; |
68 | 68 | $this->double_quote_class = $css_double; |
@@ -75,32 +75,32 @@ discard block |
||
75 | 75 | * @param Settings $settings Required. |
76 | 76 | * @param bool $is_title Optional. Default false. |
77 | 77 | */ |
78 | - public function apply_internal( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
79 | - if ( empty( $settings['styleInitialQuotes'] ) || empty( $settings['initialQuoteTags'] ) ) { |
|
78 | + public function apply_internal(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
79 | + if (empty($settings['styleInitialQuotes']) || empty($settings['initialQuoteTags'])) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | - if ( '' === DOM::get_prev_chr( $textnode ) ) { // we have the first text in a block level element. |
|
83 | + if ('' === DOM::get_prev_chr($textnode)) { // we have the first text in a block level element. |
|
84 | 84 | |
85 | - $func = Strings::functions( $textnode->data ); |
|
86 | - $first_character = $func['substr']( $textnode->data, 0, 1 ); |
|
85 | + $func = Strings::functions($textnode->data); |
|
86 | + $first_character = $func['substr']($textnode->data, 0, 1); |
|
87 | 87 | |
88 | - if ( self::is_single_quote( $first_character ) || self::is_double_quote( $first_character ) ) { |
|
89 | - $block_level_parent = DOM::get_block_parent_name( $textnode ); |
|
88 | + if (self::is_single_quote($first_character) || self::is_double_quote($first_character)) { |
|
89 | + $block_level_parent = DOM::get_block_parent_name($textnode); |
|
90 | 90 | |
91 | - if ( $is_title ) { |
|
91 | + if ($is_title) { |
|
92 | 92 | // Assume page title is h2. |
93 | 93 | $block_level_parent = 'h2'; |
94 | 94 | } |
95 | 95 | |
96 | - if ( ! empty( $block_level_parent ) && isset( $settings['initialQuoteTags'][ $block_level_parent ] ) ) { |
|
97 | - if ( self::is_single_quote( $first_character ) ) { |
|
96 | + if ( ! empty($block_level_parent) && isset($settings['initialQuoteTags'][$block_level_parent])) { |
|
97 | + if (self::is_single_quote($first_character)) { |
|
98 | 98 | $span_class = $this->single_quote_class; |
99 | 99 | } else { |
100 | 100 | $span_class = $this->double_quote_class; |
101 | 101 | } |
102 | 102 | |
103 | - $textnode->data = '<span class="' . $span_class . '">' . $first_character . '</span>' . $func['substr']( $textnode->data, 1, $func['strlen']( $textnode->data ) ); |
|
103 | + $textnode->data = '<span class="' . $span_class . '">' . $first_character . '</span>' . $func['substr']($textnode->data, 1, $func['strlen']($textnode->data)); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return bool |
115 | 115 | */ |
116 | - private static function is_single_quote( $quote ) { |
|
117 | - return ( "'" === $quote || U::SINGLE_QUOTE_OPEN === $quote || U::SINGLE_LOW_9_QUOTE === $quote || U::SINGLE_ANGLE_QUOTE_OPEN === $quote || U::SINGLE_ANGLE_QUOTE_CLOSE === $quote || ',' === $quote ); |
|
116 | + private static function is_single_quote($quote) { |
|
117 | + return ("'" === $quote || U::SINGLE_QUOTE_OPEN === $quote || U::SINGLE_LOW_9_QUOTE === $quote || U::SINGLE_ANGLE_QUOTE_OPEN === $quote || U::SINGLE_ANGLE_QUOTE_CLOSE === $quote || ',' === $quote); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | - private static function is_double_quote( $quote ) { |
|
128 | - return ( '"' === $quote || U::DOUBLE_QUOTE_OPEN === $quote || U::GUILLEMET_OPEN === $quote || U::GUILLEMET_CLOSE === $quote || U::DOUBLE_LOW_9_QUOTE === $quote ); |
|
127 | + private static function is_double_quote($quote) { |
|
128 | + return ('"' === $quote || U::DOUBLE_QUOTE_OPEN === $quote || U::GUILLEMET_OPEN === $quote || U::GUILLEMET_CLOSE === $quote || U::DOUBLE_LOW_9_QUOTE === $quote); |
|
129 | 129 | } |
130 | 130 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param string $pull_double_class Required. |
100 | 100 | * @param bool $feed_compatible Optional. Default false. |
101 | 101 | */ |
102 | - public function __construct( $push_single_class, $push_double_class, $pull_single_class, $pull_double_class, $feed_compatible = false ) { |
|
103 | - parent::__construct( [ $pull_single_class, $pull_double_class ], $feed_compatible ); |
|
102 | + public function __construct($push_single_class, $push_double_class, $pull_single_class, $pull_double_class, $feed_compatible = false) { |
|
103 | + parent::__construct([$pull_single_class, $pull_double_class], $feed_compatible); |
|
104 | 104 | |
105 | 105 | $this->push_single_class = $push_single_class; |
106 | 106 | $this->push_double_class = $push_double_class; |
@@ -115,34 +115,34 @@ discard block |
||
115 | 115 | * @param Settings $settings Required. |
116 | 116 | * @param bool $is_title Optional. Default false. |
117 | 117 | */ |
118 | - public function apply_internal( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
119 | - if ( empty( $settings['styleHangingPunctuation'] ) ) { |
|
118 | + public function apply_internal(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
119 | + if (empty($settings['styleHangingPunctuation'])) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // We need the parent. |
124 | - $block = DOM::get_block_parent( $textnode ); |
|
125 | - $firstnode = ! empty( $block ) ? DOM::get_first_textnode( $block ) : null; |
|
124 | + $block = DOM::get_block_parent($textnode); |
|
125 | + $firstnode = ! empty($block) ? DOM::get_first_textnode($block) : null; |
|
126 | 126 | |
127 | 127 | // Need to get context of adjacent characters outside adjacent inline tags or HTML comment |
128 | 128 | // if we have adjacent characters add them to the text. |
129 | - $next_character = DOM::get_next_chr( $textnode ); |
|
130 | - if ( '' !== $next_character ) { |
|
129 | + $next_character = DOM::get_next_chr($textnode); |
|
130 | + if ('' !== $next_character) { |
|
131 | 131 | $textnode->data = $textnode->data . $next_character; |
132 | 132 | } |
133 | 133 | |
134 | - $textnode->data = preg_replace( self::STYLE_DOUBLE, '$1<span class="' . $this->push_double_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_double_class . '">$2</span>$3', $textnode->data ); |
|
135 | - $textnode->data = preg_replace( self::STYLE_SINGLE, '$1<span class="' . $this->push_single_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_single_class . '">$2</span>$3', $textnode->data ); |
|
134 | + $textnode->data = preg_replace(self::STYLE_DOUBLE, '$1<span class="' . $this->push_double_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_double_class . '">$2</span>$3', $textnode->data); |
|
135 | + $textnode->data = preg_replace(self::STYLE_SINGLE, '$1<span class="' . $this->push_single_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_single_class . '">$2</span>$3', $textnode->data); |
|
136 | 136 | |
137 | - if ( empty( $block ) || $firstnode === $textnode ) { |
|
138 | - $textnode->data = preg_replace( self::STYLE_INITIAL_DOUBLE, '<span class="' . $this->pull_double_class . '">$1</span>$2', $textnode->data ); |
|
139 | - $textnode->data = preg_replace( self::STYLE_INITIAL_SINGLE, '<span class="' . $this->pull_single_class . '">$1</span>$2', $textnode->data ); |
|
137 | + if (empty($block) || $firstnode === $textnode) { |
|
138 | + $textnode->data = preg_replace(self::STYLE_INITIAL_DOUBLE, '<span class="' . $this->pull_double_class . '">$1</span>$2', $textnode->data); |
|
139 | + $textnode->data = preg_replace(self::STYLE_INITIAL_SINGLE, '<span class="' . $this->pull_single_class . '">$1</span>$2', $textnode->data); |
|
140 | 140 | } else { |
141 | - $textnode->data = preg_replace( self::STYLE_INITIAL_DOUBLE, '<span class="' . $this->push_double_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_double_class . '">$1</span>$2', $textnode->data ); |
|
142 | - $textnode->data = preg_replace( self::STYLE_INITIAL_SINGLE, '<span class="' . $this->push_single_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_single_class . '">$1</span>$2', $textnode->data ); |
|
141 | + $textnode->data = preg_replace(self::STYLE_INITIAL_DOUBLE, '<span class="' . $this->push_double_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_double_class . '">$1</span>$2', $textnode->data); |
|
142 | + $textnode->data = preg_replace(self::STYLE_INITIAL_SINGLE, '<span class="' . $this->push_single_class . '"></span>' . U::ZERO_WIDTH_SPACE . '<span class="' . $this->pull_single_class . '">$1</span>$2', $textnode->data); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Remove any added characters. |
146 | - $textnode->data = self::remove_adjacent_characters( $textnode->data, '', $next_character ); |
|
146 | + $textnode->data = self::remove_adjacent_characters($textnode->data, '', $next_character); |
|
147 | 147 | } |
148 | 148 | } |
@@ -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 | } |
@@ -67,23 +67,23 @@ discard block |
||
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 | /* |
89 | 89 | $parsed_mixed_words = $this->wrap_hard_hyphens( $parsed_mixed_words, $settings ); |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | */ |
95 | 95 | |
96 | 96 | // Process individual text parts here. |
97 | - foreach ( $this->token_fixes as $fix ) { |
|
97 | + foreach ($this->token_fixes as $fix) { |
|
98 | 98 | $t = $fix->target(); |
99 | 99 | |
100 | - $tokens[ $t ] = $fix->apply( $tokens[ $t ], $settings, $is_title, $textnode ); |
|
100 | + $tokens[$t] = $fix->apply($tokens[$t], $settings, $is_title, $textnode); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Apply updates to our text. |
104 | - $text_parser->update( $tokens[ Token_Fix::MIXED_WORDS ] + $tokens[ Token_Fix::COMPOUND_WORDS ] + $tokens[ Token_Fix::WORDS ] + $tokens[ Token_Fix::OTHER ] ); |
|
104 | + $text_parser->update($tokens[Token_Fix::MIXED_WORDS] + $tokens[Token_Fix::COMPOUND_WORDS] + $tokens[Token_Fix::WORDS] + $tokens[Token_Fix::OTHER]); |
|
105 | 105 | $textnode->data = $text_parser->unload(); |
106 | 106 | } |
107 | 107 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function get_text_parser() { |
114 | 114 | // Lazy-load text parser. |
115 | - if ( ! isset( $this->text_parser ) ) { |
|
115 | + if ( ! isset($this->text_parser)) { |
|
116 | 116 | $this->text_parser = new Text_Parser(); |
117 | 117 | } |
118 | 118 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param Token_Fix $fix Required. |
126 | 126 | */ |
127 | - public function register_token_fix( Token_Fix $fix ) { |
|
127 | + public function register_token_fix(Token_Fix $fix) { |
|
128 | 128 | $this->token_fixes[] = $fix; |
129 | 129 | } |
130 | 130 | } |
@@ -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; |