diff --git a/src/Control/Director.php b/src/Control/Director.php index 119d4e746d0..966dea3c33b 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -486,7 +486,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')) { @@ -528,7 +528,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; @@ -540,7 +540,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; @@ -553,7 +553,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); } @@ -564,7 +564,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://'; } @@ -575,7 +575,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')) { @@ -900,7 +900,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 = ''; @@ -960,7 +960,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) { @@ -977,7 +977,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); @@ -993,7 +993,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) { @@ -1038,7 +1038,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); @@ -1114,7 +1114,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 52b05dc944f..0f3e967a729 100644 --- a/src/Control/Email/Email.php +++ b/src/Control/Email/Email.php @@ -226,7 +226,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() @@ -324,7 +324,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 66e2a2afe60..449da1b0007 100644 --- a/src/Control/Middleware/CanonicalURLMiddleware.php +++ b/src/Control/Middleware/CanonicalURLMiddleware.php @@ -308,7 +308,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) { @@ -326,7 +326,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; @@ -524,7 +524,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/BaseKernel.php b/src/Core/BaseKernel.php index a1dbc503ba5..16885a50182 100644 --- a/src/Core/BaseKernel.php +++ b/src/Core/BaseKernel.php @@ -2,6 +2,7 @@ namespace SilverStripe\Core; +use Exception; use InvalidArgumentException; use Monolog\Handler\StreamHandler; use Monolog\Logger; @@ -21,13 +22,12 @@ use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Core\Manifest\ModuleManifest; use SilverStripe\Dev\DebugView; +use SilverStripe\Dev\Deprecation; use SilverStripe\Logging\ErrorHandler; use SilverStripe\View\PublicThemes; use SilverStripe\View\SSViewer; use SilverStripe\View\ThemeManifest; use SilverStripe\View\ThemeResourceLoader; -use Exception; -use SilverStripe\Dev\Deprecation; /** * Simple Kernel container @@ -142,10 +142,10 @@ protected function bootPHP() { if ($this->getEnvironment() === BaseKernel::LIVE) { // limited to fatal errors and warnings in live mode - error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT | E_NOTICE)); + error_reporting(E_ALL & ~(E_DEPRECATED | E_NOTICE)); } else { // Report all errors in dev / test mode - error_reporting(E_ALL | E_STRICT); + error_reporting(E_ALL); } /** diff --git a/src/Core/Cache/DefaultCacheFactory.php b/src/Core/Cache/DefaultCacheFactory.php index b82d6f08a2b..77acafe61bb 100644 --- a/src/Core/Cache/DefaultCacheFactory.php +++ b/src/Core/Cache/DefaultCacheFactory.php @@ -39,7 +39,7 @@ class DefaultCacheFactory implements CacheFactory * @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; $this->logger = $logger; diff --git a/src/Core/Cache/ManifestCacheFactory.php b/src/Core/Cache/ManifestCacheFactory.php index 52d3b294fe2..9481a1c8251 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/Cache/MemcachedCacheFactory.php b/src/Core/Cache/MemcachedCacheFactory.php index 1752baf5ba9..a511ce6f208 100644 --- a/src/Core/Cache/MemcachedCacheFactory.php +++ b/src/Core/Cache/MemcachedCacheFactory.php @@ -18,7 +18,7 @@ class MemcachedCacheFactory implements CacheFactory /** * @param Memcached $memcachedClient */ - public function __construct(Memcached $memcachedClient = null) + public function __construct(?Memcached $memcachedClient = null) { $this->memcachedClient = $memcachedClient; } 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 0e2887635ab..b1385729067 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/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/DebugView.php b/src/Dev/DebugView.php index c1953031abb..65f5f91cd64 100644 --- a/src/Dev/DebugView.php +++ b/src/Dev/DebugView.php @@ -102,10 +102,6 @@ class DebugView 'title' => 'User Warning', 'class' => 'warning' ], - E_STRICT => [ - 'title' => 'Strict Notice', - 'class' => 'notice' - ], E_RECOVERABLE_ERROR => [ 'title' => 'Recoverable Error', 'class' => 'warning' diff --git a/src/Dev/FunctionalTest.php b/src/Dev/FunctionalTest.php index 3adadde3dc4..1b37946dbf3 100644 --- a/src/Dev/FunctionalTest.php +++ b/src/Dev/FunctionalTest.php @@ -193,7 +193,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 2c1ff07a659..d67c124d4ec 100644 --- a/src/Dev/TestSession.php +++ b/src/Dev/TestSession.php @@ -206,7 +206,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 69151c12145..91a23da0400 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -277,11 +277,11 @@ class Form extends ViewableData 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 d6039fe4c93..dfd857ce5d2 100644 --- a/src/Forms/GridField/GridField.php +++ b/src/Forms/GridField/GridField.php @@ -157,7 +157,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 a8b712a14e7..04fa74b0f98 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/ORM/DataExtension.php b/src/ORM/DataExtension.php index 1644ee1b7ef..ecf5c0f717a 100644 --- a/src/ORM/DataExtension.php +++ b/src/ORM/DataExtension.php @@ -48,7 +48,7 @@ public function validate(ValidationResult $validationResult) * @param SQLSelect $query Query to augment. * @param DataQuery $dataQuery Container DataQuery for this SQLSelect */ - public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) + public function augmentSQL(SQLSelect $query, ?DataQuery $dataQuery = null) { } diff --git a/src/Security/Authenticator.php b/src/Security/Authenticator.php index 856f65654e2..87ffc1924d0 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 a3c3dc0d7f4..e419423e13b 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -310,7 +310,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()) { @@ -379,7 +379,7 @@ public function isLockedOut() * * @param PasswordValidator $validator */ - public static function set_password_validator(PasswordValidator $validator = null) + public static function set_password_validator(?PasswordValidator $validator = null) { // Override existing config Config::modify()->remove(Injector::class, PasswordValidator::class); @@ -493,7 +493,7 @@ public function regenerateTempID() * * @param HTTPRequest|null $request */ - public function beforeMemberLoggedOut(HTTPRequest $request = null) + public function beforeMemberLoggedOut(?HTTPRequest $request = null) { $this->extend('beforeMemberLoggedOut', $request); } @@ -503,7 +503,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('afterMemberLoggedOut', $request); } diff --git a/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php b/src/Security/MemberAuthenticator/CMSMemberAuthenticator.php index 467823b4d1b..a60a3d31c32 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 db672e11c46..69921db9f41 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 29ed27a17e8..531a164b639 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/SSViewer.php b/src/View/SSViewer.php index 92d28f8843f..915fcc94aa3 100644 --- a/src/View/SSViewer.php +++ b/src/View/SSViewer.php @@ -190,7 +190,7 @@ class SSViewer implements Flushable * * @param TemplateParser $parser */ - public function __construct($templates, TemplateParser $parser = null) + public function __construct($templates, ?TemplateParser $parser = null) { if ($parser) { Deprecation::noticeWithNoReplacment('5.4.0', 'The $parser parameter is deprecated and will be removed'); diff --git a/src/View/SSViewer_DataPresenter.php b/src/View/SSViewer_DataPresenter.php index e09fe83f146..7f9ca631b48 100644 --- a/src/View/SSViewer_DataPresenter.php +++ b/src/View/SSViewer_DataPresenter.php @@ -62,9 +62,9 @@ class SSViewer_DataPresenter extends SSViewer_Scope */ public function __construct( $item, - array $overlay = null, - array $underlay = null, - SSViewer_Scope $inheritedScope = null + ?array $overlay = null, + ?array $underlay = null, + ?SSViewer_Scope $inheritedScope = null ) { Deprecation::noticeWithNoReplacment('5.4.0', 'Will be merged into ' . SSViewer_Scope::class, Deprecation::SCOPE_CLASS); parent::__construct($item, $inheritedScope); diff --git a/src/View/SSViewer_FromString.php b/src/View/SSViewer_FromString.php index 23b808179e6..fcf9b450320 100644 --- a/src/View/SSViewer_FromString.php +++ b/src/View/SSViewer_FromString.php @@ -37,7 +37,7 @@ class SSViewer_FromString extends SSViewer * @param string $content * @param TemplateParser $parser */ - public function __construct($content, TemplateParser $parser = null) + public function __construct($content, ?TemplateParser $parser = null) { Deprecation::noticeWithNoReplacment( '5.4.0', diff --git a/src/View/SSViewer_Scope.php b/src/View/SSViewer_Scope.php index f6f46b4cb54..8862b1ecf05 100644 --- a/src/View/SSViewer_Scope.php +++ b/src/View/SSViewer_Scope.php @@ -114,7 +114,7 @@ class SSViewer_Scope * @var object $item * @var SSViewer_Scope $inheritedScope */ - public function __construct($item, SSViewer_Scope $inheritedScope = null) + public function __construct($item, ?SSViewer_Scope $inheritedScope = null) { Deprecation::noticeWithNoReplacment( '5.4.0', 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 7bc44598b56..3384990de34 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -927,7 +927,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 ffbd2cbfcfe..5c3e0e72d35 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; }