From 91a8bed27a6a3a4ab4369f475a3da5f7f75cbbfb Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 28 Nov 2024 14:02:14 +1300 Subject: [PATCH] API Explicity mark nullable paramters for PHP 8.4 --- code/Forms/AssetFormFactory.php | 8 ++++---- code/Forms/FileFormFactory.php | 6 +++--- code/Forms/FileHistoryFormFactory.php | 6 +++--- code/Forms/FileSearchFormFactory.php | 4 ++-- code/Forms/FolderCreateFormFactory.php | 2 +- code/Forms/FolderFormFactory.php | 2 +- code/Forms/ImageFormFactory.php | 2 +- code/Forms/MoveFormFactory.php | 2 +- code/Forms/RemoteFileFormFactory.php | 2 +- code/Forms/UploadField.php | 2 +- code/Model/ThumbnailGenerator.php | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/code/Forms/AssetFormFactory.php b/code/Forms/AssetFormFactory.php index 1b0a7f267..463226bba 100644 --- a/code/Forms/AssetFormFactory.php +++ b/code/Forms/AssetFormFactory.php @@ -68,7 +68,7 @@ public function __construct() * @param array $context * @return Form */ - public function getForm(RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) { // Validate context foreach ($this->getRequiredContext() as $required) { @@ -110,7 +110,7 @@ public function getForm(RequestHandler $controller = null, $name = FormFactory:: * @param $context * @return RequiredFields */ - protected function getValidator(RequestHandler $controller = null, $formName, $context = []) + protected function getValidator(?RequestHandler $controller = null, $formName, $context = []) { $validator = new RequiredFields('Name'); @@ -199,7 +199,7 @@ protected function getDeleteAction($record) * @param array $context * @return FieldList */ - protected function getFormActions(RequestHandler $controller = null, $formName, $context = []) + protected function getFormActions(?RequestHandler $controller = null, $formName, $context = []) { $record = isset($context['Record']) ? $context['Record'] : null; @@ -224,7 +224,7 @@ protected function getFormActions(RequestHandler $controller = null, $formName, * @param array $context * @return FieldList */ - protected function getFormFields(RequestHandler $controller = null, $formName, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $formName, $context = []) { /** @var File $record */ $record = isset($context['Record']) ? $context['Record'] : null; diff --git a/code/Forms/FileFormFactory.php b/code/Forms/FileFormFactory.php index 1eb0e5658..0b13988ae 100644 --- a/code/Forms/FileFormFactory.php +++ b/code/Forms/FileFormFactory.php @@ -198,7 +198,7 @@ protected function getFormFieldHistoryTab($record, $context = []) * @param array $context * @return FieldList */ - protected function getFormFields(RequestHandler $controller = null, $formName, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $formName, $context = []) { /** @var File $record */ $record = $context['Record']; @@ -266,7 +266,7 @@ protected function getPublishAction($record) * @param array $context * @return FieldList */ - protected function getFormActions(RequestHandler $controller = null, $formName, $context = []) + protected function getFormActions(?RequestHandler $controller = null, $formName, $context = []) { $record = $context['Record']; $fileSelected = $context['FileSelected'] ?? false; @@ -505,7 +505,7 @@ public function getRequiredContext() * @param $context * @return RequiredFields */ - protected function getValidator(RequestHandler $controller = null, $formName, $context = []) + protected function getValidator(?RequestHandler $controller = null, $formName, $context = []) { $validator = parent::getValidator($controller, $formName, $context); diff --git a/code/Forms/FileHistoryFormFactory.php b/code/Forms/FileHistoryFormFactory.php index b6d2d095b..1167ed086 100644 --- a/code/Forms/FileHistoryFormFactory.php +++ b/code/Forms/FileHistoryFormFactory.php @@ -12,7 +12,7 @@ class FileHistoryFormFactory extends FileFormFactory { - public function getForm(RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) { $context['RequireLinkText'] = false; $form = parent::getForm($controller, $name, $context); @@ -47,7 +47,7 @@ protected function getSpecsMarkup($record) ); } - protected function getFormFields(RequestHandler $controller = null, $name, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $name, $context = []) { $record = $context['Record']; @@ -68,7 +68,7 @@ protected function getFormFields(RequestHandler $controller = null, $name, $cont } - protected function getFormActions(RequestHandler $controller = null, $formName, $context = []) + protected function getFormActions(?RequestHandler $controller = null, $formName, $context = []) { $actions = new FieldList(); // Update diff --git a/code/Forms/FileSearchFormFactory.php b/code/Forms/FileSearchFormFactory.php index b1c85802b..abecaeb71 100644 --- a/code/Forms/FileSearchFormFactory.php +++ b/code/Forms/FileSearchFormFactory.php @@ -31,7 +31,7 @@ class FileSearchFormFactory implements FormFactory * Custom factories may support more advanced parameters. * @return Form */ - public function getForm(RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) { $fields = $this->getFormFields($controller, $name, $context); $actions = FieldList::create(); @@ -49,7 +49,7 @@ public function getForm(RequestHandler $controller = null, $name = FormFactory:: * @param array $context * @return FieldList */ - protected function getFormFields(RequestHandler $controller = null, $name, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $name, $context = []) { // Note: "Name" field is excluded as it is baked directly into the Search.js react component diff --git a/code/Forms/FolderCreateFormFactory.php b/code/Forms/FolderCreateFormFactory.php index 4ddd26232..ac8d15a88 100644 --- a/code/Forms/FolderCreateFormFactory.php +++ b/code/Forms/FolderCreateFormFactory.php @@ -16,7 +16,7 @@ public function getRequiredContext() return ['ParentID']; } - public function getFormFields(RequestHandler $controller = null, $name, $context = []) + public function getFormFields(?RequestHandler $controller = null, $name, $context = []) { // Add status flag before extensions are triggered $this->beforeExtending('updateFormFields', function (FieldList $fields) use ($context) { diff --git a/code/Forms/FolderFormFactory.php b/code/Forms/FolderFormFactory.php index b90c050ff..afa290c70 100644 --- a/code/Forms/FolderFormFactory.php +++ b/code/Forms/FolderFormFactory.php @@ -13,7 +13,7 @@ class FolderFormFactory extends AssetFormFactory { - protected function getFormFields(RequestHandler $controller = null, $name, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $name, $context = []) { /** @var Folder $record */ $record = $context['Record'] ?? null; diff --git a/code/Forms/ImageFormFactory.php b/code/Forms/ImageFormFactory.php index 44c4cda7a..48be78f24 100644 --- a/code/Forms/ImageFormFactory.php +++ b/code/Forms/ImageFormFactory.php @@ -137,7 +137,7 @@ protected function getFormFieldAttributesTab($record, $context = []) * @param array $context * @return Form */ - public function getForm(RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) { $this->beforeExtending('updateForm', function (Form $form) use ($context) { $record = null; diff --git a/code/Forms/MoveFormFactory.php b/code/Forms/MoveFormFactory.php index 42bdb3b0a..676793e95 100644 --- a/code/Forms/MoveFormFactory.php +++ b/code/Forms/MoveFormFactory.php @@ -15,7 +15,7 @@ class MoveFormFactory implements FormFactory { use Extensible; - public function getForm(RequestHandler $controller = null, $name = MoveFormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = MoveFormFactory::DEFAULT_NAME, $context = []) { $form = Form::create( $controller, diff --git a/code/Forms/RemoteFileFormFactory.php b/code/Forms/RemoteFileFormFactory.php index 8cc3070ce..f44590111 100644 --- a/code/Forms/RemoteFileFormFactory.php +++ b/code/Forms/RemoteFileFormFactory.php @@ -92,7 +92,7 @@ class RemoteFileFormFactory implements FormFactory * @param array $context * @return Form */ - public function getForm(RequestHandler $controller = null, $name = RemoteFileFormFactory::DEFAULT_NAME, $context = []) + public function getForm(?RequestHandler $controller = null, $name = RemoteFileFormFactory::DEFAULT_NAME, $context = []) { // Allow form to be disabled if (!static::config()->get('enabled')) { diff --git a/code/Forms/UploadField.php b/code/Forms/UploadField.php index 2f235b368..1880b2db4 100644 --- a/code/Forms/UploadField.php +++ b/code/Forms/UploadField.php @@ -91,7 +91,7 @@ class UploadField extends FormField implements FileHandleField * @param string $title The field label. * @param SS_List $items Items assigned to this field */ - public function __construct($name, $title = null, SS_List $items = null) + public function __construct($name, $title = null, ?SS_List $items = null) { $this->constructFileUploadReceiver(); diff --git a/code/Model/ThumbnailGenerator.php b/code/Model/ThumbnailGenerator.php index 87b5596f1..d71fd458e 100644 --- a/code/Model/ThumbnailGenerator.php +++ b/code/Model/ThumbnailGenerator.php @@ -147,7 +147,7 @@ public function generateThumbnail(AssetContainer $file, $width, $height) * @param AssetContainer $thumbnail * @return string */ - public function generateLink(AssetContainer $thumbnail = null) + public function generateLink(?AssetContainer $thumbnail = null) { // Check if thumbnail can be found if (!$thumbnail || !$thumbnail->exists() || !$thumbnail->getIsImage()) {