@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | public function copy($originFile, $targetFile, $overwriteNewerFiles = \false) |
39 | 39 | { |
40 | 40 | $originIsLocal = \stream_is_local($originFile) || 0 === \stripos($originFile, 'file://'); |
41 | - if ($originIsLocal && !\is_file($originFile)) { |
|
41 | + if ($originIsLocal && ! \is_file($originFile)) { |
|
42 | 42 | throw new FileNotFoundException(\sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile); |
43 | 43 | } |
44 | 44 | $this->mkdir(\dirname($targetFile)); |
45 | 45 | $doCopy = \true; |
46 | - if (!$overwriteNewerFiles && null === \parse_url($originFile, \PHP_URL_HOST) && \is_file($targetFile)) { |
|
46 | + if ( ! $overwriteNewerFiles && null === \parse_url($originFile, \PHP_URL_HOST) && \is_file($targetFile)) { |
|
47 | 47 | $doCopy = \filemtime($originFile) > \filemtime($targetFile); |
48 | 48 | } |
49 | 49 | if ($doCopy) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | \fclose($source); |
60 | 60 | \fclose($target); |
61 | 61 | unset($source, $target); |
62 | - if (!\is_file($targetFile)) { |
|
62 | + if ( ! \is_file($targetFile)) { |
|
63 | 63 | throw new IOException(\sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile); |
64 | 64 | } |
65 | 65 | if ($originIsLocal) { |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | if (\is_dir($dir)) { |
86 | 86 | continue; |
87 | 87 | } |
88 | - if (!self::box('mkdir', $dir, $mode, \true)) { |
|
89 | - if (!\is_dir($dir)) { |
|
88 | + if ( ! self::box('mkdir', $dir, $mode, \true)) { |
|
89 | + if ( ! \is_dir($dir)) { |
|
90 | 90 | // The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one |
91 | 91 | if (self::$lastError) { |
92 | - throw new IOException(\sprintf('Failed to create "%s": ', $dir) . self::$lastError, 0, null, $dir); |
|
92 | + throw new IOException(\sprintf('Failed to create "%s": ', $dir).self::$lastError, 0, null, $dir); |
|
93 | 93 | } |
94 | 94 | throw new IOException(\sprintf('Failed to create "%s".', $dir), 0, null, $dir); |
95 | 95 | } |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function exists($files) |
107 | 107 | { |
108 | - $maxPathLength = \PHP_MAXPATHLEN - 2; |
|
108 | + $maxPathLength = \PHP_MAXPATHLEN -2; |
|
109 | 109 | foreach ($this->toIterable($files) as $file) { |
110 | 110 | if (\strlen($file) > $maxPathLength) { |
111 | 111 | throw new IOException(\sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file); |
112 | 112 | } |
113 | - if (!\file_exists($file)) { |
|
113 | + if ( ! \file_exists($file)) { |
|
114 | 114 | return \false; |
115 | 115 | } |
116 | 116 | } |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | { |
146 | 146 | if ($files instanceof \Traversable) { |
147 | 147 | $files = \iterator_to_array($files, \false); |
148 | - } elseif (!\is_array($files)) { |
|
148 | + } elseif ( ! \is_array($files)) { |
|
149 | 149 | $files = [$files]; |
150 | 150 | } |
151 | 151 | $files = \array_reverse($files); |
152 | 152 | foreach ($files as $file) { |
153 | 153 | if (\is_link($file)) { |
154 | 154 | // See https://bugs.php.net/52176 |
155 | - if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && \file_exists($file)) { |
|
156 | - throw new IOException(\sprintf('Failed to remove symlink "%s": ', $file) . self::$lastError); |
|
155 | + if ( ! (self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && \file_exists($file)) { |
|
156 | + throw new IOException(\sprintf('Failed to remove symlink "%s": ', $file).self::$lastError); |
|
157 | 157 | } |
158 | 158 | } elseif (\is_dir($file)) { |
159 | 159 | $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS)); |
160 | - if (!self::box('rmdir', $file) && \file_exists($file)) { |
|
161 | - throw new IOException(\sprintf('Failed to remove directory "%s": ', $file) . self::$lastError); |
|
160 | + if ( ! self::box('rmdir', $file) && \file_exists($file)) { |
|
161 | + throw new IOException(\sprintf('Failed to remove directory "%s": ', $file).self::$lastError); |
|
162 | 162 | } |
163 | - } elseif (!self::box('unlink', $file) && (\str_contains(self::$lastError, 'Permission denied') || \file_exists($file))) { |
|
164 | - throw new IOException(\sprintf('Failed to remove file "%s": ', $file) . self::$lastError); |
|
163 | + } elseif ( ! self::box('unlink', $file) && (\str_contains(self::$lastError, 'Permission denied') || \file_exists($file))) { |
|
164 | + throw new IOException(\sprintf('Failed to remove file "%s": ', $file).self::$lastError); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && \true !== @\chmod($file, $mode & ~$umask)) { |
182 | 182 | throw new IOException(\sprintf('Failed to chmod file "%s".', $file), 0, null, $file); |
183 | 183 | } |
184 | - if ($recursive && \is_dir($file) && !\is_link($file)) { |
|
184 | + if ($recursive && \is_dir($file) && ! \is_link($file)) { |
|
185 | 185 | $this->chmod(new \FilesystemIterator($file), $mode, $umask, \true); |
186 | 186 | } |
187 | 187 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public function chown($files, $user, $recursive = \false) |
199 | 199 | { |
200 | 200 | foreach ($this->toIterable($files) as $file) { |
201 | - if ($recursive && \is_dir($file) && !\is_link($file)) { |
|
201 | + if ($recursive && \is_dir($file) && ! \is_link($file)) { |
|
202 | 202 | $this->chown(new \FilesystemIterator($file), $user, \true); |
203 | 203 | } |
204 | 204 | if (\is_link($file) && \function_exists('lchown')) { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function chgrp($files, $group, $recursive = \false) |
225 | 225 | { |
226 | 226 | foreach ($this->toIterable($files) as $file) { |
227 | - if ($recursive && \is_dir($file) && !\is_link($file)) { |
|
227 | + if ($recursive && \is_dir($file) && ! \is_link($file)) { |
|
228 | 228 | $this->chgrp(new \FilesystemIterator($file), $group, \true); |
229 | 229 | } |
230 | 230 | if (\is_link($file) && \function_exists('lchgrp')) { |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function rename($origin, $target, $overwrite = \false) |
252 | 252 | { |
253 | 253 | // we check that target does not exist |
254 | - if (!$overwrite && $this->isReadable($target)) { |
|
254 | + if ( ! $overwrite && $this->isReadable($target)) { |
|
255 | 255 | throw new IOException(\sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); |
256 | 256 | } |
257 | 257 | if (\true !== @\rename($origin, $target)) { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | private function isReadable(string $filename) : bool |
273 | 273 | { |
274 | - $maxPathLength = \PHP_MAXPATHLEN - 2; |
|
274 | + $maxPathLength = \PHP_MAXPATHLEN -2; |
|
275 | 275 | if (\strlen($filename) > $maxPathLength) { |
276 | 276 | throw new IOException(\sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename); |
277 | 277 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | $this->remove($targetDir); |
306 | 306 | } |
307 | - if (!self::box('symlink', $originDir, $targetDir)) { |
|
307 | + if ( ! self::box('symlink', $originDir, $targetDir)) { |
|
308 | 308 | $this->linkException($originDir, $targetDir, 'symbolic'); |
309 | 309 | } |
310 | 310 | } |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | public function hardlink($originFile, $targetFiles) |
321 | 321 | { |
322 | 322 | self::assertFunctionExists('link'); |
323 | - if (!$this->exists($originFile)) { |
|
323 | + if ( ! $this->exists($originFile)) { |
|
324 | 324 | throw new FileNotFoundException(null, 0, null, $originFile); |
325 | 325 | } |
326 | - if (!\is_file($originFile)) { |
|
326 | + if ( ! \is_file($originFile)) { |
|
327 | 327 | throw new FileNotFoundException(\sprintf('Origin file "%s" is not a file.', $originFile)); |
328 | 328 | } |
329 | 329 | foreach ($this->toIterable($targetFiles) as $targetFile) { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | $this->remove($targetFile); |
335 | 335 | } |
336 | - if (!self::box('link', $originFile, $targetFile)) { |
|
336 | + if ( ! self::box('link', $originFile, $targetFile)) { |
|
337 | 337 | $this->linkException($originFile, $targetFile, 'hard'); |
338 | 338 | } |
339 | 339 | } |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function readlink($path, $canonicalize = \false) |
370 | 370 | { |
371 | - if (!$canonicalize && !\is_link($path)) { |
|
371 | + if ( ! $canonicalize && ! \is_link($path)) { |
|
372 | 372 | return null; |
373 | 373 | } |
374 | 374 | if ($canonicalize) { |
375 | - if (!$this->exists($path)) { |
|
375 | + if ( ! $this->exists($path)) { |
|
376 | 376 | return null; |
377 | 377 | } |
378 | 378 | if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) { |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function makePathRelative($endPath, $startPath) |
397 | 397 | { |
398 | - if (!$this->isAbsolutePath($startPath)) { |
|
398 | + if ( ! $this->isAbsolutePath($startPath)) { |
|
399 | 399 | throw new InvalidArgumentException(\sprintf('The start path "%s" is not absolute.', $startPath)); |
400 | 400 | } |
401 | - if (!$this->isAbsolutePath($endPath)) { |
|
401 | + if ( ! $this->isAbsolutePath($endPath)) { |
|
402 | 402 | throw new InvalidArgumentException(\sprintf('The end path "%s" is not absolute.', $endPath)); |
403 | 403 | } |
404 | 404 | // Normalize separators on Windows |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | $endPath = \str_replace('\\', '/', $endPath); |
407 | 407 | $startPath = \str_replace('\\', '/', $startPath); |
408 | 408 | } |
409 | - $splitDriveLetter = function ($path) { |
|
409 | + $splitDriveLetter = function($path) { |
|
410 | 410 | return \strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && \ctype_alpha($path[0]) ? [\substr($path, 2), \strtoupper($path[0])] : [$path, null]; |
411 | 411 | }; |
412 | - $splitPath = function ($path) { |
|
412 | + $splitPath = function($path) { |
|
413 | 413 | $result = []; |
414 | 414 | foreach (\explode('/', \trim($path, '/')) as $segment) { |
415 | 415 | if ('..' === $segment) { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $endPathArr = $splitPath($endPath); |
427 | 427 | if ($endDriveLetter && $startDriveLetter && $endDriveLetter != $startDriveLetter) { |
428 | 428 | // End path is on another drive, so no relative path exists |
429 | - return $endDriveLetter . ':/' . ($endPathArr ? \implode('/', $endPathArr) . '/' : ''); |
|
429 | + return $endDriveLetter.':/'.($endPathArr ? \implode('/', $endPathArr).'/' : ''); |
|
430 | 430 | } |
431 | 431 | // Find for which directory the common path stops |
432 | 432 | $index = 0; |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | $traverser = \str_repeat('../', $depth); |
444 | 444 | $endPathRemainder = \implode('/', \array_slice($endPathArr, $index)); |
445 | 445 | // Construct $endPath from traversing to the common path, then to the remaining $endPath |
446 | - $relativePath = $traverser . ('' !== $endPathRemainder ? $endPathRemainder . '/' : ''); |
|
446 | + $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : ''); |
|
447 | 447 | return '' === $relativePath ? './' : $relativePath; |
448 | 448 | } |
449 | 449 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $targetDir = \rtrim($targetDir, '/\\'); |
471 | 471 | $originDir = \rtrim($originDir, '/\\'); |
472 | 472 | $originDirLen = \strlen($originDir); |
473 | - if (!$this->exists($originDir)) { |
|
473 | + if ( ! $this->exists($originDir)) { |
|
474 | 474 | throw new IOException(\sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir); |
475 | 475 | } |
476 | 476 | // Iterate in destination folder to remove obsolete entries |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | } |
483 | 483 | $targetDirLen = \strlen($targetDir); |
484 | 484 | foreach ($deleteIterator as $file) { |
485 | - $origin = $originDir . \substr($file->getPathname(), $targetDirLen); |
|
486 | - if (!$this->exists($origin)) { |
|
485 | + $origin = $originDir.\substr($file->getPathname(), $targetDirLen); |
|
486 | + if ( ! $this->exists($origin)) { |
|
487 | 487 | $this->remove($file); |
488 | 488 | } |
489 | 489 | } |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) { |
500 | 500 | continue; |
501 | 501 | } |
502 | - $target = $targetDir . \substr($file->getPathname(), $originDirLen); |
|
502 | + $target = $targetDir.\substr($file->getPathname(), $originDirLen); |
|
503 | 503 | $filesCreatedWhileMirroring[$target] = \true; |
504 | - if (!$copyOnWindows && \is_link($file)) { |
|
504 | + if ( ! $copyOnWindows && \is_link($file)) { |
|
505 | 505 | $this->symlink($file->getLinkTarget(), $target); |
506 | 506 | } elseif (\is_dir($file)) { |
507 | 507 | $this->mkdir($target); |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | // If tempnam failed or no scheme return the filename otherwise prepend the scheme |
545 | 545 | if (\false !== $tmpFile) { |
546 | 546 | if (null !== $scheme && 'gs' !== $scheme) { |
547 | - return $scheme . '://' . $tmpFile; |
|
547 | + return $scheme.'://'.$tmpFile; |
|
548 | 548 | } |
549 | 549 | return $tmpFile; |
550 | 550 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | // Loop until we create a valid temp file or have reached 10 attempts |
554 | 554 | for ($i = 0; $i < 10; ++$i) { |
555 | 555 | // Create a unique filename |
556 | - $tmpFile = $dir . '/' . $prefix . \uniqid(\mt_rand(), \true); |
|
556 | + $tmpFile = $dir.'/'.$prefix.\uniqid(\mt_rand(), \true); |
|
557 | 557 | // Use fopen instead of file_exists as some streams do not support stat |
558 | 558 | // Use mode 'x+' to atomically check existence and create to avoid a TOCTOU vulnerability |
559 | 559 | $handle = @\fopen($tmpFile, 'x+'); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | @\trigger_error(\sprintf('Calling "%s()" with an array in the $content argument is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED); |
582 | 582 | } |
583 | 583 | $dir = \dirname($filename); |
584 | - if (!\is_dir($dir)) { |
|
584 | + if ( ! \is_dir($dir)) { |
|
585 | 585 | $this->mkdir($dir); |
586 | 586 | } |
587 | 587 | // Will create a temp file with 0600 access rights |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | @\trigger_error(\sprintf('Calling "%s()" with an array in the $content argument is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED); |
614 | 614 | } |
615 | 615 | $dir = \dirname($filename); |
616 | - if (!\is_dir($dir)) { |
|
616 | + if ( ! \is_dir($dir)) { |
|
617 | 617 | $this->mkdir($dir); |
618 | 618 | } |
619 | 619 | if (\false === @\file_put_contents($filename, $content, \FILE_APPEND)) { |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | } |
635 | 635 | private static function assertFunctionExists(string $func) : void |
636 | 636 | { |
637 | - if (!\function_exists($func)) { |
|
637 | + if ( ! \function_exists($func)) { |
|
638 | 638 | throw new IOException(\sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func)); |
639 | 639 | } |
640 | 640 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | { |
648 | 648 | self::assertFunctionExists($func); |
649 | 649 | self::$lastError = null; |
650 | - \set_error_handler(__CLASS__ . '::handleError'); |
|
650 | + \set_error_handler(__CLASS__.'::handleError'); |
|
651 | 651 | try { |
652 | 652 | $result = $func(...$args); |
653 | 653 | \restore_error_handler(); |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public static function requiresDoubleQuoting($value) |
39 | 39 | { |
40 | - return 0 < \preg_match('/' . self::REGEX_CHARACTER_TO_ESCAPE . '/u', $value); |
|
40 | + return 0 < \preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value); |
|
41 | 41 | } |
42 | 42 | /** |
43 | 43 | * Escapes and surrounds a PHP value with double quotes. |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function unescapeDoubleQuotedString($value) |
47 | 47 | { |
48 | - $callback = function ($match) { |
|
48 | + $callback = function($match) { |
|
49 | 49 | return $this->unescapeCharacter($match[0]); |
50 | 50 | }; |
51 | 51 | // evaluate the string |
52 | - return \preg_replace_callback('/' . self::REGEX_ESCAPED_CHARACTER . '/u', $callback, $value); |
|
52 | + return \preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value); |
|
53 | 53 | } |
54 | 54 | /** |
55 | 55 | * Unescapes a character that was found in a double-quoted string. |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | return \chr($c); |
125 | 125 | } |
126 | 126 | if (0x800 > $c) { |
127 | - return \chr(0xc0 | $c >> 6) . \chr(0x80 | $c & 0x3f); |
|
127 | + return \chr(0xc0 | $c >> 6).\chr(0x80 | $c & 0x3f); |
|
128 | 128 | } |
129 | 129 | if (0x10000 > $c) { |
130 | - return \chr(0xe0 | $c >> 12) . \chr(0x80 | $c >> 6 & 0x3f) . \chr(0x80 | $c & 0x3f); |
|
130 | + return \chr(0xe0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3f).\chr(0x80 | $c & 0x3f); |
|
131 | 131 | } |
132 | - return \chr(0xf0 | $c >> 18) . \chr(0x80 | $c >> 12 & 0x3f) . \chr(0x80 | $c >> 6 & 0x3f) . \chr(0x80 | $c & 0x3f); |
|
132 | + return \chr(0xf0 | $c >> 18).\chr(0x80 | $c >> 12 & 0x3f).\chr(0x80 | $c >> 6 & 0x3f).\chr(0x80 | $c & 0x3f); |
|
133 | 133 | } |
134 | 134 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $flags = 0; |
67 | 67 | } |
68 | 68 | } |
69 | - if (\func_num_args() >= 3 && !\is_array($references)) { |
|
69 | + if (\func_num_args() >= 3 && ! \is_array($references)) { |
|
70 | 70 | @\trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', \E_USER_DEPRECATED); |
71 | 71 | if ($references) { |
72 | 72 | $flags |= Yaml::PARSE_OBJECT; |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | return $value->format('c'); |
158 | 158 | case \is_object($value): |
159 | 159 | if ($value instanceof TaggedValue) { |
160 | - return '!' . $value->getTag() . ' ' . self::dump($value->getValue(), $flags); |
|
160 | + return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); |
|
161 | 161 | } |
162 | 162 | if (Yaml::DUMP_OBJECT & $flags) { |
163 | - return '!php/object ' . self::dump(\serialize($value)); |
|
163 | + return '!php/object '.self::dump(\serialize($value)); |
|
164 | 164 | } |
165 | 165 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { |
166 | 166 | return self::dumpArray($value, $flags & ~Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $repr = \str_ireplace('INF', '.Inf', $repr); |
191 | 191 | } elseif (\floor($value) == $value && $repr == $value) { |
192 | 192 | // Preserve float data type since storing a whole number will result in integer value. |
193 | - $repr = '!!float ' . $repr; |
|
193 | + $repr = '!!float '.$repr; |
|
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | $repr = \is_string($value) ? "'{$value}'" : (string) $value; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | case '' == $value: |
203 | 203 | return "''"; |
204 | 204 | case self::isBinaryString($value): |
205 | - return '!!binary ' . \base64_encode($value); |
|
205 | + return '!!binary '.\base64_encode($value); |
|
206 | 206 | case Escaper::requiresDoubleQuoting($value): |
207 | 207 | return Escaper::escapeWithDoubleQuotes($value); |
208 | 208 | case Escaper::requiresSingleQuoting($value): |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | private static function dumpArray($value, $flags) |
248 | 248 | { |
249 | 249 | // array |
250 | - if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) { |
|
250 | + if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && ! self::isHash($value)) { |
|
251 | 251 | $output = []; |
252 | 252 | foreach ($value as $val) { |
253 | 253 | $output[] = self::dump($val, $flags); |
@@ -287,20 +287,20 @@ discard block |
||
287 | 287 | if ('' === $tmp) { |
288 | 288 | throw new ParseException(\sprintf('Unexpected end of line, expected one of "%s".', \implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
289 | 289 | } |
290 | - if (!\in_array($tmp[0], $delimiters)) { |
|
290 | + if ( ! \in_array($tmp[0], $delimiters)) { |
|
291 | 291 | throw new ParseException(\sprintf('Unexpected characters (%s).', \substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
292 | 292 | } |
293 | 293 | } |
294 | 294 | } else { |
295 | 295 | // "normal" string |
296 | - if (!$delimiters) { |
|
296 | + if ( ! $delimiters) { |
|
297 | 297 | $output = \substr($scalar, $i); |
298 | 298 | $i += \strlen($output); |
299 | 299 | // remove comments |
300 | 300 | if (Parser::preg_match('/[ \\t]+#/', $output, $match, \PREG_OFFSET_CAPTURE)) { |
301 | 301 | $output = \substr($output, 0, $match[0][1]); |
302 | 302 | } |
303 | - } elseif (Parser::preg_match('/^(.' . ($legacyOmittedKeySupport ? '+' : '*') . '?)(' . \implode('|', $delimiters) . ')/', \substr($scalar, $i), $match)) { |
|
303 | + } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.\implode('|', $delimiters).')/', \substr($scalar, $i), $match)) { |
|
304 | 304 | $output = $match[1]; |
305 | 305 | $i += \strlen($output); |
306 | 306 | } else { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private static function parseQuotedScalar($scalar, &$i) |
333 | 333 | { |
334 | - if (!Parser::preg_match('/' . self::REGEX_QUOTED_STRING . '/Au', \substr($scalar, $i), $match)) { |
|
334 | + if ( ! Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', \substr($scalar, $i), $match)) { |
|
335 | 335 | throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', \substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
336 | 336 | } |
337 | 337 | $output = \substr($match[0], 1, \strlen($match[0]) - 2); |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | $isQuoted = \in_array($sequence[$i], ['"', "'"]); |
385 | 385 | $value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references); |
386 | 386 | // the value can be an array if a reference has been resolved to an array var |
387 | - if (\is_string($value) && !$isQuoted && \false !== \strpos($value, ': ')) { |
|
387 | + if (\is_string($value) && ! $isQuoted && \false !== \strpos($value, ': ')) { |
|
388 | 388 | // embedded mapping? |
389 | 389 | try { |
390 | 390 | $pos = 0; |
391 | - $value = self::parseMapping('{' . $value . '}', $flags, $pos, $references); |
|
391 | + $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references); |
|
392 | 392 | } catch (\InvalidArgumentException $e) { |
393 | 393 | // no, it's not |
394 | 394 | } |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | if (':' === $key) { |
453 | 453 | @\trigger_error(self::getDeprecationMessage('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.'), \E_USER_DEPRECATED); |
454 | 454 | } |
455 | - if (!$isKeyQuoted) { |
|
455 | + if ( ! $isKeyQuoted) { |
|
456 | 456 | $evaluatedKey = self::evaluateScalar($key, $flags, $references); |
457 | - if ('' !== $key && $evaluatedKey !== $key && !\is_string($evaluatedKey) && !\is_int($evaluatedKey)) { |
|
457 | + if ('' !== $key && $evaluatedKey !== $key && ! \is_string($evaluatedKey) && ! \is_int($evaluatedKey)) { |
|
458 | 458 | @\trigger_error(self::getDeprecationMessage('Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \\Symfony\\Component\\Yaml\\Exception\\ParseException in 4.0. Quote your evaluable mapping keys instead.'), \E_USER_DEPRECATED); |
459 | 459 | } |
460 | 460 | } |
461 | - if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}'], \true))) { |
|
461 | + if (':' !== $key && ! $isKeyQuoted && ( ! isset($mapping[$i + 1]) || ! \in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}'], \true))) { |
|
462 | 462 | @\trigger_error(self::getDeprecationMessage('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0.'), \E_USER_DEPRECATED); |
463 | 463 | } |
464 | 464 | if ('<<' === $key) { |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | foreach ($value as $parsedValue) { |
483 | 483 | $output += $parsedValue; |
484 | 484 | } |
485 | - } elseif ($allowOverwrite || !isset($output[$key])) { |
|
485 | + } elseif ($allowOverwrite || ! isset($output[$key])) { |
|
486 | 486 | if (null !== $tag) { |
487 | 487 | $output[$key] = new TaggedValue($tag, $value); |
488 | 488 | } else { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | // But overwriting is allowed when a merge node is used in current block. |
502 | 502 | if ('<<' === $key) { |
503 | 503 | $output += $value; |
504 | - } elseif ($allowOverwrite || !isset($output[$key])) { |
|
504 | + } elseif ($allowOverwrite || ! isset($output[$key])) { |
|
505 | 505 | if (null !== $tag) { |
506 | 506 | $output[$key] = new TaggedValue($tag, $value); |
507 | 507 | } else { |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | // But overwriting is allowed when a merge node is used in current block. |
520 | 520 | if ('<<' === $key) { |
521 | 521 | $output += $value; |
522 | - } elseif ($allowOverwrite || !isset($output[$key])) { |
|
522 | + } elseif ($allowOverwrite || ! isset($output[$key])) { |
|
523 | 523 | if (null !== $tag) { |
524 | 524 | $output[$key] = new TaggedValue($tag, $value); |
525 | 525 | } else { |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | if (\false === $value || '' === $value) { |
562 | 562 | throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename); |
563 | 563 | } |
564 | - if (!\array_key_exists($value, $references)) { |
|
564 | + if ( ! \array_key_exists($value, $references)) { |
|
565 | 565 | throw new ParseException(\sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename); |
566 | 566 | } |
567 | 567 | return $references[$value]; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | return null; |
606 | 606 | case 0 === \strpos($scalar, '!php/object'): |
607 | 607 | if (self::$objectSupport) { |
608 | - if (!isset($scalar[12])) { |
|
608 | + if ( ! isset($scalar[12])) { |
|
609 | 609 | return \false; |
610 | 610 | } |
611 | 611 | return \unserialize(self::parseScalar(\substr($scalar, 12))); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | return null; |
629 | 629 | case 0 === \strpos($scalar, '!php/const'): |
630 | 630 | if (self::$constantSupport) { |
631 | - if (!isset($scalar[11])) { |
|
631 | + if ( ! isset($scalar[11])) { |
|
632 | 632 | return ''; |
633 | 633 | } |
634 | 634 | $i = 0; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | case \is_numeric($scalar): |
671 | 671 | case Parser::preg_match(self::getHexRegex(), $scalar): |
672 | 672 | $scalar = \str_replace('_', '', $scalar); |
673 | - return '0x' === $scalar[0] . $scalar[1] ? \hexdec($scalar) : (float) $scalar; |
|
673 | + return '0x' === $scalar[0].$scalar[1] ? \hexdec($scalar) : (float) $scalar; |
|
674 | 674 | case '.inf' === $scalarLower: |
675 | 675 | case '.nan' === $scalarLower: |
676 | 676 | return -\log(0); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $nextOffset = $i + $tagLength + 1; |
714 | 714 | $nextOffset += \strspn($value, ' ', $nextOffset); |
715 | 715 | // Is followed by a scalar |
716 | - if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], \true)) && 'tagged' !== $tag) { |
|
716 | + if (( ! isset($value[$nextOffset]) || ! \in_array($value[$nextOffset], ['[', '{'], \true)) && 'tagged' !== $tag) { |
|
717 | 717 | // Manage non-whitelisted scalars in {@link self::evaluateScalar()} |
718 | 718 | return null; |
719 | 719 | } |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | if (0 !== \strlen($parsedBinaryData) % 4) { |
741 | 741 | throw new ParseException(\sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
742 | 742 | } |
743 | - if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) { |
|
743 | + if ( ! Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) { |
|
744 | 744 | throw new ParseException(\sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); |
745 | 745 | } |
746 | 746 | return \base64_decode($parsedBinaryData, \true); |
747 | 747 | } |
748 | 748 | private static function isBinaryString($value) |
749 | 749 | { |
750 | - return !\preg_match('//u', $value) || \preg_match('/[^\\x00\\x07-\\x0d\\x1B\\x20-\\xff]/', $value); |
|
750 | + return ! \preg_match('//u', $value) || \preg_match('/[^\\x00\\x07-\\x0d\\x1B\\x20-\\xff]/', $value); |
|
751 | 751 | } |
752 | 752 | /** |
753 | 753 | * Gets a regex that matches a YAML date. |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | { |
787 | 787 | $message = \rtrim($message, '.'); |
788 | 788 | if (null !== self::$parsedFilename) { |
789 | - $message .= ' in ' . self::$parsedFilename; |
|
789 | + $message .= ' in '.self::$parsedFilename; |
|
790 | 790 | } |
791 | 791 | if (-1 !== self::$parsedLineNumber) { |
792 | - $message .= ' on line ' . (self::$parsedLineNumber + 1); |
|
792 | + $message .= ' on line '.(self::$parsedLineNumber + 1); |
|
793 | 793 | } |
794 | - return $message . '.'; |
|
794 | + return $message.'.'; |
|
795 | 795 | } |
796 | 796 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function parseFile($filename, $flags = 0) |
60 | 60 | { |
61 | - if (!\is_file($filename)) { |
|
61 | + if ( ! \is_file($filename)) { |
|
62 | 62 | throw new ParseException(\sprintf('File "%s" does not exist.', $filename)); |
63 | 63 | } |
64 | - if (!\is_readable($filename)) { |
|
64 | + if ( ! \is_readable($filename)) { |
|
65 | 65 | throw new ParseException(\sprintf('File "%s" cannot be read.', $filename)); |
66 | 66 | } |
67 | 67 | $this->filename = $filename; |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | if (null === $this->totalNumberOfLines) { |
147 | 147 | $this->totalNumberOfLines = \count($this->lines); |
148 | 148 | } |
149 | - if (!$this->moveToNextLine()) { |
|
149 | + if ( ! $this->moveToNextLine()) { |
|
150 | 150 | return null; |
151 | 151 | } |
152 | 152 | $data = []; |
153 | 153 | $context = null; |
154 | 154 | $allowOverwrite = \false; |
155 | 155 | while ($this->isCurrentLineEmpty()) { |
156 | - if (!$this->moveToNextLine()) { |
|
156 | + if ( ! $this->moveToNextLine()) { |
|
157 | 157 | return null; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | // Resolves the tag and returns if end of the document |
161 | - if (null !== ($tag = $this->getLineTag($this->currentLine, $flags, \false)) && !$this->moveToNextLine()) { |
|
161 | + if (null !== ($tag = $this->getLineTag($this->currentLine, $flags, \false)) && ! $this->moveToNextLine()) { |
|
162 | 162 | return new TaggedValue($tag, ''); |
163 | 163 | } |
164 | 164 | do { |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | @\trigger_error($this->getDeprecationMessage('Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \\Symfony\\Component\\Yaml\\Exception\\ParseException in 4.0.'), \E_USER_DEPRECATED); |
186 | 186 | } |
187 | 187 | // array |
188 | - if (!isset($values['value']) || '' == \trim($values['value'], ' ') || 0 === \strpos(\ltrim($values['value'], ' '), '#')) { |
|
188 | + if ( ! isset($values['value']) || '' == \trim($values['value'], ' ') || 0 === \strpos(\ltrim($values['value'], ' '), '#')) { |
|
189 | 189 | $data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, \true), $flags); |
190 | 190 | } elseif (null !== ($subTag = $this->getLineTag(\ltrim($values['value'], ' '), $flags))) { |
191 | 191 | $data[] = new TaggedValue($subTag, $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, \true), $flags)); |
192 | 192 | } else { |
193 | - if (isset($values['leadspaces']) && ('!' === $values['value'][0] || self::preg_match('#^(?P<key>' . Inline::REGEX_QUOTED_STRING . '|[^ \'"\\{\\[].*?) *\\:(\\s+(?P<value>.+?))?\\s*$#u', $this->trimTag($values['value']), $matches))) { |
|
193 | + if (isset($values['leadspaces']) && ('!' === $values['value'][0] || self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\\{\\[].*?) *\\:(\\s+(?P<value>.+?))?\\s*$#u', $this->trimTag($values['value']), $matches))) { |
|
194 | 194 | // this is a compact notation element, add to next block and parse |
195 | 195 | $block = $values['value']; |
196 | 196 | if ($this->isNextLineIndented()) { |
197 | - $block .= "\n" . $this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); |
|
197 | + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); |
|
198 | 198 | } |
199 | 199 | $data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags); |
200 | 200 | } else { |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | $this->refs[$isRef] = \end($data); |
206 | 206 | \array_pop($this->refsBeingParsed); |
207 | 207 | } |
208 | - } elseif (self::preg_match('#^(?P<key>(?:![^\\s]++\\s++)?(?:' . Inline::REGEX_QUOTED_STRING . '|(?:!?!php/const:)?[^ \'"\\[\\{!].*?)) *\\:(\\s++(?P<value>.+))?$#u', \rtrim($this->currentLine), $values) && (\false === \strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))) { |
|
208 | + } elseif (self::preg_match('#^(?P<key>(?:![^\\s]++\\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\\[\\{!].*?)) *\\:(\\s++(?P<value>.+))?$#u', \rtrim($this->currentLine), $values) && (\false === \strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))) { |
|
209 | 209 | if ($context && 'sequence' == $context) { |
210 | 210 | throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename); |
211 | 211 | } |
212 | 212 | $context = 'mapping'; |
213 | 213 | try { |
214 | 214 | $i = 0; |
215 | - $evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS & $flags); |
|
215 | + $evaluateKey = ! (Yaml::PARSE_KEYS_AS_STRINGS & $flags); |
|
216 | 216 | // constants in key will be evaluated anyway |
217 | 217 | if (isset($values['key'][0]) && '!' === $values['key'][0] && Yaml::PARSE_CONSTANT & $flags) { |
218 | 218 | $evaluateKey = \true; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $e->setSnippet($this->currentLine); |
224 | 224 | throw $e; |
225 | 225 | } |
226 | - if (!\is_string($key) && !\is_int($key)) { |
|
226 | + if ( ! \is_string($key) && ! \is_int($key)) { |
|
227 | 227 | $keyType = \is_numeric($key) ? 'numeric key' : 'non-string key'; |
228 | 228 | @\trigger_error($this->getDeprecationMessage(\sprintf('Implicit casting of %s to string is deprecated since Symfony 3.3 and will throw \\Symfony\\Component\\Yaml\\Exception\\ParseException in 4.0. Quote your evaluable mapping keys instead.', $keyType)), \E_USER_DEPRECATED); |
229 | 229 | } |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | if (\is_float($key)) { |
232 | 232 | $key = (string) $key; |
233 | 233 | } |
234 | - if ('<<' === $key && (!isset($values['value']) || !self::preg_match('#^&(?P<ref>[^ ]+)#u', $values['value'], $refMatches))) { |
|
234 | + if ('<<' === $key && ( ! isset($values['value']) || ! self::preg_match('#^&(?P<ref>[^ ]+)#u', $values['value'], $refMatches))) { |
|
235 | 235 | $mergeNode = \true; |
236 | 236 | $allowOverwrite = \true; |
237 | 237 | if (isset($values['value'][0]) && '*' === $values['value'][0]) { |
238 | 238 | $refName = \substr(\rtrim($values['value']), 1); |
239 | - if (!\array_key_exists($refName, $this->refs)) { |
|
239 | + if ( ! \array_key_exists($refName, $this->refs)) { |
|
240 | 240 | if (\false !== ($pos = \array_search($refName, $this->refsBeingParsed, \true))) { |
241 | 241 | throw new ParseException(\sprintf('Circular reference [%s, %s] detected for reference "%s".', \implode(', ', \array_slice($this->refsBeingParsed, $pos)), $refName, $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename); |
242 | 242 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $refValue instanceof \stdClass) { |
247 | 247 | $refValue = (array) $refValue; |
248 | 248 | } |
249 | - if (!\is_array($refValue)) { |
|
249 | + if ( ! \is_array($refValue)) { |
|
250 | 250 | throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); |
251 | 251 | } |
252 | 252 | $data += $refValue; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsed instanceof \stdClass) { |
262 | 262 | $parsed = (array) $parsed; |
263 | 263 | } |
264 | - if (!\is_array($parsed)) { |
|
264 | + if ( ! \is_array($parsed)) { |
|
265 | 265 | throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); |
266 | 266 | } |
267 | 267 | if (isset($parsed[0])) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsedItem instanceof \stdClass) { |
273 | 273 | $parsedItem = (array) $parsedItem; |
274 | 274 | } |
275 | - if (!\is_array($parsedItem)) { |
|
275 | + if ( ! \is_array($parsedItem)) { |
|
276 | 276 | throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem, $this->filename); |
277 | 277 | } |
278 | 278 | $data += $parsedItem; |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | $subTag = null; |
294 | 294 | if ($mergeNode) { |
295 | 295 | // Merge keys |
296 | - } elseif (!isset($values['value']) || '' === $values['value'] || 0 === \strpos($values['value'], '#') || null !== ($subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { |
|
296 | + } elseif ( ! isset($values['value']) || '' === $values['value'] || 0 === \strpos($values['value'], '#') || null !== ($subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { |
|
297 | 297 | // hash |
298 | 298 | // if next line is less indented or equal, then it means that the current value is null |
299 | - if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { |
|
299 | + if ( ! $this->isNextLineIndented() && ! $this->isNextLineUnIndentedCollection()) { |
|
300 | 300 | // Spec: Keys MUST be unique; first one wins. |
301 | 301 | // But overwriting is allowed when a merge node is used in current block. |
302 | - if ($allowOverwrite || !isset($data[$key])) { |
|
302 | + if ($allowOverwrite || ! isset($data[$key])) { |
|
303 | 303 | if (null !== $subTag) { |
304 | 304 | $data[$key] = new TaggedValue($subTag, ''); |
305 | 305 | } else { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $value = (array) $value; |
317 | 317 | } |
318 | 318 | $data += $value; |
319 | - } elseif ($allowOverwrite || !isset($data[$key])) { |
|
319 | + } elseif ($allowOverwrite || ! isset($data[$key])) { |
|
320 | 320 | // Spec: Keys MUST be unique; first one wins. |
321 | 321 | // But overwriting is allowed when a merge node is used in current block. |
322 | 322 | if (null !== $subTag) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $value = $this->parseValue(\rtrim($values['value']), $flags, $context); |
333 | 333 | // Spec: Keys MUST be unique; first one wins. |
334 | 334 | // But overwriting is allowed when a merge node is used in current block. |
335 | - if ($allowOverwrite || !isset($data[$key])) { |
|
335 | + if ($allowOverwrite || ! isset($data[$key])) { |
|
336 | 336 | $data[$key] = $value; |
337 | 337 | } else { |
338 | 338 | @\trigger_error($this->getDeprecationMessage(\sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \\Symfony\\Component\\Yaml\\Exception\\ParseException in 4.0.', $key)), \E_USER_DEPRECATED); |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | continue; |
372 | 372 | } |
373 | 373 | // If the indentation is not consistent at offset 0, it is to be considered as a ParseError |
374 | - if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { |
|
374 | + if (0 === $this->offset && ! $deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { |
|
375 | 375 | throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); |
376 | 376 | } |
377 | 377 | if ('' === \trim($line)) { |
378 | 378 | $value .= "\n"; |
379 | - } elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) { |
|
379 | + } elseif ( ! $previousLineWasNewline && ! $previousLineWasTerminatedWithBackslash) { |
|
380 | 380 | $value .= ' '; |
381 | 381 | } |
382 | 382 | if ('' !== \trim($line) && '\\' === \substr($line, -1)) { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | if (null !== $tag) { |
408 | 408 | $data = new TaggedValue($tag, $data); |
409 | 409 | } |
410 | - if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !\is_object($data) && 'mapping' === $context) { |
|
410 | + if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && ! \is_object($data) && 'mapping' === $context) { |
|
411 | 411 | $object = new \stdClass(); |
412 | 412 | foreach ($data as $key => $value) { |
413 | 413 | $object->{$key} = $value; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $parser->offset = $offset; |
430 | 430 | $parser->totalNumberOfLines = $this->totalNumberOfLines; |
431 | 431 | $parser->skippedLineNumbers = $skippedLineNumbers; |
432 | - $parser->refs =& $this->refs; |
|
432 | + $parser->refs = & $this->refs; |
|
433 | 433 | $parser->refsBeingParsed = $this->refsBeingParsed; |
434 | 434 | return $parser->doParse($yaml, $flags); |
435 | 435 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | private function getNextEmbedBlock($indentation = null, $inSequence = \false) |
474 | 474 | { |
475 | 475 | $oldLineIndentation = $this->getCurrentLineIndentation(); |
476 | - if (!$this->moveToNextLine()) { |
|
476 | + if ( ! $this->moveToNextLine()) { |
|
477 | 477 | return ''; |
478 | 478 | } |
479 | 479 | if (null === $indentation) { |
@@ -483,19 +483,19 @@ discard block |
||
483 | 483 | $EOF = \false; |
484 | 484 | // empty and comment-like lines do not influence the indentation depth |
485 | 485 | if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) { |
486 | - $EOF = !$this->moveToNextLine(); |
|
487 | - if (!$EOF) { |
|
486 | + $EOF = ! $this->moveToNextLine(); |
|
487 | + if ( ! $EOF) { |
|
488 | 488 | ++$movements; |
489 | 489 | } |
490 | 490 | } else { |
491 | 491 | $newIndent = $this->getCurrentLineIndentation(); |
492 | 492 | } |
493 | - } while (!$EOF && null === $newIndent); |
|
493 | + } while ( ! $EOF && null === $newIndent); |
|
494 | 494 | for ($i = 0; $i < $movements; ++$i) { |
495 | 495 | $this->moveToPreviousLine(); |
496 | 496 | } |
497 | 497 | $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem(); |
498 | - if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { |
|
498 | + if ( ! $this->isCurrentLineEmpty() && 0 === $newIndent && ! $unindentedEmbedBlock) { |
|
499 | 499 | throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); |
500 | 500 | } |
501 | 501 | } else { |
@@ -519,12 +519,12 @@ discard block |
||
519 | 519 | $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); |
520 | 520 | $isItComment = $this->isCurrentLineComment(); |
521 | 521 | while ($this->moveToNextLine()) { |
522 | - if ($isItComment && !$isItUnindentedCollection) { |
|
522 | + if ($isItComment && ! $isItUnindentedCollection) { |
|
523 | 523 | $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); |
524 | 524 | $isItComment = $this->isCurrentLineComment(); |
525 | 525 | } |
526 | 526 | $indent = $this->getCurrentLineIndentation(); |
527 | - if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { |
|
527 | + if ($isItUnindentedCollection && ! $this->isCurrentLineEmpty() && ! $this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { |
|
528 | 528 | $this->moveToPreviousLine(); |
529 | 529 | break; |
530 | 530 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | } else { |
591 | 591 | $value = \substr($value, 1); |
592 | 592 | } |
593 | - if (!\array_key_exists($value, $this->refs)) { |
|
593 | + if ( ! \array_key_exists($value, $this->refs)) { |
|
594 | 594 | if (\false !== ($pos = \array_search($value, $this->refsBeingParsed, \true))) { |
595 | 595 | throw new ParseException(\sprintf('Circular reference [%s, %s] detected for reference "%s".', \implode(', ', \array_slice($this->refsBeingParsed, $pos)), $value, $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); |
596 | 596 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | } |
599 | 599 | return $this->refs[$value]; |
600 | 600 | } |
601 | - if (self::preg_match('/^(?:' . self::TAG_PATTERN . ' +)?' . self::BLOCK_SCALAR_HEADER_PATTERN . '$/', $value, $matches)) { |
|
601 | + if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) { |
|
602 | 602 | $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; |
603 | 603 | $data = $this->parseBlockScalar($matches['separator'], \preg_replace('#\\d+#', '', $modifiers), \abs((int) $modifiers)); |
604 | 604 | if ('' !== $matches['tag']) { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | try { |
616 | 616 | $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null; |
617 | 617 | // do not take following lines into account when the current line is a quoted single line value |
618 | - if (null !== $quotation && self::preg_match('/^' . $quotation . '.*' . $quotation . '(\\s*#.*)?$/', $value)) { |
|
618 | + if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\\s*#.*)?$/', $value)) { |
|
619 | 619 | return Inline::parse($value, $flags, $this->refs); |
620 | 620 | } |
621 | 621 | $lines = []; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | $value .= $lines[$i]; |
641 | 641 | $previousLineBlank = \false; |
642 | 642 | } else { |
643 | - $value .= ' ' . $lines[$i]; |
|
643 | + $value .= ' '.$lines[$i]; |
|
644 | 644 | $previousLineBlank = \false; |
645 | 645 | } |
646 | 646 | } |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | private function parseBlockScalar($style, $chomping = '', $indentation = 0) |
669 | 669 | { |
670 | 670 | $notEOF = $this->moveToNextLine(); |
671 | - if (!$notEOF) { |
|
671 | + if ( ! $notEOF) { |
|
672 | 672 | return ''; |
673 | 673 | } |
674 | 674 | $isCurrentLineBlank = $this->isCurrentLineBlank(); |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | if ($notEOF) { |
709 | 709 | $blockLines[] = ''; |
710 | 710 | $this->moveToPreviousLine(); |
711 | - } elseif (!$notEOF && !$this->isCurrentLineLastLineInDocument()) { |
|
711 | + } elseif ( ! $notEOF && ! $this->isCurrentLineLastLineInDocument()) { |
|
712 | 712 | $blockLines[] = ''; |
713 | 713 | } |
714 | 714 | // folded style |
@@ -722,11 +722,11 @@ discard block |
||
722 | 722 | $previousLineIndented = \false; |
723 | 723 | $previousLineBlank = \true; |
724 | 724 | } elseif (' ' === $blockLines[$i][0]) { |
725 | - $text .= "\n" . $blockLines[$i]; |
|
725 | + $text .= "\n".$blockLines[$i]; |
|
726 | 726 | $previousLineIndented = \true; |
727 | 727 | $previousLineBlank = \false; |
728 | 728 | } elseif ($previousLineIndented) { |
729 | - $text .= "\n" . $blockLines[$i]; |
|
729 | + $text .= "\n".$blockLines[$i]; |
|
730 | 730 | $previousLineIndented = \false; |
731 | 731 | $previousLineBlank = \false; |
732 | 732 | } elseif ($previousLineBlank || 0 === $i) { |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | $previousLineIndented = \false; |
735 | 735 | $previousLineBlank = \false; |
736 | 736 | } else { |
737 | - $text .= ' ' . $blockLines[$i]; |
|
737 | + $text .= ' '.$blockLines[$i]; |
|
738 | 738 | $previousLineIndented = \false; |
739 | 739 | $previousLineBlank = \false; |
740 | 740 | } |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | $currentIndentation = $this->getCurrentLineIndentation(); |
761 | 761 | $movements = 0; |
762 | 762 | do { |
763 | - $EOF = !$this->moveToNextLine(); |
|
764 | - if (!$EOF) { |
|
763 | + $EOF = ! $this->moveToNextLine(); |
|
764 | + if ( ! $EOF) { |
|
765 | 765 | ++$movements; |
766 | 766 | } |
767 | - } while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment())); |
|
767 | + } while ( ! $EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment())); |
|
768 | 768 | if ($EOF) { |
769 | 769 | return \false; |
770 | 770 | } |
@@ -849,11 +849,11 @@ discard block |
||
849 | 849 | $currentIndentation = $this->getCurrentLineIndentation(); |
850 | 850 | $movements = 0; |
851 | 851 | do { |
852 | - $EOF = !$this->moveToNextLine(); |
|
853 | - if (!$EOF) { |
|
852 | + $EOF = ! $this->moveToNextLine(); |
|
853 | + if ( ! $EOF) { |
|
854 | 854 | ++$movements; |
855 | 855 | } |
856 | - } while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment())); |
|
856 | + } while ( ! $EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment())); |
|
857 | 857 | if ($EOF) { |
858 | 858 | return \false; |
859 | 859 | } |
@@ -929,10 +929,10 @@ discard block |
||
929 | 929 | */ |
930 | 930 | private function getLineTag($value, $flags, $nextLineCheck = \true) |
931 | 931 | { |
932 | - if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^' . self::TAG_PATTERN . ' *( +#.*)?$/', $value, $matches)) { |
|
932 | + if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) { |
|
933 | 933 | return null; |
934 | 934 | } |
935 | - if ($nextLineCheck && !$this->isNextLineIndented()) { |
|
935 | + if ($nextLineCheck && ! $this->isNextLineIndented()) { |
|
936 | 936 | return null; |
937 | 937 | } |
938 | 938 | $tag = \substr($matches['tag'], 1); |
@@ -949,9 +949,9 @@ discard block |
||
949 | 949 | { |
950 | 950 | $message = \rtrim($message, '.'); |
951 | 951 | if (null !== $this->filename) { |
952 | - $message .= ' in ' . $this->filename; |
|
952 | + $message .= ' in '.$this->filename; |
|
953 | 953 | } |
954 | - $message .= ' on line ' . ($this->getRealCurrentLineNb() + 1); |
|
955 | - return $message . '.'; |
|
954 | + $message .= ' on line '.($this->getRealCurrentLineNb() + 1); |
|
955 | + return $message.'.'; |
|
956 | 956 | } |
957 | 957 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function setIndentation($num) |
47 | 47 | { |
48 | - @\trigger_error('The ' . __METHOD__ . ' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', \E_USER_DEPRECATED); |
|
48 | + @\trigger_error('The '.__METHOD__.' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', \E_USER_DEPRECATED); |
|
49 | 49 | $this->indentation = (int) $num; |
50 | 50 | } |
51 | 51 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { |
81 | 81 | $dumpObjectAsInlineMap = empty((array) $input); |
82 | 82 | } |
83 | - if ($inline <= 0 || !\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap || empty($input)) { |
|
84 | - $output .= $prefix . Inline::dump($input, $flags); |
|
83 | + if ($inline <= 0 || ! \is_array($input) && ! $input instanceof TaggedValue && $dumpObjectAsInlineMap || empty($input)) { |
|
84 | + $output .= $prefix.Inline::dump($input, $flags); |
|
85 | 85 | } else { |
86 | 86 | $dumpAsMap = Inline::isHash($input); |
87 | 87 | foreach ($input as $key => $value) { |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator |
90 | 90 | // http://www.yaml.org/spec/1.2/spec.html#id2793979 |
91 | 91 | $blockIndentationIndicator = ' ' === \substr($value, 0, 1) ? (string) $this->indentation : ''; |
92 | - $output .= \sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', '', $blockIndentationIndicator); |
|
92 | + $output .= \sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); |
|
93 | 93 | foreach (\explode("\n", $value) as $row) { |
94 | 94 | $output .= \sprintf("%s%s%s\n", $prefix, \str_repeat(' ', $this->indentation), $row); |
95 | 95 | } |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | if ($value instanceof TaggedValue) { |
99 | - $output .= \sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', $value->getTag()); |
|
99 | + $output .= \sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); |
|
100 | 100 | if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && \false !== \strpos($value->getValue(), "\n") && \false === \strpos($value->getValue(), "\r\n")) { |
101 | 101 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator |
102 | 102 | // http://www.yaml.org/spec/1.2/spec.html#id2793979 |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | if ($inline - 1 <= 0 || null === $value->getValue() || \is_scalar($value->getValue())) { |
111 | - $output .= ' ' . $this->dump($value->getValue(), $inline - 1, 0, $flags) . "\n"; |
|
111 | + $output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n"; |
|
112 | 112 | } else { |
113 | 113 | $output .= "\n"; |
114 | 114 | $output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags); |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { |
120 | 120 | $dumpObjectAsInlineMap = empty((array) $value); |
121 | 121 | } |
122 | - $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value); |
|
123 | - $output .= \sprintf('%s%s%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags) . ':' : '-', $willBeInlined ? ' ' : "\n", $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)) . ($willBeInlined ? "\n" : ''); |
|
122 | + $willBeInlined = $inline - 1 <= 0 || ! \is_array($value) && $dumpObjectAsInlineMap || empty($value); |
|
123 | + $output .= \sprintf('%s%s%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $willBeInlined ? ' ' : "\n", $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)).($willBeInlined ? "\n" : ''); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | return $output; |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $this->format = $input->getOption('format'); |
73 | 73 | $this->displayCorrectFiles = $output->isVerbose(); |
74 | 74 | $flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0; |
75 | - if (!$filename) { |
|
76 | - if (!($stdin = $this->getStdin())) { |
|
75 | + if ( ! $filename) { |
|
76 | + if ( ! ($stdin = $this->getStdin())) { |
|
77 | 77 | throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); |
78 | 78 | } |
79 | 79 | return $this->display($io, [$this->validate($stdin, $flags)]); |
80 | 80 | } |
81 | - if (!$this->isReadable($filename)) { |
|
81 | + if ( ! $this->isReadable($filename)) { |
|
82 | 82 | throw new RuntimeException(\sprintf('File or directory "%s" is not readable.', $filename)); |
83 | 83 | } |
84 | 84 | $filesInfo = []; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | private function validate($content, $flags, $file = null) |
91 | 91 | { |
92 | - $prevErrorHandler = \set_error_handler(function ($level, $message, $file, $line) use(&$prevErrorHandler) { |
|
92 | + $prevErrorHandler = \set_error_handler(function($level, $message, $file, $line) use(&$prevErrorHandler) { |
|
93 | 93 | if (\E_USER_DEPRECATED === $level) { |
94 | 94 | throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1); |
95 | 95 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | $erroredFiles = 0; |
122 | 122 | foreach ($filesInfo as $info) { |
123 | 123 | if ($info['valid'] && $this->displayCorrectFiles) { |
124 | - $io->comment('<info>OK</info>' . ($info['file'] ? \sprintf(' in %s', $info['file']) : '')); |
|
125 | - } elseif (!$info['valid']) { |
|
124 | + $io->comment('<info>OK</info>'.($info['file'] ? \sprintf(' in %s', $info['file']) : '')); |
|
125 | + } elseif ( ! $info['valid']) { |
|
126 | 126 | ++$erroredFiles; |
127 | - $io->text('<error> ERROR </error>' . ($info['file'] ? \sprintf(' in %s', $info['file']) : '')); |
|
127 | + $io->text('<error> ERROR </error>'.($info['file'] ? \sprintf(' in %s', $info['file']) : '')); |
|
128 | 128 | $io->text(\sprintf('<error> >> %s</error>', $info['message'])); |
129 | 129 | } |
130 | 130 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | private function displayJson(SymfonyStyle $io, array $filesInfo) |
139 | 139 | { |
140 | 140 | $errors = 0; |
141 | - \array_walk($filesInfo, function (&$v) use(&$errors) { |
|
141 | + \array_walk($filesInfo, function(&$v) use(&$errors) { |
|
142 | 142 | $v['file'] = (string) $v['file']; |
143 | - if (!$v['valid']) { |
|
143 | + if ( ! $v['valid']) { |
|
144 | 144 | ++$errors; |
145 | 145 | } |
146 | 146 | }); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return; |
155 | 155 | } |
156 | 156 | foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) { |
157 | - if (!\in_array($file->getExtension(), ['yml', 'yaml'])) { |
|
157 | + if ( ! \in_array($file->getExtension(), ['yml', 'yaml'])) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | (yield $file); |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | return null; |
170 | 170 | } |
171 | 171 | $inputs = ''; |
172 | - while (!\feof(\STDIN)) { |
|
172 | + while ( ! \feof(\STDIN)) { |
|
173 | 173 | $inputs .= \fread(\STDIN, 1024); |
174 | 174 | } |
175 | 175 | return $inputs; |
176 | 176 | } |
177 | 177 | private function getParser() |
178 | 178 | { |
179 | - if (!$this->parser) { |
|
179 | + if ( ! $this->parser) { |
|
180 | 180 | $this->parser = new Parser(); |
181 | 181 | } |
182 | 182 | return $this->parser; |
183 | 183 | } |
184 | 184 | private function getDirectoryIterator($directory) |
185 | 185 | { |
186 | - $default = function ($directory) { |
|
186 | + $default = function($directory) { |
|
187 | 187 | return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), \RecursiveIteratorIterator::LEAVES_ONLY); |
188 | 188 | }; |
189 | 189 | if (null !== $this->directoryIteratorProvider) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | private function isReadable($fileOrDirectory) |
195 | 195 | { |
196 | - $default = function ($fileOrDirectory) { |
|
196 | + $default = function($fileOrDirectory) { |
|
197 | 197 | return \is_readable($fileOrDirectory); |
198 | 198 | }; |
199 | 199 | if (null !== $this->isReadableProvider) { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public static function ctype_alnum($text) |
32 | 32 | { |
33 | 33 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
34 | - return \is_string($text) && '' !== $text && !\preg_match('/[^A-Za-z0-9]/', $text); |
|
34 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^A-Za-z0-9]/', $text); |
|
35 | 35 | } |
36 | 36 | /** |
37 | 37 | * Returns TRUE if every character in text is a letter, FALSE otherwise. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public static function ctype_alpha($text) |
46 | 46 | { |
47 | 47 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
48 | - return \is_string($text) && '' !== $text && !\preg_match('/[^A-Za-z]/', $text); |
|
48 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^A-Za-z]/', $text); |
|
49 | 49 | } |
50 | 50 | /** |
51 | 51 | * Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public static function ctype_cntrl($text) |
60 | 60 | { |
61 | 61 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
62 | - return \is_string($text) && '' !== $text && !\preg_match('/[^\\x00-\\x1f\\x7f]/', $text); |
|
62 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^\\x00-\\x1f\\x7f]/', $text); |
|
63 | 63 | } |
64 | 64 | /** |
65 | 65 | * Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise. |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public static function ctype_digit($text) |
74 | 74 | { |
75 | 75 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
76 | - return \is_string($text) && '' !== $text && !\preg_match('/[^0-9]/', $text); |
|
76 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^0-9]/', $text); |
|
77 | 77 | } |
78 | 78 | /** |
79 | 79 | * Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise. |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public static function ctype_graph($text) |
88 | 88 | { |
89 | 89 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
90 | - return \is_string($text) && '' !== $text && !\preg_match('/[^!-~]/', $text); |
|
90 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^!-~]/', $text); |
|
91 | 91 | } |
92 | 92 | /** |
93 | 93 | * Returns TRUE if every character in text is a lowercase letter. |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public static function ctype_lower($text) |
102 | 102 | { |
103 | 103 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
104 | - return \is_string($text) && '' !== $text && !\preg_match('/[^a-z]/', $text); |
|
104 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^a-z]/', $text); |
|
105 | 105 | } |
106 | 106 | /** |
107 | 107 | * Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all. |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public static function ctype_print($text) |
116 | 116 | { |
117 | 117 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
118 | - return \is_string($text) && '' !== $text && !\preg_match('/[^ -~]/', $text); |
|
118 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^ -~]/', $text); |
|
119 | 119 | } |
120 | 120 | /** |
121 | 121 | * Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise. |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public static function ctype_punct($text) |
130 | 130 | { |
131 | 131 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
132 | - return \is_string($text) && '' !== $text && !\preg_match('/[^!-\\/\\:-@\\[-`\\{-~]/', $text); |
|
132 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^!-\\/\\:-@\\[-`\\{-~]/', $text); |
|
133 | 133 | } |
134 | 134 | /** |
135 | 135 | * Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public static function ctype_space($text) |
144 | 144 | { |
145 | 145 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
146 | - return \is_string($text) && '' !== $text && !\preg_match('/[^\\s]/', $text); |
|
146 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^\\s]/', $text); |
|
147 | 147 | } |
148 | 148 | /** |
149 | 149 | * Returns TRUE if every character in text is an uppercase letter. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public static function ctype_upper($text) |
158 | 158 | { |
159 | 159 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
160 | - return \is_string($text) && '' !== $text && !\preg_match('/[^A-Z]/', $text); |
|
160 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^A-Z]/', $text); |
|
161 | 161 | } |
162 | 162 | /** |
163 | 163 | * Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public static function ctype_xdigit($text) |
172 | 172 | { |
173 | 173 | $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__); |
174 | - return \is_string($text) && '' !== $text && !\preg_match('/[^A-Fa-f0-9]/', $text); |
|
174 | + return \is_string($text) && '' !== $text && ! \preg_match('/[^A-Fa-f0-9]/', $text); |
|
175 | 175 | } |
176 | 176 | /** |
177 | 177 | * Converts integers to their char versions according to normal ctype behaviour, if needed. |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | */ |
189 | 189 | private static function convert_int_to_char_for_ctype($int, $function) |
190 | 190 | { |
191 | - if (!\is_int($int)) { |
|
191 | + if ( ! \is_int($int)) { |
|
192 | 192 | return $int; |
193 | 193 | } |
194 | 194 | if ($int < -128 || $int > 255) { |
195 | 195 | return (string) $int; |
196 | 196 | } |
197 | 197 | if (\PHP_VERSION_ID >= 80100) { |
198 | - @\trigger_error($function . '(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED); |
|
198 | + @\trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED); |
|
199 | 199 | } |
200 | 200 | if ($int < 0) { |
201 | 201 | $int += 256; |
@@ -11,67 +11,67 @@ |
||
11 | 11 | * file that was distributed with this source code. |
12 | 12 | */ |
13 | 13 | use Wordlift\Modules\Plugin_Diagnostics\Symfony\Polyfill\Ctype as p; |
14 | -if (!\function_exists('ctype_alnum')) { |
|
14 | +if ( ! \function_exists('ctype_alnum')) { |
|
15 | 15 | function ctype_alnum(mixed $text) : bool |
16 | 16 | { |
17 | 17 | return p\Ctype::ctype_alnum($text); |
18 | 18 | } |
19 | 19 | } |
20 | -if (!\function_exists('ctype_alpha')) { |
|
20 | +if ( ! \function_exists('ctype_alpha')) { |
|
21 | 21 | function ctype_alpha(mixed $text) : bool |
22 | 22 | { |
23 | 23 | return p\Ctype::ctype_alpha($text); |
24 | 24 | } |
25 | 25 | } |
26 | -if (!\function_exists('ctype_cntrl')) { |
|
26 | +if ( ! \function_exists('ctype_cntrl')) { |
|
27 | 27 | function ctype_cntrl(mixed $text) : bool |
28 | 28 | { |
29 | 29 | return p\Ctype::ctype_cntrl($text); |
30 | 30 | } |
31 | 31 | } |
32 | -if (!\function_exists('ctype_digit')) { |
|
32 | +if ( ! \function_exists('ctype_digit')) { |
|
33 | 33 | function ctype_digit(mixed $text) : bool |
34 | 34 | { |
35 | 35 | return p\Ctype::ctype_digit($text); |
36 | 36 | } |
37 | 37 | } |
38 | -if (!\function_exists('ctype_graph')) { |
|
38 | +if ( ! \function_exists('ctype_graph')) { |
|
39 | 39 | function ctype_graph(mixed $text) : bool |
40 | 40 | { |
41 | 41 | return p\Ctype::ctype_graph($text); |
42 | 42 | } |
43 | 43 | } |
44 | -if (!\function_exists('ctype_lower')) { |
|
44 | +if ( ! \function_exists('ctype_lower')) { |
|
45 | 45 | function ctype_lower(mixed $text) : bool |
46 | 46 | { |
47 | 47 | return p\Ctype::ctype_lower($text); |
48 | 48 | } |
49 | 49 | } |
50 | -if (!\function_exists('ctype_print')) { |
|
50 | +if ( ! \function_exists('ctype_print')) { |
|
51 | 51 | function ctype_print(mixed $text) : bool |
52 | 52 | { |
53 | 53 | return p\Ctype::ctype_print($text); |
54 | 54 | } |
55 | 55 | } |
56 | -if (!\function_exists('ctype_punct')) { |
|
56 | +if ( ! \function_exists('ctype_punct')) { |
|
57 | 57 | function ctype_punct(mixed $text) : bool |
58 | 58 | { |
59 | 59 | return p\Ctype::ctype_punct($text); |
60 | 60 | } |
61 | 61 | } |
62 | -if (!\function_exists('ctype_space')) { |
|
62 | +if ( ! \function_exists('ctype_space')) { |
|
63 | 63 | function ctype_space(mixed $text) : bool |
64 | 64 | { |
65 | 65 | return p\Ctype::ctype_space($text); |
66 | 66 | } |
67 | 67 | } |
68 | -if (!\function_exists('ctype_upper')) { |
|
68 | +if ( ! \function_exists('ctype_upper')) { |
|
69 | 69 | function ctype_upper(mixed $text) : bool |
70 | 70 | { |
71 | 71 | return p\Ctype::ctype_upper($text); |
72 | 72 | } |
73 | 73 | } |
74 | -if (!\function_exists('ctype_xdigit')) { |
|
74 | +if ( ! \function_exists('ctype_xdigit')) { |
|
75 | 75 | function ctype_xdigit(mixed $text) : bool |
76 | 76 | { |
77 | 77 | return p\Ctype::ctype_xdigit($text); |