Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRules([
'@PHP81Migration' => true, // take lowest version from `git grep -h '"php"' **/composer.json | uniq | sort`
'@PHPUnit91Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
'@Symfony' => true,
'@Symfony:risky' => true,
'phpdoc_var_annotation_correct_order' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
foreach ($this->registry->getManagers() as $em) {
// we need the directory no matter the proxy cache generation strategy
if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
if (false === @mkdir($proxyCacheDir, 0777, true) && !is_dir($proxyCacheDir)) {
if (false === @mkdir($proxyCacheDir, 0o777, true) && !is_dir($proxyCacheDir)) {
throw new \RuntimeException(\sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
}
} elseif (!is_writable($proxyCacheDir)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
$prevCacheDir = getenv('COMPOSER_CACHE_DIR');
if ($prevCacheDir) {
if (false === $absoluteCacheDir = realpath($prevCacheDir)) {
@mkdir($prevCacheDir, 0777, true);
@mkdir($prevCacheDir, 0o777, true);
$absoluteCacheDir = realpath($prevCacheDir);
}
if ($absoluteCacheDir) {
Expand All @@ -181,7 +181,7 @@
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
// Build a standalone phpunit without symfony/yaml nor prophecy by default

@mkdir($PHPUNIT_DIR, 0777, true);
@mkdir($PHPUNIT_DIR, 0o777, true);
chdir($PHPUNIT_DIR);
if (file_exists("$PHPUNIT_VERSION_DIR")) {
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s 2> NUL' : 'rm -rf %s', escapeshellarg("$PHPUNIT_VERSION_DIR.old")));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function move(string $directory, ?string $name = null): File
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, $e->getMessage()), 0, $e);
}

@chmod($target, 0666 & ~umask());
@chmod($target, 0o666 & ~umask());

return $target;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function symlink(string $originDir, string $targetDir, bool $relative =
*/
private function hardCopy(string $originDir, string $targetDir): string
{
$this->filesystem->mkdir($targetDir, 0777);
$this->filesystem->mkdir($targetDir, 0o777);
// We use a custom iterator to ignore VCS files
$this->filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function process(ContainerBuilder $container): void

$fs = new Filesystem();
$fs->dumpFile($file, serialize($dump));
$fs->chmod($file, 0666, umask());
$fs->chmod($file, 0o666, umask());
} catch (\Throwable $e) {
$container->getCompiler()->log($this, $e->getMessage());
// ignore serialization and file-system errors
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private function export(string $filename, string $data): void

private function createSecretsDir(): void
{
if ($this->secretsDir && !is_dir($this->secretsDir) && !@mkdir($this->secretsDir, 0777, true) && !is_dir($this->secretsDir)) {
if ($this->secretsDir && !is_dir($this->secretsDir) && !@mkdir($this->secretsDir, 0o777, true) && !is_dir($this->secretsDir)) {
throw new \RuntimeException(\sprintf('Unable to create the secrets directory (%s).', $this->secretsDir));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testAboutWithReadableFiles()
$this->fs->mkdir($kernel->getProjectDir());

$this->fs->dumpFile($kernel->getCacheDir().'/readable_file', 'The file content.');
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0o777);

$tester = $this->createCommandTester($kernel);
$ret = $tester->execute([]);
Expand All @@ -43,7 +43,7 @@ public function testAboutWithReadableFiles()
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
$this->assertStringContainsString('Log directory', $tester->getDisplay());

$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0o777);

try {
$this->fs->remove($kernel->getProjectDir());
Expand All @@ -62,7 +62,7 @@ public function testAboutWithUnreadableFiles()
}

$this->fs->dumpFile($kernel->getCacheDir().'/unreadable_file', 'The file content.');
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0222);
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0o222);

$tester = $this->createCommandTester($kernel);
$ret = $tester->execute([]);
Expand All @@ -71,7 +71,7 @@ public function testAboutWithUnreadableFiles()
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
$this->assertStringContainsString('Log directory', $tester->getDisplay());

$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0777);
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0o777);

try {
$this->fs->remove($kernel->getProjectDir());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ public function testFilterDuplicateTransPaths()

if (preg_match('/\.[a-z]+$/', $transPath)) {
if (!realpath(\dirname($transPath))) {
mkdir(\dirname($transPath), 0777, true);
mkdir(\dirname($transPath), 0o777, true);
}

touch($transPath);
} else {
mkdir($transPath, 0777, true);
mkdir($transPath, 0o777, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ private static function createLocalEntry(string $importName, string $path, Impor

private static function createRemoteEntry(string $importName, string $version, ?string $path = null, ImportMapType $type = ImportMapType::JS, ?string $packageSpecifier = null): ImportMapEntry
{
$packageSpecifier = $packageSpecifier ?? $importName;
$path = $path ?? '/vendor/any-path.js';
$packageSpecifier ??= $importName;
$path ??= '/vendor/any-path.js';

return ImportMapEntry::createRemote($importName, $type, path: $path, version: $version, packageModuleSpecifier: $packageSpecifier, isEntrypoint: false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ private static function createLocalEntry(string $importName, string $path, Impor

private static function createRemoteEntry(string $importName, string $version, ?string $path = null, ImportMapType $type = ImportMapType::JS, ?string $packageSpecifier = null): ImportMapEntry
{
$packageSpecifier = $packageSpecifier ?? $importName;
$path = $path ?? '/vendor/any-path.js';
$packageSpecifier ??= $importName;
$path ??= '/vendor/any-path.js';

return ImportMapEntry::createRemote($importName, $type, path: $path, version: $version, packageModuleSpecifier: $packageSpecifier, isEntrypoint: false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private function responseFactory($method, $url): MockResponse

private static function createRemoteEntry(string $importName, string $version, ImportMapType $type = ImportMapType::JS, ?string $packageSpecifier = null): ImportMapEntry
{
$packageSpecifier = $packageSpecifier ?? $importName;
$packageSpecifier ??= $importName;

return ImportMapEntry::createRemote($importName, $type, path: '/vendor/any-path.js', version: $version, packageModuleSpecifier: $packageSpecifier, isEntrypoint: false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public static function getNpmSpecificVersionConstraints()

private static function createRemoteEntry(string $importName, string $version, ?string $packageModuleSpecifier = null): ImportMapEntry
{
$packageModuleSpecifier = $packageModuleSpecifier ?? $importName;
$packageModuleSpecifier ??= $importName;

return ImportMapEntry::createRemote($importName, ImportMapType::JS, '/path/to/'.$importName, $version, $packageModuleSpecifier, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function testSaveThrowsWhenFailing()
$this->filesystem->mkdir($vendorDir.'/module_specifier');
$this->filesystem->touch($vendorDir.'/module_specifier/module_specifier.index.js');
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0555);
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0o555);
} else {
$this->filesystem->chmod($vendorDir.'/module_specifier/', 0555);
$this->filesystem->chmod($vendorDir.'/module_specifier/', 0o555);
}

$storage = new RemotePackageStorage($vendorDir);
Expand All @@ -63,9 +63,9 @@ public function testSaveThrowsWhenFailing()
$storage->save($entry, 'any content');
} finally {
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0777);
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0o777);
} else {
$this->filesystem->chmod($vendorDir.'/module_specifier/', 0777);
$this->filesystem->chmod($vendorDir.'/module_specifier/', 0o777);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public static function provideImportRegex(): iterable

private static function createRemoteEntry(string $importName, string $version, ImportMapType $type = ImportMapType::JS, ?string $packageSpecifier = null): ImportMapEntry
{
$packageSpecifier = $packageSpecifier ?? $importName;
$packageSpecifier ??= $importName;

return ImportMapEntry::createRemote($importName, $type, path: 'does not matter', version: $version, packageModuleSpecifier: $packageSpecifier, isEntrypoint: false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function warmUp(array $values): array
} else {
$directory = \dirname($this->file);

if (!is_dir($directory) && !@mkdir($directory, 0777, true)) {
if (!is_dir($directory) && !@mkdir($directory, 0o777, true)) {
throw new InvalidArgumentException(\sprintf('Cache directory does not exist and cannot be created: "%s".', $directory));
}

Expand Down Expand Up @@ -324,7 +324,7 @@ public function warmUp(array $values): array
$tmpFile = tempnam(\dirname($this->file), basename($this->file));

file_put_contents($tmpFile, $dump);
@chmod($tmpFile, 0666 & ~umask());
@chmod($tmpFile, 0o666 & ~umask());
unset($serialized, $value, $dump);

@rename($tmpFile, $this->file);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function init(string $namespace, ?string $directory): void
$directory .= \DIRECTORY_SEPARATOR.'@';
}
if (!is_dir($directory)) {
@mkdir($directory, 0777, true);
@mkdir($directory, 0o777, true);
}
$directory .= \DIRECTORY_SEPARATOR;
// On Windows the whole path is limited to 258 chars
Expand Down Expand Up @@ -130,7 +130,7 @@ private function getFile(string $id, bool $mkdir = false, ?string $directory = n
$dir = ($directory ?? $this->directory).strtoupper($hash[0].\DIRECTORY_SEPARATOR.$hash[1].\DIRECTORY_SEPARATOR);

if ($mkdir && !is_dir($dir)) {
@mkdir($dir, 0777, true);
@mkdir($dir, 0o777, true);
}

return $dir.substr($hash, 2, 20);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function getFullPath(ClassBuilder $class): string
{
$directory = $this->outputDir.\DIRECTORY_SEPARATOR.$class->getDirectory();
if (!is_dir($directory)) {
@mkdir($directory, 0777, true);
@mkdir($directory, 0o777, true);
}

return $directory.\DIRECTORY_SEPARATOR.$class->getFilename();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function isFresh(): bool
*/
public function write(string $content, ?array $metadata = null): void
{
$mode = 0666;
$mode = 0o666;
$umask = umask();
$filesystem = new Filesystem();
$filesystem->dumpFile($this->file, $content);
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public function testLoadFile()
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('chmod is not supported on Windows');
}
chmod($fixtures.'not_readable.xml', 000);
chmod($fixtures.'not_readable.xml', 0o00);
XmlUtils::loadFile($fixtures.'not_readable.xml');
$this->fail();
} catch (\InvalidArgumentException $e) {
chmod($fixtures.'not_readable.xml', 0644);
chmod($fixtures.'not_readable.xml', 0o644);
$this->assertStringContainsString('is not readable', $e->getMessage());
}

Expand Down Expand Up @@ -167,7 +167,7 @@ public static function getDataForPhpize(): array
[0, '0'],
[1, '1'],
[-1, '-1'],
[0777, '0777'],
[0o777, '0777'],
[-511, '-0777'],
['0877', '0877'],
[255, '0xFF'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function getTypeConversions()
['zero', 0, true],
['0b0110_byte_string', bindec('0b0110'), false], // not supported by INI_SCANNER_TYPED
['11112222333344445555_great_number', '1111,2222,3333,4444,5555', true],
['0777_number_starting_with_0', 0777, false], // not supported by INI_SCANNER_TYPED
['0777_number_starting_with_0', 0o777, false], // not supported by INI_SCANNER_TYPED
['255_hexadecimal', 0xFF, false], // not supported by INI_SCANNER_TYPED
['100.0_exponential', 1e2, false], // not supported by INI_SCANNER_TYPED
['-120.0_exponential', -1.2E2, false], // not supported by INI_SCANNER_TYPED
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe

if ($originIsLocal) {
// Like `cp`, preserve executable permission bits
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0o111));

// Like `cp`, preserve the file modification time
self::box('touch', $targetFile, filemtime($originFile));
Expand All @@ -87,7 +87,7 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
*
* @throws IOException On any directory creation failure
*/
public function mkdir(string|iterable $dirs, int $mode = 0777): void
public function mkdir(string|iterable $dirs, int $mode = 0o777): void
{
foreach ($this->toIterable($dirs) as $dir) {
if (is_dir($dir)) {
Expand Down Expand Up @@ -208,7 +208,7 @@ private static function doRemove(array $files, bool $isRecursive): void
*
* @throws IOException When the change fails
*/
public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false): void
public function chmod(string|iterable $files, int $mode, int $umask = 0o000, bool $recursive = false): void
{
foreach ($this->toIterable($files) as $file) {
if (!self::box('chmod', $file, $mode & ~$umask)) {
Expand Down Expand Up @@ -670,13 +670,13 @@ public function dumpFile(string $filename, $content): void
throw new IOException(\sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
}

self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask());
self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0o666 & ~umask());

$this->rename($tmpFile, $filename, true);
} finally {
if (file_exists($tmpFile)) {
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0o200);
}

self::box('unlink', $tmpFile);
Expand Down
Loading
Loading