Skip to content

Commit

Permalink
API Explicity mark nullable parameters for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Dec 1, 2024
1 parent 7ada4e1 commit 6480a91
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions code/Forms/AssetFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions code/Forms/FileFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions code/Forms/FileHistoryFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'];

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/Forms/FileSearchFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/Forms/FolderCreateFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/FolderFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/ImageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/MoveFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/RemoteFileFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/UploadField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion code/Model/ThumbnailGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 6480a91

Please sign in to comment.