Skip to content

Commit f3312e7

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent 5cfc856 commit f3312e7

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

Filesystem.php

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

47-
$this->mkdir(dirname($targetFile));
47+
$this->mkdir(\dirname($targetFile));
4848

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

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

@@ -163,7 +163,7 @@ public function remove($files)
163163
{
164164
if ($files instanceof \Traversable) {
165165
$files = iterator_to_array($files, false);
166-
} elseif (!is_array($files)) {
166+
} elseif (!\is_array($files)) {
167167
$files = array($files);
168168
}
169169
$files = array_reverse($files);
@@ -222,7 +222,7 @@ public function chown($files, $user, $recursive = false)
222222
if ($recursive && is_dir($file) && !is_link($file)) {
223223
$this->chown(new \FilesystemIterator($file), $user, true);
224224
}
225-
if (is_link($file) && function_exists('lchown')) {
225+
if (is_link($file) && \function_exists('lchown')) {
226226
if (true !== @lchown($file, $user)) {
227227
throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
228228
}
@@ -249,8 +249,8 @@ public function chgrp($files, $group, $recursive = false)
249249
if ($recursive && is_dir($file) && !is_link($file)) {
250250
$this->chgrp(new \FilesystemIterator($file), $group, true);
251251
}
252-
if (is_link($file) && function_exists('lchgrp')) {
253-
if (true !== @lchgrp($file, $group) || (defined('HHVM_VERSION') && !posix_getgrnam($group))) {
252+
if (is_link($file) && \function_exists('lchgrp')) {
253+
if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
254254
throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
255255
}
256256
} else {
@@ -303,7 +303,7 @@ private function isReadable($filename)
303303
{
304304
$maxPathLength = PHP_MAXPATHLEN - 2;
305305

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

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

335-
$this->mkdir(dirname($targetDir));
335+
$this->mkdir(\dirname($targetDir));
336336

337337
if (is_link($targetDir)) {
338338
if (readlink($targetDir) === $originDir) {
@@ -368,7 +368,7 @@ public function makePathRelative($endPath, $startPath)
368368
}
369369

370370
$stripDriveLetter = function ($path) {
371-
if (strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
371+
if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
372372
return substr($path, 2);
373373
}
374374

@@ -386,7 +386,7 @@ public function makePathRelative($endPath, $startPath)
386386
$result = array();
387387

388388
foreach ($pathSegments as $segment) {
389-
if ('..' === $segment && ($absolute || count($result))) {
389+
if ('..' === $segment && ($absolute || \count($result))) {
390390
array_pop($result);
391391
} elseif ('.' !== $segment) {
392392
$result[] = $segment;
@@ -406,16 +406,16 @@ public function makePathRelative($endPath, $startPath)
406406
}
407407

408408
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
409-
if (1 === count($startPathArr) && '' === $startPathArr[0]) {
409+
if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
410410
$depth = 0;
411411
} else {
412-
$depth = count($startPathArr) - $index;
412+
$depth = \count($startPathArr) - $index;
413413
}
414414

415415
// Repeated "../" for each level need to reach the common path
416416
$traverser = str_repeat('../', $depth);
417417

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

420420
// Construct $endPath from traversing to the common path, then to the remaining $endPath
421421
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
@@ -446,7 +446,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
446446
{
447447
$targetDir = rtrim($targetDir, '/\\');
448448
$originDir = rtrim($originDir, '/\\');
449-
$originDirLen = strlen($originDir);
449+
$originDirLen = \strlen($originDir);
450450

451451
// Iterate in destination folder to remove obsolete entries
452452
if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
@@ -455,7 +455,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
455455
$flags = \FilesystemIterator::SKIP_DOTS;
456456
$deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
457457
}
458-
$targetDirLen = strlen($targetDir);
458+
$targetDirLen = \strlen($targetDir);
459459
foreach ($deleteIterator as $file) {
460460
$origin = $originDir.substr($file->getPathname(), $targetDirLen);
461461
if (!$this->exists($origin)) {
@@ -513,7 +513,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
513513
public function isAbsolutePath($file)
514514
{
515515
return strspn($file, '/\\', 0, 1)
516-
|| (strlen($file) > 3 && ctype_alpha($file[0])
516+
|| (\strlen($file) > 3 && ctype_alpha($file[0])
517517
&& ':' === substr($file, 1, 1)
518518
&& strspn($file, '/\\', 2, 1)
519519
)
@@ -585,7 +585,7 @@ public function tempnam($dir, $prefix)
585585
*/
586586
public function dumpFile($filename, $content, $mode = 0666)
587587
{
588-
$dir = dirname($filename);
588+
$dir = \dirname($filename);
589589

590590
if (!is_dir($dir)) {
591591
$this->mkdir($dir);
@@ -602,7 +602,7 @@ public function dumpFile($filename, $content, $mode = 0666)
602602
}
603603

604604
if (null !== $mode) {
605-
if (func_num_args() > 2) {
605+
if (\func_num_args() > 2) {
606606
@trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
607607
}
608608

@@ -622,7 +622,7 @@ public function dumpFile($filename, $content, $mode = 0666)
622622
private function toIterator($files)
623623
{
624624
if (!$files instanceof \Traversable) {
625-
$files = new \ArrayObject(is_array($files) ? $files : array($files));
625+
$files = new \ArrayObject(\is_array($files) ? $files : array($files));
626626
}
627627

628628
return $files;
@@ -639,7 +639,7 @@ private function getSchemeAndHierarchy($filename)
639639
{
640640
$components = explode('://', $filename, 2);
641641

642-
return 2 === count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
642+
return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
643643
}
644644

645645
private static function box($func)

Tests/FilesystemTest.php

Lines changed: 3 additions & 3 deletions
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
@@ -449,7 +449,7 @@ public function testChmodWithWrongModLeavesPreviousPermissionsUntouched()
449449
{
450450
$this->markAsSkippedIfChmodIsMissing();
451451

452-
if (defined('HHVM_VERSION')) {
452+
if (\defined('HHVM_VERSION')) {
453453
$this->markTestSkipped('chmod() changes permissions even when passing invalid modes on HHVM');
454454
}
455455

@@ -1247,7 +1247,7 @@ public function testDumpFileOverwritesAnExistingFile()
12471247

12481248
public function testDumpFileWithFileScheme()
12491249
{
1250-
if (defined('HHVM_VERSION')) {
1250+
if (\defined('HHVM_VERSION')) {
12511251
$this->markTestSkipped('HHVM does not handle the file:// scheme correctly');
12521252
}
12531253

Tests/FilesystemTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function markAsSkippedIfChmodIsMissing()
122122

123123
protected function markAsSkippedIfPosixIsMissing()
124124
{
125-
if (!function_exists('posix_isatty')) {
125+
if (!\function_exists('posix_isatty')) {
126126
$this->markTestSkipped('Function posix_isatty is required.');
127127
}
128128
}

Tests/LockHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testErrorHandlingInLockIfLockPathBecomesUnwritable()
7676
$fs->remove($lockPath);
7777
}
7878

79-
$this->assertInstanceOf('Symfony\Component\Filesystem\Exception\IOException', $e, sprintf('Expected IOException to be thrown, got %s instead.', get_class($e)));
79+
$this->assertInstanceOf('Symfony\Component\Filesystem\Exception\IOException', $e, sprintf('Expected IOException to be thrown, got %s instead.', \get_class($e)));
8080
$this->assertNull($wrongMessage, sprintf('Expected exception message to contain "Permission denied", got "%s" instead.', $wrongMessage));
8181
}
8282

0 commit comments

Comments
 (0)