Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Filesystem] toIterable() in favor of toIterator()#24928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ro0NL wants to merge2 commits intosymfony:3.4fromro0NL:filesystem-iterable
Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletionssrc/Symfony/Component/Filesystem/Filesystem.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90,7 +90,7 @@ public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
*/
public function mkdir($dirs, $mode = 0777)
{
foreach ($this->toIterator($dirs) as $dir) {
foreach ($this->toIterable($dirs) as $dir) {
if (is_dir($dir)) {
continue;
}
Expand DownExpand Up@@ -119,7 +119,7 @@ public function exists($files)
{
$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);
}
Expand All@@ -143,7 +143,7 @@ public function exists($files)
*/
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);
Expand DownExpand Up@@ -199,7 +199,7 @@ public function remove($files)
*/
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);
}
Expand All@@ -220,7 +220,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false)
*/
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);
}
Expand All@@ -247,7 +247,7 @@ public function chown($files, $user, $recursive = false)
*/
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);
}
Expand DownExpand Up@@ -369,7 +369,7 @@ public function hardlink($originFile, $targetFiles)
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;
Expand DownExpand Up@@ -722,15 +722,11 @@ public function appendToFile($filename, $content)
/**
* @param mixed $files
*
* @return \Traversable
* @returnarray|\Traversable
*/
private functiontoIterator($files)
private functiontoIterable($files)
{
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);
}

/**
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp