Skip to content

Commit 12739da

Browse files
Merge branch '3.4' into 4.0
* 3.4: Fix Clidumper tests Enable the fixer enforcing fully-qualified calls for compiler-optimized functions Apply fixers Disable the native_constant_invocation fixer until it can be scoped Update the list of excluded files for the CS fixer
2 parents 7a69e72 + 1d5b3bf commit 12739da

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

Filesystem.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
4545
throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
4646
}
4747

48-
$this->mkdir(dirname($targetFile));
48+
$this->mkdir(\dirname($targetFile));
4949

5050
$doCopy = true;
5151
if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
@@ -122,7 +122,7 @@ public function exists($files)
122122
$maxPathLength = PHP_MAXPATHLEN - 2;
123123

124124
foreach ($this->toIterable($files) as $file) {
125-
if (strlen($file) > $maxPathLength) {
125+
if (\strlen($file) > $maxPathLength) {
126126
throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
127127
}
128128

@@ -164,7 +164,7 @@ public function remove($files)
164164
{
165165
if ($files instanceof \Traversable) {
166166
$files = iterator_to_array($files, false);
167-
} elseif (!is_array($files)) {
167+
} elseif (!\is_array($files)) {
168168
$files = array($files);
169169
}
170170
$files = array_reverse($files);
@@ -223,7 +223,7 @@ public function chown($files, $user, $recursive = false)
223223
if ($recursive && is_dir($file) && !is_link($file)) {
224224
$this->chown(new \FilesystemIterator($file), $user, true);
225225
}
226-
if (is_link($file) && function_exists('lchown')) {
226+
if (is_link($file) && \function_exists('lchown')) {
227227
if (true !== @lchown($file, $user)) {
228228
throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
229229
}
@@ -250,7 +250,7 @@ public function chgrp($files, $group, $recursive = false)
250250
if ($recursive && is_dir($file) && !is_link($file)) {
251251
$this->chgrp(new \FilesystemIterator($file), $group, true);
252252
}
253-
if (is_link($file) && function_exists('lchgrp')) {
253+
if (is_link($file) && \function_exists('lchgrp')) {
254254
if (true !== @lchgrp($file, $group)) {
255255
throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
256256
}
@@ -304,7 +304,7 @@ private function isReadable($filename)
304304
{
305305
$maxPathLength = PHP_MAXPATHLEN - 2;
306306

307-
if (strlen($filename) > $maxPathLength) {
307+
if (\strlen($filename) > $maxPathLength) {
308308
throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
309309
}
310310

@@ -333,7 +333,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
333333
}
334334
}
335335

336-
$this->mkdir(dirname($targetDir));
336+
$this->mkdir(\dirname($targetDir));
337337

338338
if (is_link($targetDir)) {
339339
if (readlink($targetDir) === $originDir) {
@@ -461,7 +461,7 @@ public function makePathRelative($endPath, $startPath)
461461
}
462462

463463
$stripDriveLetter = function ($path) {
464-
if (strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
464+
if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
465465
return substr($path, 2);
466466
}
467467

@@ -499,16 +499,16 @@ public function makePathRelative($endPath, $startPath)
499499
}
500500

501501
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
502-
if (1 === count($startPathArr) && '' === $startPathArr[0]) {
502+
if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
503503
$depth = 0;
504504
} else {
505-
$depth = count($startPathArr) - $index;
505+
$depth = \count($startPathArr) - $index;
506506
}
507507

508508
// Repeated "../" for each level need to reach the common path
509509
$traverser = str_repeat('../', $depth);
510510

511-
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
511+
$endPathRemainder = implode('/', \array_slice($endPathArr, $index));
512512

513513
// Construct $endPath from traversing to the common path, then to the remaining $endPath
514514
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
@@ -539,7 +539,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
539539
{
540540
$targetDir = rtrim($targetDir, '/\\');
541541
$originDir = rtrim($originDir, '/\\');
542-
$originDirLen = strlen($originDir);
542+
$originDirLen = \strlen($originDir);
543543

544544
// Iterate in destination folder to remove obsolete entries
545545
if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
@@ -548,7 +548,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
548548
$flags = \FilesystemIterator::SKIP_DOTS;
549549
$deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
550550
}
551-
$targetDirLen = strlen($targetDir);
551+
$targetDirLen = \strlen($targetDir);
552552
foreach ($deleteIterator as $file) {
553553
$origin = $originDir.substr($file->getPathname(), $targetDirLen);
554554
if (!$this->exists($origin)) {
@@ -606,7 +606,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
606606
public function isAbsolutePath($file)
607607
{
608608
return strspn($file, '/\\', 0, 1)
609-
|| (strlen($file) > 3 && ctype_alpha($file[0])
609+
|| (\strlen($file) > 3 && ctype_alpha($file[0])
610610
&& ':' === $file[1]
611611
&& strspn($file, '/\\', 2, 1)
612612
)
@@ -676,7 +676,7 @@ public function tempnam($dir, $prefix)
676676
*/
677677
public function dumpFile($filename, $content)
678678
{
679-
$dir = dirname($filename);
679+
$dir = \dirname($filename);
680680

681681
if (!is_dir($dir)) {
682682
$this->mkdir($dir);
@@ -709,7 +709,7 @@ public function dumpFile($filename, $content)
709709
*/
710710
public function appendToFile($filename, $content)
711711
{
712-
$dir = dirname($filename);
712+
$dir = \dirname($filename);
713713

714714
if (!is_dir($dir)) {
715715
$this->mkdir($dir);
@@ -726,7 +726,7 @@ public function appendToFile($filename, $content)
726726

727727
private function toIterable($files): iterable
728728
{
729-
return is_array($files) || $files instanceof \Traversable ? $files : array($files);
729+
return \is_array($files) || $files instanceof \Traversable ? $files : array($files);
730730
}
731731

732732
/**
@@ -736,7 +736,7 @@ private function getSchemeAndHierarchy(string $filename): array
736736
{
737737
$components = explode('://', $filename, 2);
738738

739-
return 2 === count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
739+
return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
740740
}
741741

742742
private static function box($func)

Tests/FilesystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public function testFilesExistsFails()
383383
$oldPath = getcwd();
384384
mkdir($basePath);
385385
chdir($basePath);
386-
$file = str_repeat('T', $maxPathLength - strlen($basePath) + 1);
386+
$file = str_repeat('T', $maxPathLength - \strlen($basePath) + 1);
387387
$path = $basePath.$file;
388388
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
389389
$this->longPathNamesWindows[] = $path; // save this so we can clean up later

Tests/FilesystemTestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function setUpBeforeClass()
4848
$targetFile = tempnam(sys_get_temp_dir(), 'li');
4949
if (true !== @link($originFile, $targetFile)) {
5050
$report = error_get_last();
51-
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
51+
if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
5252
self::$linkOnWindows = false;
5353
}
5454
} else {
@@ -60,7 +60,7 @@ public static function setUpBeforeClass()
6060
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
6161
if (true !== @symlink($originDir, $targetDir)) {
6262
$report = error_get_last();
63-
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
63+
if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
6464
self::$symlinkOnWindows = false;
6565
}
6666
} else {
@@ -129,7 +129,7 @@ protected function getFileGroup($filepath)
129129

130130
protected function markAsSkippedIfLinkIsMissing()
131131
{
132-
if (!function_exists('link')) {
132+
if (!\function_exists('link')) {
133133
$this->markTestSkipped('link is not supported');
134134
}
135135

@@ -159,7 +159,7 @@ protected function markAsSkippedIfChmodIsMissing()
159159

160160
protected function markAsSkippedIfPosixIsMissing()
161161
{
162-
if (!function_exists('posix_isatty')) {
162+
if (!\function_exists('posix_isatty')) {
163163
$this->markTestSkipped('Function posix_isatty is required.');
164164
}
165165
}

0 commit comments

Comments
 (0)