@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * @return string |
18 | 18 | * @throws Exception |
19 | 19 | */ |
20 | - public static function cleanCDATA( $testString ) { |
|
21 | - $cleanXMLContent = new SimpleXMLElement( '<rootNoteNode>' . $testString . '</rootNoteNode>', LIBXML_NOCDATA ); |
|
20 | + public static function cleanCDATA($testString) { |
|
21 | + $cleanXMLContent = new SimpleXMLElement('<rootNoteNode>' . $testString . '</rootNoteNode>', LIBXML_NOCDATA); |
|
22 | 22 | |
23 | 23 | return $cleanXMLContent->__toString(); |
24 | 24 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | * @return bool |
30 | 30 | * @throws Exception |
31 | 31 | */ |
32 | - public static function isJSON( $string ) { |
|
33 | - if ( is_numeric( $string ) ) { |
|
32 | + public static function isJSON($string) { |
|
33 | + if (is_numeric($string)) { |
|
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | 37 | try { |
38 | - $string = Strings::cleanCDATA( $string ); |
|
38 | + $string = Strings::cleanCDATA($string); |
|
39 | 39 | |
40 | - if ( empty( $string ) ) { |
|
40 | + if (empty($string)) { |
|
41 | 41 | throw new Exception(); |
42 | 42 | } |
43 | 43 | |
44 | - json_decode( $string ); |
|
44 | + json_decode($string); |
|
45 | 45 | self::raiseJsonExceptionError(); |
46 | - } catch ( Exception $exception ) { |
|
46 | + } catch (Exception $exception) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public static function jsonToArray( $string ) { |
|
59 | - return ( is_array( json_decode( $string, true ) ) ) ? json_decode( $string, true ) : []; |
|
58 | + public static function jsonToArray($string) { |
|
59 | + return (is_array(json_decode($string, true))) ? json_decode($string, true) : []; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * @return string|null |
66 | 66 | * @throws NotValidJSONException |
67 | 67 | */ |
68 | - private static function raiseJsonExceptionError( $raise = true ) { |
|
69 | - if ( function_exists( "json_last_error" ) ) { |
|
68 | + private static function raiseJsonExceptionError($raise = true) { |
|
69 | + if (function_exists("json_last_error")) { |
|
70 | 70 | $error = json_last_error(); |
71 | 71 | |
72 | - switch ( $error ) { |
|
72 | + switch ($error) { |
|
73 | 73 | case JSON_ERROR_NONE: |
74 | 74 | $msg = null; # - No errors |
75 | 75 | break; |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | break; |
94 | 94 | } |
95 | 95 | |
96 | - if ( $raise && $error != JSON_ERROR_NONE ) { |
|
97 | - throw new NotValidJSONException( $msg, $error ); |
|
98 | - } elseif ( $error != JSON_ERROR_NONE ) { |
|
96 | + if ($raise && $error != JSON_ERROR_NONE) { |
|
97 | + throw new NotValidJSONException($msg, $error); |
|
98 | + } elseif ($error != JSON_ERROR_NONE) { |
|
99 | 99 | return $msg; |
100 | 100 | } |
101 | 101 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public static function fixNonWellFormedXml( $content, $escapeStrings = true ) { |
|
124 | - if ( self::$find_xliff_tags_reg === null ) { |
|
123 | + public static function fixNonWellFormedXml($content, $escapeStrings = true) { |
|
124 | + if (self::$find_xliff_tags_reg === null) { |
|
125 | 125 | // Convert the list of tags in a regexp list, for example "g|x|bx|ex" |
126 | 126 | $xliffTags = XliffTags::$tags; |
127 | - $xliff_tags_reg_list = implode( '|', $xliffTags ); |
|
127 | + $xliff_tags_reg_list = implode('|', $xliffTags); |
|
128 | 128 | // Regexp to find all the XLIFF tags: |
129 | 129 | // </? -> matches the tag start, for both opening and |
130 | 130 | // closure tags (see the optional slash) |
@@ -145,30 +145,30 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | // Find all the XLIFF tags |
148 | - preg_match_all( self::$find_xliff_tags_reg, $content, $matches ); |
|
149 | - $tags = (array)$matches[ 0 ]; |
|
148 | + preg_match_all(self::$find_xliff_tags_reg, $content, $matches); |
|
149 | + $tags = (array)$matches[0]; |
|
150 | 150 | |
151 | 151 | // Prepare placeholders |
152 | 152 | $tags_placeholders = []; |
153 | - $tagsNum = count( $tags ); |
|
154 | - for ( $i = 0; $i < $tagsNum; $i++ ) { |
|
155 | - $tag = $tags[ $i ]; |
|
156 | - $tags_placeholders[ $tag ] = "#@!XLIFF-TAG-$i!@#"; |
|
153 | + $tagsNum = count($tags); |
|
154 | + for ($i = 0; $i < $tagsNum; $i++) { |
|
155 | + $tag = $tags[$i]; |
|
156 | + $tags_placeholders[$tag] = "#@!XLIFF-TAG-$i!@#"; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Replace all XLIFF tags with placeholders that will not be escaped |
160 | - foreach ( $tags_placeholders as $tag => $placeholder ) { |
|
161 | - $content = str_replace( $tag, $placeholder, $content ); |
|
160 | + foreach ($tags_placeholders as $tag => $placeholder) { |
|
161 | + $content = str_replace($tag, $placeholder, $content); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Escape the string with the remaining non-XLIFF tags |
165 | - if ( $escapeStrings ) { |
|
166 | - $content = htmlspecialchars( $content, ENT_NOQUOTES, 'UTF-8', false ); |
|
165 | + if ($escapeStrings) { |
|
166 | + $content = htmlspecialchars($content, ENT_NOQUOTES, 'UTF-8', false); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Put again in place the original XLIFF tags replacing placeholders |
170 | - foreach ( $tags_placeholders as $tag => $placeholder ) { |
|
171 | - $content = str_replace( $placeholder, $tag, $content ); |
|
170 | + foreach ($tags_placeholders as $tag => $placeholder) { |
|
171 | + $content = str_replace($placeholder, $tag, $content); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $content; |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public static function removeDangerousChars( $string ) { |
|
182 | + public static function removeDangerousChars($string) { |
|
183 | 183 | // clean invalid xml entities ( characters with ascii < 32 and different from 0A, 0D and 09 |
184 | 184 | $regexpEntity = '/&#x(0[0-8BCEF]|1[0-9A-F]|7F);/u'; |
185 | 185 | |
186 | 186 | // remove binary chars in some xliff files |
187 | 187 | $regexpAscii = '/[\x{00}-\x{08}\x{0B}\x{0C}\x{0E}-\x{1F}\x{7F}]/u'; |
188 | 188 | |
189 | - $string = preg_replace( $regexpAscii, '', $string ); |
|
190 | - $string = preg_replace( $regexpEntity, '', $string ); |
|
189 | + $string = preg_replace($regexpAscii, '', $string); |
|
190 | + $string = preg_replace($regexpEntity, '', $string); |
|
191 | 191 | |
192 | - return !empty( $string ) ? $string : ""; |
|
192 | + return !empty($string) ? $string : ""; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return bool |
200 | 200 | */ |
201 | - public static function contains( $needle, $haystack ) { |
|
202 | - return strpos( $haystack, $needle ) !== false; |
|
201 | + public static function contains($needle, $haystack) { |
|
202 | + return strpos($haystack, $needle) !== false; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - public static function htmlentities( $string ) { |
|
211 | - return htmlentities( $string, ENT_NOQUOTES ); |
|
210 | + public static function htmlentities($string) { |
|
211 | + return htmlentities($string, ENT_NOQUOTES); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public static function htmlspecialchars_decode( $string, $onlyEscapedEntities = false ) { |
|
221 | - if ( false === $onlyEscapedEntities ) { |
|
222 | - return htmlspecialchars_decode( $string, ENT_NOQUOTES ); |
|
220 | + public static function htmlspecialchars_decode($string, $onlyEscapedEntities = false) { |
|
221 | + if (false === $onlyEscapedEntities) { |
|
222 | + return htmlspecialchars_decode($string, ENT_NOQUOTES); |
|
223 | 223 | } |
224 | 224 | |
225 | - return preg_replace_callback( self::$htmlEntityRegex, |
|
226 | - function ( $match ) { |
|
227 | - return self::htmlspecialchars_decode( $match[ 0 ] ); |
|
228 | - }, $string ); |
|
225 | + return preg_replace_callback(self::$htmlEntityRegex, |
|
226 | + function($match) { |
|
227 | + return self::htmlspecialchars_decode($match[0]); |
|
228 | + }, $string); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool |
242 | 242 | */ |
243 | - public static function isADoubleEscapedEntity( $str ) { |
|
244 | - return preg_match( self::$htmlEntityRegex, $str ) != 0; |
|
243 | + public static function isADoubleEscapedEntity($str) { |
|
244 | + return preg_match(self::$htmlEntityRegex, $str) != 0; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return bool |
251 | 251 | */ |
252 | - public static function isAnEscapedHTML( $str ) { |
|
253 | - return preg_match( "/\/[a-z]*>/i", $str ) != 0; |
|
252 | + public static function isAnEscapedHTML($str) { |
|
253 | + return preg_match("/\/[a-z]*>/i", $str) != 0; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public static function isAValidUuid( $uuid ) { |
|
262 | - return preg_match( '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid ) === 1; |
|
261 | + public static function isAValidUuid($uuid) { |
|
262 | + return preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid) === 1; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return array|false|string[] |
270 | 270 | */ |
271 | - public static function preg_split( $pattern, $subject ) { |
|
272 | - return preg_split( $pattern, $subject, -1, PREG_SPLIT_NO_EMPTY ); |
|
271 | + public static function preg_split($pattern, $subject) { |
|
272 | + return preg_split($pattern, $subject, -1, PREG_SPLIT_NO_EMPTY); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public static function escapeOnlyHTMLTags( $string ) { |
|
291 | - return preg_replace( '/<(.*?)>/iu', '<$1>', $string ); |
|
290 | + public static function escapeOnlyHTMLTags($string) { |
|
291 | + return preg_replace('/<(.*?)>/iu', '<$1>', $string); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return false|string |
300 | 300 | */ |
301 | - public static function lastChar( $string ) { |
|
302 | - return substr( $string, -1 ); |
|
301 | + public static function lastChar($string) { |
|
302 | + return substr($string, -1); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return int |
309 | 309 | */ |
310 | - public static function getTheNumberOfTrailingSpaces( $segment ) { |
|
310 | + public static function getTheNumberOfTrailingSpaces($segment) { |
|
311 | 311 | $number = 0; |
312 | 312 | |
313 | - return self::recursiveIncrementNumberOfTrailingSpaces( $segment, $number ); |
|
313 | + return self::recursiveIncrementNumberOfTrailingSpaces($segment, $number); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return int |
321 | 321 | */ |
322 | - private static function recursiveIncrementNumberOfTrailingSpaces( $segment, &$number ) { |
|
323 | - if ( self::lastChar( $segment ) === ' ' ) { |
|
322 | + private static function recursiveIncrementNumberOfTrailingSpaces($segment, &$number) { |
|
323 | + if (self::lastChar($segment) === ' ') { |
|
324 | 324 | $number++; |
325 | - $segment = substr( $segment, 0, -1 ); |
|
325 | + $segment = substr($segment, 0, -1); |
|
326 | 326 | |
327 | - return self::recursiveIncrementNumberOfTrailingSpaces( $segment, $number ); |
|
327 | + return self::recursiveIncrementNumberOfTrailingSpaces($segment, $number); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | return $number; |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return bool |
339 | 339 | */ |
340 | - public static function isHtmlString( $string ) { |
|
341 | - $string = stripslashes( $string ); |
|
340 | + public static function isHtmlString($string) { |
|
341 | + $string = stripslashes($string); |
|
342 | 342 | |
343 | - if ( $string === '<>' ) { |
|
343 | + if ($string === '<>') { |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
347 | - preg_match( "/<\/?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/", $string, $matches ); |
|
347 | + preg_match("/<\/?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/", $string, $matches); |
|
348 | 348 | |
349 | - return count( $matches ) !== 0; |
|
349 | + return count($matches) !== 0; |
|
350 | 350 | } |
351 | 351 | } |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array|mixed |
20 | 20 | */ |
21 | - public static function pathInfo( $path, $options = 15 ) { |
|
22 | - $rawPath = explode( DIRECTORY_SEPARATOR, $path ); |
|
21 | + public static function pathInfo($path, $options = 15) { |
|
22 | + $rawPath = explode(DIRECTORY_SEPARATOR, $path); |
|
23 | 23 | |
24 | - $basename = array_pop( $rawPath ); |
|
25 | - $dirname = implode( DIRECTORY_SEPARATOR, $rawPath ); |
|
24 | + $basename = array_pop($rawPath); |
|
25 | + $dirname = implode(DIRECTORY_SEPARATOR, $rawPath); |
|
26 | 26 | |
27 | - $explodedFileName = explode( ".", $basename ); |
|
28 | - $extension = strtolower( array_pop( $explodedFileName ) ); |
|
29 | - $filename = implode( ".", $explodedFileName ); |
|
27 | + $explodedFileName = explode(".", $basename); |
|
28 | + $extension = strtolower(array_pop($explodedFileName)); |
|
29 | + $filename = implode(".", $explodedFileName); |
|
30 | 30 | |
31 | 31 | $returnArray = []; |
32 | 32 | |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | |
40 | 40 | // foreach flag, add in $return_array the corresponding field, |
41 | 41 | // obtained by variable name correspondence |
42 | - foreach ( $flagMap as $field => $i ) { |
|
42 | + foreach ($flagMap as $field => $i) { |
|
43 | 43 | //binary AND |
44 | - if ( ( $options & $i ) > 0 ) { |
|
44 | + if (($options & $i) > 0) { |
|
45 | 45 | //variable substitution: $field can be one between 'dirname', 'basename', 'extension', 'filename' |
46 | 46 | // $$field gets the value of the variable named $field |
47 | - $returnArray[ $field ] = $$field; |
|
47 | + $returnArray[$field] = $$field; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - if ( count( $returnArray ) == 1 ) { |
|
52 | - $returnArray = array_pop( $returnArray ); |
|
51 | + if (count($returnArray) == 1) { |
|
52 | + $returnArray = array_pop($returnArray); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return $returnArray; |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return false|string |
62 | 62 | */ |
63 | - public static function getExtension( $path ) { |
|
64 | - $pathInfo = self::pathInfo( $path ); |
|
63 | + public static function getExtension($path) { |
|
64 | + $pathInfo = self::pathInfo($path); |
|
65 | 65 | |
66 | - if ( empty( $pathInfo ) ) { |
|
66 | + if (empty($pathInfo)) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
70 | - return strtolower( $pathInfo[ 'extension' ] ); |
|
70 | + return strtolower($pathInfo['extension']); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public static function isXliff( $path ) { |
|
79 | - $extension = self::getExtension( $path ); |
|
78 | + public static function isXliff($path) { |
|
79 | + $extension = self::getExtension($path); |
|
80 | 80 | |
81 | - if ( !$extension ) { |
|
81 | + if (!$extension) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | - switch ( $extension ) { |
|
85 | + switch ($extension) { |
|
86 | 86 | case 'xliff': |
87 | 87 | case 'sdlxliff': |
88 | 88 | case 'tmx': |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return bool|string |
100 | 100 | */ |
101 | - public static function getMemoryFileType( $path ) { |
|
102 | - $pathInfo = self::pathInfo( $path ); |
|
101 | + public static function getMemoryFileType($path) { |
|
102 | + $pathInfo = self::pathInfo($path); |
|
103 | 103 | |
104 | - if ( empty( $pathInfo ) ) { |
|
104 | + if (empty($pathInfo)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - switch ( strtolower( $pathInfo[ 'extension' ] ) ) { |
|
108 | + switch (strtolower($pathInfo['extension'])) { |
|
109 | 109 | case 'tmx': |
110 | 110 | return 'tmx'; |
111 | 111 | case 'g': |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - public static function isTMXFile( $path ) { |
|
124 | - return self::getMemoryFileType( $path ) === 'tmx'; |
|
123 | + public static function isTMXFile($path) { |
|
124 | + return self::getMemoryFileType($path) === 'tmx'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - public static function isGlossaryFile( $path ) { |
|
133 | - return self::getMemoryFileType( $path ) === 'glossary'; |
|
132 | + public static function isGlossaryFile($path) { |
|
133 | + return self::getMemoryFileType($path) === 'glossary'; |
|
134 | 134 | } |
135 | 135 | } |
@@ -7404,7 +7404,7 @@ |
||
7404 | 7404 | ' |
@@ -7402,7 +7402,7 @@ |
||
7402 | 7402 | ' |