Skip to content

Commit 89cbf6c

Browse files
minor #61371 chore: PHP CS Fixer - restore PHP / PHPUnit rulesets (keradus)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- chore: PHP CS Fixer - restore PHP / PHPUnit rulesets | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix CS <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT relates to 5d4e211#r163638626 , showing: - possible improvements to codebase that those ruleset can still offer (especially when targetting newest possible target version) - and also preventing old way to still be in use, if someone forget to use new syntax/methods with love by [PHP Coding Standards Fixer](https://cs.symfony.com/) Commits ------- 92940de chore: PHP CS Fixer - restore PHP / PHPUnit rulesets
2 parents 78e6eac + 92940de commit 89cbf6c

File tree

51 files changed

+109
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+109
-107
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
return (new PhpCsFixer\Config())
3131
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
3232
->setRules([
33+
'@PHP81Migration' => true, // take lowest version from `git grep -h '"php"' **/composer.json | uniq | sort`
34+
'@PHPUnit91Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
3335
'@Symfony' => true,
3436
'@Symfony:risky' => true,
3537
'phpdoc_var_annotation_correct_order' => true,

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
4545
foreach ($this->registry->getManagers() as $em) {
4646
// we need the directory no matter the proxy cache generation strategy
4747
if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
48-
if (false === @mkdir($proxyCacheDir, 0777, true) && !is_dir($proxyCacheDir)) {
48+
if (false === @mkdir($proxyCacheDir, 0o777, true) && !is_dir($proxyCacheDir)) {
4949
throw new \RuntimeException(\sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
5050
}
5151
} elseif (!is_writable($proxyCacheDir)) {

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
$prevCacheDir = getenv('COMPOSER_CACHE_DIR');
166166
if ($prevCacheDir) {
167167
if (false === $absoluteCacheDir = realpath($prevCacheDir)) {
168-
@mkdir($prevCacheDir, 0777, true);
168+
@mkdir($prevCacheDir, 0o777, true);
169169
$absoluteCacheDir = realpath($prevCacheDir);
170170
}
171171
if ($absoluteCacheDir) {
@@ -181,7 +181,7 @@
181181
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
182182
// Build a standalone phpunit without symfony/yaml nor prophecy by default
183183

184-
@mkdir($PHPUNIT_DIR, 0777, true);
184+
@mkdir($PHPUNIT_DIR, 0o777, true);
185185
chdir($PHPUNIT_DIR);
186186
if (file_exists("$PHPUNIT_VERSION_DIR")) {
187187
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s 2> NUL' : 'rm -rf %s', escapeshellarg("$PHPUNIT_VERSION_DIR.old")));

src/Symfony/Bridge/PsrHttpMessage/Factory/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function move(string $directory, ?string $name = null): File
6262
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, $e->getMessage()), 0, $e);
6363
}
6464

65-
@chmod($target, 0666 & ~umask());
65+
@chmod($target, 0o666 & ~umask());
6666

6767
return $target;
6868
}

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function symlink(string $originDir, string $targetDir, bool $relative =
237237
*/
238238
private function hardCopy(string $originDir, string $targetDir): string
239239
{
240-
$this->filesystem->mkdir($targetDir, 0777);
240+
$this->filesystem->mkdir($targetDir, 0o777);
241241
// We use a custom iterator to ignore VCS files
242242
$this->filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));
243243

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function process(ContainerBuilder $container): void
5959

6060
$fs = new Filesystem();
6161
$fs->dumpFile($file, serialize($dump));
62-
$fs->chmod($file, 0666, umask());
62+
$fs->chmod($file, 0o666, umask());
6363
} catch (\Throwable $e) {
6464
$container->getCompiler()->log($this, $e->getMessage());
6565
// ignore serialization and file-system errors

src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function export(string $filename, string $data): void
228228

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

src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/AboutCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testAboutWithReadableFiles()
3434
$this->fs->mkdir($kernel->getProjectDir());
3535

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

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

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

4848
try {
4949
$this->fs->remove($kernel->getProjectDir());
@@ -62,7 +62,7 @@ public function testAboutWithUnreadableFiles()
6262
}
6363

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

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

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

7676
try {
7777
$this->fs->remove($kernel->getProjectDir());

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationExtractCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ public function testFilterDuplicateTransPaths()
155155

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

161161
touch($transPath);
162162
} else {
163-
mkdir($transPath, 0777, true);
163+
mkdir($transPath, 0o777, true);
164164
}
165165
}
166166

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ private static function createLocalEntry(string $importName, string $path, Impor
743743

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

749749
return ImportMapEntry::createRemote($importName, $type, path: $path, version: $version, packageModuleSpecifier: $packageSpecifier, isEntrypoint: false);
750750
}

0 commit comments

Comments
 (0)