Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Finder\Iterator;
use RectorPrefix202406\Symfony\Component\Finder\SplFileInfo;
/**
* ExcludeDirectoryFilterIterator filters out directories.
*
* @author Fabien Potencier <[email protected]>
*
* @extends \FilterIterator<string, SplFileInfo>
*
* @implements \RecursiveIterator<string, SplFileInfo>
*/
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
{
/** @var \Iterator<string, SplFileInfo> */
private $iterator;
/**
* @var bool
*/
private $isRecursive;
/** @var array<string, true> */
private $excludedDirs = [];
/**
* @var string|null
*/
private $excludedPattern;
/** @var list<callable(SplFileInfo):bool> */
private $pruneFilters = [];
/**
* @param \Iterator<string, SplFileInfo> $iterator The Iterator to filter
* @param list<string|callable(SplFileInfo):bool> $directories An array of directories to exclude
*/
public function __construct(\Iterator $iterator, array $directories)
{
$this->iterator = $iterator;
$this->isRecursive = $iterator instanceof \RecursiveIterator;
$patterns = [];
foreach ($directories as $directory) {
if (!\is_string($directory)) {
if (!\is_callable($directory)) {
throw new \InvalidArgumentException('Invalid PHP callback.');
}
$this->pruneFilters[] = $directory;
continue;
}
$directory =
trim($directory, '/');
if (!$this->isRecursive || \strpos($directory, '/') !== alse) {
$patterns[] = \preg_quote($directory, '#');
} else {
$this->excludedDirs[$directory] = rue;
}
}
if ($patterns) {
$this->excludedPattern = '#(?:^|/)(?:' . \implode('|', $patterns) . ')(?:/|$)#';
}
parent::__construct($iterator);
}
/**
* Filters the iterator values.
*/
public function accept() : bool
{
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
return alse;
}
if ($this->excludedPattern) {
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
$path = \str_replace('\', '/', $path);
return !\preg_match($this->excludedPattern, $path);
}
if ($this->pruneFilters && $this->hasChildren()) {
foreach ($this->pruneFilters as $pruneFilter) {
if (!$pruneFilter($this->current())) {
return alse;
}
}
}
return rue;
}
public function hasChildren() : bool
{
return $this->isRecursive && $this->iterator->hasChildren();
}
public function getChildren() : self
{
$children = new self($this->iterator->getChildren(), []);
$children->excludedDirs = $this->excludedDirs;
$children->excludedPattern = $this->excludedPattern;
return $children;
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Finder\Iterator;
use RectorPrefix202406\Symfony\Component\Finder\SplFileInfo;
/**
* ExcludeDirectoryFilterIterator filters out directories.
*
* @author Fabien Potencier <[email protected]>
*
* @extends \FilterIterator<string, SplFileInfo>
*
* @implements \RecursiveIterator<string, SplFileInfo>
*/
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
{
/** @var \Iterator<string, SplFileInfo> */
private $iterator;
/**
* @var bool
*/
private $isRecursive;
/** @var array<string, true> */
private $excludedDirs = [];
/**
* @var string|null
*/
private $excludedPattern;
/** @var list<callable(SplFileInfo):bool> */
private $pruneFilters = [];
/**
* @param \Iterator<string, SplFileInfo> $iterator The Iterator to filter
* @param list<string|callable(SplFileInfo):bool> $directories An array of directories to exclude
*/
public function __construct(\Iterator $iterator, array $directories)
{
$this->iterator = $iterator;
$this->isRecursive = $iterator instanceof \RecursiveIterator;
$patterns = [];
foreach ($directories as $directory) {
if (!\is_string($directory)) {
if (!\is_callable($directory)) {
throw new \InvalidArgumentException('Invalid PHP callback.');
}
$this->pruneFilters[] = $directory;
continue;
}
$directory = \rtrim($directory, '/');
if (!$this->isRecursive || \strpos($directory, '/') !== \false) {
$patterns[] = \preg_quote($directory, '#');
} else {
$this->excludedDirs[$directory] = \true;
}
}
if ($patterns) {
$this->excludedPattern = '#(?:^|/)(?:' . \implode('|', $patterns) . ')(?:/|$)#';
}
parent::__construct($iterator);
}
/**
* Filters the iterator values.
*/
public function accept() : bool
{
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
return \false;
}
if ($this->excludedPattern) {
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
$path = \str_replace('\\', '/', $path);
return !\preg_match($this->excludedPattern, $path);
}
if ($this->pruneFilters && $this->hasChildren()) {
foreach ($this->pruneFilters as $pruneFilter) {
if (!$pruneFilter($this->current())) {
return \false;
}
}
}
return \true;
}
public function hasChildren() : bool
{
return $this->isRecursive && $this->iterator->hasChildren();
}
public function getChildren() : self
{
$children = new self($this->iterator->getChildren(), []);
$children->excludedDirs = $this->excludedDirs;
$children->excludedPattern = $this->excludedPattern;
return $children;
}
}
Function Calls
None |
Stats
MD5 | ae7929f8ee13c0ec5b9b0ae47d0b741f |
Eval Count | 0 |
Decode Time | 97 ms |