We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -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; |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * @param string $url The TeX pattern file URL. |
64 | 64 | * @param string $language A human-readable language name. |
65 | 65 | */ |
66 | - public function __construct( $url, $language ) { |
|
66 | + public function __construct($url, $language) { |
|
67 | 67 | $this->url = $url; |
68 | 68 | $this->language = $language; |
69 | 69 | |
70 | - $this->word_characters = join( [ |
|
70 | + $this->word_characters = join([ |
|
71 | 71 | "\w.'ʼ᾽ʼ᾿’", |
72 | - Strings::uchr( 8205, 8204, 768, 769, 771, 772, 775, 776, 784, 803, 805, 814, 817 ), |
|
73 | - '\p{Devanagari}' . Strings::uchr( 2385, 2386 ), |
|
72 | + Strings::uchr(8205, 8204, 768, 769, 771, 772, 775, 776, 784, 803, 805, 814, 817), |
|
73 | + '\p{Devanagari}' . Strings::uchr(2385, 2386), |
|
74 | 74 | '\p{Bengali}', |
75 | 75 | '\p{Gujarati}', |
76 | 76 | '\p{Gurmukhi}', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | '\p{Malayalam}', |
82 | 82 | '\p{Thai}', |
83 | 83 | '-', |
84 | - ] ); |
|
84 | + ]); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * @param string $pattern TeX hyphenation pattern. |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - protected function get_segment( $pattern ) { |
|
94 | - return preg_replace( '/[0-9]/', '', str_replace( '.', '_', $pattern ) ); |
|
93 | + protected function get_segment($pattern) { |
|
94 | + return preg_replace('/[0-9]/', '', str_replace('.', '_', $pattern)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string|null Script exits on error. |
103 | 103 | */ |
104 | - protected function get_sequence( $pattern ) { |
|
105 | - $characters = Strings::mb_str_split( str_replace( '.', '_', $pattern ) ); |
|
104 | + protected function get_sequence($pattern) { |
|
105 | + $characters = Strings::mb_str_split(str_replace('.', '_', $pattern)); |
|
106 | 106 | $result = []; |
107 | 107 | |
108 | - foreach ( $characters as $index => $chr ) { |
|
109 | - if ( ctype_digit( $chr ) ) { |
|
108 | + foreach ($characters as $index => $chr) { |
|
109 | + if (ctype_digit($chr)) { |
|
110 | 110 | $result[] = $chr; |
111 | 111 | } else { |
112 | - if ( ! isset( $characters[ $index - 1 ] ) || ! ctype_digit( $characters[ $index - 1 ] ) ) { |
|
112 | + if ( ! isset($characters[$index - 1]) || ! ctype_digit($characters[$index - 1])) { |
|
113 | 113 | $result[] = '0'; |
114 | 114 | } |
115 | 115 | |
116 | - if ( ! isset( $characters[ $index + 1 ] ) && ! ctype_digit( $characters[ $index ] ) ) { |
|
116 | + if ( ! isset($characters[$index + 1]) && ! ctype_digit($characters[$index])) { |
|
117 | 117 | $result[] = '0'; |
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | 122 | // Do some error checking. |
123 | - $count = count( $result ); |
|
124 | - $count_seg = mb_strlen( $this->get_segment( $pattern ) ); |
|
125 | - $sequence = implode( $result ); |
|
123 | + $count = count($result); |
|
124 | + $count_seg = mb_strlen($this->get_segment($pattern)); |
|
125 | + $sequence = implode($result); |
|
126 | 126 | |
127 | - if ( $count !== $count_seg + 1 ) { |
|
128 | - trigger_error( "Invalid segment length $count for pattern $pattern (result sequence $sequence)", E_USER_ERROR ); // @codingStandardsIgnoreLine |
|
127 | + if ($count !== $count_seg + 1) { |
|
128 | + trigger_error("Invalid segment length $count for pattern $pattern (result sequence $sequence)", E_USER_ERROR); // @codingStandardsIgnoreLine |
|
129 | 129 | |
130 | 130 | die( -3000 ); |
131 | 131 | } |
@@ -146,32 +146,32 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - protected function format_results( array $patterns, array $exceptions, array $comments ) { |
|
149 | + protected function format_results(array $patterns, array $exceptions, array $comments) { |
|
150 | 150 | $pattern_mapping = []; |
151 | 151 | |
152 | - foreach ( $patterns as $pattern ) { |
|
153 | - $segment = $this->get_segment( $pattern ); |
|
152 | + foreach ($patterns as $pattern) { |
|
153 | + $segment = $this->get_segment($pattern); |
|
154 | 154 | |
155 | - if ( ! isset( $pattern_mapping[ $segment ] ) ) { |
|
156 | - $pattern_mapping[ $segment ] = $this->get_sequence( $pattern ); |
|
155 | + if ( ! isset($pattern_mapping[$segment])) { |
|
156 | + $pattern_mapping[$segment] = $this->get_sequence($pattern); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Produce a nice exceptions mapping. |
161 | 161 | $json_exceptions = []; |
162 | - foreach ( $exceptions as $exception ) { |
|
163 | - $json_exceptions[ mb_strtolower( str_replace( '-', '', $exception ) ) ] = mb_strtolower( $exception ); |
|
162 | + foreach ($exceptions as $exception) { |
|
163 | + $json_exceptions[mb_strtolower(str_replace('-', '', $exception))] = mb_strtolower($exception); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $json_results = [ |
167 | 167 | 'language' => $this->language, |
168 | 168 | 'source_url' => $this->url, |
169 | - 'copyright' => array_map( 'rtrim', $comments ), |
|
169 | + 'copyright' => array_map('rtrim', $comments), |
|
170 | 170 | 'exceptions' => $json_exceptions, |
171 | 171 | 'patterns' => $pattern_mapping, |
172 | 172 | ]; |
173 | 173 | |
174 | - return json_encode( $json_results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE ); |
|
174 | + return json_encode($json_results, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -188,27 +188,27 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return bool |
190 | 190 | */ |
191 | - protected function match_exceptions( $line, array &$exceptions ) { |
|
192 | - if ( preg_match( '/^\s*([\w-]+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
191 | + protected function match_exceptions($line, array &$exceptions) { |
|
192 | + if (preg_match('/^\s*([\w-]+)\s*}\s*(?:%.*)?$/u', $line, $matches)) { |
|
193 | 193 | $exceptions[] = $matches[1]; |
194 | 194 | return false; |
195 | - } if ( preg_match( '/^\s*((?:[\w-]+\s*)+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
196 | - $this->match_exceptions( $matches[1], $exceptions ); |
|
195 | + } if (preg_match('/^\s*((?:[\w-]+\s*)+)\s*}\s*(?:%.*)?$/u', $line, $matches)) { |
|
196 | + $this->match_exceptions($matches[1], $exceptions); |
|
197 | 197 | return false; |
198 | - } elseif ( preg_match( '/^\s*}\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
198 | + } elseif (preg_match('/^\s*}\s*(?:%.*)?$/u', $line, $matches)) { |
|
199 | 199 | return false; |
200 | - } elseif ( preg_match( '/^\s*([\w-]+)\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
200 | + } elseif (preg_match('/^\s*([\w-]+)\s*(?:%.*)?$/u', $line, $matches)) { |
|
201 | 201 | $exceptions[] = $matches[1]; |
202 | - } elseif ( preg_match( '/^\s*((?:[\w-]+\s*)+)(?:%.*)?$/u', $line, $matches ) ) { |
|
202 | + } elseif (preg_match('/^\s*((?:[\w-]+\s*)+)(?:%.*)?$/u', $line, $matches)) { |
|
203 | 203 | // Sometimes there are multiple exceptions on a single line. |
204 | - foreach ( self::split_at_whitespace( $matches[1] ) as $match ) { |
|
204 | + foreach (self::split_at_whitespace($matches[1]) as $match) { |
|
205 | 205 | $exceptions[] = $match; |
206 | 206 | } |
207 | - } elseif ( preg_match( '/^\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
207 | + } elseif (preg_match('/^\s*(?:%.*)?$/u', $line, $matches)) { |
|
208 | 208 | // Ignore comments and whitespace in exceptions. |
209 | 209 | return true; |
210 | 210 | } else { |
211 | - throw new RangeException( "Error: unknown exception line $line\n" ); |
|
211 | + throw new RangeException("Error: unknown exception line $line\n"); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | return true; |
@@ -224,24 +224,24 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return bool |
226 | 226 | */ |
227 | - protected function match_patterns( $line, array &$patterns ) { |
|
228 | - if ( preg_match( '/^\s*([' . $this->word_characters . ']+)\s*}\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
227 | + protected function match_patterns($line, array &$patterns) { |
|
228 | + if (preg_match('/^\s*([' . $this->word_characters . ']+)\s*}\s*(?:%.*)?$/u', $line, $matches)) { |
|
229 | 229 | $patterns[] = $matches[1]; |
230 | 230 | return false; |
231 | - } elseif ( preg_match( '/^\s*}\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
231 | + } elseif (preg_match('/^\s*}\s*(?:%.*)?$/u', $line, $matches)) { |
|
232 | 232 | return false; |
233 | - } elseif ( preg_match( '/^\s*([' . $this->word_characters . ']+)\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
233 | + } elseif (preg_match('/^\s*([' . $this->word_characters . ']+)\s*(?:%.*)?$/u', $line, $matches)) { |
|
234 | 234 | $patterns[] = $matches[1]; |
235 | - } elseif ( preg_match( '/^\s*((?:[' . $this->word_characters . ']+\s*)+)(?:%.*)?$/u', $line, $matches ) ) { |
|
235 | + } elseif (preg_match('/^\s*((?:[' . $this->word_characters . ']+\s*)+)(?:%.*)?$/u', $line, $matches)) { |
|
236 | 236 | // Sometimes there are multiple patterns on a single line. |
237 | - foreach ( self::split_at_whitespace( $matches[1] ) as $match ) { |
|
237 | + foreach (self::split_at_whitespace($matches[1]) as $match) { |
|
238 | 238 | $patterns[] = $match; |
239 | 239 | } |
240 | - } elseif ( preg_match( '/^\s*(?:%.*)?$/u', $line, $matches ) ) { |
|
240 | + } elseif (preg_match('/^\s*(?:%.*)?$/u', $line, $matches)) { |
|
241 | 241 | // Ignore comments and whitespace in patterns. |
242 | 242 | return true; |
243 | 243 | } else { |
244 | - throw new RangeException( 'Error: unknown pattern line ' . htmlentities( $line, ENT_NOQUOTES | ENT_HTML5 ) . "\n" ); |
|
244 | + throw new RangeException('Error: unknown pattern line ' . htmlentities($line, ENT_NOQUOTES | ENT_HTML5) . "\n"); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return true; |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return array |
256 | 256 | */ |
257 | - private static function split_at_whitespace( $line ) { |
|
258 | - return preg_split( '/\s+/Su', $line, -1, PREG_SPLIT_NO_EMPTY ); |
|
257 | + private static function split_at_whitespace($line) { |
|
258 | + return preg_split('/\s+/Su', $line, -1, PREG_SPLIT_NO_EMPTY); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | * @return string |
268 | 268 | */ |
269 | 269 | public function convert() { |
270 | - if ( ! file_exists( $this->url ) ) { |
|
271 | - $file_headers = @get_headers( $this->url ); |
|
272 | - if ( 'HTTP/1.0 404 Not Found' === $file_headers[0] ) { |
|
273 | - throw new RuntimeException( "Error: unknown pattern file '{$this->url}'\n" ); |
|
270 | + if ( ! file_exists($this->url)) { |
|
271 | + $file_headers = @get_headers($this->url); |
|
272 | + if ('HTTP/1.0 404 Not Found' === $file_headers[0]) { |
|
273 | + throw new RuntimeException("Error: unknown pattern file '{$this->url}'\n"); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
@@ -283,36 +283,36 @@ discard block |
||
283 | 283 | $reading_patterns = false; |
284 | 284 | $reading_exceptions = false; |
285 | 285 | |
286 | - $file = new \SplFileObject( $this->url ); |
|
287 | - while ( ! $file->eof() ) { |
|
286 | + $file = new \SplFileObject($this->url); |
|
287 | + while ( ! $file->eof()) { |
|
288 | 288 | $line = $file->fgets(); |
289 | 289 | |
290 | - if ( $reading_patterns ) { |
|
291 | - $reading_patterns = $this->match_patterns( $line, $patterns ); |
|
292 | - } elseif ( $reading_exceptions ) { |
|
293 | - $reading_exceptions = $this->match_exceptions( $line, $exceptions ); |
|
290 | + if ($reading_patterns) { |
|
291 | + $reading_patterns = $this->match_patterns($line, $patterns); |
|
292 | + } elseif ($reading_exceptions) { |
|
293 | + $reading_exceptions = $this->match_exceptions($line, $exceptions); |
|
294 | 294 | } else { |
295 | 295 | // Not a pattern & not an exception. |
296 | - if ( preg_match( '/^\s*%.*$/u', $line, $matches ) ) { |
|
296 | + if (preg_match('/^\s*%.*$/u', $line, $matches)) { |
|
297 | 297 | $comments[] = $line; |
298 | - } elseif ( preg_match( '/^\s*\\\patterns\s*\{\s*(.*)$/u', $line, $matches ) ) { |
|
299 | - $reading_patterns = $this->match_patterns( $matches[1], $patterns ); |
|
300 | - } elseif ( preg_match( '/^\s*\\\hyphenation\s*{\s*(.*)$/u', $line, $matches ) ) { |
|
301 | - $reading_exceptions = $this->match_exceptions( $matches[1], $exceptions ); |
|
302 | - } elseif ( preg_match( '/^\s*\\\endinput.*$/u', $line, $matches ) ) { |
|
298 | + } elseif (preg_match('/^\s*\\\patterns\s*\{\s*(.*)$/u', $line, $matches)) { |
|
299 | + $reading_patterns = $this->match_patterns($matches[1], $patterns); |
|
300 | + } elseif (preg_match('/^\s*\\\hyphenation\s*{\s*(.*)$/u', $line, $matches)) { |
|
301 | + $reading_exceptions = $this->match_exceptions($matches[1], $exceptions); |
|
302 | + } elseif (preg_match('/^\s*\\\endinput.*$/u', $line, $matches)) { |
|
303 | 303 | // Ignore this line completely. |
304 | 304 | continue; |
305 | - } elseif ( preg_match( '/^\s*\\\[\w]+.*$/u', $line, $matches ) ) { |
|
305 | + } elseif (preg_match('/^\s*\\\[\w]+.*$/u', $line, $matches)) { |
|
306 | 306 | // Treat other commands as comments unless we are matching exceptions or patterns. |
307 | 307 | $comments[] = $line; |
308 | - } elseif ( preg_match( '/^\s*$/u', $line, $matches ) ) { |
|
308 | + } elseif (preg_match('/^\s*$/u', $line, $matches)) { |
|
309 | 309 | continue; // Do nothing. |
310 | 310 | } else { |
311 | - throw new RangeException( "Error: unknown line $line\n" ); |
|
311 | + throw new RangeException("Error: unknown line $line\n"); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | - return $this->format_results( $patterns, $exceptions, $comments ); |
|
316 | + return $this->format_results($patterns, $exceptions, $comments); |
|
317 | 317 | } |
318 | 318 | } |