diff --git a/composer.json b/composer.json index f170b073..05b2ecd0 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "symfony/asset": "^4.4 || ^5.4 || ^6.0", "symfony/event-dispatcher-contracts": "^1.0 || ^2.0 || ^3.0", "symfony/finder": "^4.4 || ^5.4 || ^6.0", diff --git a/doc/custom_uploader.md b/doc/custom_uploader.md index 5e267f58..93a3a16f 100644 --- a/doc/custom_uploader.md +++ b/doc/custom_uploader.md @@ -33,14 +33,18 @@ namespace Acme\DemoBundle\Controller; use Symfony\Component\HttpFoundation\File\Exception\UploadException; use Symfony\Component\HttpFoundation\JsonResponse; use Oneup\UploaderBundle\Controller\UploaderController; -use Oneup\UploaderBundle\Uploader\Response\EmptyResponse; +use Oneup\UploaderBundle\Uploader\Response\EmptyResponse;use Symfony\Component\HttpFoundation\RequestStack; class CustomUploader extends UploaderController { + + public function __construct(protected RequestStack $requestStack) { + } + public function upload() { // get some basic stuff together - $request = $this->container->get('request_stack')->getMasterRequest(); + $request = $this->requestStack->getMainRequest(); $response = new EmptyResponse(); // get file from request (your own logic) @@ -100,7 +104,7 @@ class FineUploaderResponse extends AbstractResponse public function assemble() { // explicitly overwrite success and error key - // as these keys are used internaly by the + // as these keys are used internally by the // frontend uploader $data = $this->data; $data['success'] = $this->success; diff --git a/src/Command/ClearChunkCommand.php b/src/Command/ClearChunkCommand.php index 4385071e..eda3ee69 100644 --- a/src/Command/ClearChunkCommand.php +++ b/src/Command/ClearChunkCommand.php @@ -5,14 +5,16 @@ namespace Oneup\UploaderBundle\Command; use Oneup\UploaderBundle\Uploader\Chunk\ChunkManager; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'oneup:uploader:clear-chunks' +)] class ClearChunkCommand extends Command { - protected static $defaultName = 'oneup:uploader:clear-chunks'; // Make command lazy load - /** * @var ChunkManager */ diff --git a/src/Command/ClearOrphansCommand.php b/src/Command/ClearOrphansCommand.php index 80b78141..717c59fc 100644 --- a/src/Command/ClearOrphansCommand.php +++ b/src/Command/ClearOrphansCommand.php @@ -5,10 +5,14 @@ namespace Oneup\UploaderBundle\Command; use Oneup\UploaderBundle\Uploader\Orphanage\OrphanageManager; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'oneup:uploader:clear-orphans' +)] class ClearOrphansCommand extends Command { protected static $defaultName = 'oneup:uploader:clear-orphans'; diff --git a/src/Controller/AbstractController.php b/src/Controller/AbstractController.php index 8d77b507..b454d51d 100644 --- a/src/Controller/AbstractController.php +++ b/src/Controller/AbstractController.php @@ -24,38 +24,8 @@ abstract class AbstractController { - /** - * @var ErrorHandlerInterface - */ - protected $errorHandler; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var StorageInterface - */ - protected $storage; - - /** - * @var array - */ - protected $config; - - /** - * @var string - */ - protected $type; - - public function __construct(ContainerInterface $container, StorageInterface $storage, ErrorHandlerInterface $errorHandler, array $config, string $type) + public function __construct(protected ContainerInterface $container, protected StorageInterface $storage, protected ErrorHandlerInterface $errorHandler, protected array $config, protected string $type) { - $this->errorHandler = $errorHandler; - $this->container = $container; - $this->storage = $storage; - $this->config = $config; - $this->type = $type; } abstract public function upload(): JsonResponse; @@ -223,9 +193,7 @@ protected function getRequest(): Request $requestStack = $this->container->get('request_stack'); /** @var Request $request */ - $request = method_exists($requestStack, 'getMainRequest') - ? $requestStack->getMainRequest() - : $requestStack->getMasterRequest(); + $request = $requestStack->getMainRequest(); return $request; } diff --git a/src/Event/PostChunkUploadEvent.php b/src/Event/PostChunkUploadEvent.php index 83f9292f..4ab7d1ce 100644 --- a/src/Event/PostChunkUploadEvent.php +++ b/src/Event/PostChunkUploadEvent.php @@ -13,53 +13,21 @@ class PostChunkUploadEvent extends Event { public const NAME = UploadEvents::POST_CHUNK_UPLOAD; - /** - * @var mixed - */ - protected $chunk; - - /** - * @var Request - */ - protected $request; - - /** - * @var string - */ - protected $type; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @var array - */ - protected $config; - - /** - * @var bool - */ - protected $isLast; - /** * @param mixed $chunk + * @param ResponseInterface $response + * @param Request $request + * @param bool $isLast + * @param string $type + * @param array $config */ - public function __construct($chunk, ResponseInterface $response, Request $request, bool $isLast, string $type, array $config) - { - $this->chunk = $chunk; - $this->request = $request; - $this->response = $response; - $this->isLast = $isLast; - $this->type = $type; - $this->config = $config; + public function __construct(protected mixed $chunk, protected ResponseInterface $response, protected Request $request, protected bool $isLast, protected string $type, protected array $config) { } /** * @return mixed */ - public function getChunk() + public function getChunk(): mixed { return $this->chunk; } diff --git a/src/Event/PostPersistEvent.php b/src/Event/PostPersistEvent.php index d5db86c6..9a7e98a4 100644 --- a/src/Event/PostPersistEvent.php +++ b/src/Event/PostPersistEvent.php @@ -15,41 +15,14 @@ class PostPersistEvent extends Event { public const NAME = UploadEvents::POST_PERSIST; - /** - * @var FileInterface|File - */ - protected $file; - - /** - * @var Request - */ - protected $request; - - /** - * @var string - */ - protected $type; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @var array - */ - protected $config; - /** * @param FileInterface|File $file + * @param ResponseInterface $response + * @param Request $request + * @param string $type + * @param array $config */ - public function __construct($file, ResponseInterface $response, Request $request, string $type, array $config) - { - $this->file = $file; - $this->request = $request; - $this->response = $response; - $this->type = $type; - $this->config = $config; + public function __construct(protected FileInterface|File $file, protected ResponseInterface $response, protected Request $request, protected string $type, protected array $config) { } /** diff --git a/src/Event/PostUploadEvent.php b/src/Event/PostUploadEvent.php index 31495474..2f68483b 100644 --- a/src/Event/PostUploadEvent.php +++ b/src/Event/PostUploadEvent.php @@ -15,41 +15,14 @@ class PostUploadEvent extends Event { public const NAME = UploadEvents::POST_UPLOAD; - /** - * @var FileInterface|File - */ - protected $file; - - /** - * @var Request - */ - protected $request; - - /** - * @var string - */ - protected $type; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @var array - */ - protected $config; - /** * @param FileInterface|File $file + * @param ResponseInterface $response + * @param Request $request + * @param string $type + * @param array $config */ - public function __construct($file, ResponseInterface $response, Request $request, string $type, array $config) - { - $this->file = $file; - $this->request = $request; - $this->response = $response; - $this->type = $type; - $this->config = $config; + public function __construct(protected FileInterface|File $file, protected ResponseInterface $response, protected Request $request, protected string $type, protected array $config) { } /** diff --git a/src/Event/PreUploadEvent.php b/src/Event/PreUploadEvent.php index 9398907f..7a80a4c1 100644 --- a/src/Event/PreUploadEvent.php +++ b/src/Event/PreUploadEvent.php @@ -16,40 +16,13 @@ class PreUploadEvent extends Event public const NAME = UploadEvents::PRE_UPLOAD; /** - * @var FileInterface|File + * @param File|FileInterface $file + * @param ResponseInterface $response + * @param Request $request + * @param string $type + * @param array $config */ - protected $file; - - /** - * @var Request - */ - protected $request; - - /** - * @var string - */ - protected $type; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @var array - */ - protected $config; - - /** - * @param FileInterface|File $file - */ - public function __construct($file, ResponseInterface $response, Request $request, string $type, array $config) - { - $this->file = $file; - $this->request = $request; - $this->response = $response; - $this->type = $type; - $this->config = $config; + public function __construct(protected File|FileInterface $file, protected ResponseInterface $response, protected Request $request, protected string $type, protected array $config) { } /** diff --git a/src/Event/ValidationEvent.php b/src/Event/ValidationEvent.php index 1481b00a..24dd4b59 100644 --- a/src/Event/ValidationEvent.php +++ b/src/Event/ValidationEvent.php @@ -15,41 +15,14 @@ class ValidationEvent extends Event { public const NAME = UploadEvents::VALIDATION; - /** - * @var FileInterface|File - */ - protected $file; - - /** - * @var array - */ - protected $config; - - /** - * @var string - */ - protected $type; - - /** - * @var Request - */ - protected $request; - - /** - * @var ResponseInterface|null - */ - protected $response; - /** * @param FileInterface|File $file + * @param Request $request + * @param array $config + * @param string $type + * @param ResponseInterface|null $response */ - public function __construct($file, Request $request, array $config, string $type, ResponseInterface $response = null) - { - $this->file = $file; - $this->config = $config; - $this->type = $type; - $this->request = $request; - $this->response = $response; + public function __construct(protected FileInterface|File $file, protected Request $request, protected array $config, protected string $type, protected ?ResponseInterface $response = null) { } /** diff --git a/src/Routing/RouteLoader.php b/src/Routing/RouteLoader.php index 0f388439..e9aecb85 100644 --- a/src/Routing/RouteLoader.php +++ b/src/Routing/RouteLoader.php @@ -10,14 +10,9 @@ class RouteLoader extends Loader { - /** - * @var array - */ - protected $controllers; - public function __construct(array $controllers) - { - $this->controllers = $controllers; + public function __construct(protected array $controllers) { + parent::__construct(); } /** diff --git a/src/Templating/Helper/UploaderHelper.php b/src/Templating/Helper/UploaderHelper.php index 6fb06644..73c36861 100644 --- a/src/Templating/Helper/UploaderHelper.php +++ b/src/Templating/Helper/UploaderHelper.php @@ -10,19 +10,10 @@ class UploaderHelper extends Helper { /** - * @var RouterInterface + * @param RouterInterface $router + * @param array $maxsize */ - protected $router; - - /** - * @var array - */ - protected $maxsize; - - public function __construct(RouterInterface $router, array $maxsize) - { - $this->router = $router; - $this->maxsize = $maxsize; + public function __construct(protected RouterInterface $router, protected array $maxsize) { } public function getName(): string diff --git a/src/Twig/Extension/UploaderExtension.php b/src/Twig/Extension/UploaderExtension.php index 6e291e60..f0e025b3 100644 --- a/src/Twig/Extension/UploaderExtension.php +++ b/src/Twig/Extension/UploaderExtension.php @@ -11,13 +11,9 @@ class UploaderExtension extends AbstractExtension { /** - * @var UploaderHelper + * @param UploaderHelper $helper */ - protected $helper; - - public function __construct(UploaderHelper $helper) - { - $this->helper = $helper; + public function __construct(protected UploaderHelper $helper){ } public function getName(): string diff --git a/src/Uploader/Chunk/ChunkManager.php b/src/Uploader/Chunk/ChunkManager.php index 9d52e139..892b5e68 100644 --- a/src/Uploader/Chunk/ChunkManager.php +++ b/src/Uploader/Chunk/ChunkManager.php @@ -10,19 +10,10 @@ class ChunkManager implements ChunkManagerInterface { /** - * @var array + * @param array $configuration + * @param ChunkStorageInterface $storage */ - protected $configuration; - - /** - * @var ChunkStorageInterface - */ - protected $storage; - - public function __construct(array $configuration, ChunkStorageInterface $storage) - { - $this->configuration = $configuration; - $this->storage = $storage; + public function __construct(protected array $configuration, protected ChunkStorageInterface $storage) { } public function clear(): void diff --git a/src/Uploader/Chunk/Storage/FilesystemStorage.php b/src/Uploader/Chunk/Storage/FilesystemStorage.php index 760084d5..7d56676c 100644 --- a/src/Uploader/Chunk/Storage/FilesystemStorage.php +++ b/src/Uploader/Chunk/Storage/FilesystemStorage.php @@ -13,13 +13,9 @@ class FilesystemStorage implements ChunkStorageInterface { /** - * @var string + * @param string $directory */ - protected $directory; - - public function __construct(string $directory) - { - $this->directory = $directory; + public function __construct(protected string $directory) { } public function clear(int $maxAge): void diff --git a/src/Uploader/Chunk/Storage/FlysystemStorage.php b/src/Uploader/Chunk/Storage/FlysystemStorage.php index 9b3a6421..b8878292 100644 --- a/src/Uploader/Chunk/Storage/FlysystemStorage.php +++ b/src/Uploader/Chunk/Storage/FlysystemStorage.php @@ -14,36 +14,17 @@ class FlysystemStorage implements ChunkStorageInterface { /** - * @var int - */ - public $bufferSize; - - /** - * @var array + * @var array|null */ protected $unhandledChunk; /** - * @var string - */ - protected $prefix; - - /** - * @var string + * @param Filesystem $filesystem + * @param int $bufferSize + * @param string $streamWrapperPrefix + * @param string $prefix */ - protected $streamWrapperPrefix; - - /** - * @var FilesystemOperator - */ - private $filesystem; - - public function __construct(Filesystem $filesystem, int $bufferSize, string $streamWrapperPrefix, string $prefix) - { - $this->filesystem = $filesystem; - $this->bufferSize = $bufferSize; - $this->prefix = $prefix; - $this->streamWrapperPrefix = $streamWrapperPrefix; + public function __construct(protected Filesystem $filesystem, public int $bufferSize, protected string $streamWrapperPrefix, protected string $prefix) { } public function addChunk(string $uuid, int $index, UploadedFile $chunk, string $original): void diff --git a/src/Uploader/Chunk/Storage/GaufretteStorage.php b/src/Uploader/Chunk/Storage/GaufretteStorage.php index 581adeac..ebc24d8c 100644 --- a/src/Uploader/Chunk/Storage/GaufretteStorage.php +++ b/src/Uploader/Chunk/Storage/GaufretteStorage.php @@ -21,16 +21,12 @@ class GaufretteStorage extends StreamManager implements ChunkStorageInterface protected $unhandledChunk; /** - * @var string + * @param FilesystemInterface $filesystem + * @param int $bufferSize + * @param string|null $streamWrapperPrefix + * @param string $prefix */ - protected $prefix; - - /** - * @var string|null - */ - protected $streamWrapperPrefix; - - public function __construct(FilesystemInterface $filesystem, int $bufferSize, ?string $streamWrapperPrefix, string $prefix) + public function __construct(FilesystemInterface $filesystem, int $bufferSize, protected ?string $streamWrapperPrefix, protected string $prefix) { $base = interface_exists(FilesystemInterface::class) ? FilesystemInterface::class @@ -45,8 +41,6 @@ public function __construct(FilesystemInterface $filesystem, int $bufferSize, ?s } $this->filesystem = $filesystem; $this->buffersize = $bufferSize; - $this->prefix = $prefix; - $this->streamWrapperPrefix = $streamWrapperPrefix; } /** diff --git a/src/Uploader/ErrorHandler/BlueimpErrorHandler.php b/src/Uploader/ErrorHandler/BlueimpErrorHandler.php index 2af40b46..e2a46665 100644 --- a/src/Uploader/ErrorHandler/BlueimpErrorHandler.php +++ b/src/Uploader/ErrorHandler/BlueimpErrorHandler.php @@ -11,13 +11,9 @@ class BlueimpErrorHandler implements ErrorHandlerInterface { /** - * @var TranslatorInterface + * @param TranslatorInterface $translator */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator){ } public function addException(AbstractResponse $response, Exception $exception): void diff --git a/src/Uploader/File/FlysystemFile.php b/src/Uploader/File/FlysystemFile.php index ab179a95..b3cb6752 100644 --- a/src/Uploader/File/FlysystemFile.php +++ b/src/Uploader/File/FlysystemFile.php @@ -9,16 +9,11 @@ class FlysystemFile implements FileInterface { - /** @var string */ - private $pathname; - - /** @var FilesystemOperator */ - private $filesystem; - - public function __construct(string $pathname, FilesystemOperator $filesystem) - { - $this->pathname = $pathname; - $this->filesystem = $filesystem; + /** + * @param string $pathname + * @param FilesystemOperator $filesystem + */ + public function __construct(private string $pathname, private FilesystemOperator $filesystem) { } /** diff --git a/src/Uploader/File/GaufretteFile.php b/src/Uploader/File/GaufretteFile.php index 82c76645..198c7c55 100644 --- a/src/Uploader/File/GaufretteFile.php +++ b/src/Uploader/File/GaufretteFile.php @@ -11,21 +11,19 @@ class GaufretteFile extends File implements FileInterface { - /** - * @var string|null - */ - protected $streamWrapperPrefix; - /** * @var string */ protected $mimeType; - public function __construct(File $file, FilesystemInterface $filesystem, string $streamWrapperPrefix = null) + /** + * @param File $file + * @param FilesystemInterface $filesystem + * @param string|null $streamWrapperPrefix + */ + public function __construct(File $file, FilesystemInterface $filesystem, protected ?string $streamWrapperPrefix = null) { parent::__construct($file->getKey(), $filesystem); - - $this->streamWrapperPrefix = $streamWrapperPrefix; } /** diff --git a/src/Uploader/Orphanage/OrphanageManager.php b/src/Uploader/Orphanage/OrphanageManager.php index 8a15620d..6d7aa35c 100644 --- a/src/Uploader/Orphanage/OrphanageManager.php +++ b/src/Uploader/Orphanage/OrphanageManager.php @@ -12,20 +12,8 @@ class OrphanageManager { - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var array - */ - protected $config; - public function __construct(ContainerInterface $container, array $config) - { - $this->container = $container; - $this->config = $config; + public function __construct(protected ContainerInterface $container, protected array $config) { } public function has(string $key): bool diff --git a/src/Uploader/Response/AbstractResponse.php b/src/Uploader/Response/AbstractResponse.php index e2507e05..f6af027e 100644 --- a/src/Uploader/Response/AbstractResponse.php +++ b/src/Uploader/Response/AbstractResponse.php @@ -7,13 +7,9 @@ abstract class AbstractResponse implements \ArrayAccess, ResponseInterface { /** - * @var array + * @param array $data */ - protected $data; - - public function __construct() - { - $this->data = []; + public function __construct(protected array $data = []){ } /** diff --git a/src/Uploader/Response/FineUploaderResponse.php b/src/Uploader/Response/FineUploaderResponse.php index 907a7bca..8fdce58a 100644 --- a/src/Uploader/Response/FineUploaderResponse.php +++ b/src/Uploader/Response/FineUploaderResponse.php @@ -7,27 +7,17 @@ class FineUploaderResponse extends AbstractResponse { /** - * @var bool + * @param bool $success + * @param string|null $error */ - protected $success; - - /** - * @var string|null - */ - protected $error; - - public function __construct() - { - $this->success = true; - $this->error = null; - + public function __construct(protected bool $success = true, protected ?string $error = null) { parent::__construct(); } public function assemble(): array { // explicitly overwrite success and error key - // as these keys are used internaly by the + // as these keys are used internally by the // frontend uploader $data = $this->data; $data['success'] = $this->success; diff --git a/src/Uploader/Response/MooUploadResponse.php b/src/Uploader/Response/MooUploadResponse.php index f566c9ca..af72defb 100644 --- a/src/Uploader/Response/MooUploadResponse.php +++ b/src/Uploader/Response/MooUploadResponse.php @@ -21,26 +21,12 @@ class MooUploadResponse extends AbstractResponse */ protected $size; - /** - * @var int - */ - protected $error; - - /** - * @var bool - */ - protected $finish; - /** * @var string */ protected $uploadedName; - public function __construct() - { - $this->finish = true; - $this->error = 0; - + public function __construct(protected bool $finish = true, protected int $error = 0) { parent::__construct(); } diff --git a/src/Uploader/Storage/FilesystemOrphanageStorage.php b/src/Uploader/Storage/FilesystemOrphanageStorage.php index 7ed19a37..b3227932 100644 --- a/src/Uploader/Storage/FilesystemOrphanageStorage.php +++ b/src/Uploader/Storage/FilesystemOrphanageStorage.php @@ -15,43 +15,25 @@ class FilesystemOrphanageStorage extends FilesystemStorage implements OrphanageStorageInterface { - /** - * @var StorageInterface - */ - protected $storage; - /** * @var SessionInterface */ protected $session; /** - * @var ChunkStorage - */ - protected $chunkStorage; - - /** - * @var array + * @param StorageInterface $storage + * @param RequestStack $requestStack + * @param ChunkStorage $chunkStorage + * @param array $config + * @param string $type */ - protected $config; - - /** - * @var string - */ - protected $type; - - public function __construct(StorageInterface $storage, RequestStack $requestStack, ChunkStorage $chunkStorage, array $config, string $type) + public function __construct(protected StorageInterface $storage, RequestStack $requestStack, protected ChunkStorage $chunkStorage, protected array $config, protected string $type) { parent::__construct($config['directory']); /** @var Request $request */ $request = $requestStack->getCurrentRequest(); - - $this->storage = $storage; $this->session = $request->getSession(); - $this->chunkStorage = $chunkStorage; - $this->config = $config; - $this->type = $type; } /** diff --git a/src/Uploader/Storage/FilesystemStorage.php b/src/Uploader/Storage/FilesystemStorage.php index 3bcd28c9..781d54e7 100644 --- a/src/Uploader/Storage/FilesystemStorage.php +++ b/src/Uploader/Storage/FilesystemStorage.php @@ -11,13 +11,9 @@ class FilesystemStorage implements StorageInterface { /** - * @var string + * @param string $directory */ - protected $directory; - - public function __construct(string $directory) - { - $this->directory = $directory; + public function __construct(protected string $directory){ } /** diff --git a/src/Uploader/Storage/FlysystemOrphanageStorage.php b/src/Uploader/Storage/FlysystemOrphanageStorage.php index 49307c88..ce4addb3 100644 --- a/src/Uploader/Storage/FlysystemOrphanageStorage.php +++ b/src/Uploader/Storage/FlysystemOrphanageStorage.php @@ -16,32 +16,19 @@ class FlysystemOrphanageStorage extends FlysystemStorage implements OrphanageStorageInterface { - /** - * @var StorageInterface - */ - protected $storage; - /** * @var SessionInterface */ protected $session; /** - * @var ChunkStorage - */ - protected $chunkStorage; - - /** - * @var array + * @param StorageInterface $storage + * @param RequestStack $requestStack + * @param ChunkStorage $chunkStorage + * @param array $config + * @param string $type */ - protected $config; - - /** - * @var string - */ - protected $type; - - public function __construct(StorageInterface $storage, RequestStack $requestStack, ChunkStorage $chunkStorage, array $config, string $type) + public function __construct(protected StorageInterface $storage, RequestStack $requestStack, protected ChunkStorage $chunkStorage, protected array $config, protected string $type) { /* * initiate the storage on the chunk storage's filesystem @@ -51,12 +38,7 @@ public function __construct(StorageInterface $storage, RequestStack $requestStac /** @var Request $request */ $request = $requestStack->getCurrentRequest(); - - $this->storage = $storage; - $this->chunkStorage = $chunkStorage; $this->session = $request->getSession(); - $this->config = $config; - $this->type = $type; } /** diff --git a/src/Uploader/Storage/FlysystemStorage.php b/src/Uploader/Storage/FlysystemStorage.php index 854757dd..3ae2f1a4 100644 --- a/src/Uploader/Storage/FlysystemStorage.php +++ b/src/Uploader/Storage/FlysystemStorage.php @@ -15,25 +15,11 @@ class FlysystemStorage implements StorageInterface { /** - * @var string|null + * @param FilesystemOperator $filesystem + * @param int $bufferSize + * @param string|null $streamWrapperPrefix */ - protected $streamWrapperPrefix; - - /** - * @var int - */ - protected $bufferSize; - - /** - * @var FilesystemOperator - */ - private $filesystem; - - public function __construct(FilesystemOperator $filesystem, int $bufferSize, ?string $streamWrapperPrefix = null) - { - $this->filesystem = $filesystem; - $this->bufferSize = $bufferSize; - $this->streamWrapperPrefix = $streamWrapperPrefix; + public function __construct(private FilesystemOperator $filesystem, protected int $bufferSize, protected ?string $streamWrapperPrefix = null) { } /** diff --git a/src/Uploader/Storage/GaufretteOrphanageStorage.php b/src/Uploader/Storage/GaufretteOrphanageStorage.php index cfab590b..5a0a5e4b 100644 --- a/src/Uploader/Storage/GaufretteOrphanageStorage.php +++ b/src/Uploader/Storage/GaufretteOrphanageStorage.php @@ -14,32 +14,19 @@ class GaufretteOrphanageStorage extends GaufretteStorage implements OrphanageStorageInterface { - /** - * @var StorageInterface - */ - protected $storage; - /** * @var SessionInterface */ protected $session; /** - * @var GaufretteChunkStorage - */ - protected $chunkStorage; - - /** - * @var array + * @param StorageInterface $storage + * @param RequestStack $requestStack + * @param GaufretteChunkStorage $chunkStorage + * @param array $config + * @param string $type */ - protected $config; - - /** - * @var string - */ - protected $type; - - public function __construct(StorageInterface $storage, RequestStack $requestStack, GaufretteChunkStorage $chunkStorage, array $config, string $type) + public function __construct(protected StorageInterface $storage, RequestStack $requestStack, protected GaufretteChunkStorage $chunkStorage, protected array $config, protected string $type) { /* * initiate the storage on the chunk storage's filesystem @@ -49,12 +36,7 @@ public function __construct(StorageInterface $storage, RequestStack $requestStac /** @var Request $request */ $request = $requestStack->getCurrentRequest(); - - $this->storage = $storage; - $this->chunkStorage = $chunkStorage; $this->session = $request->getSession(); - $this->config = $config; - $this->type = $type; } /** diff --git a/src/Uploader/Storage/GaufretteStorage.php b/src/Uploader/Storage/GaufretteStorage.php index 98e02671..1f598cf7 100644 --- a/src/Uploader/Storage/GaufretteStorage.php +++ b/src/Uploader/Storage/GaufretteStorage.php @@ -15,11 +15,11 @@ class GaufretteStorage extends StreamManager implements StorageInterface { /** - * @var string|null + * @param FilesystemInterface $filesystem + * @param int $bufferSize + * @param string|null $streamWrapperPrefix */ - protected $streamWrapperPrefix; - - public function __construct(FilesystemInterface $filesystem, int $bufferSize, ?string $streamWrapperPrefix = null) + public function __construct(FilesystemInterface $filesystem, int $bufferSize, protected ?string $streamWrapperPrefix = null) { $base = interface_exists(FilesystemInterface::class) ? FilesystemInterface::class @@ -31,7 +31,6 @@ public function __construct(FilesystemInterface $filesystem, int $bufferSize, ?s $this->filesystem = $filesystem; $this->buffersize = $bufferSize; - $this->streamWrapperPrefix = $streamWrapperPrefix; } /**