Skip to content

Commit 510977d

Browse files
Merge branch '4.1'
* 4.1: Enable native_constant_invocation CS fixer
2 parents f51a76c + c4d10c4 commit 510977d

File tree

90 files changed

+372
-374
lines changed

Some content is hidden

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

90 files changed

+372
-374
lines changed

.php_cs.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ return PhpCsFixer\Config::create()
1313
'array_syntax' => array('syntax' => 'long'),
1414
'ordered_imports' => true,
1515
'protected_to_private' => false,
16-
// TODO remove the disabling once https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876 is merged and released
17-
'native_constant_invocation' => false,
1816
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
1917
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
2018
))

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
126126
}
127127
$firstNamespace = false;
128128
foreach ($paths as $path) {
129-
$rows[] = array($namespace, $path.DIRECTORY_SEPARATOR);
129+
$rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR);
130130
$namespace = '';
131131
}
132132
if (\count($paths) > 1) {
@@ -159,7 +159,7 @@ private function getLoaderPaths()
159159
foreach ($loader->getNamespaces() as $namespace) {
160160
$paths = array_map(function ($path) {
161161
if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) {
162-
$path = ltrim(substr($path, \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
162+
$path = ltrim(substr($path, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
163163
}
164164

165165
return $path;
@@ -272,7 +272,7 @@ private function findWrongBundleOverrides(): array
272272

273273
if ($this->rootDir && $this->projectDir) {
274274
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
275-
$relativePath = ltrim(substr($this->rootDir.'/Resources/', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
275+
$relativePath = ltrim(substr($this->rootDir.'/Resources/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
276276
$bundleNames = array_reduce(
277277
$folders,
278278
function ($carry, $absolutePath) use ($relativePath) {
@@ -290,13 +290,13 @@ function ($carry, $absolutePath) use ($relativePath) {
290290

291291
if ($this->twigDefaultPath && $this->projectDir) {
292292
$folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR);
293-
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
293+
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
294294
$bundleNames = array_reduce(
295295
$folders,
296296
function ($carry, $absolutePath) use ($relativePath) {
297297
if (0 === strpos($absolutePath, $this->projectDir)) {
298-
$path = ltrim(substr($absolutePath, \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
299-
$name = ltrim(substr($path, \strlen($relativePath)), DIRECTORY_SEPARATOR);
298+
$path = ltrim(substr($absolutePath, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
299+
$name = ltrim(substr($path, \strlen($relativePath)), \DIRECTORY_SEPARATOR);
300300
$carry[$name] = $path;
301301
}
302302

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CodeExtension extends AbstractExtension
3535
public function __construct($fileLinkFormat, string $rootDir, string $charset, string $projectDir = null)
3636
{
3737
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
38-
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, \dirname($rootDir)).DIRECTORY_SEPARATOR;
38+
$this->rootDir = str_replace('/', \DIRECTORY_SEPARATOR, \dirname($rootDir)).\DIRECTORY_SEPARATOR;
3939
$this->charset = $charset;
4040
$this->projectDir = $projectDir;
4141
}
@@ -176,11 +176,11 @@ public function formatFile($file, $line, $text = null)
176176
$file = trim($file);
177177

178178
if (null === $text) {
179-
$text = str_replace('/', DIRECTORY_SEPARATOR, $file);
179+
$text = str_replace('/', \DIRECTORY_SEPARATOR, $file);
180180
if (0 === strpos($text, $this->rootDir)) {
181181
$text = substr($text, \strlen($this->rootDir));
182-
$text = explode(DIRECTORY_SEPARATOR, $text, 2);
183-
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : '');
182+
$text = explode(\DIRECTORY_SEPARATOR, $text, 2);
183+
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? \DIRECTORY_SEPARATOR.$text[1] : '');
184184
}
185185
}
186186

src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testLineSeparatorInLoaderPaths()
3939
FilesystemLoader::MAIN_NAMESPACE => array('extractor', 'extractor'),
4040
));
4141
$ret = $tester->execute(array(), array('decorated' => false));
42-
$ds = DIRECTORY_SEPARATOR;
42+
$ds = \DIRECTORY_SEPARATOR;
4343
$loaderPaths = <<<TXT
4444
Loader Paths
4545
------------

src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testExtractSyntaxError($resources)
9090
$extractor->extract($resources, new MessageCatalogue('en'));
9191
} catch (Error $e) {
9292
if (method_exists($e, 'getSourceContext')) {
93-
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', DIRECTORY_SEPARATOR), $e->getFile());
93+
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
9494
$this->assertSame(1, $e->getLine());
9595
$this->assertSame('Unclosed "block".', $e->getMessage());
9696
} else {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
154154
}
155155

156156
if ($method === $expectedMethod) {
157-
$rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method);
157+
$rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method);
158158
} else {
159-
$rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method);
159+
$rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method);
160160
}
161161
} catch (\Exception $e) {
162162
$exitCode = 1;
163-
$rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage());
163+
$rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage());
164164
}
165165
}
166166
// remove the assets of the bundles that no longer exist

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function setUp()
5050

5151
$this->templateLocator = new TemplateLocator($this->fileLocator);
5252

53-
$this->tmpDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('cache_template_paths_', true);
53+
$this->tmpDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('cache_template_paths_', true);
5454

5555
$this->filesystem = new Filesystem();
5656
$this->filesystem->mkdir($this->tmpDir);

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp()
3333
{
3434
$this->fs = new Filesystem();
3535
$this->kernel = new TestAppKernel('test', true);
36-
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true);
36+
$this->rootDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true);
3737
$this->kernel->setRootDir($this->rootDir);
3838
$this->fs->mkdir($this->rootDir);
3939
}
@@ -83,7 +83,7 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
8383
$this->assertTrue($found, 'Kernel file should present as resource');
8484

8585
$containerRef = new \ReflectionClass(require $containerFile);
86-
$containerFile = str_replace('tes_'.DIRECTORY_SEPARATOR, 'test'.DIRECTORY_SEPARATOR, $containerRef->getFileName());
86+
$containerFile = str_replace('tes_'.\DIRECTORY_SEPARATOR, 'test'.\DIRECTORY_SEPARATOR, $containerRef->getFileName());
8787
$this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');
8888
}
8989
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function setRootDir($rootDir)
3333

3434
public function registerContainerConfiguration(LoaderInterface $loader)
3535
{
36-
$loader->load(__DIR__.DIRECTORY_SEPARATOR.'config.yml');
36+
$loader->load(__DIR__.\DIRECTORY_SEPARATOR.'config.yml');
3737
}
3838

3939
protected function build(ContainerBuilder $container)

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -657,29 +657,29 @@ public function testTranslator()
657657
$files = array_map('realpath', $options['resource_files']['en']);
658658
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
659659
$this->assertContains(
660-
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
660+
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
661661
$files,
662662
'->registerTranslatorConfiguration() finds Validator translation resources'
663663
);
664664
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
665665
$this->assertContains(
666-
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
666+
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
667667
$files,
668668
'->registerTranslatorConfiguration() finds Form translation resources'
669669
);
670670
$ref = new \ReflectionClass('Symfony\Component\Security\Core\Security');
671671
$this->assertContains(
672-
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR),
672+
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
673673
$files,
674674
'->registerTranslatorConfiguration() finds Security translation resources'
675675
);
676676
$this->assertContains(
677-
strtr(__DIR__.'/Fixtures/translations/test_paths.en.yml', '/', DIRECTORY_SEPARATOR),
677+
strtr(__DIR__.'/Fixtures/translations/test_paths.en.yml', '/', \DIRECTORY_SEPARATOR),
678678
$files,
679679
'->registerTranslatorConfiguration() finds translation resources in custom paths'
680680
);
681681
$this->assertContains(
682-
strtr(__DIR__.'/translations/test_default.en.xlf', '/', DIRECTORY_SEPARATOR),
682+
strtr(__DIR__.'/translations/test_default.en.xlf', '/', \DIRECTORY_SEPARATOR),
683683
$files,
684684
'->registerTranslatorConfiguration() finds translation resources in default path'
685685
);
@@ -728,7 +728,7 @@ public function testValidation()
728728
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
729729
$xmlMappings = array(
730730
\dirname($ref->getFileName()).'/Resources/config/validation.xml',
731-
strtr($projectDir.'/config/validator/foo.xml', '/', DIRECTORY_SEPARATOR),
731+
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
732732
);
733733

734734
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
@@ -822,10 +822,10 @@ public function testValidationPaths()
822822
$this->assertCount(3, $xmlMappings);
823823
try {
824824
// Testing symfony/symfony
825-
$this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
825+
$this->assertStringEndsWith('Component'.\DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
826826
} catch (\Exception $e) {
827827
// Testing symfony/framework-bundle with deps=high
828-
$this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
828+
$this->assertStringEndsWith('symfony'.\DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
829829
}
830830
$this->assertStringEndsWith('TestBundle/Resources/config/validation.xml', $xmlMappings[1]);
831831

@@ -849,10 +849,10 @@ public function testValidationPathsUsingCustomBundlePath()
849849

850850
try {
851851
// Testing symfony/symfony
852-
$this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
852+
$this->assertStringEndsWith('Component'.\DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
853853
} catch (\Exception $e) {
854854
// Testing symfony/framework-bundle with deps=high
855-
$this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
855+
$this->assertStringEndsWith('symfony'.\DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
856856
}
857857
$this->assertStringEndsWith('CustomPathBundle/Resources/config/validation.xml', $xmlMappings[1]);
858858

@@ -1096,15 +1096,15 @@ public function testSerializerMapping()
10961096

10971097
foreach ($expectedLoaders as $definition) {
10981098
if (is_file($arg = $definition->getArgument(0))) {
1099-
$definition->replaceArgument(0, strtr($arg, '/', DIRECTORY_SEPARATOR));
1099+
$definition->replaceArgument(0, strtr($arg, '/', \DIRECTORY_SEPARATOR));
11001100
}
11011101
$definition->setPublic(false);
11021102
}
11031103

11041104
$loaders = $container->getDefinition('serializer.mapping.chain_loader')->getArgument(0);
11051105
foreach ($loaders as $loader) {
11061106
if (is_file($arg = $loader->getArgument(0))) {
1107-
$loader->replaceArgument(0, strtr($arg, '/', DIRECTORY_SEPARATOR));
1107+
$loader->replaceArgument(0, strtr($arg, '/', \DIRECTORY_SEPARATOR));
11081108
}
11091109
}
11101110
$this->assertEquals($expectedLoaders, $loaders);

0 commit comments

Comments
 (0)