Skip to content

Commit 9b887ac

Browse files
Merge branch '3.4' into 4.4
* 3.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents 65e70ba + 46a862d commit 9b887ac

13 files changed

+63
-63
lines changed

ExecutableFinder.php

+3-3
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function find($includeArgs = true)
3838
if ($php = getenv('PHP_BINARY')) {
3939
if (!is_executable($php)) {
4040
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
41-
if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
41+
if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
4242
if (!is_executable($php)) {
4343
return false;
4444
}
@@ -54,8 +54,8 @@ public function find($includeArgs = true)
5454
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
5555

5656
// PHP_BINARY return the current sapi executable
57-
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
58-
return PHP_BINARY.$args;
57+
if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
58+
return \PHP_BINARY.$args;
5959
}
6060

6161
if ($php = getenv('PHP_PATH')) {
@@ -72,11 +72,11 @@ public function find($includeArgs = true)
7272
}
7373
}
7474

75-
if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
75+
if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
7676
return $php;
7777
}
7878

79-
$dirs = [PHP_BINDIR];
79+
$dirs = [\PHP_BINDIR];
8080
if ('\\' === \DIRECTORY_SEPARATOR) {
8181
$dirs[] = 'C:\xampp\php\\';
8282
}

PhpProcess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function fromShellCommandline(string $command, string $cwd = null,
6565
*/
6666
public function setPhpBinary($php)
6767
{
68-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
68+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), \E_USER_DEPRECATED);
6969

7070
$this->setCommandLine($php);
7171
}

Pipes/WindowsPipes.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ public function __construct($input, bool $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(bool $blocking, bool $close = false): array
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function __construct($command, string $cwd = null, array $env = null, $in
144144
}
145145

146146
if (!\is_array($command)) {
147-
@trigger_error(sprintf('Passing a command as string when creating a "%s" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided by the shell.', __CLASS__), E_USER_DEPRECATED);
147+
@trigger_error(sprintf('Passing a command as string when creating a "%s" instance is deprecated since Symfony 4.2, pass it as an array of its arguments instead, or use the "Process::fromShellCommandline()" constructor if you need features provided by the shell.', __CLASS__), \E_USER_DEPRECATED);
148148
}
149149

150150
$this->commandline = $command;
@@ -938,7 +938,7 @@ public function addOutput(string $line)
938938
{
939939
$this->lastOutputTime = microtime(true);
940940

941-
fseek($this->stdout, 0, SEEK_END);
941+
fseek($this->stdout, 0, \SEEK_END);
942942
fwrite($this->stdout, $line);
943943
fseek($this->stdout, $this->incrementalOutputOffset);
944944
}
@@ -952,7 +952,7 @@ public function addErrorOutput(string $line)
952952
{
953953
$this->lastOutputTime = microtime(true);
954954

955-
fseek($this->stderr, 0, SEEK_END);
955+
fseek($this->stderr, 0, \SEEK_END);
956956
fwrite($this->stderr, $line);
957957
fseek($this->stderr, $this->incrementalErrorOutputOffset);
958958
}
@@ -988,7 +988,7 @@ public function getCommandLine()
988988
*/
989989
public function setCommandLine($commandline)
990990
{
991-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
991+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
992992

993993
$this->commandline = $commandline;
994994

@@ -1224,7 +1224,7 @@ public function setInput($input)
12241224
*/
12251225
public function inheritEnvironmentVariables($inheritEnv = true)
12261226
{
1227-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), E_USER_DEPRECATED);
1227+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), \E_USER_DEPRECATED);
12281228

12291229
if (!$inheritEnv) {
12301230
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
@@ -1383,7 +1383,7 @@ protected function isSigchildEnabled()
13831383
}
13841384

13851385
ob_start();
1386-
phpinfo(INFO_GENERAL);
1386+
phpinfo(\INFO_GENERAL);
13871387

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

Tests/ErrorProcessInitiator.php

+2-2
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

+9-9
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).PATH_SEPARATOR.'/');
109+
$this->iniSet('open_basedir', \dirname(\PHP_BINARY).\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.PATH_SEPARATOR.'/');
127+
$this->iniSet('open_basedir', \PHP_BINARY.\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

+4-4
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

Tests/PhpExecutableFinderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testFind()
2626
{
2727
$f = new PhpExecutableFinder();
2828

29-
$current = PHP_BINARY;
29+
$current = \PHP_BINARY;
3030
$args = 'phpdbg' === \PHP_SAPI ? ' -qrr' : '';
3131

3232
$this->assertEquals($current.$args, $f->find(), '::find() returns the executable PHP');
@@ -50,7 +50,7 @@ public function testFindArguments()
5050
public function testNotExitsBinaryFile()
5151
{
5252
$f = new PhpExecutableFinder();
53-
$phpBinaryEnv = PHP_BINARY;
53+
$phpBinaryEnv = \PHP_BINARY;
5454
putenv('PHP_BINARY=/usr/local/php/bin/php-invalid');
5555

5656
$this->assertFalse($f->find(), '::find() returns false because of not exist file');

Tests/PhpProcessTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCommandLine()
4545
$process->wait();
4646
$this->assertStringContainsString($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
4747

48-
$this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput());
48+
$this->assertSame(\PHP_VERSION.\PHP_SAPI, $process->getOutput());
4949
}
5050

5151
public function testPassingPhpExplicitly()

Tests/PipeStdinInStdoutStdErrStreamSelect.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
define('ERR_READ_FAILED', 3);
1515
define('ERR_WRITE_FAILED', 4);
1616

17-
$read = [STDIN];
18-
$write = [STDOUT, STDERR];
17+
$read = [\STDIN];
18+
$write = [\STDOUT, \STDERR];
1919

20-
stream_set_blocking(STDIN, 0);
21-
stream_set_blocking(STDOUT, 0);
22-
stream_set_blocking(STDERR, 0);
20+
stream_set_blocking(\STDIN, 0);
21+
stream_set_blocking(\STDOUT, 0);
22+
stream_set_blocking(\STDERR, 0);
2323

2424
$out = $err = '';
2525
while ($read || $write) {
@@ -34,37 +34,37 @@
3434
exit(ERR_TIMEOUT);
3535
}
3636

37-
if (in_array(STDOUT, $w) && strlen($out) > 0) {
38-
$written = fwrite(STDOUT, (string) $out, 32768);
37+
if (in_array(\STDOUT, $w) && strlen($out) > 0) {
38+
$written = fwrite(\STDOUT, (string) $out, 32768);
3939
if (false === $written) {
4040
exit(ERR_WRITE_FAILED);
4141
}
4242
$out = (string) substr($out, $written);
4343
}
4444
if (null === $read && '' === $out) {
45-
$write = array_diff($write, [STDOUT]);
45+
$write = array_diff($write, [\STDOUT]);
4646
}
4747

48-
if (in_array(STDERR, $w) && strlen($err) > 0) {
49-
$written = fwrite(STDERR, (string) $err, 32768);
48+
if (in_array(\STDERR, $w) && strlen($err) > 0) {
49+
$written = fwrite(\STDERR, (string) $err, 32768);
5050
if (false === $written) {
5151
exit(ERR_WRITE_FAILED);
5252
}
5353
$err = (string) substr($err, $written);
5454
}
5555
if (null === $read && '' === $err) {
56-
$write = array_diff($write, [STDERR]);
56+
$write = array_diff($write, [\STDERR]);
5757
}
5858

5959
if ($r) {
60-
$str = fread(STDIN, 32768);
60+
$str = fread(\STDIN, 32768);
6161
if (false !== $str) {
6262
$out .= $str;
6363
$err .= $str;
6464
}
65-
if (false === $str || feof(STDIN)) {
65+
if (false === $str || feof(\STDIN)) {
6666
$read = null;
67-
if (!feof(STDIN)) {
67+
if (!feof(\STDIN)) {
6868
exit(ERR_READ_FAILED);
6969
}
7070
}

0 commit comments

Comments
 (0)