diff --git a/core/modules/file/src/Upload/FilenameExtractor.php b/core/modules/file/src/Upload/FilenameExtractor.php index 110c166393..63420a5be4 100644 --- a/core/modules/file/src/Upload/FilenameExtractor.php +++ b/core/modules/file/src/Upload/FilenameExtractor.php @@ -11,13 +11,6 @@ */ class FilenameExtractor { - /** - * The file system. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - /** * The regex used to extract the filename from the content disposition header. * @@ -26,10 +19,12 @@ class FilenameExtractor { const REQUEST_HEADER_FILENAME_REGEX = '@\bfilename(?\*?)=\"(?.+)\"@'; /** + * Creates a new file name extractor. + * * @param \Drupal\Core\File\FileSystemInterface $fileSystem + * The file system service. */ - public function __construct(FileSystemInterface $fileSystem) { - $this->fileSystem = $fileSystem; + public function __construct(protected FileSystemInterface $fileSystem) { } /** diff --git a/core/modules/file/src/Upload/RawFileUploader.php b/core/modules/file/src/Upload/RawFileUploader.php index cc6bfb15c7..eb13e29dca 100644 --- a/core/modules/file/src/Upload/RawFileUploader.php +++ b/core/modules/file/src/Upload/RawFileUploader.php @@ -9,13 +9,6 @@ */ class RawFileUploader { - /** - * The file system. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - /** * The amount of bytes to read in each iteration when streaming file data. * @@ -24,22 +17,24 @@ class RawFileUploader { const BYTES_TO_READ = 8192; /** + * Creates a new raw file uploader. + * * @param \Drupal\Core\File\FileSystemInterface $fileSystem + * The file system service. */ - public function __construct(FileSystemInterface $fileSystem) { - $this->fileSystem = $fileSystem; + public function __construct(protected FileSystemInterface $fileSystem) { } /** * Upload file data from the input stream. * * @param string $filename - * The original file name of the uploaded file + * The original file name of the uploaded file. * @param string $source * (Optional) The source of the upload. Defaults to 'php://input'. - * @param string|null $mimeType + * @param string $mimeType * (Optional) The type of the file as provided by PHP; null defaults to - * application/octet-stream + * application/octet-stream. * * @return \Drupal\file\Upload\RawUploadedFile * The raw uploaded file. diff --git a/core/modules/file/src/Upload/RawUploadedFile.php b/core/modules/file/src/Upload/RawUploadedFile.php index fda74770ac..0f61f76cfb 100644 --- a/core/modules/file/src/Upload/RawUploadedFile.php +++ b/core/modules/file/src/Upload/RawUploadedFile.php @@ -13,37 +13,19 @@ class RawUploadedFile extends File implements UploadedFileInterface { /** - * The original name provided by the client. + * Constructs a new raw uploaded file. * - * @var string - */ - protected $originalName; - - /** - * The untrusted mimetype provided by the client. - * - * @var string - */ - protected $mimeType; - - /** - * The error code. - * - * @var int - */ - protected $error; - - /** * @param string $path + * The path to the file. * @param string $originalName + * The original name provided by the client. * @param string $mimeType + * The untrusted mimetype provided by the client. * @param int $error + * The error code. */ - public function __construct(string $path, string $originalName, string $mimeType = 'application/octet-stream', int $error = \UPLOAD_ERR_OK) { + public function __construct(string $path, protected string $originalName, protected string $mimeType = 'application/octet-stream', protected int $error = \UPLOAD_ERR_OK) { parent::__construct($path, \UPLOAD_ERR_OK === $this->error); - $this->originalName = $originalName; - $this->mimeType = $mimeType; - $this->error = $error; } /**