Skip to content

Commit 46a862d

Browse files
Enable "native_constant_invocation" CS rule
1 parent af8d812 commit 46a862d

15 files changed

+75
-75
lines changed

ExecutableFinder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function addSuffix($suffix)
5151
public function find($name, $default = null, array $extraDirs = [])
5252
{
5353
if (ini_get('open_basedir')) {
54-
$searchPath = array_merge(explode(PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
54+
$searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
5555
$dirs = [];
5656
foreach ($searchPath as $path) {
5757
// Silencing against https://bugs.php.net/69240
@@ -65,15 +65,15 @@ public function find($name, $default = null, array $extraDirs = [])
6565
}
6666
} else {
6767
$dirs = array_merge(
68-
explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
68+
explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
6969
$extraDirs
7070
);
7171
}
7272

7373
$suffixes = [''];
7474
if ('\\' === \DIRECTORY_SEPARATOR) {
7575
$pathExt = getenv('PATHEXT');
76-
$suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
76+
$suffixes = array_merge($pathExt ? explode(\PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
7777
}
7878
foreach ($suffixes as $suffix) {
7979
foreach ($dirs as $dir) {

PhpExecutableFinder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public function find($includeArgs = true)
4040

4141
// HHVM support
4242
if (\defined('HHVM_VERSION')) {
43-
return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
43+
return (getenv('PHP_BINARY') ?: \PHP_BINARY).$args;
4444
}
4545

4646
// PHP_BINARY return the current sapi executable
47-
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
48-
return PHP_BINARY.$args;
47+
if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
48+
return \PHP_BINARY.$args;
4949
}
5050

5151
if ($php = getenv('PHP_PATH')) {
@@ -62,11 +62,11 @@ public function find($includeArgs = true)
6262
}
6363
}
6464

65-
if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
65+
if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
6666
return $php;
6767
}
6868

69-
$dirs = [PHP_BINDIR];
69+
$dirs = [\PHP_BINDIR];
7070
if ('\\' === \DIRECTORY_SEPARATOR) {
7171
$dirs[] = 'C:\xampp\php\\';
7272
}

PhpProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
4747
$script = null;
4848
}
4949
if (null !== $options) {
50-
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
50+
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), \E_USER_DEPRECATED);
5151
}
5252

5353
parent::__construct($php, $cwd, $env, $script, $timeout, $options);

Pipes/WindowsPipes.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ public function __construct($input, $haveReadSupport)
6262
restore_error_handler();
6363
throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
6464
}
65-
if (!flock($h, LOCK_EX | LOCK_NB)) {
65+
if (!flock($h, \LOCK_EX | \LOCK_NB)) {
6666
continue 2;
6767
}
6868
if (isset($this->lockHandles[$pipe])) {
69-
flock($this->lockHandles[$pipe], LOCK_UN);
69+
flock($this->lockHandles[$pipe], \LOCK_UN);
7070
fclose($this->lockHandles[$pipe]);
7171
}
7272
$this->lockHandles[$pipe] = $h;
7373

7474
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
75-
flock($this->lockHandles[$pipe], LOCK_UN);
75+
flock($this->lockHandles[$pipe], \LOCK_UN);
7676
fclose($this->lockHandles[$pipe]);
7777
unset($this->lockHandles[$pipe]);
7878
continue 2;
@@ -152,7 +152,7 @@ public function readAndWrite($blocking, $close = false)
152152
if ($close) {
153153
ftruncate($fileHandle, 0);
154154
fclose($fileHandle);
155-
flock($this->lockHandles[$type], LOCK_UN);
155+
flock($this->lockHandles[$type], \LOCK_UN);
156156
fclose($this->lockHandles[$type]);
157157
unset($this->fileHandles[$type], $this->lockHandles[$type]);
158158
}
@@ -186,7 +186,7 @@ public function close()
186186
foreach ($this->fileHandles as $type => $handle) {
187187
ftruncate($handle, 0);
188188
fclose($handle);
189-
flock($this->lockHandles[$type], LOCK_UN);
189+
flock($this->lockHandles[$type], \LOCK_UN);
190190
fclose($this->lockHandles[$type]);
191191
}
192192
$this->fileHandles = $this->lockHandles = [];

Process.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
167167
$this->pty = false;
168168
$this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
169169
if (null !== $options) {
170-
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
170+
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), \E_USER_DEPRECATED);
171171
$this->options = array_replace($this->options, $options);
172172
}
173173
}
@@ -268,7 +268,7 @@ public function start(callable $callback = null/*, array $env = [*/)
268268
if (__CLASS__ !== static::class) {
269269
$r = new \ReflectionMethod($this, __FUNCTION__);
270270
if (__CLASS__ !== $r->getDeclaringClass()->getName() && (2 > $r->getNumberOfParameters() || 'env' !== $r->getParameters()[1]->name)) {
271-
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since Symfony 3.3. It will be made mandatory in 4.0.', static::class), E_USER_DEPRECATED);
271+
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since Symfony 3.3. It will be made mandatory in 4.0.', static::class), \E_USER_DEPRECATED);
272272
}
273273
}
274274
$env = null;
@@ -302,7 +302,7 @@ public function start(callable $callback = null/*, array $env = [*/)
302302
if (null !== $env && $inheritEnv) {
303303
$env += $this->getDefaultEnv();
304304
} elseif (null !== $env) {
305-
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
305+
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', \E_USER_DEPRECATED);
306306
} else {
307307
$env = $this->getDefaultEnv();
308308
}
@@ -333,7 +333,7 @@ public function start(callable $callback = null/*, array $env = [*/)
333333
}
334334

335335
if (!is_dir($this->cwd)) {
336-
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
336+
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', \E_USER_DEPRECATED);
337337
}
338338

339339
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
@@ -906,7 +906,7 @@ public function addOutput($line)
906906
{
907907
$this->lastOutputTime = microtime(true);
908908

909-
fseek($this->stdout, 0, SEEK_END);
909+
fseek($this->stdout, 0, \SEEK_END);
910910
fwrite($this->stdout, $line);
911911
fseek($this->stdout, $this->incrementalOutputOffset);
912912
}
@@ -922,7 +922,7 @@ public function addErrorOutput($line)
922922
{
923923
$this->lastOutputTime = microtime(true);
924924

925-
fseek($this->stderr, 0, SEEK_END);
925+
fseek($this->stderr, 0, \SEEK_END);
926926
fwrite($this->stderr, $line);
927927
fseek($this->stderr, $this->incrementalErrorOutputOffset);
928928
}
@@ -1185,7 +1185,7 @@ public function setInput($input)
11851185
*/
11861186
public function getOptions()
11871187
{
1188-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
1188+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), \E_USER_DEPRECATED);
11891189

11901190
return $this->options;
11911191
}
@@ -1201,7 +1201,7 @@ public function getOptions()
12011201
*/
12021202
public function setOptions(array $options)
12031203
{
1204-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
1204+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), \E_USER_DEPRECATED);
12051205

12061206
$this->options = $options;
12071207

@@ -1219,7 +1219,7 @@ public function setOptions(array $options)
12191219
*/
12201220
public function getEnhanceWindowsCompatibility()
12211221
{
1222-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1222+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), \E_USER_DEPRECATED);
12231223

12241224
return $this->enhanceWindowsCompatibility;
12251225
}
@@ -1235,7 +1235,7 @@ public function getEnhanceWindowsCompatibility()
12351235
*/
12361236
public function setEnhanceWindowsCompatibility($enhance)
12371237
{
1238-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1238+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), \E_USER_DEPRECATED);
12391239

12401240
$this->enhanceWindowsCompatibility = (bool) $enhance;
12411241

@@ -1251,7 +1251,7 @@ public function setEnhanceWindowsCompatibility($enhance)
12511251
*/
12521252
public function getEnhanceSigchildCompatibility()
12531253
{
1254-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1254+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), \E_USER_DEPRECATED);
12551255

12561256
return $this->enhanceSigchildCompatibility;
12571257
}
@@ -1271,7 +1271,7 @@ public function getEnhanceSigchildCompatibility()
12711271
*/
12721272
public function setEnhanceSigchildCompatibility($enhance)
12731273
{
1274-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1274+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), \E_USER_DEPRECATED);
12751275

12761276
$this->enhanceSigchildCompatibility = (bool) $enhance;
12771277

@@ -1288,7 +1288,7 @@ public function setEnhanceSigchildCompatibility($enhance)
12881288
public function inheritEnvironmentVariables($inheritEnv = true)
12891289
{
12901290
if (!$inheritEnv) {
1291-
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
1291+
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', \E_USER_DEPRECATED);
12921292
}
12931293

12941294
$this->inheritEnv = (bool) $inheritEnv;
@@ -1305,7 +1305,7 @@ public function inheritEnvironmentVariables($inheritEnv = true)
13051305
*/
13061306
public function areEnvironmentVariablesInherited()
13071307
{
1308-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), E_USER_DEPRECATED);
1308+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), \E_USER_DEPRECATED);
13091309

13101310
return $this->inheritEnv;
13111311
}
@@ -1452,7 +1452,7 @@ protected function isSigchildEnabled()
14521452
}
14531453

14541454
ob_start();
1455-
phpinfo(INFO_GENERAL);
1455+
phpinfo(\INFO_GENERAL);
14561456

14571457
return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
14581458
}

ProcessBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Process;
1313

14-
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the Process class instead.', ProcessBuilder::class), E_USER_DEPRECATED);
14+
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the Process class instead.', ProcessBuilder::class), \E_USER_DEPRECATED);
1515

1616
use Symfony\Component\Process\Exception\InvalidArgumentException;
1717
use Symfony\Component\Process\Exception\LogicException;

ProcessUtils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function __construct()
4040
*/
4141
public static function escapeArgument($argument)
4242
{
43-
@trigger_error('The '.__METHOD__.'() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use a command line array or give env vars to the Process::start/run() method instead.', E_USER_DEPRECATED);
43+
@trigger_error('The '.__METHOD__.'() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use a command line array or give env vars to the Process::start/run() method instead.', \E_USER_DEPRECATED);
4444

4545
//Fix for PHP bug #43784 escapeshellarg removes % from given string
4646
//Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
@@ -53,7 +53,7 @@ public static function escapeArgument($argument)
5353

5454
$escapedArgument = '';
5555
$quote = false;
56-
foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
56+
foreach (preg_split('/(")/', $argument, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE) as $part) {
5757
if ('"' === $part) {
5858
$escapedArgument .= '\\"';
5959
} elseif (self::isSurroundedBy($part, '%')) {

Tests/ErrorProcessInitiator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
while (false === strpos($process->getOutput(), 'ready')) {
2626
usleep(1000);
2727
}
28-
$process->signal(SIGSTOP);
28+
$process->signal(\SIGSTOP);
2929
$process->wait();
3030

3131
return $process->getExitCode();
3232
} catch (ProcessTimedOutException $t) {
33-
echo $t->getMessage().PHP_EOL;
33+
echo $t->getMessage().\PHP_EOL;
3434

3535
return 1;
3636
}

Tests/ExecutableFinderTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public function testFind()
4141
$this->markTestSkipped('Cannot test when open_basedir is set');
4242
}
4343

44-
$this->setPath(\dirname(PHP_BINARY));
44+
$this->setPath(\dirname(\PHP_BINARY));
4545

4646
$finder = new ExecutableFinder();
4747
$result = $finder->find($this->getPhpBinaryName());
4848

49-
$this->assertSamePath(PHP_BINARY, $result);
49+
$this->assertSamePath(\PHP_BINARY, $result);
5050
}
5151

5252
public function testFindWithDefault()
@@ -88,12 +88,12 @@ public function testFindWithExtraDirs()
8888

8989
$this->setPath('');
9090

91-
$extraDirs = [\dirname(PHP_BINARY)];
91+
$extraDirs = [\dirname(\PHP_BINARY)];
9292

9393
$finder = new ExecutableFinder();
9494
$result = $finder->find($this->getPhpBinaryName(), null, $extraDirs);
9595

96-
$this->assertSamePath(PHP_BINARY, $result);
96+
$this->assertSamePath(\PHP_BINARY, $result);
9797
}
9898

9999
public function testFindWithOpenBaseDir()
@@ -106,12 +106,12 @@ public function testFindWithOpenBaseDir()
106106
$this->markTestSkipped('Cannot test when open_basedir is set');
107107
}
108108

109-
$this->iniSet('open_basedir', \dirname(PHP_BINARY).(!\defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? PATH_SEPARATOR.'/' : ''));
109+
$this->iniSet('open_basedir', \dirname(\PHP_BINARY).(!\defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? \PATH_SEPARATOR.'/' : ''));
110110

111111
$finder = new ExecutableFinder();
112112
$result = $finder->find($this->getPhpBinaryName());
113113

114-
$this->assertSamePath(PHP_BINARY, $result);
114+
$this->assertSamePath(\PHP_BINARY, $result);
115115
}
116116

117117
public function testFindProcessInOpenBasedir()
@@ -124,12 +124,12 @@ public function testFindProcessInOpenBasedir()
124124
}
125125

126126
$this->setPath('');
127-
$this->iniSet('open_basedir', PHP_BINARY.(!\defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? PATH_SEPARATOR.'/' : ''));
127+
$this->iniSet('open_basedir', \PHP_BINARY.(!\defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? \PATH_SEPARATOR.'/' : ''));
128128

129129
$finder = new ExecutableFinder();
130130
$result = $finder->find($this->getPhpBinaryName(), false);
131131

132-
$this->assertSamePath(PHP_BINARY, $result);
132+
$this->assertSamePath(\PHP_BINARY, $result);
133133
}
134134

135135
public function testFindBatchExecutableOnWindows()
@@ -170,6 +170,6 @@ private function assertSamePath($expected, $tested)
170170

171171
private function getPhpBinaryName()
172172
{
173-
return basename(PHP_BINARY, '\\' === \DIRECTORY_SEPARATOR ? '.exe' : '');
173+
return basename(\PHP_BINARY, '\\' === \DIRECTORY_SEPARATOR ? '.exe' : '');
174174
}
175175
}

Tests/NonStopableProcess.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
function handleSignal($signal)
2020
{
2121
switch ($signal) {
22-
case SIGTERM:
22+
case \SIGTERM:
2323
$name = 'SIGTERM';
2424
break;
25-
case SIGINT:
25+
case \SIGINT:
2626
$name = 'SIGINT';
2727
break;
2828
default:
@@ -33,8 +33,8 @@ function handleSignal($signal)
3333
echo "signal $name\n";
3434
}
3535

36-
pcntl_signal(SIGTERM, 'handleSignal');
37-
pcntl_signal(SIGINT, 'handleSignal');
36+
pcntl_signal(\SIGTERM, 'handleSignal');
37+
pcntl_signal(\SIGINT, 'handleSignal');
3838

3939
echo 'received ';
4040

0 commit comments

Comments
 (0)