We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return string A list of top-level domains concatenated with '|'. |
| 105 | 105 | */ |
| 106 | - private static function get_top_level_domains_from_file( $path ) { |
|
| 106 | + private static function get_top_level_domains_from_file($path) { |
|
| 107 | 107 | $domains = []; |
| 108 | 108 | |
| 109 | - if ( file_exists( $path ) ) { |
|
| 110 | - $file = new \SplFileObject( $path ); |
|
| 109 | + if (file_exists($path)) { |
|
| 110 | + $file = new \SplFileObject($path); |
|
| 111 | 111 | |
| 112 | - while ( ! $file->eof() ) { |
|
| 112 | + while ( ! $file->eof()) { |
|
| 113 | 113 | $line = $file->fgets(); |
| 114 | 114 | |
| 115 | - if ( preg_match( '#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches ) ) { |
|
| 116 | - $domains[] = strtolower( $matches[0] ); |
|
| 115 | + if (preg_match('#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches)) { |
|
| 116 | + $domains[] = strtolower($matches[0]); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( count( $domains ) > 0 ) { |
|
| 122 | - return implode( '|', $domains ); |
|
| 121 | + if (count($domains) > 0) { |
|
| 122 | + return implode('|', $domains); |
|
| 123 | 123 | } else { |
| 124 | 124 | return 'ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|com|coop|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw'; |
| 125 | 125 | } |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | * @return string |
| 132 | 132 | */ |
| 133 | 133 | public static function top_level_domains() { |
| 134 | - if ( empty( self::$top_level_domains_pattern ) ) { |
|
| 134 | + if (empty(self::$top_level_domains_pattern)) { |
|
| 135 | 135 | // Initialize valid top level domains from IANA list. |
| 136 | - self::$top_level_domains_pattern = self::get_top_level_domains_from_file( __DIR__ . '/IANA/tlds-alpha-by-domain.txt' ); |
|
| 136 | + self::$top_level_domains_pattern = self::get_top_level_domains_from_file(__DIR__ . '/IANA/tlds-alpha-by-domain.txt'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return self::$top_level_domains_pattern; |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @param string $open Opening quote character(s). |
| 56 | 56 | * @param string $close Closing quote character(s). |
| 57 | 57 | */ |
| 58 | - public function __construct( $open, $close ) { |
|
| 58 | + public function __construct($open, $close) { |
|
| 59 | 59 | $this->open = $open; |
| 60 | 60 | $this->close = $close; |
| 61 | 61 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * @param string $interval The dash character used for interval dashes. |
| 72 | 72 | * @param string $interval_space The space character used around interval dashes. |
| 73 | 73 | */ |
| 74 | - public function __construct( $parenthetical, $parenthetical_space, $interval, $interval_space ) { |
|
| 74 | + public function __construct($parenthetical, $parenthetical_space, $interval, $interval_space) { |
|
| 75 | 75 | $this->parenthetical_dash = $parenthetical; |
| 76 | 76 | $this->parenthetical_space = $parenthetical_space; |
| 77 | 77 | $this->interval_dash = $interval; |
@@ -149,15 +149,15 @@ |
||
| 149 | 149 | * |
| 150 | 150 | * @return Quotes|null Returns null in case of an invalid $style parameter. |
| 151 | 151 | */ |
| 152 | - public static function get_styled_quotes( $style, Settings $settings ) { |
|
| 153 | - if ( isset( self::$styles[ $style ] ) ) { |
|
| 154 | - return new Simple_Quotes( self::$styles[ $style ][ self::_OPEN ], self::$styles[ $style ][ self::_CLOSE ] ); |
|
| 152 | + public static function get_styled_quotes($style, Settings $settings) { |
|
| 153 | + if (isset(self::$styles[$style])) { |
|
| 154 | + return new Simple_Quotes(self::$styles[$style][self::_OPEN], self::$styles[$style][self::_CLOSE]); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( self::DOUBLE_GUILLEMETS_FRENCH === $style ) { |
|
| 157 | + if (self::DOUBLE_GUILLEMETS_FRENCH === $style) { |
|
| 158 | 158 | $space = $settings->no_break_narrow_space(); |
| 159 | 159 | |
| 160 | - return new Simple_Quotes( U::GUILLEMET_OPEN . $space, $space . U::GUILLEMET_CLOSE ); |
|
| 160 | + return new Simple_Quotes(U::GUILLEMET_OPEN . $space, $space . U::GUILLEMET_CLOSE); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return null; |
@@ -147,7 +147,7 @@ |
||
| 147 | 147 | * @param string $style The quote style. |
| 148 | 148 | * @param Settings $settings The current settings. |
| 149 | 149 | * |
| 150 | - * @return Quotes|null Returns null in case of an invalid $style parameter. |
|
| 150 | + * @return Simple_Quotes|null Returns null in case of an invalid $style parameter. |
|
| 151 | 151 | */ |
| 152 | 152 | public static function get_styled_quotes( $style, Settings $settings ) { |
| 153 | 153 | if ( isset( self::$styles[ $style ] ) ) { |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | * @param string|null $language Optional. Short-form language name. Default null. |
| 93 | 93 | * @param array $exceptions Optional. Custom hyphenation exceptions. Default empty array. |
| 94 | 94 | */ |
| 95 | - public function __construct( $language = null, array $exceptions = [] ) { |
|
| 95 | + public function __construct($language = null, array $exceptions = []) { |
|
| 96 | 96 | |
| 97 | - if ( ! empty( $language ) ) { |
|
| 98 | - $this->set_language( $language ); |
|
| 97 | + if ( ! empty($language)) { |
|
| 98 | + $this->set_language($language); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( ! empty( $exceptions ) ) { |
|
| 102 | - $this->set_custom_exceptions( $exceptions ); |
|
| 101 | + if ( ! empty($exceptions)) { |
|
| 102 | + $this->set_custom_exceptions($exceptions); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,31 +108,31 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param array $exceptions Optional. An array of words with all hyphenation points marked with a hard hyphen. Default empty array. |
| 110 | 110 | */ |
| 111 | - public function set_custom_exceptions( array $exceptions = [] ) { |
|
| 112 | - if ( empty( $exceptions ) && empty( $this->custom_exceptions ) ) { |
|
| 111 | + public function set_custom_exceptions(array $exceptions = []) { |
|
| 112 | + if (empty($exceptions) && empty($this->custom_exceptions)) { |
|
| 113 | 113 | return; // Nothing to do at all. |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Calculate hash & check against previous exceptions. |
| 117 | - $new_hash = self::get_object_hash( $exceptions ); |
|
| 118 | - if ( $this->custom_exceptions_hash === $new_hash ) { |
|
| 117 | + $new_hash = self::get_object_hash($exceptions); |
|
| 118 | + if ($this->custom_exceptions_hash === $new_hash) { |
|
| 119 | 119 | return; // No need to update exceptions. |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Do our thing. |
| 123 | 123 | $exception_keys = []; |
| 124 | - foreach ( $exceptions as $exception ) { |
|
| 125 | - $func = Strings::functions( $exception ); |
|
| 126 | - if ( empty( $func ) ) { |
|
| 124 | + foreach ($exceptions as $exception) { |
|
| 125 | + $func = Strings::functions($exception); |
|
| 126 | + if (empty($func)) { |
|
| 127 | 127 | continue; // unknown encoding, abort. |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $exception = $func['strtolower']( $exception ); |
|
| 131 | - $exception_keys[ $exception ] = preg_replace( "#-#{$func['u']}", '', $exception ); |
|
| 130 | + $exception = $func['strtolower']($exception); |
|
| 131 | + $exception_keys[$exception] = preg_replace("#-#{$func['u']}", '', $exception); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Update exceptions. |
| 135 | - $this->custom_exceptions = array_flip( $exception_keys ); |
|
| 135 | + $this->custom_exceptions = array_flip($exception_keys); |
|
| 136 | 136 | $this->custom_exceptions_hash = $new_hash; |
| 137 | 137 | |
| 138 | 138 | // Force remerging of patgen and custom exception patterns. |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - protected static function get_object_hash( $object ) { |
|
| 150 | - return md5( json_encode( $object ), false ); |
|
| 149 | + protected static function get_object_hash($object) { |
|
| 150 | + return md5(json_encode($object), false); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return bool Whether loading the pattern file was successful. |
| 159 | 159 | */ |
| 160 | - public function set_language( $lang = 'en-US' ) { |
|
| 161 | - if ( isset( $this->language ) && $this->language === $lang ) { |
|
| 160 | + public function set_language($lang = 'en-US') { |
|
| 161 | + if (isset($this->language) && $this->language === $lang) { |
|
| 162 | 162 | return true; // Bail out, no need to do anything. |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $success = false; |
| 166 | - $language_file_name = dirname( __FILE__ ) . '/lang/' . $lang . '.json'; |
|
| 166 | + $language_file_name = dirname(__FILE__) . '/lang/' . $lang . '.json'; |
|
| 167 | 167 | |
| 168 | - if ( file_exists( $language_file_name ) ) { |
|
| 169 | - $raw_language_file = file_get_contents( $language_file_name ); |
|
| 168 | + if (file_exists($language_file_name)) { |
|
| 169 | + $raw_language_file = file_get_contents($language_file_name); |
|
| 170 | 170 | |
| 171 | - if ( false !== $raw_language_file ) { |
|
| 172 | - $language_file = json_decode( $raw_language_file, true ); |
|
| 171 | + if (false !== $raw_language_file) { |
|
| 172 | + $language_file = json_decode($raw_language_file, true); |
|
| 173 | 173 | |
| 174 | - if ( false !== $language_file ) { |
|
| 174 | + if (false !== $language_file) { |
|
| 175 | 175 | $this->language = $lang; |
| 176 | - $this->pattern_trie = Trie_Node::build_trie( $language_file['patterns'] ); |
|
| 176 | + $this->pattern_trie = Trie_Node::build_trie($language_file['patterns']); |
|
| 177 | 177 | $this->pattern_exceptions = $language_file['exceptions']; |
| 178 | 178 | |
| 179 | 179 | $success = true; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Clean up. |
| 185 | - if ( ! $success ) { |
|
| 185 | + if ( ! $success) { |
|
| 186 | 186 | $this->language = null; |
| 187 | 187 | $this->pattern_trie = null; |
| 188 | 188 | $this->pattern_exceptions = []; |
@@ -206,18 +206,18 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return array The modified text tokens. |
| 208 | 208 | */ |
| 209 | - public function hyphenate( $parsed_text_tokens, $hyphen = '-', $hyphenate_title_case = false, $min_length = 2, $min_before = 2, $min_after = 2 ) { |
|
| 210 | - if ( empty( $min_length ) || empty( $min_before ) || ! isset( $this->pattern_trie ) || ! isset( $this->pattern_exceptions ) ) { |
|
| 209 | + public function hyphenate($parsed_text_tokens, $hyphen = '-', $hyphenate_title_case = false, $min_length = 2, $min_before = 2, $min_after = 2) { |
|
| 210 | + if (empty($min_length) || empty($min_before) || ! isset($this->pattern_trie) || ! isset($this->pattern_exceptions)) { |
|
| 211 | 211 | return $parsed_text_tokens; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Make sure we have full exceptions list. |
| 215 | - if ( ! isset( $this->merged_exception_patterns ) ) { |
|
| 215 | + if ( ! isset($this->merged_exception_patterns)) { |
|
| 216 | 216 | $this->merge_hyphenation_exceptions(); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - foreach ( $parsed_text_tokens as $key => $text_token ) { |
|
| 220 | - $parsed_text_tokens[ $key ] = $text_token->with_value( $this->hyphenate_word( $text_token->value, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after ) ); |
|
| 219 | + foreach ($parsed_text_tokens as $key => $text_token) { |
|
| 220 | + $parsed_text_tokens[$key] = $text_token->with_value($this->hyphenate_word($text_token->value, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after)); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | return $parsed_text_tokens; |
@@ -235,48 +235,48 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return string |
| 237 | 237 | */ |
| 238 | - protected function hyphenate_word( $word, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after ) { |
|
| 238 | + protected function hyphenate_word($word, $hyphen, $hyphenate_title_case, $min_length, $min_before, $min_after) { |
|
| 239 | 239 | // Quickly reference string functions according to encoding. |
| 240 | - $func = Strings::functions( $word ); |
|
| 241 | - if ( empty( $func ) ) { |
|
| 240 | + $func = Strings::functions($word); |
|
| 241 | + if (empty($func)) { |
|
| 242 | 242 | return $word; // unknown encoding, abort. |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Check word length. |
| 246 | - $word_length = $func['strlen']( $word ); |
|
| 247 | - if ( $word_length < $min_length ) { |
|
| 246 | + $word_length = $func['strlen']($word); |
|
| 247 | + if ($word_length < $min_length) { |
|
| 248 | 248 | return $word; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Trie lookup requires a lowercase search term. |
| 252 | - $the_key = $func['strtolower']( $word ); |
|
| 252 | + $the_key = $func['strtolower']($word); |
|
| 253 | 253 | |
| 254 | 254 | // If this is a capitalized word, and settings do not allow hyphenation of such, abort! |
| 255 | 255 | // Note: This is different than uppercase words, where we are looking for title case. |
| 256 | - if ( ! $hyphenate_title_case && $func['substr']( $the_key, 0, 1 ) !== $func['substr']( $word, 0, 1 ) ) { |
|
| 256 | + if ( ! $hyphenate_title_case && $func['substr']($the_key, 0, 1) !== $func['substr']($word, 0, 1)) { |
|
| 257 | 257 | return $word; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Give exceptions preference. |
| 261 | - if ( isset( $this->merged_exception_patterns[ $the_key ] ) ) { |
|
| 262 | - $word_pattern = $this->merged_exception_patterns[ $the_key ]; |
|
| 261 | + if (isset($this->merged_exception_patterns[$the_key])) { |
|
| 262 | + $word_pattern = $this->merged_exception_patterns[$the_key]; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Lookup word pattern if there is no exception. |
| 266 | - if ( ! isset( $word_pattern ) ) { |
|
| 267 | - $word_pattern = $this->lookup_word_pattern( $the_key, $func['strlen'], $func['str_split'] ); |
|
| 266 | + if ( ! isset($word_pattern)) { |
|
| 267 | + $word_pattern = $this->lookup_word_pattern($the_key, $func['strlen'], $func['str_split']); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Add hyphen character based on $word_pattern. |
| 271 | - $word_parts = $func['str_split']( $word, 1 ); |
|
| 271 | + $word_parts = $func['str_split']($word, 1); |
|
| 272 | 272 | $hyphenated_word = ''; |
| 273 | 273 | |
| 274 | - for ( $i = 0; $i < $word_length; $i++ ) { |
|
| 275 | - if ( isset( $word_pattern[ $i ] ) && self::is_odd( $word_pattern[ $i ] ) && ( $i >= $min_before) && ( $i <= $word_length - $min_after ) ) { |
|
| 274 | + for ($i = 0; $i < $word_length; $i++) { |
|
| 275 | + if (isset($word_pattern[$i]) && self::is_odd($word_pattern[$i]) && ($i >= $min_before) && ($i <= $word_length - $min_after)) { |
|
| 276 | 276 | $hyphenated_word .= $hyphen; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $hyphenated_word .= $word_parts[ $i ]; |
|
| 279 | + $hyphenated_word .= $word_parts[$i]; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | return $hyphenated_word; |
@@ -291,33 +291,33 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return array The hyphenation pattern. |
| 293 | 293 | */ |
| 294 | - protected function lookup_word_pattern( $key, callable $strlen, callable $str_split ) { |
|
| 294 | + protected function lookup_word_pattern($key, callable $strlen, callable $str_split) { |
|
| 295 | 295 | // Add underscores to make out-of-index checks unnecessary, |
| 296 | 296 | // also hyphenation is done in lower case. |
| 297 | 297 | $search = '_' . $key . '_'; |
| 298 | - $search_length = $strlen( $search ); |
|
| 299 | - $chars = $str_split( $search ); |
|
| 298 | + $search_length = $strlen($search); |
|
| 299 | + $chars = $str_split($search); |
|
| 300 | 300 | $word_pattern = []; |
| 301 | 301 | |
| 302 | - for ( $start = 0; $start < $search_length; ++$start ) { |
|
| 302 | + for ($start = 0; $start < $search_length; ++$start) { |
|
| 303 | 303 | // Start from the trie root node. |
| 304 | 304 | $node = $this->pattern_trie; |
| 305 | 305 | |
| 306 | 306 | // Walk through the trie while storing detected patterns. |
| 307 | - for ( $step = $start; $step < $search_length; ++$step ) { |
|
| 307 | + for ($step = $start; $step < $search_length; ++$step) { |
|
| 308 | 308 | // No further path in the trie. |
| 309 | - if ( ! $node->exists( $chars[ $step ] ) ) { |
|
| 309 | + if ( ! $node->exists($chars[$step])) { |
|
| 310 | 310 | break; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // Look for next character. |
| 314 | - $node = $node->get_node( $chars[ $step ] ); |
|
| 314 | + $node = $node->get_node($chars[$step]); |
|
| 315 | 315 | |
| 316 | 316 | // Merge different offset values and keep maximum. |
| 317 | - foreach ( $node->offsets() as $pattern_offset ) { |
|
| 317 | + foreach ($node->offsets() as $pattern_offset) { |
|
| 318 | 318 | $value = $pattern_offset[0]; |
| 319 | 319 | $offset = $pattern_offset[1] + $start - 1; |
| 320 | - $word_pattern[ $offset ] = isset( $word_pattern[ $offset ] ) ? max( $word_pattern[ $offset ], $value ) : $value; |
|
| 320 | + $word_pattern[$offset] = isset($word_pattern[$offset]) ? max($word_pattern[$offset], $value) : $value; |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -333,18 +333,18 @@ discard block |
||
| 333 | 333 | $exceptions = []; |
| 334 | 334 | |
| 335 | 335 | // Merge custom and language specific word hyphenations. |
| 336 | - if ( ! empty( $this->pattern_exceptions ) && ! empty( $this->custom_exceptions ) ) { |
|
| 337 | - $exceptions = array_merge( $this->custom_exceptions, $this->pattern_exceptions ); |
|
| 338 | - } elseif ( ! empty( $this->pattern_exceptions ) ) { |
|
| 336 | + if ( ! empty($this->pattern_exceptions) && ! empty($this->custom_exceptions)) { |
|
| 337 | + $exceptions = array_merge($this->custom_exceptions, $this->pattern_exceptions); |
|
| 338 | + } elseif ( ! empty($this->pattern_exceptions)) { |
|
| 339 | 339 | $exceptions = $this->pattern_exceptions; |
| 340 | - } elseif ( ! empty( $this->custom_exceptions ) ) { |
|
| 340 | + } elseif ( ! empty($this->custom_exceptions)) { |
|
| 341 | 341 | $exceptions = $this->custom_exceptions; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Update patterns as well. |
| 345 | 345 | $exception_patterns = []; |
| 346 | - foreach ( $exceptions as $exception_key => $exception ) { |
|
| 347 | - $exception_patterns[ $exception_key ] = self::convert_hyphenation_exception_to_pattern( $exception ); |
|
| 346 | + foreach ($exceptions as $exception_key => $exception) { |
|
| 347 | + $exception_patterns[$exception_key] = self::convert_hyphenation_exception_to_pattern($exception); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | $this->merged_exception_patterns = $exception_patterns; |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @return array|null Returns the hyphenation pattern or null if `$exception` is using an invalid encoding. |
| 359 | 359 | */ |
| 360 | - protected static function convert_hyphenation_exception_to_pattern( $exception ) { |
|
| 361 | - $func = Strings::functions( $exception ); |
|
| 362 | - if ( empty( $func ) ) { |
|
| 360 | + protected static function convert_hyphenation_exception_to_pattern($exception) { |
|
| 361 | + $func = Strings::functions($exception); |
|
| 362 | + if (empty($func)) { |
|
| 363 | 363 | return null; // unknown encoding, abort. |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | // Set the word_pattern - this method keeps any contextually important capitalization. |
| 367 | - $lowercase_hyphened_word_parts = $func['str_split']( $exception, 1 ); |
|
| 368 | - $lowercase_hyphened_word_length = $func['strlen']( $exception ); |
|
| 367 | + $lowercase_hyphened_word_parts = $func['str_split']($exception, 1); |
|
| 368 | + $lowercase_hyphened_word_length = $func['strlen']($exception); |
|
| 369 | 369 | |
| 370 | 370 | $word_pattern = []; |
| 371 | 371 | $index = 0; |
| 372 | 372 | |
| 373 | - for ( $i = 0; $i < $lowercase_hyphened_word_length; $i++ ) { |
|
| 374 | - if ( '-' === $lowercase_hyphened_word_parts[ $i ] ) { |
|
| 375 | - $word_pattern[ $index ] = 9; |
|
| 373 | + for ($i = 0; $i < $lowercase_hyphened_word_length; $i++) { |
|
| 374 | + if ('-' === $lowercase_hyphened_word_parts[$i]) { |
|
| 375 | + $word_pattern[$index] = 9; |
|
| 376 | 376 | } else { |
| 377 | 377 | $index++; |
| 378 | 378 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @return bool true if $number is odd, false if it is even. |
| 390 | 390 | */ |
| 391 | - protected static function is_odd( $number ) { |
|
| 392 | - return (bool) ( $number % 2 ); |
|
| 391 | + protected static function is_odd($number) { |
|
| 392 | + return (bool) ($number % 2); |
|
| 393 | 393 | } |
| 394 | 394 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | * |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ); |
|
| 49 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Determines whether the fix should be applied to (RSS) feeds. |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | * |
| 53 | 53 | * @return array An array of tokens. |
| 54 | 54 | */ |
| 55 | - public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ); |
|
| 55 | + public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Determines whether the fix should be applied to (RSS) feeds. |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | * |
| 81 | 81 | * @param bool $feed_compatible Optional. Default false. |
| 82 | 82 | */ |
| 83 | - public function __construct( $feed_compatible = false ) { |
|
| 84 | - parent::__construct( self::REGEX, self::REPLACEMENT, self::SETTING, $feed_compatible ); |
|
| 83 | + public function __construct($feed_compatible = false) { |
|
| 84 | + parent::__construct(self::REGEX, self::REPLACEMENT, self::SETTING, $feed_compatible); |
|
| 85 | 85 | } |
| 86 | 86 | } |
@@ -56,25 +56,25 @@ |
||
| 56 | 56 | * @param Settings $settings Required. |
| 57 | 57 | * @param bool $is_title Optional. Default false. |
| 58 | 58 | */ |
| 59 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
| 60 | - if ( empty( $settings['singleCharacterWordSpacing'] ) ) { |
|
| 59 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
| 60 | + if (empty($settings['singleCharacterWordSpacing'])) { |
|
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Add $next_character and $previous_character for context. |
| 65 | - $previous_character = DOM::get_prev_chr( $textnode ); |
|
| 66 | - if ( '' !== $previous_character ) { |
|
| 65 | + $previous_character = DOM::get_prev_chr($textnode); |
|
| 66 | + if ('' !== $previous_character) { |
|
| 67 | 67 | $textnode->data = $previous_character . $textnode->data; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $next_character = DOM::get_next_chr( $textnode ); |
|
| 71 | - if ( '' !== $next_character ) { |
|
| 70 | + $next_character = DOM::get_next_chr($textnode); |
|
| 71 | + if ('' !== $next_character) { |
|
| 72 | 72 | $textnode->data = $textnode->data . $next_character; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $textnode->data = preg_replace( self::REGEX, '$1$2' . U::NO_BREAK_SPACE, $textnode->data ); |
|
| 75 | + $textnode->data = preg_replace(self::REGEX, '$1$2' . U::NO_BREAK_SPACE, $textnode->data); |
|
| 76 | 76 | |
| 77 | 77 | // If we have adjacent characters remove them from the text. |
| 78 | - $textnode->data = self::remove_adjacent_characters( $textnode->data, $previous_character, $next_character ); |
|
| 78 | + $textnode->data = self::remove_adjacent_characters($textnode->data, $previous_character, $next_character); |
|
| 79 | 79 | } |
| 80 | 80 | } |