We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | * @param int $target Optional. Default Token_Fix::WORDS. |
63 | 63 | * @param bool $feed_compatible Optional. Default false. |
64 | 64 | */ |
65 | - public function __construct( Hyphenator_Cache $cache = null, $target = Token_Fix::WORDS, $feed_compatible = false ) { |
|
66 | - parent::__construct( $target, $feed_compatible ); |
|
65 | + public function __construct(Hyphenator_Cache $cache = null, $target = Token_Fix::WORDS, $feed_compatible = false) { |
|
66 | + parent::__construct($target, $feed_compatible); |
|
67 | 67 | |
68 | - if ( empty( $cache ) ) { |
|
68 | + if (empty($cache)) { |
|
69 | 69 | $cache = new Hyphenator_Cache(); |
70 | 70 | } |
71 | 71 | |
@@ -89,26 +89,26 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return array An array of tokens. |
91 | 91 | */ |
92 | - public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ) { |
|
93 | - if ( empty( $settings['hyphenation'] ) ) { |
|
92 | + public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null) { |
|
93 | + if (empty($settings['hyphenation'])) { |
|
94 | 94 | return $tokens; // abort. |
95 | 95 | } |
96 | 96 | |
97 | 97 | $is_heading = false; |
98 | - if ( ! empty( $textnode ) && ! empty( $textnode->parentNode ) ) { |
|
99 | - $block_level_parent = DOM::get_block_parent_name( $textnode ); |
|
98 | + if ( ! empty($textnode) && ! empty($textnode->parentNode)) { |
|
99 | + $block_level_parent = DOM::get_block_parent_name($textnode); |
|
100 | 100 | |
101 | - if ( ! empty( $block_level_parent ) && isset( $this->heading_tags[ $block_level_parent ] ) ) { |
|
101 | + if ( ! empty($block_level_parent) && isset($this->heading_tags[$block_level_parent])) { |
|
102 | 102 | $is_heading = true; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - if ( empty( $settings['hyphenateTitle'] ) && ( $is_title || $is_heading ) ) { |
|
106 | + if (empty($settings['hyphenateTitle']) && ($is_title || $is_heading)) { |
|
107 | 107 | return $tokens; // abort. |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Call functionality as seperate function so it can be run without test for setting['hyphenation'] - such as with url wrapping. |
111 | - return $this->do_hyphenate( $tokens, $settings ); |
|
111 | + return $this->do_hyphenate($tokens, $settings); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array The hyphenated text tokens. |
122 | 122 | */ |
123 | - protected function do_hyphenate( array $tokens, Settings $settings, $hyphen = U::SOFT_HYPHEN ) { |
|
124 | - if ( empty( $settings['hyphenMinLength'] ) || empty( $settings['hyphenMinBefore'] ) ) { |
|
123 | + protected function do_hyphenate(array $tokens, Settings $settings, $hyphen = U::SOFT_HYPHEN) { |
|
124 | + if (empty($settings['hyphenMinLength']) || empty($settings['hyphenMinBefore'])) { |
|
125 | 125 | return $tokens; |
126 | 126 | } |
127 | 127 | |
128 | - return $this->get_hyphenator( $settings )->hyphenate( $tokens, $hyphen, ! empty( $settings['hyphenateTitleCase'] ), $settings['hyphenMinLength'], $settings['hyphenMinBefore'], $settings['hyphenMinAfter'] ); |
|
128 | + return $this->get_hyphenator($settings)->hyphenate($tokens, $hyphen, ! empty($settings['hyphenateTitleCase']), $settings['hyphenMinLength'], $settings['hyphenMinBefore'], $settings['hyphenMinAfter']); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return Hyphenator |
137 | 137 | */ |
138 | - public function get_hyphenator( Settings $settings ) { |
|
138 | + public function get_hyphenator(Settings $settings) { |
|
139 | 139 | $lang = $settings['hyphenLanguage']; |
140 | 140 | $exceptions = (array) $settings['hyphenationCustomExceptions']; |
141 | - $hyphenator = $this->cache->get_hyphenator( $lang ); |
|
141 | + $hyphenator = $this->cache->get_hyphenator($lang); |
|
142 | 142 | |
143 | - if ( empty( $hyphenator ) ) { |
|
144 | - $hyphenator = new Hyphenator( $lang, $exceptions ); |
|
145 | - $this->cache->set_hyphenator( $lang, $hyphenator ); |
|
143 | + if (empty($hyphenator)) { |
|
144 | + $hyphenator = new Hyphenator($lang, $exceptions); |
|
145 | + $this->cache->set_hyphenator($lang, $hyphenator); |
|
146 | 146 | } else { |
147 | - $hyphenator->set_language( $lang ); // just for insurance. |
|
148 | - $hyphenator->set_custom_exceptions( $exceptions ); |
|
147 | + $hyphenator->set_language($lang); // just for insurance. |
|
148 | + $hyphenator->set_custom_exceptions($exceptions); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $hyphenator; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @param Hyphenator_Cache $cache Required. |
158 | 158 | */ |
159 | - public function set_hyphenator_cache( Hyphenator_Cache $cache ) { |
|
159 | + public function set_hyphenator_cache(Hyphenator_Cache $cache) { |
|
160 | 160 | $this->cache = $cache; |
161 | 161 | } |
162 | 162 | } |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param bool $feed_compatible Optional. Default false. |
56 | 56 | */ |
57 | - public function __construct( $feed_compatible = false ) { |
|
58 | - parent::__construct( Token_Fix::OTHER, $feed_compatible ); |
|
57 | + public function __construct($feed_compatible = false) { |
|
58 | + parent::__construct(Token_Fix::OTHER, $feed_compatible); |
|
59 | 59 | |
60 | 60 | $this->email_pattern = "/(?: |
61 | 61 | \A |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array An array of tokens. |
90 | 90 | */ |
91 | - public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ) { |
|
92 | - if ( empty( $settings['emailWrap'] ) ) { |
|
91 | + public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null) { |
|
92 | + if (empty($settings['emailWrap'])) { |
|
93 | 93 | return $tokens; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Test for and parse urls. |
97 | - foreach ( $tokens as $index => $token ) { |
|
97 | + foreach ($tokens as $index => $token) { |
|
98 | 98 | $value = $token->value; |
99 | - if ( preg_match( $this->email_pattern, $value, $email_match ) ) { |
|
100 | - $tokens[ $index ] = $token->with_value( preg_replace( self::REPLACE_EMAILS, '$1' . U::ZERO_WIDTH_SPACE, $value ) ); |
|
99 | + if (preg_match($this->email_pattern, $value, $email_match)) { |
|
100 | + $tokens[$index] = $token->with_value(preg_replace(self::REPLACE_EMAILS, '$1' . U::ZERO_WIDTH_SPACE, $value)); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @param Hyphenator_Cache|null $cache Optional. Default null. |
49 | 49 | * @param bool $feed_compatible Optional. Default false. |
50 | 50 | */ |
51 | - public function __construct( Hyphenator_Cache $cache = null, $feed_compatible = false ) { |
|
52 | - parent::__construct( $cache, Token_Fix::COMPOUND_WORDS, $feed_compatible ); |
|
51 | + public function __construct(Hyphenator_Cache $cache = null, $feed_compatible = false) { |
|
52 | + parent::__construct($cache, Token_Fix::COMPOUND_WORDS, $feed_compatible); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return array An array of tokens. |
64 | 64 | */ |
65 | - public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ) { |
|
66 | - if ( empty( $settings['hyphenateCompounds'] ) ) { |
|
65 | + public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null) { |
|
66 | + if (empty($settings['hyphenateCompounds'])) { |
|
67 | 67 | return $tokens; // abort. |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Hyphenate compound words. |
71 | - foreach ( $tokens as $key => $word_token ) { |
|
71 | + foreach ($tokens as $key => $word_token) { |
|
72 | 72 | $component_words = []; |
73 | - foreach ( preg_split( '/(-)/', $word_token->value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) as $word_part ) { |
|
74 | - $component_words[] = new Text_Parser\Token( $word_part, Text_Parser\Token::WORD ); |
|
73 | + foreach (preg_split('/(-)/', $word_token->value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $word_part) { |
|
74 | + $component_words[] = new Text_Parser\Token($word_part, Text_Parser\Token::WORD); |
|
75 | 75 | } |
76 | 76 | |
77 | - $tokens[ $key ] = $word_token->with_value( array_reduce( parent::apply( $component_words, $settings, $is_title, $textnode ), function( $carry, $item ) { |
|
77 | + $tokens[$key] = $word_token->with_value(array_reduce(parent::apply($component_words, $settings, $is_title, $textnode), function($carry, $item) { |
|
78 | 78 | return $carry . $item->value; |
79 | - } ) ); |
|
79 | + } )); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return $tokens; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @param Hyphenator_Cache|null $cache Optional. Default null. |
61 | 61 | * @param bool $feed_compatible Optional. Default false. |
62 | 62 | */ |
63 | - public function __construct( Hyphenator_Cache $cache = null, $feed_compatible = false ) { |
|
64 | - parent::__construct( $cache, Token_Fix::OTHER, $feed_compatible ); |
|
63 | + public function __construct(Hyphenator_Cache $cache = null, $feed_compatible = false) { |
|
64 | + parent::__construct($cache, Token_Fix::OTHER, $feed_compatible); |
|
65 | 65 | |
66 | 66 | // Combined URL pattern. |
67 | 67 | $this->url_pattern = '`(?: |
@@ -106,59 +106,59 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return array An array of tokens. |
108 | 108 | */ |
109 | - public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ) { |
|
110 | - if ( empty( $settings['urlWrap'] ) || empty( $settings['urlMinAfterWrap'] ) ) { |
|
109 | + public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null) { |
|
110 | + if (empty($settings['urlWrap']) || empty($settings['urlMinAfterWrap'])) { |
|
111 | 111 | return $tokens; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Test for and parse urls. |
115 | - foreach ( $tokens as $token_index => $text_token ) { |
|
116 | - if ( preg_match( $this->url_pattern, $text_token->value, $url_match ) ) { |
|
115 | + foreach ($tokens as $token_index => $text_token) { |
|
116 | + if (preg_match($this->url_pattern, $text_token->value, $url_match)) { |
|
117 | 117 | |
118 | 118 | // $url_match['schema'] holds "http://". |
119 | 119 | // $url_match['domain'] holds "subdomains.domain.tld". |
120 | 120 | // $url_match['path'] holds the path after the domain. |
121 | - $http = ( $url_match['schema'] ) ? $url_match[1] . U::ZERO_WIDTH_SPACE : ''; |
|
121 | + $http = ($url_match['schema']) ? $url_match[1] . U::ZERO_WIDTH_SPACE : ''; |
|
122 | 122 | |
123 | - $domain_parts = preg_split( self::WRAP_URLS_DOMAIN_PARTS, $url_match['domain'], -1, PREG_SPLIT_DELIM_CAPTURE ); |
|
123 | + $domain_parts = preg_split(self::WRAP_URLS_DOMAIN_PARTS, $url_match['domain'], -1, PREG_SPLIT_DELIM_CAPTURE); |
|
124 | 124 | |
125 | 125 | // This is a hack, but it works. |
126 | 126 | // First, we hyphenate each part, we need it formated like a group of words. |
127 | 127 | $parsed_words_like = []; |
128 | - foreach ( $domain_parts as $key => $part ) { |
|
129 | - $parsed_words_like[ $key ] = new Text_Parser\Token( $part, Text_Parser\Token::OTHER ); |
|
128 | + foreach ($domain_parts as $key => $part) { |
|
129 | + $parsed_words_like[$key] = new Text_Parser\Token($part, Text_Parser\Token::OTHER); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // Do the hyphenation. |
133 | - $parsed_words_like = $this->do_hyphenate( $parsed_words_like, $settings, U::ZERO_WIDTH_SPACE ); |
|
133 | + $parsed_words_like = $this->do_hyphenate($parsed_words_like, $settings, U::ZERO_WIDTH_SPACE); |
|
134 | 134 | |
135 | 135 | // Restore format. |
136 | - foreach ( $parsed_words_like as $key => $parsed_word ) { |
|
136 | + foreach ($parsed_words_like as $key => $parsed_word) { |
|
137 | 137 | $value = $parsed_word->value; |
138 | 138 | |
139 | - if ( $key > 0 && 1 === strlen( $value ) ) { |
|
140 | - $domain_parts[ $key ] = U::ZERO_WIDTH_SPACE . $value; |
|
139 | + if ($key > 0 && 1 === strlen($value)) { |
|
140 | + $domain_parts[$key] = U::ZERO_WIDTH_SPACE . $value; |
|
141 | 141 | } else { |
142 | - $domain_parts[ $key ] = $value; |
|
142 | + $domain_parts[$key] = $value; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Lastly let's recombine. |
147 | - $domain = implode( $domain_parts ); |
|
147 | + $domain = implode($domain_parts); |
|
148 | 148 | |
149 | 149 | // Break up the URL path to individual characters. |
150 | - $path_parts = str_split( $url_match['path'], 1 ); |
|
151 | - $path_count = count( $path_parts ); |
|
150 | + $path_parts = str_split($url_match['path'], 1); |
|
151 | + $path_count = count($path_parts); |
|
152 | 152 | $path = ''; |
153 | - foreach ( $path_parts as $index => $path_part ) { |
|
154 | - if ( 0 === $index || $path_count - $index < $settings['urlMinAfterWrap'] ) { |
|
153 | + foreach ($path_parts as $index => $path_part) { |
|
154 | + if (0 === $index || $path_count - $index < $settings['urlMinAfterWrap']) { |
|
155 | 155 | $path .= $path_part; |
156 | 156 | } else { |
157 | 157 | $path .= U::ZERO_WIDTH_SPACE . $path_part; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - $tokens[ $token_index ] = $text_token->with_value( $http . $domain . $path ); |
|
161 | + $tokens[$token_index] = $text_token->with_value($http . $domain . $path); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param int $target Required. |
59 | 59 | * @param bool $feed_compatible Optional. Default false. |
60 | 60 | */ |
61 | - protected function __construct( $target, $feed_compatible = false ) { |
|
61 | + protected function __construct($target, $feed_compatible = false) { |
|
62 | 62 | $this->target = $target; |
63 | 63 | $this->feed_compatible = $feed_compatible; |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array An array of tokens. |
75 | 75 | */ |
76 | - abstract public function apply( array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null ); |
|
76 | + abstract public function apply(array $tokens, Settings $settings, $is_title = false, \DOMText $textnode = null); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * 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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @var array |
47 | 47 | */ |
48 | - const _ENCODINGS = [ 'ASCII', 'UTF-8' ]; |
|
48 | + const _ENCODINGS = ['ASCII', 'UTF-8']; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * A hash map for string functions according to encoding. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | const _STRING_FUNCTIONS = [ |
56 | 56 | 'UTF-8' => [ |
57 | 57 | 'strlen' => 'mb_strlen', |
58 | - 'str_split' => [ __CLASS__, 'mb_str_split' ], |
|
58 | + 'str_split' => [__CLASS__, 'mb_str_split'], |
|
59 | 59 | 'strtolower' => 'mb_strtolower', |
60 | 60 | 'strtoupper' => 'mb_strtoupper', |
61 | 61 | 'substr' => 'mb_substr', |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * 'u' => modifier string |
88 | 88 | * } |
89 | 89 | */ |
90 | - public static function functions( $str ) { |
|
91 | - return self::_STRING_FUNCTIONS[ mb_detect_encoding( $str, self::_ENCODINGS, true ) ]; |
|
90 | + public static function functions($str) { |
|
91 | + return self::_STRING_FUNCTIONS[mb_detect_encoding($str, self::_ENCODINGS, true)]; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array An array of $split_length character chunks. |
104 | 104 | */ |
105 | - public static function mb_str_split( $str, $split_length = 1 ) { |
|
106 | - $result = preg_split( '//u', $str , -1, PREG_SPLIT_NO_EMPTY ); |
|
105 | + public static function mb_str_split($str, $split_length = 1) { |
|
106 | + $result = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY); |
|
107 | 107 | |
108 | - if ( $split_length > 1 ) { |
|
108 | + if ($split_length > 1) { |
|
109 | 109 | $splits = []; |
110 | - foreach ( array_chunk( $result, $split_length ) as $chunk ) { |
|
111 | - $splits[] = join( '', $chunk ); |
|
110 | + foreach (array_chunk($result, $split_length) as $chunk) { |
|
111 | + $splits[] = join('', $chunk); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $result = $splits; |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string Unicode character(s). |
126 | 126 | */ |
127 | - public static function uchr( $codes ) { |
|
127 | + public static function uchr($codes) { |
|
128 | 128 | |
129 | 129 | // Single character code. |
130 | - if ( is_scalar( $codes ) ) { |
|
130 | + if (is_scalar($codes)) { |
|
131 | 131 | $codes = func_get_args(); |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Deal with an array of character codes. |
135 | 135 | $str = ''; |
136 | - foreach ( $codes as $code ) { |
|
137 | - $str .= self::_uchr( (int) $code ); |
|
136 | + foreach ($codes as $code) { |
|
137 | + $str .= self::_uchr((int) $code); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return $str; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return string Unicode character. |
150 | 150 | */ |
151 | - public static function _uchr( $code ) { |
|
152 | - return html_entity_decode( '&#' . $code . ';', ENT_NOQUOTES, 'UTF-8' ); |
|
151 | + public static function _uchr($code) { |
|
152 | + return html_entity_decode('&#' . $code . ';', ENT_NOQUOTES, 'UTF-8'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - public static function maybe_split_parameters( $params ) { |
|
163 | - if ( ! is_array( $params ) ) { |
|
164 | - $params = preg_split( self::_RE_PARAMETER_SPLITTING, $params, -1, PREG_SPLIT_NO_EMPTY ); |
|
162 | + public static function maybe_split_parameters($params) { |
|
163 | + if ( ! is_array($params)) { |
|
164 | + $params = preg_split(self::_RE_PARAMETER_SPLITTING, $params, -1, PREG_SPLIT_NO_EMPTY); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return $params; |