Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -20,22 +20,17 @@ use Symfony\Component\Translation\Exception\InvalidArgumentException;
*/
abstract class AbstractFileExtractor
{
/**
* @param string|array $resource files, a file or a directory
*
* @return array
*/
protected function extractFiles($resource)
protected function extractFiles(string|iterable $resource): iterable
{
if (is_array($resource) || $resource instanceof \Traversable) {
$files = array();
if (is_iterable($resource)) {
$files = [];
foreach ($resource as $file) {
if ($this->canBeExtracted($file)) {
$files[] = $this->toSplFileInfo($file);
}
}
} elseif (is_file($resource)) {
$files = $this->canBeExtracted($resource) ? array($this->toSplFileInfo($resource)) : array();
$files = $this->canBeExtracted($resource) ? [$this->toSplFileInfo($resource)] : [];
} else {
$files = $this->extractFromDirectory($resource);
}
@@ -43,24 +38,15 @@ abstract class AbstractFileExtractor
return $files;
}
/**
* @param string $file
*
* @return \SplFileInfo
*/
private function toSplFileInfo($file)
private function toSplFileInfo(string $file): \SplFileInfo
{
return ($file instanceof \SplFileInfo) ? $file : new \SplFileInfo($file);
return new \SplFileInfo($file);
}
/**
* @param string $file
*
* @return bool
*
* @throws InvalidArgumentException
*/
protected function isFile($file)
protected function isFile(string $file): bool
{
if (!is_file($file)) {
throw new InvalidArgumentException(sprintf('The "%s" file does not exist.', $file));
@@ -70,16 +56,12 @@ abstract class AbstractFileExtractor
}
/**
* @param string $file
*
* @return bool
*/
abstract protected function canBeExtracted($file);
abstract protected function canBeExtracted(string $file);
/**
* @param string|array $resource files, a file or a directory
*
* @return array files to be extracted
* @return iterable
*/
abstract protected function extractFromDirectory($resource);
abstract protected function extractFromDirectory(string|array $resource);
}