From 92940de5e52b55e8c8425d079cf1f37786449b17 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 9 Aug 2025 23:58:04 +0200 Subject: [PATCH] chore: PHP CS Fixer - restore PHP / PHPUnit rulesets --- .php-cs-fixer.dist.php | 2 + .../Doctrine/CacheWarmer/ProxyCacheWarmer.php | 2 +- .../Bridge/PhpUnit/bin/simple-phpunit.php | 4 +- .../PsrHttpMessage/Factory/UploadedFile.php | 2 +- .../Command/AssetsInstallCommand.php | 2 +- .../ContainerBuilderDebugDumpPass.php | 2 +- .../FrameworkBundle/Secrets/SodiumVault.php | 2 +- .../Command/AboutCommand/AboutCommandTest.php | 8 ++-- .../Command/TranslationExtractCommandTest.php | 4 +- .../ImportMap/ImportMapGeneratorTest.php | 4 +- .../Tests/ImportMap/ImportMapManagerTest.php | 4 +- .../ImportMap/ImportMapUpdateCheckerTest.php | 2 +- .../ImportMap/ImportMapVersionCheckerTest.php | 2 +- .../ImportMap/RemotePackageStorageTest.php | 8 ++-- .../Resolver/JsDelivrEsmResolverTest.php | 2 +- .../Cache/Adapter/PhpArrayAdapter.php | 4 +- .../Cache/Traits/FilesystemCommonTrait.php | 4 +- .../Config/Builder/ConfigBuilderGenerator.php | 2 +- .../Config/ResourceCheckerConfigCache.php | 2 +- .../Config/Tests/Util/XmlUtilsTest.php | 6 +-- .../Tests/Loader/IniFileLoaderTest.php | 2 +- .../Component/Filesystem/Filesystem.php | 10 ++-- .../Filesystem/Tests/FilesystemTest.php | 46 +++++++++---------- .../Filesystem/Tests/FilesystemTestCase.php | 2 +- .../Component/Finder/Tests/FinderTest.php | 8 ++-- .../Tests/Iterator/VfsIteratorTestTrait.php | 2 +- .../DataCollector/HttpClientDataCollector.php | 4 +- .../Component/HttpFoundation/File/File.php | 4 +- .../HttpFoundation/File/UploadedFile.php | 2 +- .../Handler/NativeFileSessionHandler.php | 2 +- .../Storage/MockFileSessionStorage.php | 2 +- .../HttpFoundation/Tests/FileBagTest.php | 2 +- .../HttpKernel/CacheWarmer/CacheWarmer.php | 2 +- .../Component/HttpKernel/HttpCache/Store.php | 8 ++-- src/Symfony/Component/HttpKernel/Kernel.php | 6 +-- .../Profiler/FileProfilerStorage.php | 4 +- .../Intl/Tests/Util/GitRepositoryTest.php | 2 +- .../Component/JsonStreamer/Read/Splitter.php | 2 +- .../Read/StreamReaderGenerator.php | 2 +- .../Write/StreamWriterGenerator.php | 2 +- .../Component/Lock/Store/FlockStore.php | 4 +- .../Tests/AbstractMimeTypeGuesserTestCase.php | 4 +- .../Bridge/Matrix/MatrixTransport.php | 2 +- .../Process/Tests/ExecutableFinderTest.php | 2 +- .../Component/Runtime/GenericRuntime.php | 2 +- .../Component/Serializer/Serializer.php | 2 +- .../Translation/Dumper/FileDumper.php | 2 +- .../Translation/Writer/TranslationWriter.php | 2 +- .../VarDumper/Tests/Caster/GmpCasterTest.php | 2 +- .../Component/Yaml/Tests/InlineTest.php | 8 ++-- .../Component/Yaml/Tests/ParserTest.php | 4 +- 51 files changed, 109 insertions(+), 107 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index c7b05c8e70997..fb8b3b1ab80b6 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -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, diff --git a/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php b/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php index 2ac99ae110949..69b90a449a7ba 100644 --- a/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php +++ b/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php @@ -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)) { diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index 8a018c45b8171..ee8a05386bef3 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -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) { @@ -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"))); diff --git a/src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php b/src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php index 34d405856057f..258d8fddaf16b 100644 --- a/src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php +++ b/src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php @@ -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; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index d8a4f345f18ce..67b5e7653764e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -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)); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php index ff90207969414..456305bc95f49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php @@ -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 diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index 2a8e5dcc8b147..5abdfdc702383 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -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)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/AboutCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/AboutCommandTest.php index ee3904be36a7c..044d816e06216 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/AboutCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/AboutCommandTest.php @@ -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([]); @@ -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()); @@ -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([]); @@ -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()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php index 89361e825ed11..276af4476e12c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php @@ -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); } } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php index e24708fc3fc32..2812465511e09 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php @@ -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); } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php index ec94f716db0a1..167e2fe0653be 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php @@ -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); } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php index 6c6a07d6cbe3e..2882497b6bcda 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php @@ -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); } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php index ab02e5c7da05c..d0f765351d552 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php @@ -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); } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php index c733e063af19c..d1e8019b77b8b 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php @@ -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); @@ -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); } } } diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php index 39614a7b81662..b769a861fa1d0 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 8047a8a280260..4efeb15e23caf 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -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)); } @@ -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); diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 98e0d3ec504f5..b3a156f4a5999 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -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 @@ -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); diff --git a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php index d7689901600ba..416a6d9179d3e 100644 --- a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php +++ b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php @@ -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(); diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index 955aee7e575ad..436d85ab5dee7 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -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); diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 722b18efa2c67..344e839abe702 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -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()); } @@ -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'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index c3825fbb9271d..a02d7266539fc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -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 diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index bfe3878030b36..cc553bd357596 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -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)); @@ -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)) { @@ -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)) { @@ -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); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 64d2525a3162a..39d77f3c72859 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -64,7 +64,7 @@ public function testCopyUnreadableFileFails() file_put_contents($sourceFilePath, 'SOURCE FILE'); // make sure target cannot be read - $this->filesystem->chmod($sourceFilePath, 0222); + $this->filesystem->chmod($sourceFilePath, 0o222); $this->filesystem->copy($sourceFilePath, $targetFilePath); } @@ -146,7 +146,7 @@ public function testCopyWithOverrideWithReadOnlyTargetFails() touch($targetFilePath, $modificationTime); // make sure target is read-only - $this->filesystem->chmod($targetFilePath, 0444); + $this->filesystem->chmod($targetFilePath, 0o444); $this->filesystem->copy($sourceFilePath, $targetFilePath, true); } @@ -359,7 +359,7 @@ public function testRemoveThrowsExceptionOnPermissionDenied() mkdir($basePath); $file = $basePath.\DIRECTORY_SEPARATOR.'file'; touch($file); - chmod($basePath, 0400); + chmod($basePath, 0o400); try { $this->filesystem->remove($file); @@ -369,7 +369,7 @@ public function testRemoveThrowsExceptionOnPermissionDenied() $this->assertStringContainsString('Permission denied', $e->getMessage()); } finally { // Make sure we can clean up this file - chmod($basePath, 0777); + chmod($basePath, 0o777); } } @@ -476,8 +476,8 @@ public function testChmodChangesFileMode() $file = $dir.\DIRECTORY_SEPARATOR.'file'; touch($file); - $this->filesystem->chmod($file, 0400); - $this->filesystem->chmod($dir, 0753); + $this->filesystem->chmod($file, 0o400); + $this->filesystem->chmod($dir, 0o753); $this->assertFilePermissions(753, $dir); $this->assertFilePermissions(400, $file); @@ -492,8 +492,8 @@ public function testChmodRecursive() $file = $dir.\DIRECTORY_SEPARATOR.'file'; touch($file); - $this->filesystem->chmod($file, 0400, 0000, true); - $this->filesystem->chmod($dir, 0753, 0000, true); + $this->filesystem->chmod($file, 0o400, 0o000, true); + $this->filesystem->chmod($dir, 0o753, 0o000, true); $this->assertFilePermissions(753, $dir); $this->assertFilePermissions(753, $file); @@ -506,7 +506,7 @@ public function testChmodAppliesUmask() $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; touch($file); - $this->filesystem->chmod($file, 0770, 0022); + $this->filesystem->chmod($file, 0o770, 0o022); $this->assertFilePermissions(750, $file); } @@ -521,7 +521,7 @@ public function testChmodChangesModeOfArrayOfFiles() mkdir($directory); touch($file); - $this->filesystem->chmod($files, 0753); + $this->filesystem->chmod($files, 0o753); $this->assertFilePermissions(753, $file); $this->assertFilePermissions(753, $directory); @@ -538,7 +538,7 @@ public function testChmodChangesModeOfTraversableFileObject() mkdir($directory); touch($file); - $this->filesystem->chmod($files, 0753); + $this->filesystem->chmod($files, 0o753); $this->assertFilePermissions(753, $file); $this->assertFilePermissions(753, $directory); @@ -553,9 +553,9 @@ public function testChmodChangesZeroModeOnSubdirectoriesOnRecursive() mkdir($directory); mkdir($subdirectory); - chmod($subdirectory, 0000); + chmod($subdirectory, 0o000); - $this->filesystem->chmod($directory, 0753, 0000, true); + $this->filesystem->chmod($directory, 0o753, 0o000, true); $this->assertFilePermissions(753, $subdirectory); } @@ -1294,7 +1294,7 @@ public function testMirrorCopiesLinkedDirectoryContents() $sourcePath = $this->workspace.\DIRECTORY_SEPARATOR.'source'.\DIRECTORY_SEPARATOR; - mkdir($sourcePath.'nested/', 0777, true); + mkdir($sourcePath.'nested/', 0o777, true); file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1'); // Note: We symlink directory, not file symlink($sourcePath.'nested', $sourcePath.'link1'); @@ -1315,7 +1315,7 @@ public function testMirrorCopiesRelativeLinkedContents() $sourcePath = $this->workspace.\DIRECTORY_SEPARATOR.'source'.\DIRECTORY_SEPARATOR; $oldPath = getcwd(); - mkdir($sourcePath.'nested/', 0777, true); + mkdir($sourcePath.'nested/', 0o777, true); file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1'); // Note: Create relative symlink chdir($sourcePath); @@ -1565,7 +1565,7 @@ public function testDumpFile() // skip mode check on Windows if ('\\' !== \DIRECTORY_SEPARATOR) { - $oldMask = umask(0002); + $oldMask = umask(0o002); } $this->filesystem->dumpFile($filename, 'bar'); @@ -1661,7 +1661,7 @@ public function testAppendToFile() // skip mode check on Windows if ('\\' !== \DIRECTORY_SEPARATOR) { - $oldMask = umask(0002); + $oldMask = umask(0o002); } $this->filesystem->dumpFile($filename, 'foo'); @@ -1684,7 +1684,7 @@ public function testAppendToFileWithResource() // skip mode check on Windows if ('\\' !== \DIRECTORY_SEPARATOR) { - $oldMask = umask(0002); + $oldMask = umask(0o002); } $this->filesystem->dumpFile($filename, 'foo'); @@ -1767,7 +1767,7 @@ public function testAppendToFileCreateTheFileIfNotExists() // skip mode check on Windows if ('\\' !== \DIRECTORY_SEPARATOR) { - $oldMask = umask(0002); + $oldMask = umask(0o002); } $this->filesystem->appendToFile($filename, 'bar'); @@ -1800,7 +1800,7 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile() $filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt'; file_put_contents($filename, 'FOO BAR'); - chmod($filename, 0745); + chmod($filename, 0o745); $this->filesystem->dumpFile($filename, 'bar'); @@ -1811,13 +1811,13 @@ public function testDumpFileCleansUpAfterFailure() { $targetFile = $this->workspace.'/dump-file'; $this->filesystem->touch($targetFile); - $this->filesystem->chmod($targetFile, 0444); + $this->filesystem->chmod($targetFile, 0o444); try { $this->filesystem->dumpFile($targetFile, 'any content'); } catch (IOException $e) { } finally { - $this->filesystem->chmod($targetFile, 0666); + $this->filesystem->chmod($targetFile, 0o666); } $this->assertSame([$targetFile], glob($this->workspace.'/*')); @@ -1868,7 +1868,7 @@ public function testCopyShouldKeepExecutionPermission() $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; file_put_contents($sourceFilePath, 'SOURCE FILE'); - chmod($sourceFilePath, 0745); + chmod($sourceFilePath, 0o745); $this->filesystem->copy($sourceFilePath, $targetFilePath); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index 0f060a12c4e72..8886eec58a0ff 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -59,7 +59,7 @@ protected function setUp(): void $this->umask = umask(0); $this->filesystem = new Filesystem(); $this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand(); - mkdir($this->workspace, 0777, true); + mkdir($this->workspace, 0o777, true); $this->workspace = realpath($this->workspace); } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index cdb4cc2b39223..b336e849c9740 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -1590,7 +1590,7 @@ public function testAccessDeniedException() // make 'foo' directory non-readable $testDir = self::$tmpDir.\DIRECTORY_SEPARATOR.'foo'; - chmod($testDir, 0333); + chmod($testDir, 0o333); if (false === $couldRead = is_readable($testDir)) { try { @@ -1607,7 +1607,7 @@ public function testAccessDeniedException() } // restore original permissions - chmod($testDir, 0777); + chmod($testDir, 0o777); clearstatcache(true, $testDir); if ($couldRead) { @@ -1626,7 +1626,7 @@ public function testIgnoredAccessDeniedException() // make 'foo' directory non-readable $testDir = self::$tmpDir.\DIRECTORY_SEPARATOR.'foo'; - chmod($testDir, 0333); + chmod($testDir, 0o333); if (false === ($couldRead = is_readable($testDir))) { $this->assertIterator($this->toAbsolute([ @@ -1648,7 +1648,7 @@ public function testIgnoredAccessDeniedException() } // restore original permissions - chmod($testDir, 0777); + chmod($testDir, 0o777); clearstatcache(true, $testDir); if ($couldRead) { diff --git a/src/Symfony/Component/Finder/Tests/Iterator/VfsIteratorTestTrait.php b/src/Symfony/Component/Finder/Tests/Iterator/VfsIteratorTestTrait.php index f941bb4d5dcea..dba37d7a698e3 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/VfsIteratorTestTrait.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/VfsIteratorTestTrait.php @@ -108,7 +108,7 @@ public function url_stat(string $url): array $isDir = $providerFx($path, 'is_dir'); \assert(\is_bool($isDir)); - return ['mode' => $isDir ? 0040755 : 0100644]; + return ['mode' => $isDir ? 0o040755 : 0o100644]; } }); self::$vfsProviders = &$vfsWrapperClass::$vfsProviders; diff --git a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php index 8341b3f4a0be5..e1304c3ebfb49 100644 --- a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php +++ b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php @@ -45,8 +45,8 @@ public function collect(Request $request, Response $response, ?\Throwable $excep public function lateCollect(): void { - $this->data['request_count'] = $this->data['request_count'] ?? 0; - $this->data['error_count'] = $this->data['error_count'] ?? 0; + $this->data['request_count'] ??= 0; + $this->data['error_count'] ??= 0; $this->data += ['clients' => []]; foreach ($this->clients as $name => $client) { diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index 2194c178aee7e..e17aff16efa3b 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -96,7 +96,7 @@ public function move(string $directory, ?string $name = null): self throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error))); } - @chmod($target, 0666 & ~umask()); + @chmod($target, 0o666 & ~umask()); return $target; } @@ -115,7 +115,7 @@ public function getContent(): string protected function getTargetFile(string $directory, ?string $name = null): self { if (!is_dir($directory)) { - if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) { + if (false === @mkdir($directory, 0o777, true) && !is_dir($directory)) { throw new FileException(\sprintf('Unable to create the "%s" directory.', $directory)); } } elseif (!is_writable($directory)) { diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index a27a56f96abe2..53dce7de54c6a 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -197,7 +197,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, strip_tags($error))); } - @chmod($target, 0666 & ~umask()); + @chmod($target, 0o666 & ~umask()); return $target; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php index 284cd869d34bf..81e97be9448c2 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php @@ -41,7 +41,7 @@ public function __construct(?string $savePath = null) $baseDir = ltrim(strrchr($savePath, ';'), ';'); } - if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) { + if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0o777, true) && !is_dir($baseDir)) { throw new \RuntimeException(\sprintf('Session Storage was not able to create directory "%s".', $baseDir)); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php index c230c701a07b1..41c7a386d14a9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php @@ -34,7 +34,7 @@ public function __construct(?string $savePath = null, string $name = 'MOCKSESSID { $savePath ??= sys_get_temp_dir(); - if (!is_dir($savePath) && !@mkdir($savePath, 0777, true) && !is_dir($savePath)) { + if (!is_dir($savePath) && !@mkdir($savePath, 0o777, true) && !is_dir($savePath)) { throw new \RuntimeException(\sprintf('Session Storage was not able to create directory "%s".', $savePath)); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index 1afc61d2ad64e..bea9703383d73 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -209,7 +209,7 @@ protected function createTempFile() protected function setUp(): void { - mkdir(sys_get_temp_dir().'/form_test', 0777, true); + mkdir(sys_get_temp_dir().'/form_test', 0o777, true); } protected function tearDown(): void diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php index 0139937b35301..885c9900f0031 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php @@ -22,7 +22,7 @@ protected function writeCacheFile(string $file, $content): void { $tmpFile = @tempnam(\dirname($file), basename($file)); if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { - @chmod($file, 0666 & ~umask()); + @chmod($file, 0o666 & ~umask()); return; } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 9c790f6d82734..da10ff575bfd9 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -43,7 +43,7 @@ public function __construct( protected string $root, private array $options = [], ) { - if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { + if (!is_dir($this->root) && !@mkdir($this->root, 0o777, true) && !is_dir($this->root)) { throw new \RuntimeException(\sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); @@ -75,7 +75,7 @@ public function lock(Request $request): bool|string if (!isset($this->locks[$key])) { $path = $this->getPath($key); - if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) { + if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0o777, true) && !is_dir(\dirname($path))) { return $path; } $h = fopen($path, 'c'); @@ -379,7 +379,7 @@ private function save(string $key, string $data, bool $overwrite = true): bool return false; } } else { - if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) { + if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0o777, true) && !is_dir(\dirname($path))) { return false; } @@ -405,7 +405,7 @@ private function save(string $key, string $data, bool $overwrite = true): bool } } - @chmod($path, 0666 & ~umask()); + @chmod($path, 0o666 & ~umask()); return true; } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 49c6ecbac1cb1..5b276a576e3f5 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -418,7 +418,7 @@ protected function initializeContainer(): void $oldContainer = \is_object($this->container) ? new \ReflectionClass($this->container) : $this->container = null; try { - is_dir($buildDir) ?: mkdir($buildDir, 0777, true); + is_dir($buildDir) ?: mkdir($buildDir, 0o777, true); if ($lock = fopen($cachePath.'.lock', 'w+')) { if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { @@ -597,7 +597,7 @@ protected function buildContainer(): ContainerBuilder { foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir()] as $name => $dir) { if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { + if (false === @mkdir($dir, 0o777, true) && !is_dir($dir)) { throw new \RuntimeException(\sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { @@ -697,7 +697,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container foreach ($content as $file => $code) { $fs->dumpFile($dir.$file, $code); - @chmod($dir.$file, 0666 & ~umask()); + @chmod($dir.$file, 0o666 & ~umask()); } $legacyFile = \dirname($dir.key($content)).'.legacy'; if (is_file($legacyFile)) { diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index cc1fcc53357cd..5dbd4f4ee0aa6 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -37,7 +37,7 @@ public function __construct(string $dsn) } $this->folder = substr($dsn, 5); - if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { + if (!is_dir($this->folder) && false === @mkdir($this->folder, 0o777, true) && !is_dir($this->folder)) { throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $this->folder)); } } @@ -136,7 +136,7 @@ public function write(Profile $profile): bool if (!$profileIndexed) { // Create directory $dir = \dirname($file); - if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { + if (!is_dir($dir) && false === @mkdir($dir, 0o777, true) && !is_dir($dir)) { throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $dir)); } } diff --git a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php index 84d5ae0cfa7ec..03ce8693dda5b 100644 --- a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php +++ b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php @@ -40,7 +40,7 @@ public function testItThrowsAnExceptionIfInitialisedWithNonGitDirectory() { $this->expectException(RuntimeException::class); - @mkdir($this->targetDir, 0777, true); + @mkdir($this->targetDir, 0o777, true); new GitRepository($this->targetDir); } diff --git a/src/Symfony/Component/JsonStreamer/Read/Splitter.php b/src/Symfony/Component/JsonStreamer/Read/Splitter.php index 671a1df69d644..377b592629e58 100644 --- a/src/Symfony/Component/JsonStreamer/Read/Splitter.php +++ b/src/Symfony/Component/JsonStreamer/Read/Splitter.php @@ -79,7 +79,7 @@ private static function createListBoundaries(\Iterator $tokens): \Iterator } [$value, $position] = $token; - $offset = $offset ?? $position; + $offset ??= $position; if (isset(self::NESTING_CHARS[$value])) { ++$level; diff --git a/src/Symfony/Component/JsonStreamer/Read/StreamReaderGenerator.php b/src/Symfony/Component/JsonStreamer/Read/StreamReaderGenerator.php index 8f4dc27685351..a710a20e599ef 100644 --- a/src/Symfony/Component/JsonStreamer/Read/StreamReaderGenerator.php +++ b/src/Symfony/Component/JsonStreamer/Read/StreamReaderGenerator.php @@ -76,7 +76,7 @@ public function generate(Type $type, bool $decodeFromStream, array $options = [] try { $this->fs->dumpFile($tmpFile, $php); $this->fs->rename($tmpFile, $path); - $this->fs->chmod($path, 0666 & ~umask()); + $this->fs->chmod($path, 0o666 & ~umask()); } catch (IOException $e) { throw new RuntimeException(\sprintf('Failed to write "%s" stream reader file.', $path), previous: $e); } diff --git a/src/Symfony/Component/JsonStreamer/Write/StreamWriterGenerator.php b/src/Symfony/Component/JsonStreamer/Write/StreamWriterGenerator.php index ca905650ca010..5c64ba080c777 100644 --- a/src/Symfony/Component/JsonStreamer/Write/StreamWriterGenerator.php +++ b/src/Symfony/Component/JsonStreamer/Write/StreamWriterGenerator.php @@ -76,7 +76,7 @@ public function generate(Type $type, array $options = []): string try { $this->fs->dumpFile($tmpFile, $php); $this->fs->rename($tmpFile, $path); - $this->fs->chmod($path, 0666 & ~umask()); + $this->fs->chmod($path, 0o666 & ~umask()); } catch (IOException $e) { throw new RuntimeException(\sprintf('Failed to write "%s" stream writer file.', $path), previous: $e); } diff --git a/src/Symfony/Component/Lock/Store/FlockStore.php b/src/Symfony/Component/Lock/Store/FlockStore.php index 403aede6c2bae..6559f058b6df9 100644 --- a/src/Symfony/Component/Lock/Store/FlockStore.php +++ b/src/Symfony/Component/Lock/Store/FlockStore.php @@ -40,7 +40,7 @@ class FlockStore implements BlockingStoreInterface, SharedLockStoreInterface public function __construct(?string $lockPath = null) { if (!is_dir($lockPath ??= sys_get_temp_dir())) { - if (false === @mkdir($lockPath, 0777, true) && !is_dir($lockPath)) { + if (false === @mkdir($lockPath, 0o777, true) && !is_dir($lockPath)) { throw new InvalidArgumentException(\sprintf('The FlockStore directory "%s" does not exists and cannot be created.', $lockPath)); } } elseif (!is_writable($lockPath)) { @@ -94,7 +94,7 @@ private function lock(Key $key, bool $read, bool $blocking): void try { if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) { if ($handle = fopen($fileName, 'x')) { - chmod($fileName, 0666); + chmod($fileName, 0o666); } elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) { usleep(100); // Give some time for chmod() to complete $handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r'); diff --git a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php index 4a33635d498b2..3a2a409a0c5ad 100644 --- a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php +++ b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTestCase.php @@ -20,7 +20,7 @@ public static function tearDownAfterClass(): void { $path = __DIR__.'/Fixtures/mimetypes/to_delete'; if (file_exists($path)) { - @chmod($path, 0666); + @chmod($path, 0o666); @unlink($path); } } @@ -114,7 +114,7 @@ public function testGuessWithNonReadablePath() $path = __DIR__.'/Fixtures/mimetypes/to_delete'; touch($path); - @chmod($path, 0333); + @chmod($path, 0o333); if (str_ends_with(\sprintf('%o', fileperms($path)), '0333')) { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Symfony/Component/Notifier/Bridge/Matrix/MatrixTransport.php b/src/Symfony/Component/Notifier/Bridge/Matrix/MatrixTransport.php index 60284a3473396..e705c856afaa1 100644 --- a/src/Symfony/Component/Notifier/Bridge/Matrix/MatrixTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Matrix/MatrixTransport.php @@ -63,7 +63,7 @@ protected function doSend(MessageInterface $message): SentMessage $options = $opts ? $opts->toArray() : []; - $options['msgtype'] = $options['msgtype'] ?? 'm.text'; + $options['msgtype'] ??= 'm.text'; if (!\in_array($options['msgtype'], self::SUPPORTED_MSG_TYPES_BY_API, true)) { throw new LogicException(\sprintf('Unsupported message type: "%s". Only "%s" are supported by Matrix Client-Server API v3.', $options['msgtype'], implode(', ', self::SUPPORTED_MSG_TYPES_BY_API))); diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index a605b16183158..0f5ef4c07e7bb 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -168,7 +168,7 @@ public function testEmptyDirInPath() try { touch('executable'); - chmod('executable', 0700); + chmod('executable', 0o700); $finder = new ExecutableFinder(); $result = $finder->find('executable'); diff --git a/src/Symfony/Component/Runtime/GenericRuntime.php b/src/Symfony/Component/Runtime/GenericRuntime.php index effabe2df13a2..c6e30c06102f1 100644 --- a/src/Symfony/Component/Runtime/GenericRuntime.php +++ b/src/Symfony/Component/Runtime/GenericRuntime.php @@ -69,7 +69,7 @@ public function __construct(array $options = []) } if ($debug) { - umask(0000); + umask(0o000); $_SERVER[$debugKey] = $_ENV[$debugKey] = '1'; } else { $_SERVER[$debugKey] = $_ENV[$debugKey] = '0'; diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 7308bfc7c754a..846d7cf065153 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -228,7 +228,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a continue; } - $uniqueErrors[$error->getPath()] = $uniqueErrors[$error->getPath()] ?? $error; + $uniqueErrors[$error->getPath()] ??= $error; } throw new PartialDenormalizationException($denormalized, array_values($uniqueErrors)); diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php index 2e1880f72b58b..6fae26438c621 100644 --- a/src/Symfony/Component/Translation/Dumper/FileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php @@ -49,7 +49,7 @@ public function dump(MessageCatalogue $messages, array $options = []): void $fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale()); if (!file_exists($fullpath)) { $directory = \dirname($fullpath); - if (!file_exists($directory) && !@mkdir($directory, 0777, true)) { + if (!file_exists($directory) && !@mkdir($directory, 0o777, true)) { throw new RuntimeException(\sprintf('Unable to create directory "%s".', $directory)); } } diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php index be3f6bf36b0a1..5f58e681ebab5 100644 --- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php +++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php @@ -61,7 +61,7 @@ public function write(MessageCatalogue $catalogue, string $format, array $option // get the right dumper $dumper = $this->dumpers[$format]; - if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) { + if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0o777, true) && !is_dir($options['path'])) { throw new RuntimeException(\sprintf('Translation Writer was not able to create directory "%s".', $options['path'])); } diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/GmpCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/GmpCasterTest.php index c4146375a5449..905d1e1f61448 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/GmpCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/GmpCasterTest.php @@ -25,7 +25,7 @@ class GmpCasterTest extends TestCase public function testCastGmp() { $gmpString = gmp_init('1234'); - $gmpOctal = gmp_init(010); + $gmpOctal = gmp_init(0o10); $gmp = gmp_init('01101'); $gmpDump = <<parser = null; - chmod(__DIR__.'/Fixtures/not_readable.yml', 0644); + chmod(__DIR__.'/Fixtures/not_readable.yml', 0o644); } public function testTopLevelNumber() @@ -2729,7 +2729,7 @@ public function testParsingNotReadableFilesThrowsException() } $file = __DIR__.'/Fixtures/not_readable.yml'; - chmod($file, 0200); + chmod($file, 0o200); $this->expectException(ParseException::class); $this->expectExceptionMessageMatches('#^File ".+/Fixtures/not_readable.yml" cannot be read\.$#');