Skip to content

Commit 0259fc5

Browse files
Merge branch '3.4'
* 3.4: [Process] Skip ProcessTest::testSimpleInputStream() because of bug #75515 in PHP 7.2RC6 [Filesystem] toIterable() in favor of toIterator()
2 parents 94c72d0 + e2ad892 commit 0259fc5

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
9191
*/
9292
public function mkdir($dirs, $mode = 0777)
9393
{
94-
foreach ($this->toIterator($dirs) as $dir) {
94+
foreach ($this->toIterable($dirs) as $dir) {
9595
if (is_dir($dir)) {
9696
continue;
9797
}
@@ -120,7 +120,7 @@ public function exists($files)
120120
{
121121
$maxPathLength = PHP_MAXPATHLEN - 2;
122122

123-
foreach ($this->toIterator($files) as $file) {
123+
foreach ($this->toIterable($files) as $file) {
124124
if (strlen($file) > $maxPathLength) {
125125
throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
126126
}
@@ -144,7 +144,7 @@ public function exists($files)
144144
*/
145145
public function touch($files, $time = null, $atime = null)
146146
{
147-
foreach ($this->toIterator($files) as $file) {
147+
foreach ($this->toIterable($files) as $file) {
148148
$touch = $time ? @touch($file, $time, $atime) : @touch($file);
149149
if (true !== $touch) {
150150
throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
@@ -200,7 +200,7 @@ public function remove($files)
200200
*/
201201
public function chmod($files, $mode, $umask = 0000, $recursive = false)
202202
{
203-
foreach ($this->toIterator($files) as $file) {
203+
foreach ($this->toIterable($files) as $file) {
204204
if (true !== @chmod($file, $mode & ~$umask)) {
205205
throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
206206
}
@@ -221,7 +221,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false)
221221
*/
222222
public function chown($files, $user, $recursive = false)
223223
{
224-
foreach ($this->toIterator($files) as $file) {
224+
foreach ($this->toIterable($files) as $file) {
225225
if ($recursive && is_dir($file) && !is_link($file)) {
226226
$this->chown(new \FilesystemIterator($file), $user, true);
227227
}
@@ -248,7 +248,7 @@ public function chown($files, $user, $recursive = false)
248248
*/
249249
public function chgrp($files, $group, $recursive = false)
250250
{
251-
foreach ($this->toIterator($files) as $file) {
251+
foreach ($this->toIterable($files) as $file) {
252252
if ($recursive && is_dir($file) && !is_link($file)) {
253253
$this->chgrp(new \FilesystemIterator($file), $group, true);
254254
}
@@ -370,7 +370,7 @@ public function hardlink($originFile, $targetFiles)
370370
throw new FileNotFoundException(sprintf('Origin file "%s" is not a file', $originFile));
371371
}
372372

373-
foreach ($this->toIterator($targetFiles) as $targetFile) {
373+
foreach ($this->toIterable($targetFiles) as $targetFile) {
374374
if (is_file($targetFile)) {
375375
if (fileinode($originFile) === fileinode($targetFile)) {
376376
continue;
@@ -724,18 +724,9 @@ public function appendToFile($filename, $content)
724724
}
725725
}
726726

727-
/**
728-
* @param mixed $files
729-
*
730-
* @return \Traversable
731-
*/
732-
private function toIterator($files)
727+
private function toIterable($files): iterable
733728
{
734-
if (!$files instanceof \Traversable) {
735-
$files = new \ArrayObject(is_array($files) ? $files : array($files));
736-
}
737-
738-
return $files;
729+
return is_array($files) || $files instanceof \Traversable ? $files : array($files);
739730
}
740731

741732
/**

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,10 @@ public function testIteratorInput()
12101210

12111211
public function testSimpleInputStream()
12121212
{
1213+
if (\PHP_VERSION_ID === 70200 && \PHP_EXTRA_VERSION === 'RC6') {
1214+
$this->markTestSkipped('See bug #75515 in PHP 7.2RC6.');
1215+
}
1216+
12131217
$input = new InputStream();
12141218

12151219
$process = $this->getProcessForCode('echo \'ping\'; stream_copy_to_stream(STDIN, STDOUT);');

0 commit comments

Comments
 (0)