fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -21,20 +21,13 @@ use Symfony\Component\Finder\SplFileInfo;
*/
class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
{
/**
* @var bool
*/
private $ignoreUnreadableDirs;
/**
* @var bool
*/
private $rewindable;
private bool $ignoreUnreadableDirs;
private ?bool $rewindable = null;
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
private $rootPath;
private $subPath;
private $directorySeparator = '/';
private string $rootPath;
private string $subPath;
private string $directorySeparator = '/';
/**
* @throws \RuntimeException
@@ -55,17 +48,15 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
/**
* Return an instance of SplFileInfo with support for relative paths.
*
* @return SplFileInfo
*/
#[\ReturnTypeWillChange]
public function current()
public function current(): SplFileInfo
{
// the logic here avoids redoing the same work in all iterations
if (null === $subPathname = $this->subPath) {
$subPathname = $this->subPath = $this->getSubPath();
if (!isset($this->subPath)) {
$this->subPath = $this->getSubPath();
}
$subPathname = $this->subPath;
if ('' !== $subPathname) {
$subPathname .= $this->directorySeparator;
}
@@ -78,13 +69,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
}
/**
* @param bool $allowLinks
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function hasChildren($allowLinks = false)
public function hasChildren(bool $allowLinks = false): bool
{
$hasChildren = parent::hasChildren($allowLinks);
@@ -103,12 +88,9 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
}
/**
* @return \RecursiveDirectoryIterator
*
* @throws AccessDeniedException
*/
#[\ReturnTypeWillChange]
public function getChildren()
public function getChildren(): \RecursiveDirectoryIterator
{
try {
$children = parent::getChildren();
@@ -130,11 +112,8 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
/**
* Do nothing for non rewindable stream.
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
public function rewind(): void
{
if (false === $this->isRewindable()) {
return;
@@ -145,10 +124,8 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
/**
* Checks if the stream is rewindable.
*
* @return bool
*/
public function isRewindable()
public function isRewindable(): bool
{
if (null !== $this->rewindable) {
return $this->rewindable;