@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | if ($doCopy) { |
| 52 | 52 | // https://bugs.php.net/64634 |
| 53 | 53 | if (!$source = self::box('fopen', $originFile, 'r')) { |
| 54 | - throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading: ', $originFile, $targetFile).self::$lastError, 0, null, $originFile); |
|
| 54 | + throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default |
| 58 | 58 | if (!$target = self::box('fopen', $targetFile, 'w', false, stream_context_create(['ftp' => ['overwrite' => true]]))) { |
| 59 | - throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing: ', $originFile, $targetFile).self::$lastError, 0, null, $originFile); |
|
| 59 | + throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $bytesCopied = stream_copy_to_stream($source, $target); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if (!self::box('mkdir', $dir, $mode, true) && !is_dir($dir)) { |
| 97 | - throw new IOException(sprintf('Failed to create "%s": ', $dir).self::$lastError, 0, null, $dir); |
|
| 97 | + throw new IOException(sprintf('Failed to create "%s": ', $dir) . self::$lastError, 0, null, $dir); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | foreach ($this->toIterable($files) as $file) { |
| 138 | 138 | if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) { |
| 139 | - throw new IOException(sprintf('Failed to touch "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 139 | + throw new IOException(sprintf('Failed to touch "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | if (is_link($file)) { |
| 167 | 167 | // See https://bugs.php.net/52176 |
| 168 | 168 | if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) { |
| 169 | - throw new IOException(sprintf('Failed to remove symlink "%s": ', $file).self::$lastError); |
|
| 169 | + throw new IOException(sprintf('Failed to remove symlink "%s": ', $file) . self::$lastError); |
|
| 170 | 170 | } |
| 171 | 171 | } elseif (is_dir($file)) { |
| 172 | 172 | if (!$isRecursive) { |
| 173 | - $tmpName = \dirname(realpath($file)).'/.'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-.')); |
|
| 173 | + $tmpName = \dirname(realpath($file)) . '/.' . strrev(strtr(base64_encode(random_bytes(2)), '/=', '-.')); |
|
| 174 | 174 | |
| 175 | 175 | if (file_exists($tmpName)) { |
| 176 | 176 | try { |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | $file = $origFile; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError); |
|
| 200 | + throw new IOException(sprintf('Failed to remove directory "%s": ', $file) . $lastError); |
|
| 201 | 201 | } |
| 202 | 202 | } elseif (!self::box('unlink', $file) && (false !== strpos(self::$lastError, 'Permission denied') || file_exists($file))) { |
| 203 | - throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError); |
|
| 203 | + throw new IOException(sprintf('Failed to remove file "%s": ', $file) . self::$lastError); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | foreach ($this->toIterable($files) as $file) { |
| 221 | 221 | if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && !self::box('chmod', $file, $mode & ~$umask)) { |
| 222 | - throw new IOException(sprintf('Failed to chmod file "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 222 | + throw new IOException(sprintf('Failed to chmod file "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 223 | 223 | } |
| 224 | 224 | if ($recursive && is_dir($file) && !is_link($file)) { |
| 225 | 225 | $this->chmod(new \FilesystemIterator($file), $mode, $umask, true); |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | if (is_link($file) && \function_exists('lchown')) { |
| 246 | 246 | if (!self::box('lchown', $file, $user)) { |
| 247 | - throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 247 | + throw new IOException(sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 248 | 248 | } |
| 249 | 249 | } else { |
| 250 | 250 | if (!self::box('chown', $file, $user)) { |
| 251 | - throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 251 | + throw new IOException(sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | if (is_link($file) && \function_exists('lchgrp')) { |
| 273 | 273 | if (!self::box('lchgrp', $file, $group)) { |
| 274 | - throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 274 | + throw new IOException(sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 275 | 275 | } |
| 276 | 276 | } else { |
| 277 | 277 | if (!self::box('chgrp', $file, $group)) { |
| 278 | - throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file); |
|
| 278 | + throw new IOException(sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | - throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin, $target).self::$lastError, 0, null, $target); |
|
| 305 | + throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin, $target) . self::$lastError, 0, null, $target); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | throw new IOException(sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | - throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target).self::$lastError, 0, null, $target); |
|
| 399 | + throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target) . self::$lastError, 0, null, $target); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -458,13 +458,13 @@ discard block |
||
| 458 | 458 | $startPath = str_replace('\\', '/', $startPath); |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $splitDriveLetter = function ($path) { |
|
| 461 | + $splitDriveLetter = function($path) { |
|
| 462 | 462 | return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) |
| 463 | 463 | ? [substr($path, 2), strtoupper($path[0])] |
| 464 | 464 | : [$path, null]; |
| 465 | 465 | }; |
| 466 | 466 | |
| 467 | - $splitPath = function ($path) { |
|
| 467 | + $splitPath = function($path) { |
|
| 468 | 468 | $result = []; |
| 469 | 469 | |
| 470 | 470 | foreach (explode('/', trim($path, '/')) as $segment) { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | if ($endDriveLetter && $startDriveLetter && $endDriveLetter != $startDriveLetter) { |
| 488 | 488 | // End path is on another drive, so no relative path exists |
| 489 | - return $endDriveLetter.':/'.($endPathArr ? implode('/', $endPathArr).'/' : ''); |
|
| 489 | + return $endDriveLetter . ':/' . ($endPathArr ? implode('/', $endPathArr) . '/' : ''); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | // Find for which directory the common path stops |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | $endPathRemainder = implode('/', \array_slice($endPathArr, $index)); |
| 509 | 509 | |
| 510 | 510 | // Construct $endPath from traversing to the common path, then to the remaining $endPath |
| 511 | - $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : ''); |
|
| 511 | + $relativePath = $traverser . ('' !== $endPathRemainder ? $endPathRemainder . '/' : ''); |
|
| 512 | 512 | |
| 513 | 513 | return '' === $relativePath ? './' : $relativePath; |
| 514 | 514 | } |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | } |
| 550 | 550 | $targetDirLen = \strlen($targetDir); |
| 551 | 551 | foreach ($deleteIterator as $file) { |
| 552 | - $origin = $originDir.substr($file->getPathname(), $targetDirLen); |
|
| 552 | + $origin = $originDir . substr($file->getPathname(), $targetDirLen); |
|
| 553 | 553 | if (!$this->exists($origin)) { |
| 554 | 554 | $this->remove($file); |
| 555 | 555 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | continue; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $target = $targetDir.substr($file->getPathname(), $originDirLen); |
|
| 574 | + $target = $targetDir . substr($file->getPathname(), $originDirLen); |
|
| 575 | 575 | $filesCreatedWhileMirroring[$target] = true; |
| 576 | 576 | |
| 577 | 577 | if (!$copyOnWindows && is_link($file)) { |
@@ -621,19 +621,19 @@ discard block |
||
| 621 | 621 | // If tempnam failed or no scheme return the filename otherwise prepend the scheme |
| 622 | 622 | if ($tmpFile = self::box('tempnam', $hierarchy, $prefix)) { |
| 623 | 623 | if (null !== $scheme && 'gs' !== $scheme) { |
| 624 | - return $scheme.'://'.$tmpFile; |
|
| 624 | + return $scheme . '://' . $tmpFile; |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | return $tmpFile; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - throw new IOException('A temporary file could not be created: '.self::$lastError); |
|
| 630 | + throw new IOException('A temporary file could not be created: ' . self::$lastError); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // Loop until we create a valid temp file or have reached 10 attempts |
| 634 | 634 | for ($i = 0; $i < 10; ++$i) { |
| 635 | 635 | // Create a unique filename |
| 636 | - $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true).$suffix; |
|
| 636 | + $tmpFile = $dir . '/' . $prefix . uniqid(mt_rand(), true) . $suffix; |
|
| 637 | 637 | |
| 638 | 638 | // Use fopen instead of file_exists as some streams do not support stat |
| 639 | 639 | // Use mode 'x+' to atomically check existence and create to avoid a TOCTOU vulnerability |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | return $tmpFile; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - throw new IOException('A temporary file could not be created: '.self::$lastError); |
|
| 650 | + throw new IOException('A temporary file could not be created: ' . self::$lastError); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | try { |
| 681 | 681 | if (false === self::box('file_put_contents', $tmpFile, $content)) { |
| 682 | - throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename); |
|
| 682 | + throw new IOException(sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask()); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) { |
| 719 | - throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename); |
|
| 719 | + throw new IOException(sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); |
|
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | 722 | |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | private static function box(callable $func, ...$args) |
| 744 | 744 | { |
| 745 | 745 | self::$lastError = null; |
| 746 | - set_error_handler(__CLASS__.'::handleError'); |
|
| 746 | + set_error_handler(__CLASS__ . '::handleError'); |
|
| 747 | 747 | try { |
| 748 | 748 | $result = $func(...$args); |
| 749 | 749 | restore_error_handler(); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | if (!is_scalar($s)) { |
| 47 | 47 | $hasError = false; |
| 48 | - set_error_handler(function () use (&$hasError) { $hasError = true; }); |
|
| 48 | + set_error_handler(function() use (&$hasError) { $hasError = true; }); |
|
| 49 | 49 | $next = substr($s, $start); |
| 50 | 50 | restore_error_handler(); |
| 51 | 51 | if ($hasError) { |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | } else { |
| 58 | 58 | $s = substr($s, $start); |
| 59 | 59 | } |
| 60 | - $size = (int) $size; |
|
| 61 | - $type = (int) $type; |
|
| 62 | - $start = (int) $start; |
|
| 60 | + $size = (int)$size; |
|
| 61 | + $type = (int)$type; |
|
| 62 | + $start = (int)$start; |
|
| 63 | 63 | |
| 64 | 64 | if (\GRAPHEME_EXTR_COUNT !== $type && \GRAPHEME_EXTR_MAXBYTES !== $type && \GRAPHEME_EXTR_MAXCHARS !== $type) { |
| 65 | 65 | if (80000 > \PHP_VERSION_ID) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $next = $start; |
| 80 | 80 | |
| 81 | - $s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); |
|
| 81 | + $s = preg_split('/(' . SYMFONY_GRAPHEME_CLUSTER_RX . ')/u', "\r\n" . $s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); |
|
| 82 | 82 | |
| 83 | 83 | if (!isset($s[1])) { |
| 84 | 84 | return false; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public static function grapheme_strlen($s) |
| 110 | 110 | { |
| 111 | - preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len); |
|
| 111 | + preg_replace('/' . SYMFONY_GRAPHEME_CLUSTER_RX . '/u', '', $s, -1, $len); |
|
| 112 | 112 | |
| 113 | 113 | return 0 === $len && '' !== $s ? null : $len; |
| 114 | 114 | } |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | $len = 2147483647; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s); |
|
| 122 | + preg_match_all('/' . SYMFONY_GRAPHEME_CLUSTER_RX . '/u', $s, $s); |
|
| 123 | 123 | |
| 124 | 124 | $slen = \count($s[0]); |
| 125 | - $start = (int) $start; |
|
| 125 | + $start = (int)$start; |
|
| 126 | 126 | |
| 127 | 127 | if (0 > $start) { |
| 128 | 128 | $start += $slen; |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | private static function grapheme_position($s, $needle, $offset, $mode) |
| 190 | 190 | { |
| 191 | - $needle = (string) $needle; |
|
| 191 | + $needle = (string)$needle; |
|
| 192 | 192 | if (80000 > \PHP_VERSION_ID && !preg_match('/./us', $needle)) { |
| 193 | 193 | return false; |
| 194 | 194 | } |
| 195 | - $s = (string) $s; |
|
| 195 | + $s = (string)$s; |
|
| 196 | 196 | if (!preg_match('/./us', $s)) { |
| 197 | 197 | return false; |
| 198 | 198 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | if (\PHP_VERSION_ID >= 80000) { |
| 19 | - return require __DIR__.'/bootstrap80.php'; |
|
| 19 | + return require __DIR__ . '/bootstrap80.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!defined('GRAPHEME_EXTR_COUNT')) { |
@@ -22,29 +22,29 @@ |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!function_exists('grapheme_extract')) { |
| 25 | - function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); } |
|
| 25 | + function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string | false { return p\Grapheme::grapheme_extract((string)$haystack, (int)$size, (int)$type, (int)$offset, $next); } |
|
| 26 | 26 | } |
| 27 | 27 | if (!function_exists('grapheme_stripos')) { |
| 28 | - function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 28 | + function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_stripos((string)$haystack, (string)$needle, (int)$offset); } |
|
| 29 | 29 | } |
| 30 | 30 | if (!function_exists('grapheme_stristr')) { |
| 31 | - function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 31 | + function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string | false { return p\Grapheme::grapheme_stristr((string)$haystack, (string)$needle, (bool)$beforeNeedle); } |
|
| 32 | 32 | } |
| 33 | 33 | if (!function_exists('grapheme_strlen')) { |
| 34 | - function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); } |
|
| 34 | + function grapheme_strlen(?string $string): int | false | null { return p\Grapheme::grapheme_strlen((string)$string); } |
|
| 35 | 35 | } |
| 36 | 36 | if (!function_exists('grapheme_strpos')) { |
| 37 | - function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 37 | + function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strpos((string)$haystack, (string)$needle, (int)$offset); } |
|
| 38 | 38 | } |
| 39 | 39 | if (!function_exists('grapheme_strripos')) { |
| 40 | - function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 40 | + function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strripos((string)$haystack, (string)$needle, (int)$offset); } |
|
| 41 | 41 | } |
| 42 | 42 | if (!function_exists('grapheme_strrpos')) { |
| 43 | - function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 43 | + function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strrpos((string)$haystack, (string)$needle, (int)$offset); } |
|
| 44 | 44 | } |
| 45 | 45 | if (!function_exists('grapheme_strstr')) { |
| 46 | - function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 46 | + function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string | false { return p\Grapheme::grapheme_strstr((string)$haystack, (string)$needle, (bool)$beforeNeedle); } |
|
| 47 | 47 | } |
| 48 | 48 | if (!function_exists('grapheme_substr')) { |
| 49 | - function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); } |
|
| 49 | + function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string | false { return p\Grapheme::grapheme_substr((string)$string, (int)$offset, $length); } |
|
| 50 | 50 | } |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | |
| 48 | 48 | private static $default = [ |
| 49 | 49 | 'collapseRanges' => true, // ranges of length one are rendered with the trailing `,1` |
| 50 | - 'commonLineThreshold' => 6, // number of same lines before ending a new hunk and creating a new one (if needed) |
|
| 51 | - 'contextLines' => 3, // like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3 |
|
| 50 | + 'commonLineThreshold' => 6, // number of same lines before ending a new hunk and creating a new one (if needed) |
|
| 51 | + 'contextLines' => 3, // like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3 |
|
| 52 | 52 | 'fromFile' => null, |
| 53 | 53 | 'fromFileDate' => null, |
| 54 | 54 | 'toFile' => null, |
@@ -166,7 +166,7 @@ |
||
| 166 | 166 | private function normalizeDiffInput($input) |
| 167 | 167 | { |
| 168 | 168 | if (!\is_array($input) && !\is_string($input)) { |
| 169 | - return (string) $input; |
|
| 169 | + return (string)$input; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return $input; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | return []; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $i = (int) ($cFrom / 2); |
|
| 35 | + $i = (int)($cFrom / 2); |
|
| 36 | 36 | $fromStart = \array_slice($from, 0, $i); |
| 37 | 37 | $fromEnd = \array_slice($from, $i); |
| 38 | 38 | $llB = $this->length($fromStart, $to); |
@@ -72,10 +72,10 @@ |
||
| 72 | 72 | foreach ($lines as $line) { |
| 73 | 73 | if (\preg_match('/^@@\s+-(?P<start>\d+)(?:,\s*(?P<startrange>\d+))?\s+\+(?P<end>\d+)(?:,\s*(?P<endrange>\d+))?\s+@@/', $line, $match)) { |
| 74 | 74 | $chunk = new Chunk( |
| 75 | - (int) $match['start'], |
|
| 76 | - isset($match['startrange']) ? \max(1, (int) $match['startrange']) : 1, |
|
| 77 | - (int) $match['end'], |
|
| 78 | - isset($match['endrange']) ? \max(1, (int) $match['endrange']) : 1 |
|
| 75 | + (int)$match['start'], |
|
| 76 | + isset($match['startrange']) ? \max(1, (int)$match['startrange']) : 1, |
|
| 77 | + (int)$match['end'], |
|
| 78 | + isset($match['endrange']) ? \max(1, (int)$match['endrange']) : 1 |
|
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | 81 | $chunks[] = $chunk; |
@@ -242,7 +242,7 @@ |
||
| 242 | 242 | */ |
| 243 | 243 | protected function scan($input) |
| 244 | 244 | { |
| 245 | - if (! isset($this->regex)) { |
|
| 245 | + if (!isset($this->regex)) { |
|
| 246 | 246 | $this->regex = sprintf( |
| 247 | 247 | '/(%s)|%s/%s', |
| 248 | 248 | implode(')|(', $this->getCatchablePatterns()), |