Skip to content

Commit d3a2e64

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents 1864216 + 9b887ac commit d3a2e64

12 files changed

+59
-59
lines changed

ExecutableFinder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function addSuffix(string $suffix)
4949
public function find(string $name, string $default = null, array $extraDirs = [])
5050
{
5151
if (ini_get('open_basedir')) {
52-
$searchPath = array_merge(explode(PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
52+
$searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
5353
$dirs = [];
5454
foreach ($searchPath as $path) {
5555
// Silencing against https://bugs.php.net/69240
@@ -63,15 +63,15 @@ public function find(string $name, string $default = null, array $extraDirs = []
6363
}
6464
} else {
6565
$dirs = array_merge(
66-
explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
66+
explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
6767
$extraDirs
6868
);
6969
}
7070

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

PhpExecutableFinder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function find(bool $includeArgs = true)
3636
if ($php = getenv('PHP_BINARY')) {
3737
if (!is_executable($php)) {
3838
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
39-
if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
39+
if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
4040
if (!is_executable($php)) {
4141
return false;
4242
}
@@ -52,8 +52,8 @@ public function find(bool $includeArgs = true)
5252
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
5353

5454
// PHP_BINARY return the current sapi executable
55-
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
56-
return PHP_BINARY.$args;
55+
if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
56+
return \PHP_BINARY.$args;
5757
}
5858

5959
if ($php = getenv('PHP_PATH')) {
@@ -70,11 +70,11 @@ public function find(bool $includeArgs = true)
7070
}
7171
}
7272

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

77-
$dirs = [PHP_BINDIR];
77+
$dirs = [\PHP_BINDIR];
7878
if ('\\' === \DIRECTORY_SEPARATOR) {
7979
$dirs[] = 'C:\xampp\php\\';
8080
}

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, 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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ public function addOutput(string $line)
934934
{
935935
$this->lastOutputTime = microtime(true);
936936

937-
fseek($this->stdout, 0, SEEK_END);
937+
fseek($this->stdout, 0, \SEEK_END);
938938
fwrite($this->stdout, $line);
939939
fseek($this->stdout, $this->incrementalOutputOffset);
940940
}
@@ -948,7 +948,7 @@ public function addErrorOutput(string $line)
948948
{
949949
$this->lastOutputTime = microtime(true);
950950

951-
fseek($this->stderr, 0, SEEK_END);
951+
fseek($this->stderr, 0, \SEEK_END);
952952
fwrite($this->stderr, $line);
953953
fseek($this->stderr, $this->incrementalErrorOutputOffset);
954954
}
@@ -1343,7 +1343,7 @@ protected function isSigchildEnabled()
13431343
}
13441344

13451345
ob_start();
1346-
phpinfo(INFO_GENERAL);
1346+
phpinfo(\INFO_GENERAL);
13471347

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

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).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

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

Tests/PhpExecutableFinderTest.php

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 14 additions & 14 deletions
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)