diff --git a/src/Control/Director.php b/src/Control/Director.php index f1f4b7fe5f3..a5f8aee7651 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -511,7 +511,7 @@ protected static function validateUserAndPass($url) * @param HTTPRequest $request * @return string Host name, including port (if present) */ - public static function host(HTTPRequest $request = null) + public static function host(?HTTPRequest $request = null) { // Check if overridden by alternate_base_url if ($baseURL = static::config()->get('alternate_base_url')) { @@ -553,7 +553,7 @@ public static function host(HTTPRequest $request = null) * @param HTTPRequest $request * @return int|null */ - public static function port(HTTPRequest $request = null) + public static function port(?HTTPRequest $request = null) { $host = static::host($request); return (int)parse_url($host ?? '', PHP_URL_PORT) ?: null; @@ -565,7 +565,7 @@ public static function port(HTTPRequest $request = null) * @param HTTPRequest|null $request * @return string|null */ - public static function hostName(HTTPRequest $request = null) + public static function hostName(?HTTPRequest $request = null) { $host = static::host($request); return parse_url($host ?? '', PHP_URL_HOST) ?: null; @@ -578,7 +578,7 @@ public static function hostName(HTTPRequest $request = null) * @param HTTPRequest $request * @return bool|string */ - public static function protocolAndHost(HTTPRequest $request = null) + public static function protocolAndHost(?HTTPRequest $request = null) { return static::protocol($request) . static::host($request); } @@ -589,7 +589,7 @@ public static function protocolAndHost(HTTPRequest $request = null) * @param HTTPRequest $request * @return string */ - public static function protocol(HTTPRequest $request = null) + public static function protocol(?HTTPRequest $request = null) { return (Director::is_https($request)) ? 'https://' : 'http://'; } @@ -600,7 +600,7 @@ public static function protocol(HTTPRequest $request = null) * @param HTTPRequest $request * @return bool */ - public static function is_https(HTTPRequest $request = null) + public static function is_https(?HTTPRequest $request = null) { // Check override from alternate_base_url if ($baseURL = static::config()->uninherited('alternate_base_url')) { @@ -925,7 +925,7 @@ public static function absoluteBaseURL() * @param HTTPRequest|null $request * @return string */ - public static function absoluteBaseURLWithAuth(HTTPRequest $request = null) + public static function absoluteBaseURLWithAuth(?HTTPRequest $request = null) { // Detect basic auth $login = ''; @@ -985,7 +985,7 @@ protected static function force_redirect($destURL) * Can include port number. * @param HTTPRequest|null $request Request object to check */ - public static function forceSSL($patterns = null, $secureDomain = null, HTTPRequest $request = null) + public static function forceSSL($patterns = null, $secureDomain = null, ?HTTPRequest $request = null) { $handler = CanonicalURLMiddleware::singleton()->setForceSSL(true); if ($patterns) { @@ -1002,7 +1002,7 @@ public static function forceSSL($patterns = null, $secureDomain = null, HTTPRequ * * @param HTTPRequest $request */ - public static function forceWWW(HTTPRequest $request = null) + public static function forceWWW(?HTTPRequest $request = null) { $handler = CanonicalURLMiddleware::singleton()->setForceWWW(true); $handler->throwRedirectIfNeeded($request); @@ -1018,7 +1018,7 @@ public static function forceWWW(HTTPRequest $request = null) * @param HTTPRequest $request * @return bool */ - public static function is_ajax(HTTPRequest $request = null) + public static function is_ajax(?HTTPRequest $request = null) { $request = Director::currentRequest($request); if ($request) { @@ -1063,7 +1063,7 @@ public static function get_environment_type() * * @return string|null null if not overridden, otherwise the actual value */ - public static function get_session_environment_type(HTTPRequest $request = null) + public static function get_session_environment_type(?HTTPRequest $request = null) { $request = static::currentRequest($request); @@ -1139,7 +1139,7 @@ public static function get_template_global_variables() * @param HTTPRequest $request * @return HTTPRequest Request object if one is both current and valid */ - protected static function currentRequest(HTTPRequest $request = null) + protected static function currentRequest(?HTTPRequest $request = null) { // Ensure we only use a registered HTTPRequest and don't // incidentally construct a singleton diff --git a/src/Control/Email/Email.php b/src/Control/Email/Email.php index 8ee6040583e..ea8901fe34c 100644 --- a/src/Control/Email/Email.php +++ b/src/Control/Email/Email.php @@ -228,7 +228,7 @@ private function getDefaultFrom(): string|array /** * Passing a string of HTML for $body will have no affect if you also call either setData() or addData() */ - public function setBody(AbstractPart|string $body = null): static + public function setBody(AbstractPart|string|null $body = null): static { if ($body instanceof AbstractPart) { // pass to Symfony\Component\Mime\Message::setBody() @@ -326,7 +326,7 @@ public function addAttachment(string $path, ?string $alias = null, ?string $mime return $this->attachFromPath($path, $alias, $mime); } - public function addAttachmentFromData(string $data, string $name, string $mime = null): static + public function addAttachmentFromData(string $data, string $name, ?string $mime = null): static { return $this->attach($data, $name, $mime); } diff --git a/src/Control/Middleware/CanonicalURLMiddleware.php b/src/Control/Middleware/CanonicalURLMiddleware.php index a6582514216..a3b536c1717 100644 --- a/src/Control/Middleware/CanonicalURLMiddleware.php +++ b/src/Control/Middleware/CanonicalURLMiddleware.php @@ -310,7 +310,7 @@ protected function getRedirect(HTTPRequest $request) * @param HTTPRequest|null $request Allow HTTPRequest to be used for the base comparison * @throws HTTPResponse_Exception */ - public function throwRedirectIfNeeded(HTTPRequest $request = null) + public function throwRedirectIfNeeded(?HTTPRequest $request = null) { $request = $this->getOrValidateRequest($request); if (!$request) { @@ -328,7 +328,7 @@ public function throwRedirectIfNeeded(HTTPRequest $request = null) * @param HTTPRequest $request * @return HTTPRequest|null */ - protected function getOrValidateRequest(HTTPRequest $request = null) + protected function getOrValidateRequest(?HTTPRequest $request = null) { if ($request instanceof HTTPRequest) { return $request; @@ -526,7 +526,7 @@ protected function isEnabled() * @param HTTPResponse $response * @return bool */ - protected function hasBasicAuthPrompt(HTTPResponse $response = null) + protected function hasBasicAuthPrompt(?HTTPResponse $response = null) { if (!$response) { return false; diff --git a/src/Control/Middleware/RequestHandlerMiddlewareAdapter.php b/src/Control/Middleware/RequestHandlerMiddlewareAdapter.php index 561199fb619..cbfee9d2f9a 100644 --- a/src/Control/Middleware/RequestHandlerMiddlewareAdapter.php +++ b/src/Control/Middleware/RequestHandlerMiddlewareAdapter.php @@ -18,7 +18,7 @@ class RequestHandlerMiddlewareAdapter extends RequestHandler */ protected $requestHandler = null; - public function __construct(RequestHandler $handler = null) + public function __construct(?RequestHandler $handler = null) { if ($handler) { $this->setRequestHandler($handler); diff --git a/src/Control/PjaxResponseNegotiator.php b/src/Control/PjaxResponseNegotiator.php index 70d3b76570b..71d765ecd64 100644 --- a/src/Control/PjaxResponseNegotiator.php +++ b/src/Control/PjaxResponseNegotiator.php @@ -41,7 +41,7 @@ class PjaxResponseNegotiator * @param array $callbacks * @param HTTPResponse $response An existing response to reuse (optional) */ - public function __construct($callbacks = [], HTTPResponse $response = null) + public function __construct($callbacks = [], ?HTTPResponse $response = null) { $this->callbacks = $callbacks; $this->response = $response ?: HTTPResponse::create(); diff --git a/src/Control/Session.php b/src/Control/Session.php index 51194b3783a..59ac008c099 100644 --- a/src/Control/Session.php +++ b/src/Control/Session.php @@ -404,7 +404,7 @@ private function isCookieSecure(string $sameSite, bool $isHttps): bool * @param bool $removeCookie * @param HTTPRequest $request The request for which to destroy a session */ - public function destroy($removeCookie = true, HTTPRequest $request = null) + public function destroy($removeCookie = true, ?HTTPRequest $request = null) { if (session_id()) { if ($removeCookie) { diff --git a/src/Core/Cache/AbstractCacheFactory.php b/src/Core/Cache/AbstractCacheFactory.php index 3a9251c7348..32a3262ae29 100644 --- a/src/Core/Cache/AbstractCacheFactory.php +++ b/src/Core/Cache/AbstractCacheFactory.php @@ -20,7 +20,7 @@ abstract class AbstractCacheFactory implements CacheFactory /** * @param LoggerInterface $logger Logger instance to assign */ - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger; } diff --git a/src/Core/Cache/DefaultCacheFactory.php b/src/Core/Cache/DefaultCacheFactory.php index 5dc712ef18c..7be196a1d78 100644 --- a/src/Core/Cache/DefaultCacheFactory.php +++ b/src/Core/Cache/DefaultCacheFactory.php @@ -25,7 +25,7 @@ class DefaultCacheFactory extends AbstractCacheFactory * @param array $args List of global options to merge with args during create() * @param LoggerInterface $logger Logger instance to assign */ - public function __construct($args = [], LoggerInterface $logger = null) + public function __construct($args = [], ?LoggerInterface $logger = null) { $this->args = $args; parent::__construct($logger); diff --git a/src/Core/Cache/ManifestCacheFactory.php b/src/Core/Cache/ManifestCacheFactory.php index 8c0b9b688f1..1f979fce488 100644 --- a/src/Core/Cache/ManifestCacheFactory.php +++ b/src/Core/Cache/ManifestCacheFactory.php @@ -17,7 +17,7 @@ */ class ManifestCacheFactory extends DefaultCacheFactory { - public function __construct(array $args = [], LoggerInterface $logger = null) + public function __construct(array $args = [], ?LoggerInterface $logger = null) { // Build default manifest logger if (!$logger) { diff --git a/src/Core/Config/CoreConfigFactory.php b/src/Core/Config/CoreConfigFactory.php index c607a10e636..3d76c300b1a 100644 --- a/src/Core/Config/CoreConfigFactory.php +++ b/src/Core/Config/CoreConfigFactory.php @@ -33,7 +33,7 @@ class CoreConfigFactory * * @param CacheFactory $cacheFactory */ - public function __construct(CacheFactory $cacheFactory = null) + public function __construct(?CacheFactory $cacheFactory = null) { $this->cacheFactory = $cacheFactory; } diff --git a/src/Core/Manifest/ClassManifest.php b/src/Core/Manifest/ClassManifest.php index 9b8b32b3618..a6192116672 100644 --- a/src/Core/Manifest/ClassManifest.php +++ b/src/Core/Manifest/ClassManifest.php @@ -198,7 +198,7 @@ class ClassManifest * @param string $base The manifest base path. * @param CacheFactory $cacheFactory Optional cache to use. Set to null to not cache. */ - public function __construct($base, CacheFactory $cacheFactory = null) + public function __construct($base, ?CacheFactory $cacheFactory = null) { $this->base = $base; $this->cacheFactory = $cacheFactory; diff --git a/src/Core/Manifest/ModuleManifest.php b/src/Core/Manifest/ModuleManifest.php index bb8f29a50bd..6e0681f425f 100644 --- a/src/Core/Manifest/ModuleManifest.php +++ b/src/Core/Manifest/ModuleManifest.php @@ -73,7 +73,7 @@ class ModuleManifest * @param string $base The project base path. * @param CacheFactory $cacheFactory Cache factory to use */ - public function __construct($base, CacheFactory $cacheFactory = null) + public function __construct($base, ?CacheFactory $cacheFactory = null) { $this->base = $base; $this->cacheKey = sha1($base ?? '') . '_modules'; diff --git a/src/Core/Validation/FieldValidation/DecimalFieldValidator.php b/src/Core/Validation/FieldValidation/DecimalFieldValidator.php index 17888f4d942..2d13f12f060 100644 --- a/src/Core/Validation/FieldValidation/DecimalFieldValidator.php +++ b/src/Core/Validation/FieldValidation/DecimalFieldValidator.php @@ -40,8 +40,8 @@ public function __construct( mixed $value, int $wholeSize, int $decimalSize, - int $minValue = null, - int $maxValue = null, + ?int $minValue = null, + ?int $maxValue = null, ) { parent::__construct($name, $value, $minValue, $maxValue); $this->wholeSize = $wholeSize; diff --git a/src/Dev/Debug.php b/src/Dev/Debug.php index 5701577f08f..d1db47671dc 100644 --- a/src/Dev/Debug.php +++ b/src/Dev/Debug.php @@ -38,7 +38,7 @@ class Debug * @param bool $showHeader * @param HTTPRequest|null $request */ - public static function show($val, $showHeader = true, HTTPRequest $request = null) + public static function show($val, $showHeader = true, ?HTTPRequest $request = null) { // Don't show on live if (Director::isLive()) { @@ -80,7 +80,7 @@ public static function caller() * @param bool $showHeader * @param HTTPRequest $request */ - public static function endshow($val, $showHeader = true, HTTPRequest $request = null) + public static function endshow($val, $showHeader = true, ?HTTPRequest $request = null) { // Don't show on live if (Director::isLive()) { @@ -100,7 +100,7 @@ public static function endshow($val, $showHeader = true, HTTPRequest $request = * @param mixed $val * @param HTTPRequest $request Current request to influence output format */ - public static function dump($val, HTTPRequest $request = null) + public static function dump($val, ?HTTPRequest $request = null) { echo Debug::create_debug_view($request) ->renderVariable($val, Debug::caller()); @@ -113,7 +113,7 @@ public static function dump($val, HTTPRequest $request = null) * @param HTTPRequest $request * @return string */ - public static function text($val, HTTPRequest $request = null) + public static function text($val, ?HTTPRequest $request = null) { return static::create_debug_view($request) ->debugVariableText($val); @@ -127,7 +127,7 @@ public static function text($val, HTTPRequest $request = null) * @param bool $showHeader * @param HTTPRequest|null $request */ - public static function message($message, $showHeader = true, HTTPRequest $request = null) + public static function message($message, $showHeader = true, ?HTTPRequest $request = null) { // Don't show on live if (Director::isLive()) { @@ -144,7 +144,7 @@ public static function message($message, $showHeader = true, HTTPRequest $reques * @param HTTPRequest $request Optional request to target this view for * @return DebugView */ - public static function create_debug_view(HTTPRequest $request = null) + public static function create_debug_view(?HTTPRequest $request = null) { $service = static::supportsHTML($request) ? DebugView::class @@ -158,7 +158,7 @@ public static function create_debug_view(HTTPRequest $request = null) * @param HTTPRequest $request * @return bool */ - protected static function supportsHTML(HTTPRequest $request = null) + protected static function supportsHTML(?HTTPRequest $request = null) { // No HTML output in CLI if (Director::is_cli()) { diff --git a/src/Dev/FunctionalTest.php b/src/Dev/FunctionalTest.php index d36bf833153..0c252f49875 100644 --- a/src/Dev/FunctionalTest.php +++ b/src/Dev/FunctionalTest.php @@ -191,7 +191,7 @@ public function post($url, $data, $headers = null, $session = null, $body = null * @param array $data Map of GET/POST data. * @param bool $withSecurityToken Submit with the form's security token if there is one. */ - public function submitForm(string $formID, string $button = null, array $data = [], bool $withSecurityToken = true): HTTPResponse + public function submitForm(string $formID, ?string $button = null, array $data = [], bool $withSecurityToken = true): HTTPResponse { $this->cssParser = null; $response = $this->mainSession->submitForm($formID, $button, $data, $withSecurityToken); diff --git a/src/Dev/TestMailer.php b/src/Dev/TestMailer.php index 7bfe228acc1..4fc7ad1b627 100644 --- a/src/Dev/TestMailer.php +++ b/src/Dev/TestMailer.php @@ -33,7 +33,7 @@ public function __construct( $this->dispatcher = $dispatcher; } - public function send(RawMessage $message, Envelope $envelope = null): void + public function send(RawMessage $message, ?Envelope $envelope = null): void { if (!is_a($message, Email::class)) { throw new InvalidArgumentException('$message must be a ' . Email::class); @@ -122,7 +122,7 @@ private function convertAddressesToString(array $addresses): string return implode(',', array_map(fn(Address $address) => $address->getAddress(), $addresses)); } - private function dispatchEvent(Email $email, Envelope $envelope = null): void + private function dispatchEvent(Email $email, ?Envelope $envelope = null): void { $sender = $email->getSender()[0] ?? $email->getFrom()[0] ?? new Address('test.sender@example.com'); $recipients = empty($email->getTo()) ? [new Address('test.recipient@example.com')] : $email->getTo(); diff --git a/src/Dev/TestSession.php b/src/Dev/TestSession.php index ae61630e4ba..215af9adc8d 100644 --- a/src/Dev/TestSession.php +++ b/src/Dev/TestSession.php @@ -207,7 +207,7 @@ public function sendRequest($method, $url, $data, $headers = null, $session = nu * @param array $data Map of GET/POST data. * @param bool $withSecurityToken Submit with the form's security token if there is one. */ - public function submitForm(string $formID, string $button = null, array $data = [], bool $withSecurityToken = true): HTTPResponse + public function submitForm(string $formID, ?string $button = null, array $data = [], bool $withSecurityToken = true): HTTPResponse { $page = $this->lastPage(); if ($page) { diff --git a/src/Forms/DefaultFormFactory.php b/src/Forms/DefaultFormFactory.php index 8b737d0481e..733f8cc085f 100644 --- a/src/Forms/DefaultFormFactory.php +++ b/src/Forms/DefaultFormFactory.php @@ -33,7 +33,7 @@ public function __construct() * @return Form * @throws InvalidArgumentException When required context is missing */ - 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) { @@ -64,7 +64,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 = []) { // Fall back to standard "getCMSFields" which itself uses the FormScaffolder as a fallback $fields = $context['Record']->getCMSFields(); @@ -80,7 +80,7 @@ protected function getFormFields(RequestHandler $controller = null, $name, $cont * @param array $context * @return FieldList */ - protected function getFormActions(RequestHandler $controller = null, $name, $context = []) + protected function getFormActions(?RequestHandler $controller = null, $name, $context = []) { $actions = $context['Record']->getCMSActions(); $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context); @@ -93,7 +93,7 @@ protected function getFormActions(RequestHandler $controller = null, $name, $con * @param array $context * @return null|Validator */ - protected function getFormValidator(RequestHandler $controller = null, $name, $context = []) + protected function getFormValidator(?RequestHandler $controller = null, $name, $context = []) { if (!$context['Record'] instanceof DataObject) { return null; diff --git a/src/Forms/Form.php b/src/Forms/Form.php index a0483b68cc6..5d25b4f543f 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -277,11 +277,11 @@ class Form extends ModelData implements HasRequestHandler * @param Validator|null $validator Override the default validator instance (Default: {@link RequiredFields}) */ public function __construct( - RequestHandler $controller = null, + ?RequestHandler $controller = null, $name = Form::DEFAULT_NAME, - FieldList $fields = null, - FieldList $actions = null, - Validator $validator = null + ?FieldList $fields = null, + ?FieldList $actions = null, + ?Validator $validator = null ) { parent::__construct(); @@ -1130,7 +1130,7 @@ public function getController() * @param RequestHandler $controller * @return $this */ - public function setController(RequestHandler $controller = null) + public function setController(?RequestHandler $controller = null) { $this->controller = $controller; return $this; diff --git a/src/Forms/FormFactory.php b/src/Forms/FormFactory.php index b900fbcd2fd..d953608bb13 100644 --- a/src/Forms/FormFactory.php +++ b/src/Forms/FormFactory.php @@ -25,7 +25,7 @@ interface 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 = []); /** * Return list of mandatory context keys diff --git a/src/Forms/GridField/GridField.php b/src/Forms/GridField/GridField.php index a00aab521cf..6cd206d68c9 100644 --- a/src/Forms/GridField/GridField.php +++ b/src/Forms/GridField/GridField.php @@ -165,7 +165,7 @@ class GridField extends FormField * @param SS_List $dataList * @param GridFieldConfig $config */ - public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null) + public function __construct($name, $title = null, ?SS_List $dataList = null, ?GridFieldConfig $config = null) { parent::__construct($name, $title, null); diff --git a/src/Forms/HTMLEditor/HTMLEditorConfig.php b/src/Forms/HTMLEditor/HTMLEditorConfig.php index 6c685bf29c5..b35d7d4b165 100644 --- a/src/Forms/HTMLEditor/HTMLEditorConfig.php +++ b/src/Forms/HTMLEditor/HTMLEditorConfig.php @@ -95,7 +95,7 @@ public static function get($identifier = null) * @param HTMLEditorConfig $config Config to set, or null to clear * @return HTMLEditorConfig The assigned config */ - public static function set_config($identifier, HTMLEditorConfig $config = null) + public static function set_config($identifier, ?HTMLEditorConfig $config = null) { if ($config) { HTMLEditorConfig::$configs[$identifier] = $config; diff --git a/src/Forms/Schema/FormSchema.php b/src/Forms/Schema/FormSchema.php index e5cfc639a79..e0fa090afd2 100644 --- a/src/Forms/Schema/FormSchema.php +++ b/src/Forms/Schema/FormSchema.php @@ -50,7 +50,7 @@ class FormSchema * @param ValidationResult $result Required for 'error' response * @return array */ - public function getMultipartSchema($schemaParts, $schemaID, Form $form = null, ValidationResult $result = null) + public function getMultipartSchema($schemaParts, $schemaID, ?Form $form = null, ?ValidationResult $result = null) { if (!is_array($schemaParts)) { $schemaParts = preg_split('#\s*,\s*#', $schemaParts ?? '') ?: []; diff --git a/src/PolyExecution/AnsiToHtmlConverter.php b/src/PolyExecution/AnsiToHtmlConverter.php index 9d3bbb35a50..a821231b6cd 100644 --- a/src/PolyExecution/AnsiToHtmlConverter.php +++ b/src/PolyExecution/AnsiToHtmlConverter.php @@ -13,7 +13,7 @@ class AnsiToHtmlConverter extends BaseAnsiConverter { use Injectable; - public function __construct(Theme $theme = null, $inlineStyles = true, $charset = 'UTF-8') + public function __construct(?Theme $theme = null, $inlineStyles = true, $charset = 'UTF-8') { $theme ??= AnsiToHtmlTheme::create(); parent::__construct($theme, $inlineStyles, $charset); diff --git a/src/Security/Authenticator.php b/src/Security/Authenticator.php index 3a8925975e4..72350f421ca 100644 --- a/src/Security/Authenticator.php +++ b/src/Security/Authenticator.php @@ -110,7 +110,7 @@ public function getLostPasswordHandler($link); * @param ValidationResult $result A validationresult which is either valid or contains the error message(s) * @return Member The matched member, or null if the authentication fails */ - public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null); + public function authenticate(array $data, HTTPRequest $request, ?ValidationResult &$result = null); /** * Check if the passed password matches the stored one (if the member is not locked out). @@ -123,5 +123,5 @@ public function authenticate(array $data, HTTPRequest $request, ValidationResult * @param ValidationResult $result * @return ValidationResult */ - public function checkPassword(Member $member, $password, ValidationResult &$result = null); + public function checkPassword(Member $member, $password, ?ValidationResult &$result = null); } diff --git a/src/Security/BasicAuth.php b/src/Security/BasicAuth.php index d99d7802d90..ad13d131652 100644 --- a/src/Security/BasicAuth.php +++ b/src/Security/BasicAuth.php @@ -207,7 +207,7 @@ public static function protect_entire_site($protect = true, $code = BasicAuth::A * @param HTTPRequest|null $request * @throws HTTPResponse_Exception */ - public static function protect_site_if_necessary(HTTPRequest $request = null) + public static function protect_site_if_necessary(?HTTPRequest $request = null) { $config = static::config(); diff --git a/src/Security/DefaultPermissionChecker.php b/src/Security/DefaultPermissionChecker.php index 0982846432b..6d3ed3a4d46 100644 --- a/src/Security/DefaultPermissionChecker.php +++ b/src/Security/DefaultPermissionChecker.php @@ -16,7 +16,7 @@ interface DefaultPermissionChecker * @param Member $member * @return bool */ - public function canEdit(Member $member = null); + public function canEdit(?Member $member = null); /** * Can root be viewed? @@ -24,7 +24,7 @@ public function canEdit(Member $member = null); * @param Member $member * @return bool */ - public function canView(Member $member = null); + public function canView(?Member $member = null); /** * Can root be deleted? @@ -32,7 +32,7 @@ public function canView(Member $member = null); * @param Member $member * @return bool */ - public function canDelete(Member $member = null); + public function canDelete(?Member $member = null); /** * Can root objects be created? @@ -40,5 +40,5 @@ public function canDelete(Member $member = null); * @param Member $member * @return bool */ - public function canCreate(Member $member = null); + public function canCreate(?Member $member = null); } diff --git a/src/Security/IdentityStore.php b/src/Security/IdentityStore.php index 6a07f1653bc..4f25955575d 100644 --- a/src/Security/IdentityStore.php +++ b/src/Security/IdentityStore.php @@ -19,12 +19,12 @@ interface IdentityStore * @param Boolean $persistent boolean If set to true, the login may persist beyond the current session. * @param HTTPRequest $request The request of the visitor that is logging in, to get, for example, cookies. */ - public function logIn(Member $member, $persistent = false, HTTPRequest $request = null); + public function logIn(Member $member, $persistent = false, ?HTTPRequest $request = null); /** * Log any logged-in member out of this identity store. * * @param HTTPRequest $request The request of the visitor that is logging out, to get, for example, cookies. */ - public function logOut(HTTPRequest $request = null); + public function logOut(?HTTPRequest $request = null); } diff --git a/src/Security/InheritedPermissions.php b/src/Security/InheritedPermissions.php index 65b66044819..9b06cce28dd 100644 --- a/src/Security/InheritedPermissions.php +++ b/src/Security/InheritedPermissions.php @@ -103,7 +103,7 @@ class InheritedPermissions implements PermissionChecker, MemberCacheFlusher * @param string $baseClass Base class * @param CacheInterface $cache */ - public function __construct($baseClass, CacheInterface $cache = null) + public function __construct($baseClass, ?CacheInterface $cache = null) { if (!is_a($baseClass, DataObject::class, true)) { throw new InvalidArgumentException('Invalid DataObject class: ' . $baseClass); @@ -249,7 +249,7 @@ public function prePopulatePermissionCache($permission = 'edit', $ids = []) protected function batchPermissionCheck( $type, $ids, - Member $member = null, + ?Member $member = null, $globalPermission = [], $useCached = true ) { @@ -353,7 +353,7 @@ protected function batchPermissionCheckForStage( $globalPermission, DataList $stageRecords, $groupIDsSQLList, - Member $member = null + ?Member $member = null ) { // Initialise all IDs to false $result = array_fill_keys($stageRecords->column('ID') ?? [], false); @@ -453,7 +453,7 @@ protected function batchPermissionCheckForStage( * @param bool $useCached * @return array */ - public function canEditMultiple($ids, Member $member = null, $useCached = true) + public function canEditMultiple($ids, ?Member $member = null, $useCached = true) { return $this->batchPermissionCheck( InheritedPermissions::EDIT, @@ -470,7 +470,7 @@ public function canEditMultiple($ids, Member $member = null, $useCached = true) * @param bool $useCached * @return array */ - public function canViewMultiple($ids, Member $member = null, $useCached = true) + public function canViewMultiple($ids, ?Member $member = null, $useCached = true) { return $this->batchPermissionCheck(InheritedPermissions::VIEW, $ids, $member, [], $useCached); } @@ -481,7 +481,7 @@ public function canViewMultiple($ids, Member $member = null, $useCached = true) * @param bool $useCached * @return array */ - public function canDeleteMultiple($ids, Member $member = null, $useCached = true) + public function canDeleteMultiple($ids, ?Member $member = null, $useCached = true) { // Validate ids $ids = array_filter($ids ?? [], 'is_numeric'); @@ -555,7 +555,7 @@ public function canDeleteMultiple($ids, Member $member = null, $useCached = true * @param Member|null $member * @return bool|mixed */ - public function canDelete($id, Member $member = null) + public function canDelete($id, ?Member $member = null) { // No ID: Check default permission if (!$id) { @@ -577,7 +577,7 @@ public function canDelete($id, Member $member = null) * @param Member|null $member * @return bool|mixed */ - public function canEdit($id, Member $member = null) + public function canEdit($id, ?Member $member = null) { // No ID: Check default permission if (!$id) { @@ -599,7 +599,7 @@ public function canEdit($id, Member $member = null) * @param Member|null $member * @return bool|mixed */ - public function canView($id, Member $member = null) + public function canView($id, ?Member $member = null) { // No ID: Check default permission if (!$id) { @@ -700,7 +700,7 @@ protected function getMemberJoinTable($type) * @param Member $member * @return bool */ - protected function checkDefaultPermissions($type, Member $member = null) + protected function checkDefaultPermissions($type, ?Member $member = null) { $defaultPermissions = $this->getDefaultPermissions(); if (!$defaultPermissions) { diff --git a/src/Security/LogoutForm.php b/src/Security/LogoutForm.php index 03ad3a05965..5b12c2c3563 100644 --- a/src/Security/LogoutForm.php +++ b/src/Security/LogoutForm.php @@ -22,11 +22,11 @@ class LogoutForm extends Form * {@inheritdoc} */ public function __construct( - RequestHandler $controller = null, + ?RequestHandler $controller = null, $name = LogoutForm::DEFAULT_NAME, - FieldList $fields = null, - FieldList $actions = null, - Validator $validator = null + ?FieldList $fields = null, + ?FieldList $actions = null, + ?Validator $validator = null ) { $this->setController($controller); diff --git a/src/Security/Member.php b/src/Security/Member.php index 4f139a9b8d0..1e025d5a159 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -317,7 +317,7 @@ public function canLogin() * @param ValidationResult $result Optional result to add errors to * @return ValidationResult */ - public function validateCanLogin(ValidationResult &$result = null) + public function validateCanLogin(?ValidationResult &$result = null) { $result = $result ?: ValidationResult::create(); if ($this->isLockedOut()) { @@ -495,7 +495,7 @@ public function regenerateTempID() * * @param HTTPRequest|null $request */ - public function beforeMemberLoggedOut(HTTPRequest $request = null) + public function beforeMemberLoggedOut(?HTTPRequest $request = null) { $this->extend('onBeforeMemberLoggedOut', $request); } @@ -505,7 +505,7 @@ public function beforeMemberLoggedOut(HTTPRequest $request = null) * * @param HTTPRequest|null $request */ - public function afterMemberLoggedOut(HTTPRequest $request = null) + public function afterMemberLoggedOut(?HTTPRequest $request = null) { $this->extend('onAfterMemberLoggedOut', $request); } diff --git a/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php b/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php index bdc93e422ad..d4f487d06cb 100644 --- a/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php +++ b/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php @@ -23,7 +23,7 @@ public function supportedServices() * @param Member|null $member * @return Member */ - protected function authenticateMember($data, ValidationResult &$result = null, Member $member = null) + protected function authenticateMember($data, ?ValidationResult &$result = null, ?Member $member = null) { // Attempt to identify by temporary ID if (!empty($data['tempid'])) { diff --git a/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php b/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php index 2ac9ddd9fdc..8f71d503d45 100644 --- a/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php +++ b/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php @@ -203,7 +203,7 @@ public function authenticateRequest(HTTPRequest $request) * @param bool $persistent * @param HTTPRequest $request */ - public function logIn(Member $member, $persistent = false, HTTPRequest $request = null) + public function logIn(Member $member, $persistent = false, ?HTTPRequest $request = null) { // Cleans up any potential previous hash for this member on this device if ($alcDevice = Cookie::get($this->getDeviceCookieName())) { @@ -243,7 +243,7 @@ public function logIn(Member $member, $persistent = false, HTTPRequest $request /** * @param HTTPRequest $request */ - public function logOut(HTTPRequest $request = null) + public function logOut(?HTTPRequest $request = null) { $member = Security::getCurrentUser(); if ($member) { diff --git a/src/Security/MemberAuthenticator/LoginHandler.php b/src/Security/MemberAuthenticator/LoginHandler.php index d7604da9c0b..0e574ff5781 100644 --- a/src/Security/MemberAuthenticator/LoginHandler.php +++ b/src/Security/MemberAuthenticator/LoginHandler.php @@ -217,7 +217,7 @@ protected function redirectAfterSuccessfulLogin() * @return Member Returns the member object on successful authentication * or NULL on failure. */ - public function checkLogin($data, HTTPRequest $request, ValidationResult &$result = null) + public function checkLogin($data, HTTPRequest $request, ?ValidationResult &$result = null) { $member = $this->authenticator->authenticate($data, $request, $result); if ($member instanceof Member) { diff --git a/src/Security/MemberAuthenticator/MemberAuthenticator.php b/src/Security/MemberAuthenticator/MemberAuthenticator.php index b8aeee7c468..7e5ad05c9e7 100644 --- a/src/Security/MemberAuthenticator/MemberAuthenticator.php +++ b/src/Security/MemberAuthenticator/MemberAuthenticator.php @@ -31,7 +31,7 @@ public function supportedServices() | Authenticator::RESET_PASSWORD | Authenticator::CHECK_PASSWORD; } - public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null) + public function authenticate(array $data, HTTPRequest $request, ?ValidationResult &$result = null) { // Find authenticated member if (class_exists(Versioned::class)) { @@ -62,7 +62,7 @@ public function authenticate(array $data, HTTPRequest $request, ValidationResult * @param Member $member This third parameter is used in the CMSAuthenticator(s) * @return Member Found member, regardless of successful login */ - protected function authenticateMember($data, ValidationResult &$result = null, Member $member = null) + protected function authenticateMember($data, ?ValidationResult &$result = null, ?Member $member = null) { $email = !empty($data['Email']) ? $data['Email'] : null; $result = $result ?: ValidationResult::create(); @@ -135,7 +135,7 @@ protected function authenticateMember($data, ValidationResult &$result = null, M * @param ValidationResult $result * @return ValidationResult */ - public function checkPassword(Member $member, $password, ValidationResult &$result = null) + public function checkPassword(Member $member, $password, ?ValidationResult &$result = null) { // Check if allowed to login $result = $member->validateCanLogin($result); diff --git a/src/Security/MemberAuthenticator/SessionAuthenticationHandler.php b/src/Security/MemberAuthenticator/SessionAuthenticationHandler.php index 252bb749315..8d8e5ff69af 100644 --- a/src/Security/MemberAuthenticator/SessionAuthenticationHandler.php +++ b/src/Security/MemberAuthenticator/SessionAuthenticationHandler.php @@ -71,7 +71,7 @@ public function authenticateRequest(HTTPRequest $request) * @param bool $persistent * @param HTTPRequest $request */ - public function logIn(Member $member, $persistent = false, HTTPRequest $request = null) + public function logIn(Member $member, $persistent = false, ?HTTPRequest $request = null) { static::regenerateSessionId(); $request = $request ?: Controller::curr()->getRequest(); @@ -116,7 +116,7 @@ protected static function regenerateSessionId() /** * @param HTTPRequest $request */ - public function logOut(HTTPRequest $request = null) + public function logOut(?HTTPRequest $request = null) { $request = $request ?: Controller::curr()->getRequest(); $request->getSession()->destroy(true, $request); diff --git a/src/Security/PermissionChecker.php b/src/Security/PermissionChecker.php index 0c1e0b99944..16be55d37c5 100644 --- a/src/Security/PermissionChecker.php +++ b/src/Security/PermissionChecker.php @@ -17,7 +17,7 @@ interface PermissionChecker * @return array A map where the IDs are keys and the values are * booleans stating whether the given object can be edited */ - public function canEditMultiple($ids, Member $member = null, $useCached = true); + public function canEditMultiple($ids, ?Member $member = null, $useCached = true); /** * Get the canView information for a number of objects @@ -27,7 +27,7 @@ public function canEditMultiple($ids, Member $member = null, $useCached = true); * @param bool $useCached * @return mixed */ - public function canViewMultiple($ids, Member $member = null, $useCached = true); + public function canViewMultiple($ids, ?Member $member = null, $useCached = true); /** * Get the 'can edit' information for a number of SiteTree pages. @@ -37,7 +37,7 @@ public function canViewMultiple($ids, Member $member = null, $useCached = true); * @param bool $useCached Return values from the permission cache if they exist * @return array */ - public function canDeleteMultiple($ids, Member $member = null, $useCached = true); + public function canDeleteMultiple($ids, ?Member $member = null, $useCached = true); /** * Check delete permission for a single record ID @@ -46,7 +46,7 @@ public function canDeleteMultiple($ids, Member $member = null, $useCached = true * @param Member $member * @return bool */ - public function canDelete($id, Member $member = null); + public function canDelete($id, ?Member $member = null); /** * Check edit permission for a single record ID @@ -55,7 +55,7 @@ public function canDelete($id, Member $member = null); * @param Member $member * @return bool */ - public function canEdit($id, Member $member = null); + public function canEdit($id, ?Member $member = null); /** * Check view permission for a single record ID @@ -64,5 +64,5 @@ public function canEdit($id, Member $member = null); * @param Member $member * @return bool */ - public function canView($id, Member $member = null); + public function canView($id, ?Member $member = null); } diff --git a/src/Security/RequestAuthenticationHandler.php b/src/Security/RequestAuthenticationHandler.php index 20db10a4db1..a2a49494112 100644 --- a/src/Security/RequestAuthenticationHandler.php +++ b/src/Security/RequestAuthenticationHandler.php @@ -54,7 +54,7 @@ public function authenticateRequest(HTTPRequest $request) * @param bool $persistent * @param HTTPRequest $request */ - public function logIn(Member $member, $persistent = false, HTTPRequest $request = null) + public function logIn(Member $member, $persistent = false, ?HTTPRequest $request = null) { $member->beforeMemberLoggedIn(); @@ -71,7 +71,7 @@ public function logIn(Member $member, $persistent = false, HTTPRequest $request * * @param HTTPRequest $request */ - public function logOut(HTTPRequest $request = null) + public function logOut(?HTTPRequest $request = null) { $member = Security::getCurrentUser(); if ($member) { diff --git a/src/View/ThemeManifest.php b/src/View/ThemeManifest.php index 402ac4aa6b5..9b2303c7487 100644 --- a/src/View/ThemeManifest.php +++ b/src/View/ThemeManifest.php @@ -63,7 +63,7 @@ class ThemeManifest implements ThemeList * @param string $project Path to application code * @param CacheFactory $cacheFactory Cache factory to generate backend cache with */ - public function __construct($base, $project = null, CacheFactory $cacheFactory = null) + public function __construct($base, $project = null, ?CacheFactory $cacheFactory = null) { $this->base = $base; $this->project = $project; diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index 28a7448a3fa..ce64e3039a4 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -926,7 +926,7 @@ public function collectFromTemplate($content, $fileName, Module $module, &$parse * @param Module $module * @return array */ - public function collectFromEntityProviders($filePath, Module $module = null) + public function collectFromEntityProviders($filePath, ?Module $module = null) { $entities = []; $classes = ClassInfo::classes_for_file($filePath); diff --git a/tests/php/Control/HttpRequestMockBuilder.php b/tests/php/Control/HttpRequestMockBuilder.php index ef06255e580..37f40db5809 100644 --- a/tests/php/Control/HttpRequestMockBuilder.php +++ b/tests/php/Control/HttpRequestMockBuilder.php @@ -18,7 +18,7 @@ trait HttpRequestMockBuilder * * @return HTTPRequest */ - public function buildRequestMock($url, $getVars = [], $postVars = [], $method = null, Session $session = null) + public function buildRequestMock($url, $getVars = [], $postVars = [], $method = null, ?Session $session = null) { if (is_null($session)) { $session = new Session([]); diff --git a/tests/php/Forms/FormFactoryTest/EditFormFactory.php b/tests/php/Forms/FormFactoryTest/EditFormFactory.php index 6ada58c98fd..9bf2c8ddb2a 100644 --- a/tests/php/Forms/FormFactoryTest/EditFormFactory.php +++ b/tests/php/Forms/FormFactoryTest/EditFormFactory.php @@ -18,7 +18,7 @@ class EditFormFactory extends DefaultFormFactory ControllerExtension::class ]; - protected function getFormFields(RequestHandler $controller = null, $name, $context = []) + protected function getFormFields(?RequestHandler $controller = null, $name, $context = []) { $fields = new FieldList( new HiddenField('ID'), @@ -28,7 +28,7 @@ protected function getFormFields(RequestHandler $controller = null, $name, $cont return $fields; } - protected function getFormActions(RequestHandler $controller = null, $name, $context = []) + protected function getFormActions(?RequestHandler $controller = null, $name, $context = []) { $actions = new FieldList( new FormAction('save', 'Save') diff --git a/tests/php/Security/InheritedPermissionsTest/TestDefaultPermissionChecker.php b/tests/php/Security/InheritedPermissionsTest/TestDefaultPermissionChecker.php index c82407c1133..2b07f3ada6f 100644 --- a/tests/php/Security/InheritedPermissionsTest/TestDefaultPermissionChecker.php +++ b/tests/php/Security/InheritedPermissionsTest/TestDefaultPermissionChecker.php @@ -17,7 +17,7 @@ class TestDefaultPermissionChecker implements DefaultPermissionChecker * @param Member $member * @return bool */ - public function canEdit(Member $member = null) + public function canEdit(?Member $member = null) { return $this->canEdit; } @@ -28,7 +28,7 @@ public function canEdit(Member $member = null) * @param Member $member * @return bool */ - public function canView(Member $member = null) + public function canView(?Member $member = null) { return $this->canView; } @@ -39,7 +39,7 @@ public function canView(Member $member = null) * @param Member $member * @return bool */ - public function canDelete(Member $member = null) + public function canDelete(?Member $member = null) { return $this->canEdit; } @@ -50,7 +50,7 @@ public function canDelete(Member $member = null) * @param Member $member * @return bool */ - public function canCreate(Member $member = null) + public function canCreate(?Member $member = null) { return $this->canEdit; }