Merge branch '3.4'
* 3.4: [Process] Skip ProcessTest::testSimpleInputStream() because of bug #75515 in PHP 7.2RC6 [Filesystem] toIterable() in favor of toIterator()
This commit is contained in:
commit
0259fc5e17
@ -91,7 +91,7 @@ class Filesystem
|
||||
*/
|
||||
public function mkdir($dirs, $mode = 0777)
|
||||
{
|
||||
foreach ($this->toIterator($dirs) as $dir) {
|
||||
foreach ($this->toIterable($dirs) as $dir) {
|
||||
if (is_dir($dir)) {
|
||||
continue;
|
||||
}
|
||||
@ -120,7 +120,7 @@ class Filesystem
|
||||
{
|
||||
$maxPathLength = PHP_MAXPATHLEN - 2;
|
||||
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
if (strlen($file) > $maxPathLength) {
|
||||
throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
|
||||
}
|
||||
@ -144,7 +144,7 @@ class Filesystem
|
||||
*/
|
||||
public function touch($files, $time = null, $atime = null)
|
||||
{
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
$touch = $time ? @touch($file, $time, $atime) : @touch($file);
|
||||
if (true !== $touch) {
|
||||
throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
|
||||
@ -200,7 +200,7 @@ class Filesystem
|
||||
*/
|
||||
public function chmod($files, $mode, $umask = 0000, $recursive = false)
|
||||
{
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
if (true !== @chmod($file, $mode & ~$umask)) {
|
||||
throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
|
||||
}
|
||||
@ -221,7 +221,7 @@ class Filesystem
|
||||
*/
|
||||
public function chown($files, $user, $recursive = false)
|
||||
{
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
if ($recursive && is_dir($file) && !is_link($file)) {
|
||||
$this->chown(new \FilesystemIterator($file), $user, true);
|
||||
}
|
||||
@ -248,7 +248,7 @@ class Filesystem
|
||||
*/
|
||||
public function chgrp($files, $group, $recursive = false)
|
||||
{
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
if ($recursive && is_dir($file) && !is_link($file)) {
|
||||
$this->chgrp(new \FilesystemIterator($file), $group, true);
|
||||
}
|
||||
@ -370,7 +370,7 @@ class Filesystem
|
||||
throw new FileNotFoundException(sprintf('Origin file "%s" is not a file', $originFile));
|
||||
}
|
||||
|
||||
foreach ($this->toIterator($targetFiles) as $targetFile) {
|
||||
foreach ($this->toIterable($targetFiles) as $targetFile) {
|
||||
if (is_file($targetFile)) {
|
||||
if (fileinode($originFile) === fileinode($targetFile)) {
|
||||
continue;
|
||||
@ -724,18 +724,9 @@ class Filesystem
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $files
|
||||
*
|
||||
* @return \Traversable
|
||||
*/
|
||||
private function toIterator($files)
|
||||
private function toIterable($files): iterable
|
||||
{
|
||||
if (!$files instanceof \Traversable) {
|
||||
$files = new \ArrayObject(is_array($files) ? $files : array($files));
|
||||
}
|
||||
|
||||
return $files;
|
||||
return is_array($files) || $files instanceof \Traversable ? $files : array($files);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1210,6 +1210,10 @@ class ProcessTest extends TestCase
|
||||
|
||||
public function testSimpleInputStream()
|
||||
{
|
||||
if (\PHP_VERSION_ID === 70200 && \PHP_EXTRA_VERSION === 'RC6') {
|
||||
$this->markTestSkipped('See bug #75515 in PHP 7.2RC6.');
|
||||
}
|
||||
|
||||
$input = new InputStream();
|
||||
|
||||
$process = $this->getProcessForCode('echo \'ping\'; stream_copy_to_stream(STDIN, STDOUT);');
|
||||
|
Reference in New Issue
Block a user