Skip to content

Commit 3af3dd1

Browse files
authored
Add native_constant_invocation cs rule (#1271)
* Add native_constant_invocation cs rule * Adapt code
1 parent dce9ab1 commit 3af3dd1

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

.php_cs.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ return PhpCsFixer\Config::create()
1414
'@Symfony' => true,
1515
'header_comment' => ['header' => $header],
1616
'full_opening_tag' => false,
17+
'native_constant_invocation' => true,
1718
'native_function_invocation' => true,
1819
'yoda_style' => false,
1920
'array_syntax' => ['syntax' => 'short'],

Command/BaseBootstrapSymlinkCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink
7474
if (!$forceSymlink) {
7575
throw new \Exception(\sprintf('Symlink "%s" points to "%s" instead of "%s"', $symlinkName, $linkTarget, $symlinkTarget));
7676
}
77-
if (\strtoupper(\substr(PHP_OS, 0, 3)) === 'WIN' && \is_dir($linkTarget)) {
77+
if (\strtoupper(\substr(\PHP_OS, 0, 3)) === 'WIN' && \is_dir($linkTarget)) {
7878
\rmdir($symlinkName);
7979
} else {
8080
\unlink($symlinkName);
@@ -126,7 +126,7 @@ public static function createMirror($symlinkTarget, $symlinkName)
126126
$filesystem = new Filesystem();
127127
$filesystem->mkdir($symlinkName);
128128
$filesystem->mirror(
129-
$symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget,
129+
$symlinkName.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.$symlinkTarget,
130130
$symlinkName,
131131
null,
132132
['copy_on_windows' => true, 'delete' => true, 'override' => true]
@@ -169,8 +169,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
169169
} elseif (false !== $composer = ComposerAdapter::getComposer($input, $output)) {
170170
$cmanager = new ComposerPathFinder($composer);
171171
$options = [
172-
'targetSuffix' => DIRECTORY_SEPARATOR.$this->bootstrapInstallPath.static::$targetSuffix,
173-
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
172+
'targetSuffix' => \DIRECTORY_SEPARATOR.$this->bootstrapInstallPath.static::$targetSuffix,
173+
'sourcePrefix' => '..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR,
174174
];
175175
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
176176
self::$mopaBootstrapBundleName,
@@ -184,15 +184,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
184184
}
185185

186186
// Automatically detect if on Win XP where symlink will allways fail
187-
if ($input->getOption('no-symlink') || PHP_OS == 'WINNT') {
187+
if ($input->getOption('no-symlink') || \PHP_OS == 'WINNT') {
188188
$this->output->write('Checking destination');
189189

190190
if (true === self::checkSymlink($symlinkTarget, $symlinkName)) {
191191
$this->output->writeln(' ... <comment>symlink already exists</comment>');
192192
} else {
193193
$this->output->writeln(' ... <comment>not existing</comment>');
194194
$this->output->writeln(\sprintf('Mirroring to: %s', $symlinkName));
195-
$this->output->write(\sprintf('from target: %s', \realpath($symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget)));
195+
$this->output->write(\sprintf('from target: %s', \realpath($symlinkName.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.$symlinkTarget)));
196196
self::createMirror($symlinkTarget, $symlinkName);
197197
}
198198
} else {
@@ -231,7 +231,7 @@ protected function getBootstrapPathsFromUser()
231231
throw new \Exception('Target path '.$symlinkTarget.'is not a directory!');
232232
}
233233
} else {
234-
$symlinkTarget = $symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget;
234+
$symlinkTarget = $symlinkName.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.$symlinkTarget;
235235
}
236236

237237
if (!\is_dir($symlinkTarget)) {

Command/InstallFontCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
7777
$finder = new Finder();
7878

7979
if (Kernel::VERSION_ID >= 40200) {
80-
$webPath = $this->kernel->getProjectDir().DIRECTORY_SEPARATOR.'web';
80+
$webPath = $this->kernel->getProjectDir().\DIRECTORY_SEPARATOR.'web';
8181
} else {
82-
$webPath = $this->kernel->getRootDir().DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'web';
82+
$webPath = $this->kernel->getRootDir().\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'web';
8383
}
8484

85-
$iconWebPath = $webPath.DIRECTORY_SEPARATOR.'fonts';
85+
$iconWebPath = $webPath.\DIRECTORY_SEPARATOR.'fonts';
8686

8787
$fs = new Filesystem();
8888

@@ -98,12 +98,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
9898

9999
$bsbPath = $composer->getInstallationManager()->getInstallPath($sourcePackage);
100100

101-
$iconSetPath = $bsbPath.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.self::$iconSetsPaths[$this->iconSet];
101+
$iconSetPath = $bsbPath.\DIRECTORY_SEPARATOR.'Resources'.\DIRECTORY_SEPARATOR.'public'.\DIRECTORY_SEPARATOR.self::$iconSetsPaths[$this->iconSet];
102102

103103
$finder->files()->in($iconSetPath);
104104

105105
foreach ($finder as $file) {
106-
$fs->copy($file->getRealpath(), $iconWebPath.DIRECTORY_SEPARATOR.$file->getRelativePathname());
106+
$fs->copy($file->getRealpath(), $iconWebPath.\DIRECTORY_SEPARATOR.$file->getRelativePathname());
107107
}
108108

109109
$output->writeln('Font: '.$this->iconSet.' Installed... <info>OK</info>');

Composer/ScriptHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function postInstallSymlinkTwitterBootstrap(Event $event)
2828
$cmanager = new ComposerPathFinder($composer);
2929
$options = [
3030
'targetSuffix' => self::getTargetSuffix(),
31-
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
31+
'sourcePrefix' => '..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR,
3232
];
3333
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
3434
BootstrapSymlinkLessCommand::$mopaBootstrapBundleName,
@@ -51,7 +51,7 @@ public static function postInstallMirrorTwitterBootstrap(Event $event)
5151
$cmanager = new ComposerPathFinder($composer);
5252
$options = [
5353
'targetSuffix' => self::getTargetSuffix(),
54-
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
54+
'sourcePrefix' => '..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR,
5555
];
5656
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
5757
BootstrapSymlinkLessCommand::$mopaBootstrapBundleName,
@@ -74,7 +74,7 @@ public static function postInstallSymlinkTwitterBootstrapSass(Event $event)
7474
$cmanager = new ComposerPathFinder($composer);
7575
$options = [
7676
'targetSuffix' => self::getTargetSuffix('-sass'),
77-
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
77+
'sourcePrefix' => '..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR,
7878
];
7979
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
8080
BootstrapSymlinkSassCommand::$mopaBootstrapBundleName,
@@ -97,7 +97,7 @@ public static function postInstallMirrorTwitterBootstrapSass(Event $event)
9797
$cmanager = new ComposerPathFinder($composer);
9898
$options = [
9999
'targetSuffix' => self::getTargetSuffix('-sass'),
100-
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
100+
'sourcePrefix' => '..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR,
101101
];
102102
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
103103
BootstrapSymlinkSassCommand::$mopaBootstrapBundleName,
@@ -115,6 +115,6 @@ public static function postInstallMirrorTwitterBootstrapSass(Event $event)
115115

116116
protected static function getTargetSuffix($end = '')
117117
{
118-
return DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'bootstrap'.$end;
118+
return \DIRECTORY_SEPARATOR.'Resources'.\DIRECTORY_SEPARATOR.'public'.\DIRECTORY_SEPARATOR.'bootstrap'.$end;
119119
}
120120
}

DependencyInjection/MopaBootstrapExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function load(array $configs, ContainerBuilder $container)
7878
if ($this->isConfigEnabled($container, $config['menu']) || $this->isConfigEnabled($container, $config['navbar'])) {
7979
// @deprecated: remove this BC layer
8080
if ($this->isConfigEnabled($container, $config['navbar'])) {
81-
\trigger_error(\sprintf('mopa_bootstrap.navbar is deprecated. Use mopa_bootstrap.menu.'), E_USER_DEPRECATED);
81+
\trigger_error(\sprintf('mopa_bootstrap.navbar is deprecated. Use mopa_bootstrap.menu.'), \E_USER_DEPRECATED);
8282
}
8383
$loader->load('menu.xml');
8484
$this->remapParameters($container, 'mopa_bootstrap.menu', $config['menu']);

0 commit comments

Comments
 (0)