diff --git a/src/AzureBlobStorage/AzureBlobStorageAdapter.php b/src/AzureBlobStorage/AzureBlobStorageAdapter.php index ec21b146f..7842a5879 100644 --- a/src/AzureBlobStorage/AzureBlobStorageAdapter.php +++ b/src/AzureBlobStorage/AzureBlobStorageAdapter.php @@ -56,30 +56,20 @@ class AzureBlobStorageAdapter implements FilesystemAdapter, PublicUrlGenerator, const ON_VISIBILITY_THROW_ERROR = 'throw'; const ON_VISIBILITY_IGNORE = 'ignore'; - private BlobRestProxy $client; private MimeTypeDetector $mimeTypeDetector; - private int $maxResultsForContentsListing; - private string $container; private PathPrefixer $prefixer; - private string $visibilityHandling; - private ?StorageServiceSettings $serviceSettings; public function __construct( - BlobRestProxy $client, - string $container, + private BlobRestProxy $client, + private string $container, string $prefix = '', MimeTypeDetector $mimeTypeDetector = null, - int $maxResultsForContentsListing = 5000, - string $visibilityHandling = self::ON_VISIBILITY_THROW_ERROR, - StorageServiceSettings $serviceSettings = null, + private int $maxResultsForContentsListing = 5000, + private string $visibilityHandling = self::ON_VISIBILITY_THROW_ERROR, + private ?StorageServiceSettings $serviceSettings = null, ) { - $this->client = $client; - $this->container = $container; $this->prefixer = new PathPrefixer($prefix); $this->mimeTypeDetector = $mimeTypeDetector ?? new FinfoMimeTypeDetector(); - $this->maxResultsForContentsListing = $maxResultsForContentsListing; - $this->visibilityHandling = $visibilityHandling; - $this->serviceSettings = $serviceSettings; } public function copy(string $source, string $destination, Config $config): void diff --git a/src/Config.php b/src/Config.php index 77c3b5a1d..ace07099b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -11,14 +11,8 @@ class Config public const OPTION_VISIBILITY = 'visibility'; public const OPTION_DIRECTORY_VISIBILITY = 'directory_visibility'; - /** - * @var array - */ - private $options; - - public function __construct(array $options = []) + public function __construct(private array $options = []) { - $this->options = $options; } /** diff --git a/src/DirectoryAttributes.php b/src/DirectoryAttributes.php index 3eb1ced61..7841b3cc1 100644 --- a/src/DirectoryAttributes.php +++ b/src/DirectoryAttributes.php @@ -7,38 +7,15 @@ class DirectoryAttributes implements StorageAttributes { use ProxyArrayAccessToProperties; + private string $type = StorageAttributes::TYPE_DIRECTORY; - /** - * @var string - */ - private $type = StorageAttributes::TYPE_DIRECTORY; - - /** - * @var string - */ - private $path; - - /** - * @var string|null - */ - private $visibility; - - /** - * @var int|null - */ - private $lastModified; - - /** - * @var array - */ - private $extraMetadata; - - public function __construct(string $path, ?string $visibility = null, ?int $lastModified = null, array $extraMetadata = []) + public function __construct( + private string $path, + private ?string $visibility = null, + private ?int $lastModified = null, + private array $extraMetadata = []) { - $this->path = trim($path, '/'); - $this->visibility = $visibility; - $this->lastModified = $lastModified; - $this->extraMetadata = $extraMetadata; + $this->path = trim($this->path, '/'); } public function path(): string @@ -48,7 +25,7 @@ public function path(): string public function type(): string { - return StorageAttributes::TYPE_DIRECTORY; + return $this->type; } public function visibility(): ?string diff --git a/src/DirectoryListing.php b/src/DirectoryListing.php index 0f429a875..ab73a5467 100644 --- a/src/DirectoryListing.php +++ b/src/DirectoryListing.php @@ -14,17 +14,11 @@ */ class DirectoryListing implements IteratorAggregate { - /** - * @var iterable - */ - private $listing; - /** * @param iterable $listing */ - public function __construct(iterable $listing) + public function __construct(private iterable $listing) { - $this->listing = $listing; } public function filter(callable $filter): DirectoryListing diff --git a/src/FileAttributes.php b/src/FileAttributes.php index 35ccc7c1f..42172f8c4 100644 --- a/src/FileAttributes.php +++ b/src/FileAttributes.php @@ -7,56 +7,17 @@ class FileAttributes implements StorageAttributes { use ProxyArrayAccessToProperties; - - /** - * @var string - */ - private $type = StorageAttributes::TYPE_FILE; - - /** - * @var string - */ - private $path; - - /** - * @var int|null - */ - private $fileSize; - - /** - * @var string|null - */ - private $visibility; - - /** - * @var int|null - */ - private $lastModified; - - /** - * @var string|null - */ - private $mimeType; - - /** - * @var array - */ - private $extraMetadata; + private string $type = StorageAttributes::TYPE_FILE; public function __construct( - string $path, - ?int $fileSize = null, - ?string $visibility = null, - ?int $lastModified = null, - ?string $mimeType = null, - array $extraMetadata = [] + private string $path, + private ?int $fileSize = null, + private ?string $visibility = null, + private ?int $lastModified = null, + private ?string $mimeType = null, + private array $extraMetadata = [] ) { - $this->path = ltrim($path, '/'); - $this->fileSize = $fileSize; - $this->visibility = $visibility; - $this->lastModified = $lastModified; - $this->mimeType = $mimeType; - $this->extraMetadata = $extraMetadata; + $this->path = ltrim($this->path, '/'); } public function type(): string diff --git a/src/Filesystem.php b/src/Filesystem.php index 216a5f7bc..94fae15ef 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -18,24 +18,18 @@ class Filesystem implements FilesystemOperator { use CalculateChecksumFromStream; - private FilesystemAdapter $adapter; private Config $config; private PathNormalizer $pathNormalizer; - private ?PublicUrlGenerator $publicUrlGenerator; - private ?TemporaryUrlGenerator $temporaryUrlGenerator; public function __construct( - FilesystemAdapter $adapter, + private FilesystemAdapter $adapter, array $config = [], PathNormalizer $pathNormalizer = null, - PublicUrlGenerator $publicUrlGenerator = null, - TemporaryUrlGenerator $temporaryUrlGenerator = null, + private ?PublicUrlGenerator $publicUrlGenerator = null, + private ?TemporaryUrlGenerator $temporaryUrlGenerator = null, ) { - $this->adapter = $adapter; $this->config = new Config($config); $this->pathNormalizer = $pathNormalizer ?: new WhitespacePathNormalizer(); - $this->publicUrlGenerator = $publicUrlGenerator; - $this->temporaryUrlGenerator = $temporaryUrlGenerator; } public function fileExists(string $location): bool diff --git a/src/InMemory/InMemoryFile.php b/src/InMemory/InMemoryFile.php index 9e7e46b44..f9d90ac5a 100644 --- a/src/InMemory/InMemoryFile.php +++ b/src/InMemory/InMemoryFile.php @@ -12,20 +12,9 @@ */ class InMemoryFile { - /** - * @var string - */ - private $contents; - - /** - * @var int - */ - private $lastModified; - - /** - * @var string - */ - private $visibility; + private string $contents = ''; + private int $lastModified = 0; + private ?string $visibility = null; public function updateContents(string $contents, ?int $timestamp): void { diff --git a/src/InMemory/InMemoryFilesystemAdapter.php b/src/InMemory/InMemoryFilesystemAdapter.php index b744c0f48..fb6d18d23 100644 --- a/src/InMemory/InMemoryFilesystemAdapter.php +++ b/src/InMemory/InMemoryFilesystemAdapter.php @@ -28,21 +28,13 @@ class InMemoryFilesystemAdapter implements FilesystemAdapter /** * @var InMemoryFile[] */ - private $files = []; + private array $files = []; + private MimeTypeDetector $mimeTypeDetector; - /** - * @var string - */ - private $defaultVisibility; - - /** - * @var MimeTypeDetector - */ - private $mimeTypeDetector; - - public function __construct(string $defaultVisibility = Visibility::PUBLIC, MimeTypeDetector $mimeTypeDetector = null) - { - $this->defaultVisibility = $defaultVisibility; + public function __construct( + private string $defaultVisibility = Visibility::PUBLIC, + MimeTypeDetector $mimeTypeDetector = null + ) { $this->mimeTypeDetector = $mimeTypeDetector ?: new FinfoMimeTypeDetector(); } diff --git a/src/PathPrefixer.php b/src/PathPrefixer.php index 2a9cd45d0..ca4f007fc 100644 --- a/src/PathPrefixer.php +++ b/src/PathPrefixer.php @@ -10,25 +10,15 @@ final class PathPrefixer { - /** - * @var string - */ - private $prefix = ''; + private string $prefix = ''; - /** - * @var string - */ - private $separator = '/'; - - public function __construct(string $prefix, string $separator = '/') + public function __construct(string $prefix, private string $separator = '/') { $this->prefix = rtrim($prefix, '\\/'); if ($this->prefix !== '' || $prefix === $separator) { $this->prefix .= $separator; } - - $this->separator = $separator; } public function prefixPath(string $path): string diff --git a/src/PathTraversalDetected.php b/src/PathTraversalDetected.php index d149997f7..fef3edf18 100644 --- a/src/PathTraversalDetected.php +++ b/src/PathTraversalDetected.php @@ -8,10 +8,7 @@ class PathTraversalDetected extends RuntimeException implements FilesystemException { - /** - * @var string - */ - private $path; + private string $path; public function path(): string { diff --git a/src/SymbolicLinkEncountered.php b/src/SymbolicLinkEncountered.php index 8091f5904..e4e0a5334 100644 --- a/src/SymbolicLinkEncountered.php +++ b/src/SymbolicLinkEncountered.php @@ -8,10 +8,7 @@ final class SymbolicLinkEncountered extends RuntimeException implements FilesystemException { - /** - * @var string - */ - private $location; + private string $location; public function location(): string { diff --git a/src/UnixVisibility/PortableVisibilityConverter.php b/src/UnixVisibility/PortableVisibilityConverter.php index 5cc1eb232..117b4d966 100644 --- a/src/UnixVisibility/PortableVisibilityConverter.php +++ b/src/UnixVisibility/PortableVisibilityConverter.php @@ -9,43 +9,13 @@ class PortableVisibilityConverter implements VisibilityConverter { - /** - * @var int - */ - private $filePublic; - - /** - * @var int - */ - private $filePrivate; - - /** - * @var int - */ - private $directoryPublic; - - /** - * @var int - */ - private $directoryPrivate; - - /** - * @var string - */ - private $defaultForDirectories; - public function __construct( - int $filePublic = 0644, - int $filePrivate = 0600, - int $directoryPublic = 0755, - int $directoryPrivate = 0700, - string $defaultForDirectories = Visibility::PRIVATE + private int $filePublic = 0644, + private int $filePrivate = 0600, + private int $directoryPublic = 0755, + private int $directoryPrivate = 0700, + private string $defaultForDirectories = Visibility::PRIVATE ) { - $this->filePublic = $filePublic; - $this->filePrivate = $filePrivate; - $this->directoryPublic = $directoryPublic; - $this->directoryPrivate = $directoryPrivate; - $this->defaultForDirectories = $defaultForDirectories; } public function forFile(string $visibility): int diff --git a/src/ZipArchive/FilesystemZipArchiveProvider.php b/src/ZipArchive/FilesystemZipArchiveProvider.php index 93da27cac..1ceb51516 100644 --- a/src/ZipArchive/FilesystemZipArchiveProvider.php +++ b/src/ZipArchive/FilesystemZipArchiveProvider.php @@ -8,25 +8,13 @@ class FilesystemZipArchiveProvider implements ZipArchiveProvider { - /** - * @var string - */ - private $filename; - - /** - * @var int - */ - private $localDirectoryPermissions; - /** * @var bool */ private $parentDirectoryCreated = false; - public function __construct(string $filename, int $localDirectoryPermissions = 0700) + public function __construct(private string $filename, private int $localDirectoryPermissions = 0700) { - $this->filename = $filename; - $this->localDirectoryPermissions = $localDirectoryPermissions; } public function createZipArchive(): ZipArchive diff --git a/src/ZipArchive/StubZipArchive.php b/src/ZipArchive/StubZipArchive.php index 28670ee3d..5fb6ec2f2 100644 --- a/src/ZipArchive/StubZipArchive.php +++ b/src/ZipArchive/StubZipArchive.php @@ -8,30 +8,11 @@ class StubZipArchive extends ZipArchive { - /** - * @var bool - */ - private $failNextDirectoryCreation = false; - - /** - * @var bool - */ - private $failNextWrite = false; - - /** - * @var bool - */ - private $failNextDeleteName = false; - - /** - * @var bool - */ - private $failWhenSettingVisibility = false; - - /** - * @var bool - */ - private $failWhenDeletingAnIndex = false; + private bool $failNextDirectoryCreation = false; + private bool $failNextWrite = false; + private bool $failNextDeleteName = false; + private bool $failWhenSettingVisibility = false; + private bool $failWhenDeletingAnIndex = false; public function failNextDirectoryCreation(): void { diff --git a/src/ZipArchive/StubZipArchiveProvider.php b/src/ZipArchive/StubZipArchiveProvider.php index 914e0438d..a8e8f68f4 100644 --- a/src/ZipArchive/StubZipArchiveProvider.php +++ b/src/ZipArchive/StubZipArchiveProvider.php @@ -8,25 +8,17 @@ class StubZipArchiveProvider implements ZipArchiveProvider { - /** - * @var FilesystemZipArchiveProvider - */ - private $provider; + private FilesystemZipArchiveProvider $provider; - /** - * @var string - */ - private $filename; /** * @var StubZipArchive */ private $archive; - public function __construct(string $filename, int $localDirectoryPermissions = 0700) + public function __construct(private string $filename, int $localDirectoryPermissions = 0700) { $this->provider = new FilesystemZipArchiveProvider($filename, $localDirectoryPermissions); - $this->filename = $filename; } public function createZipArchive(): ZipArchive diff --git a/src/ZipArchive/ZipArchiveAdapter.php b/src/ZipArchive/ZipArchiveAdapter.php index 9b0ba0bf3..3c3b4db5d 100644 --- a/src/ZipArchive/ZipArchiveAdapter.php +++ b/src/ZipArchive/ZipArchiveAdapter.php @@ -33,17 +33,12 @@ final class ZipArchiveAdapter implements FilesystemAdapter { - /** @var PathPrefixer */ - private $pathPrefixer; - /** @var MimeTypeDetector */ - private $mimeTypeDetector; - /** @var VisibilityConverter */ - private $visibility; - /** @var ZipArchiveProvider */ - private $zipArchiveProvider; + private PathPrefixer $pathPrefixer; + private MimeTypeDetector$mimeTypeDetector; + private VisibilityConverter $visibility; public function __construct( - ZipArchiveProvider $zipArchiveProvider, + private ZipArchiveProvider $zipArchiveProvider, string $root = '', ?MimeTypeDetector $mimeTypeDetector = null, ?VisibilityConverter $visibility = null @@ -51,7 +46,6 @@ public function __construct( $this->pathPrefixer = new PathPrefixer(ltrim($root, '/')); $this->mimeTypeDetector = $mimeTypeDetector ?? new FinfoMimeTypeDetector(); $this->visibility = $visibility ?? new PortableVisibilityConverter(); - $this->zipArchiveProvider = $zipArchiveProvider; } public function fileExists(string $path): bool