Mercurial > hg > isophonics-drupal-site
comparison vendor/squizlabs/php_codesniffer/src/Util/Common.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
224 * @return string | 224 * @return string |
225 */ | 225 */ |
226 public static function prepareForOutput($content, $exclude=[]) | 226 public static function prepareForOutput($content, $exclude=[]) |
227 { | 227 { |
228 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { | 228 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
229 if (in_array("\r", $exclude) === false) { | 229 if (in_array("\r", $exclude, true) === false) { |
230 $content = str_replace("\r", '\r', $content); | 230 $content = str_replace("\r", '\r', $content); |
231 } | 231 } |
232 | 232 |
233 if (in_array("\n", $exclude) === false) { | 233 if (in_array("\n", $exclude, true) === false) { |
234 $content = str_replace("\n", '\n', $content); | 234 $content = str_replace("\n", '\n', $content); |
235 } | 235 } |
236 | 236 |
237 if (in_array("\t", $exclude) === false) { | 237 if (in_array("\t", $exclude, true) === false) { |
238 $content = str_replace("\t", '\t', $content); | 238 $content = str_replace("\t", '\t', $content); |
239 } | 239 } |
240 } else { | 240 } else { |
241 if (in_array("\r", $exclude) === false) { | 241 if (in_array("\r", $exclude, true) === false) { |
242 $content = str_replace("\r", "\033[30;1m\\r\033[0m", $content); | 242 $content = str_replace("\r", "\033[30;1m\\r\033[0m", $content); |
243 } | 243 } |
244 | 244 |
245 if (in_array("\n", $exclude) === false) { | 245 if (in_array("\n", $exclude, true) === false) { |
246 $content = str_replace("\n", "\033[30;1m\\n\033[0m", $content); | 246 $content = str_replace("\n", "\033[30;1m\\n\033[0m", $content); |
247 } | 247 } |
248 | 248 |
249 if (in_array("\t", $exclude) === false) { | 249 if (in_array("\t", $exclude, true) === false) { |
250 $content = str_replace("\t", "\033[30;1m\\t\033[0m", $content); | 250 $content = str_replace("\t", "\033[30;1m\\t\033[0m", $content); |
251 } | 251 } |
252 | 252 |
253 if (in_array(' ', $exclude) === false) { | 253 if (in_array(' ', $exclude, true) === false) { |
254 $content = str_replace(' ', "\033[30;1m·\033[0m", $content); | 254 $content = str_replace(' ', "\033[30;1m·\033[0m", $content); |
255 } | 255 } |
256 }//end if | 256 }//end if |
257 | 257 |
258 return $content; | 258 return $content; |
382 | 382 |
383 }//end isUnderscoreName() | 383 }//end isUnderscoreName() |
384 | 384 |
385 | 385 |
386 /** | 386 /** |
387 * Returns a valid variable type for param/var tag. | 387 * Returns a valid variable type for param/var tags. |
388 * | 388 * |
389 * If type is not one of the standard type, it must be a custom type. | 389 * If type is not one of the standard types, it must be a custom type. |
390 * Returns the correct type name suggestion if type name is invalid. | 390 * Returns the correct type name suggestion if type name is invalid. |
391 * | 391 * |
392 * @param string $varType The variable type to process. | 392 * @param string $varType The variable type to process. |
393 * | 393 * |
394 * @return string | 394 * @return string |
397 { | 397 { |
398 if ($varType === '') { | 398 if ($varType === '') { |
399 return ''; | 399 return ''; |
400 } | 400 } |
401 | 401 |
402 if (in_array($varType, self::$allowedTypes) === true) { | 402 if (in_array($varType, self::$allowedTypes, true) === true) { |
403 return $varType; | 403 return $varType; |
404 } else { | 404 } else { |
405 $lowerVarType = strtolower($varType); | 405 $lowerVarType = strtolower($varType); |
406 switch ($lowerVarType) { | 406 switch ($lowerVarType) { |
407 case 'bool': | 407 case 'bool': |
443 | 443 |
444 return "array($type1$type2)"; | 444 return "array($type1$type2)"; |
445 } else { | 445 } else { |
446 return 'array'; | 446 return 'array'; |
447 }//end if | 447 }//end if |
448 } else if (in_array($lowerVarType, self::$allowedTypes) === true) { | 448 } else if (in_array($lowerVarType, self::$allowedTypes, true) === true) { |
449 // A valid type, but not lower cased. | 449 // A valid type, but not lower cased. |
450 return $lowerVarType; | 450 return $lowerVarType; |
451 } else { | 451 } else { |
452 // Must be a custom type name. | 452 // Must be a custom type name. |
453 return $varType; | 453 return $varType; |