Aggiornato Composer
This commit is contained in:
@@ -17,6 +17,7 @@ namespace Symfony\Component\Finder\Iterator;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*
|
||||
* @implements \RecursiveIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
|
||||
|
||||
@@ -29,7 +29,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $rewindable;
|
||||
private $ignoreFirstRewind = true;
|
||||
|
||||
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
|
||||
private $rootPath;
|
||||
@@ -118,7 +118,6 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
$children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
|
||||
|
||||
// performance optimization to avoid redoing the same work in all children
|
||||
$children->rewindable = &$this->rewindable;
|
||||
$children->rootPath = $this->rootPath;
|
||||
}
|
||||
|
||||
@@ -129,40 +128,30 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing for non rewindable stream.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
$this->ignoreFirstRewind = false;
|
||||
|
||||
parent::next();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
if (false === $this->isRewindable()) {
|
||||
// some streams like FTP are not rewindable, ignore the first rewind after creation,
|
||||
// as newly created DirectoryIterator does not need to be rewound
|
||||
if ($this->ignoreFirstRewind) {
|
||||
$this->ignoreFirstRewind = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the stream is rewindable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRewindable()
|
||||
{
|
||||
if (null !== $this->rewindable) {
|
||||
return $this->rewindable;
|
||||
}
|
||||
|
||||
if (false !== $stream = @opendir($this->getPath())) {
|
||||
$infos = stream_get_meta_data($stream);
|
||||
closedir($stream);
|
||||
|
||||
if ($infos['seekable']) {
|
||||
return $this->rewindable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->rewindable = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user