From 85c4b8279ee54cbd289632ede503a726d2c8a7ba Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 25 Oct 2024 18:20:41 +0100 Subject: [PATCH] fixes for PHP 8.4 - Implicitly nullable parameter declarations deprecated --- composer.json | 3 +- composer.lock | 63 ++++++++++++++++++- system/src/Grav/Common/Backup/Backups.php | 2 +- system/src/Grav/Common/Cache.php | 4 +- system/src/Grav/Common/Data/Data.php | 2 +- system/src/Grav/Common/Data/DataInterface.php | 2 +- system/src/Grav/Common/Data/Validation.php | 2 +- system/src/Grav/Common/Debugger.php | 6 +- .../src/Grav/Common/Filesystem/Archiver.php | 6 +- .../Grav/Common/Filesystem/ZipArchiver.php | 6 +- system/src/Grav/Common/Flex/FlexObject.php | 2 +- .../Flex/Types/Pages/PageCollection.php | 4 +- .../Common/Flex/Types/Pages/PageIndex.php | 12 ++-- .../Common/Flex/Types/Pages/PageObject.php | 4 +- .../Types/Pages/Traits/PageRoutableTrait.php | 2 +- .../Types/UserGroups/UserGroupCollection.php | 2 +- .../Flex/Types/UserGroups/UserGroupObject.php | 2 +- .../Types/Users/Storage/UserFileStorage.php | 2 +- .../Common/Flex/Types/Users/UserObject.php | 4 +- system/src/Grav/Common/Grav.php | 6 +- system/src/Grav/Common/HTTP/Client.php | 2 +- system/src/Grav/Common/HTTP/Response.php | 4 +- system/src/Grav/Common/Helpers/Excerpts.php | 10 +-- system/src/Grav/Common/Helpers/YamlLinter.php | 2 +- system/src/Grav/Common/Iterator.php | 4 +- system/src/Grav/Common/Language/Language.php | 6 +- .../Interfaces/MediaCollectionInterface.php | 2 +- .../Media/Interfaces/MediaUploadInterface.php | 8 +-- .../Common/Media/Traits/MediaUploadTrait.php | 10 +-- system/src/Grav/Common/Page/Collection.php | 2 +- .../Page/Interfaces/PageRoutableInterface.php | 2 +- .../Page/Interfaces/PagesSourceInterface.php | 2 +- .../Grav/Common/Page/Markdown/Excerpts.php | 2 +- system/src/Grav/Common/Page/Media.php | 2 +- .../Grav/Common/Page/Medium/AbstractMedia.php | 2 +- .../Grav/Common/Page/Medium/ImageMedium.php | 2 +- system/src/Grav/Common/Page/Medium/Medium.php | 2 +- .../Grav/Common/Page/Medium/MediumFactory.php | 2 +- .../Common/Page/Medium/VectorImageMedium.php | 2 +- system/src/Grav/Common/Page/Page.php | 2 +- system/src/Grav/Common/Page/Pages.php | 8 +-- system/src/Grav/Common/Plugin.php | 4 +- .../Common/Processors/InitializeProcessor.php | 2 +- system/src/Grav/Common/Scheduler/Job.php | 4 +- .../src/Grav/Common/Scheduler/Scheduler.php | 2 +- system/src/Grav/Common/Security.php | 8 +-- .../Common/Twig/Extension/GravExtension.php | 2 +- .../Grav/Common/Twig/Node/TwigNodeSwitch.php | 2 +- .../Common/Twig/Node/TwigNodeTryCatch.php | 2 +- .../User/Interfaces/AuthorizeInterface.php | 2 +- .../src/Grav/Common/User/Traits/UserTrait.php | 2 +- system/src/Grav/Common/Utils.php | 6 +- .../Console/Application/PluginApplication.php | 2 +- .../src/Grav/Console/Cli/InstallCommand.php | 2 +- system/src/Grav/Console/ConsoleTrait.php | 2 +- .../src/Grav/Console/Gpm/InstallCommand.php | 2 +- system/src/Grav/Framework/Acl/Access.php | 6 +- system/src/Grav/Framework/Acl/Permissions.php | 2 +- .../Collection/AbstractIndexCollection.php | 4 +- .../Framework/Collection/FileCollection.php | 4 +- .../Relationships/RelationshipInterface.php | 4 +- .../ToManyRelationshipInterface.php | 4 +- .../ToOneRelationshipInterface.php | 6 +- .../Traits/ControllerResponseTrait.php | 8 +-- .../src/Grav/Framework/File/AbstractFile.php | 2 +- .../File/Formatter/AbstractFormatter.php | 2 +- .../File/Formatter/MarkdownFormatter.php | 2 +- .../Grav/Framework/Filesystem/Filesystem.php | 6 +- system/src/Grav/Framework/Flex/Flex.php | 10 +-- .../Grav/Framework/Flex/FlexCollection.php | 16 ++--- .../src/Grav/Framework/Flex/FlexDirectory.php | 30 ++++----- .../Grav/Framework/Flex/FlexDirectoryForm.php | 4 +- system/src/Grav/Framework/Flex/FlexForm.php | 4 +- system/src/Grav/Framework/Flex/FlexIndex.php | 22 +++---- system/src/Grav/Framework/Flex/FlexObject.php | 28 ++++----- .../Interfaces/FlexAuthorizeInterface.php | 2 +- .../Interfaces/FlexCollectionInterface.php | 8 +-- .../Interfaces/FlexDirectoryInterface.php | 24 +++---- .../Flex/Interfaces/FlexIndexInterface.php | 4 +- .../Flex/Interfaces/FlexInterface.php | 6 +- .../Flex/Interfaces/FlexObjectInterface.php | 10 +-- .../Flex/Interfaces/FlexStorageInterface.php | 6 +- .../Interfaces/FlexTranslateInterface.php | 4 +- .../Framework/Flex/Pages/FlexPageObject.php | 4 +- .../Flex/Pages/Traits/PageAuthorsTrait.php | 2 +- .../Flex/Pages/Traits/PageLegacyTrait.php | 2 +- .../Flex/Pages/Traits/PageRoutableTrait.php | 2 +- .../Flex/Pages/Traits/PageTranslateTrait.php | 8 +-- .../Framework/Flex/Storage/FileStorage.php | 2 +- .../Framework/Flex/Storage/FolderStorage.php | 6 +- .../Framework/Flex/Storage/SimpleStorage.php | 6 +- .../Flex/Traits/FlexAuthorizeTrait.php | 2 +- .../Framework/Flex/Traits/FlexMediaTrait.php | 6 +- system/src/Grav/Framework/Form/FormFlash.php | 14 ++--- .../Form/Interfaces/FormFlashInterface.php | 6 +- .../Form/Interfaces/FormInterface.php | 2 +- .../Grav/Framework/Form/Traits/FormTrait.php | 6 +- .../Framework/Interfaces/RenderInterface.php | 2 +- .../Collection/ObjectExpressionVisitor.php | 2 +- .../Pagination/AbstractPagination.php | 20 +++--- .../Interfaces/PaginationInterface.php | 10 +-- .../Grav/Framework/Pagination/Pagination.php | 2 +- system/src/Grav/Framework/Psr7/Response.php | 4 +- system/src/Grav/Framework/Psr7/Uri.php | 2 +- .../Relationships/ToManyRelationship.php | 8 +-- .../Relationships/ToOneRelationship.php | 12 ++-- .../Exception/InvalidArgumentException.php | 2 +- .../Exception/NotFoundException.php | 2 +- .../Exception/PageExpiredException.php | 2 +- .../Exception/RequestException.php | 2 +- .../RequestHandler/RequestHandler.php | 2 +- system/src/Grav/Framework/Route/Route.php | 2 +- .../src/Grav/Framework/Session/Messages.php | 6 +- system/src/Grav/Framework/Session/Session.php | 2 +- system/src/Grav/Framework/Uri/Uri.php | 2 +- system/src/Grav/Installer/VersionUpdater.php | 6 +- system/src/Grav/Installer/Versions.php | 2 +- 117 files changed, 353 insertions(+), 293 deletions(-) diff --git a/composer.json b/composer.json index c9ffb8912..fd41e78d5 100644 --- a/composer.json +++ b/composer.json @@ -72,7 +72,8 @@ "phpunit/php-code-coverage": "~9.2", "getgrav/markdowndocs": "^2.0", "codeception/module-asserts": "*", - "codeception/module-phpbrowser": "*" + "codeception/module-phpbrowser": "*", + "rector/rector": "^1.2" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index a56f75a3c..47593206c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "55a4b92c7d97394ff5d898440f4e11f4", + "content-hash": "93cb46c384939d2a4edb42a301745aeb", "packages": [ { "name": "antoligy/dom-string-iterators", @@ -6077,6 +6077,65 @@ }, "time": "2024-06-10T01:18:23+00:00" }, + { + "name": "rector/rector", + "version": "1.2.8", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "05755bf43617449c08ee8e50fb840c85ad3b1240" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/05755bf43617449c08ee8e50fb840c85ad3b1240", + "reference": "05755bf43617449c08ee8e50fb840c85ad3b1240", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.12.5" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/1.2.8" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-10-18T11:54:27+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -7373,7 +7432,7 @@ "ext-libxml": "*", "ext-gd": "*" }, - "platform-dev": {}, + "platform-dev": [], "platform-overrides": { "php": "8.2" }, diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php index dd2cf379c..d9a1531a6 100644 --- a/system/src/Grav/Common/Backup/Backups.php +++ b/system/src/Grav/Common/Backup/Backups.php @@ -194,7 +194,7 @@ class Backups * @param callable|null $status * @return string|null */ - public static function backup($id = 0, callable $status = null) + public static function backup($id = 0, ?callable $status = null) { $grav = Grav::instance(); diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 1af5d4c0b..4d70089ca 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -241,7 +241,7 @@ class Cache extends Getters * @throws \RedisException * @throws \Symfony\Component\Cache\Exception\CacheException */ - public function getCacheAdapter(string $namespace = null, int $defaultLifetime = null): AdapterInterface + public function getCacheAdapter(?string $namespace = null, ?int $defaultLifetime = null): AdapterInterface { $setting = $this->driver_setting ?? 'auto'; $driver_name = 'file'; @@ -333,7 +333,7 @@ class Cache extends Getters * * @return CacheProvider The cache driver to use */ - public function getCacheDriver(AdapterInterface $adapter = null) + public function getCacheDriver(?AdapterInterface $adapter = null) { if (null === $adapter) { $adapter = $this->getCacheAdapter(); diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php index 95944b2fa..0900a7430 100644 --- a/system/src/Grav/Common/Data/Data.php +++ b/system/src/Grav/Common/Data/Data.php @@ -323,7 +323,7 @@ class Data implements DataInterface, ArrayAccess, \Countable, JsonSerializable, * @param FileInterface|null $storage Optionally enter a new storage. * @return FileInterface|null */ - public function file(FileInterface $storage = null) + public function file(?FileInterface $storage = null) { if ($storage) { $this->storage = $storage; diff --git a/system/src/Grav/Common/Data/DataInterface.php b/system/src/Grav/Common/Data/DataInterface.php index 52469b18f..a34fe69ad 100644 --- a/system/src/Grav/Common/Data/DataInterface.php +++ b/system/src/Grav/Common/Data/DataInterface.php @@ -80,5 +80,5 @@ interface DataInterface * @param FileInterface|null $storage Optionally enter a new storage. * @return FileInterface */ - public function file(FileInterface $storage = null); + public function file(?FileInterface $storage = null); } diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index d0f5bff8a..1b799ad87 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -162,7 +162,7 @@ class Validation * @param UserInterface|null $user * @return bool */ - public static function authorize($action, UserInterface $user = null) + public static function authorize($action, ?UserInterface $user = null) { if (!$user) { return false; diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php index 6d412c36c..c732cbeaf 100644 --- a/system/src/Grav/Common/Debugger.php +++ b/system/src/Grav/Common/Debugger.php @@ -544,7 +544,7 @@ class Debugger * @param string|null $message * @return mixed */ - public function profile(callable $callable, string $message = null) + public function profile(callable $callable, ?string $message = null) { $this->startProfiling(); $response = $callable(); @@ -585,7 +585,7 @@ class Debugger * @param string|null $message * @return array|null */ - public function stopProfiling(string $message = null): ?array + public function stopProfiling(?string $message = null): ?array { $timings = null; if ($this->enabled && extension_loaded('tideways_xhprof')) { @@ -776,7 +776,7 @@ class Debugger * @param float|null $time * @return $this */ - public function addEvent(string $name, $event, EventDispatcherInterface $dispatcher, float $time = null) + public function addEvent(string $name, $event, EventDispatcherInterface $dispatcher, ?float $time = null) { if ($this->enabled && $this->clockwork) { $time = $time ?? microtime(true); diff --git a/system/src/Grav/Common/Filesystem/Archiver.php b/system/src/Grav/Common/Filesystem/Archiver.php index bf07791d4..a69b12ab3 100644 --- a/system/src/Grav/Common/Filesystem/Archiver.php +++ b/system/src/Grav/Common/Filesystem/Archiver.php @@ -75,21 +75,21 @@ abstract class Archiver * @param callable|null $status * @return $this */ - abstract public function compress($folder, callable $status = null); + abstract public function compress($folder, ?callable $status = null); /** * @param string $destination * @param callable|null $status * @return $this */ - abstract public function extract($destination, callable $status = null); + abstract public function extract($destination, ?callable $status = null); /** * @param array $folders * @param callable|null $status * @return $this */ - abstract public function addEmptyFolders($folders, callable $status = null); + abstract public function addEmptyFolders($folders, ?callable $status = null); /** * @param string $rootPath diff --git a/system/src/Grav/Common/Filesystem/ZipArchiver.php b/system/src/Grav/Common/Filesystem/ZipArchiver.php index 8e61a5d4f..82b5a769c 100644 --- a/system/src/Grav/Common/Filesystem/ZipArchiver.php +++ b/system/src/Grav/Common/Filesystem/ZipArchiver.php @@ -26,7 +26,7 @@ class ZipArchiver extends Archiver * @param callable|null $status * @return $this */ - public function extract($destination, callable $status = null) + public function extract($destination, ?callable $status = null) { $zip = new ZipArchive(); $archive = $zip->open($this->archive_file); @@ -51,7 +51,7 @@ class ZipArchiver extends Archiver * @param callable|null $status * @return $this */ - public function compress($source, callable $status = null) + public function compress($source, ?callable $status = null) { if (!extension_loaded('zip')) { throw new InvalidArgumentException('ZipArchiver: Zip PHP module not installed...'); @@ -105,7 +105,7 @@ class ZipArchiver extends Archiver * @param callable|null $status * @return $this */ - public function addEmptyFolders($folders, callable $status = null) + public function addEmptyFolders($folders, ?callable $status = null) { if (!extension_loaded('zip')) { throw new InvalidArgumentException('ZipArchiver: Zip PHP module not installed...'); diff --git a/system/src/Grav/Common/Flex/FlexObject.php b/system/src/Grav/Common/Flex/FlexObject.php index 870bc05fc..3ec49efa7 100644 --- a/system/src/Grav/Common/Flex/FlexObject.php +++ b/system/src/Grav/Common/Flex/FlexObject.php @@ -32,7 +32,7 @@ abstract class FlexObject extends \Grav\Framework\Flex\FlexObject implements Med * {@inheritdoc} * @see FlexObjectInterface::getFormValue() */ - public function getFormValue(string $name, $default = null, string $separator = null) + public function getFormValue(string $name, $default = null, ?string $separator = null) { $value = $this->getNestedProperty($name, null, $separator); diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php index bf1e2d55b..a061f86ef 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php @@ -766,7 +766,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa * @return static * @phpstan-return static */ - public function withTranslation(bool $bool = true, string $languageCode = null, bool $fallback = null) + public function withTranslation(bool $bool = true, ?string $languageCode = null, ?bool $fallback = null) { $list = array_keys(array_filter($this->call('hasTranslation', [$languageCode, $fallback]))); @@ -778,7 +778,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa * @param bool|null $fallback * @return PageIndex */ - public function withTranslated(string $languageCode = null, bool $fallback = null) + public function withTranslated(?string $languageCode = null, ?bool $fallback = null) { return $this->getIndex()->withTranslated($languageCode, $fallback); } diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php index f0b45e159..82e8501ea 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php @@ -66,7 +66,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @param array $entries * @param FlexDirectory|null $directory */ - public function __construct(array $entries = [], FlexDirectory $directory = null) + public function __construct(array $entries = [], ?FlexDirectory $directory = null) { // Remove root if it's taken. if (isset($entries[''])) { @@ -181,7 +181,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @return static * @phpstan-return static */ - public function withTranslated(string $languageCode = null, bool $fallback = null) + public function withTranslated(?string $languageCode = null, ?bool $fallback = null) { if (null === $languageCode) { return $this; @@ -413,7 +413,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @return static * @phpstan-return static */ - protected function createFrom(array $entries, string $keyField = null) + protected function createFrom(array $entries, ?string $keyField = null) { /** @var static $index */ $index = parent::createFrom($entries, $keyField); @@ -428,7 +428,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @param bool|null $fallback * @return array */ - protected function translateEntries(array $entries, string $lang, bool $fallback = null): array + protected function translateEntries(array $entries, string $lang, ?bool $fallback = null): array { $languages = $this->getFallbackLanguages($lang, $fallback); foreach ($entries as $key => &$entry) { @@ -493,7 +493,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @param bool|null $fallback * @return array */ - protected function getFallbackLanguages(string $languageCode = null, bool $fallback = null): array + protected function getFallbackLanguages(?string $languageCode = null, ?bool $fallback = null): array { $fallback = $fallback ?? true; if (!$fallback && null !== $languageCode) { @@ -781,7 +781,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface * @param int|null $timestamp * @return string|null */ - private function jsDate(int $timestamp = null): ?string + private function jsDate(?int $timestamp = null): ?string { if (!$timestamp) { return null; diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php index 9f71df72e..2af4ee7c8 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php @@ -129,7 +129,7 @@ class PageObject extends FlexPageObject /** * @inheritdoc PageInterface */ - public function getFormValue(string $name, $default = null, string $separator = null) + public function getFormValue(string $name, $default = null, ?string $separator = null) { $test = new stdClass(); @@ -261,7 +261,7 @@ class PageObject extends FlexPageObject /** * @param UserInterface|null $user */ - public function check(UserInterface $user = null): void + public function check(?UserInterface $user = null): void { parent::check($user); diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php index 2cfe45020..8aeeed136 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php +++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php @@ -32,7 +32,7 @@ trait PageRoutableTrait * @return PageInterface|null the parent page object if it exists. */ - public function parent(PageInterface $var = null) + public function parent(?PageInterface $var = null) { if (Utils::isAdminPlugin()) { return parent::parent(); diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php index daaa94236..f2c8591b0 100644 --- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php +++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php @@ -38,7 +38,7 @@ class UserGroupCollection extends FlexCollection * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool + public function authorize(string $action, ?string $scope = null): ?bool { $authorized = null; /** @var UserGroupObject $object */ diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php index c8da8a2a1..9e753d21b 100644 --- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php +++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php @@ -57,7 +57,7 @@ class UserGroupObject extends FlexObject implements UserGroupInterface * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool + public function authorize(string $action, ?string $scope = null): ?bool { if ($scope === 'test') { $scope = null; diff --git a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php index 01e3f967a..771210e1b 100644 --- a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php +++ b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php @@ -23,7 +23,7 @@ class UserFileStorage extends FileStorage * {@inheritdoc} * @see FlexStorageInterface::getMediaPath() */ - public function getMediaPath(string $key = null): ?string + public function getMediaPath(?string $key = null): ?string { // There is no media support for file storage (fallback to common location). return null; diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php index c59bfb4ec..1a3eb3fa2 100644 --- a/system/src/Grav/Common/Flex/Types/Users/UserObject.php +++ b/system/src/Grav/Common/Flex/Types/Users/UserObject.php @@ -270,7 +270,7 @@ class UserObject extends FlexObject implements UserInterface, Countable * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool + public function authorize(string $action, ?string $scope = null): ?bool { if ($scope === 'test') { // Special scope to test user permissions. @@ -557,7 +557,7 @@ class UserObject extends FlexObject implements UserInterface, Countable * @param FileInterface|null $storage Optionally enter a new storage. * @return FileInterface|null */ - public function file(FileInterface $storage = null) + public function file(?FileInterface $storage = null) { if (null !== $storage) { $this->_storage = $storage; diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 5f879ca53..f9c9b00fb 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -200,7 +200,7 @@ class Grav extends Container * @param string|null $environment * @return $this */ - public function setup(string $environment = null) + public function setup(?string $environment = null) { if (isset($this->initialized['setup'])) { return $this; @@ -522,7 +522,7 @@ class Grav extends Container * @param ResponseInterface|null $response * @return void */ - public function header(ResponseInterface $response = null): void + public function header(?ResponseInterface $response = null): void { if (null === $response) { /** @var PageInterface $page */ @@ -585,7 +585,7 @@ class Grav extends Container * @param Event|null $event * @return Event */ - public function fireEvent($eventName, Event $event = null) + public function fireEvent($eventName, ?Event $event = null) { /** @var EventDispatcherInterface $events */ $events = $this['events']; diff --git a/system/src/Grav/Common/HTTP/Client.php b/system/src/Grav/Common/HTTP/Client.php index 02a420b84..4c9a79616 100644 --- a/system/src/Grav/Common/HTTP/Client.php +++ b/system/src/Grav/Common/HTTP/Client.php @@ -25,7 +25,7 @@ class Client 'User-Agent' => 'Grav CMS' ]; - public static function getClient(array $overrides = [], int $connections = 6, callable $callback = null): HttpClientInterface + public static function getClient(array $overrides = [], int $connections = 6, ?callable $callback = null): HttpClientInterface { $config = Grav::instance()['config']; $options = static::getOptions(); diff --git a/system/src/Grav/Common/HTTP/Response.php b/system/src/Grav/Common/HTTP/Response.php index f05af0e5e..ca3a6efba 100644 --- a/system/src/Grav/Common/HTTP/Response.php +++ b/system/src/Grav/Common/HTTP/Response.php @@ -41,7 +41,7 @@ class Response * @return string * @throws TransportExceptionInterface|RedirectionExceptionInterface|ServerExceptionInterface|TransportExceptionInterface|ClientExceptionInterface */ - public static function get(string $uri = '', array $overrides = [], callable $callback = null): string + public static function get(string $uri = '', array $overrides = [], ?callable $callback = null): string { $response = static::request('GET', $uri, $overrides, $callback); return $response->getContent(); @@ -58,7 +58,7 @@ class Response * @return ResponseInterface * @throws TransportExceptionInterface */ - public static function request(string $method, string $uri, array $overrides = [], callable $callback = null): ResponseInterface + public static function request(string $method, string $uri, array $overrides = [], ?callable $callback = null): ResponseInterface { if (empty($method)) { throw new TransportException('missing method (GET, PUT, etc.)'); diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php index 254edc497..77726d302 100644 --- a/system/src/Grav/Common/Helpers/Excerpts.php +++ b/system/src/Grav/Common/Helpers/Excerpts.php @@ -30,7 +30,7 @@ class Excerpts * @param PageInterface|null $page Page, defaults to the current page object * @return string Returns final HTML string */ - public static function processImageHtml($html, PageInterface $page = null) + public static function processImageHtml($html, ?PageInterface $page = null) { $excerpt = static::getExcerptFromHtml($html, 'img'); if (null === $excerpt) { @@ -61,7 +61,7 @@ class Excerpts * @param PageInterface|null $page Page, defaults to the current page object * @return string Returns final HTML string */ - public static function processLinkHtml($html, PageInterface $page = null) + public static function processLinkHtml($html, ?PageInterface $page = null) { $excerpt = static::getExcerptFromHtml($html, 'a'); if (null === $excerpt) { @@ -158,7 +158,7 @@ class Excerpts * @param string $type * @return mixed */ - public static function processLinkExcerpt($excerpt, PageInterface $page = null, $type = 'link') + public static function processLinkExcerpt($excerpt, ?PageInterface $page = null, $type = 'link') { $excerpts = new ExcerptsObject($page); @@ -172,7 +172,7 @@ class Excerpts * @param PageInterface|null $page Page, defaults to the current page object * @return array */ - public static function processImageExcerpt(array $excerpt, PageInterface $page = null) + public static function processImageExcerpt(array $excerpt, ?PageInterface $page = null) { $excerpts = new ExcerptsObject($page); @@ -187,7 +187,7 @@ class Excerpts * @param PageInterface|null $page Page, defaults to the current page object * @return Medium|Link */ - public static function processMediaActions($medium, $url, PageInterface $page = null) + public static function processMediaActions($medium, $url, ?PageInterface $page = null) { $excerpts = new ExcerptsObject($page); diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php index 1dee4958a..53fe4f9dc 100644 --- a/system/src/Grav/Common/Helpers/YamlLinter.php +++ b/system/src/Grav/Common/Helpers/YamlLinter.php @@ -29,7 +29,7 @@ class YamlLinter * @param string|null $folder * @return array */ - public static function lint(string $folder = null) + public static function lint(?string $folder = null) { if (null !== $folder) { $folder = $folder ?: GRAV_ROOT; diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php index a60c74fb4..51ed5d185 100644 --- a/system/src/Grav/Common/Iterator.php +++ b/system/src/Grav/Common/Iterator.php @@ -230,7 +230,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable * * @return $this */ - public function filter(callable $callback = null) + public function filter(?callable $callback = null) { foreach ($this->items as $key => $value) { if ((!$callback && !(bool)$value) || ($callback && !$callback($value, $key))) { @@ -250,7 +250,7 @@ class Iterator implements \ArrayAccess, \Iterator, \Countable, \Serializable * @return $this|array * */ - public function sort(callable $callback = null, $desc = false) + public function sort(?callable $callback = null, $desc = false) { if (!$callback || !is_callable($callback)) { return $this; diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index f2f3c1baa..0e6096c69 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -358,7 +358,7 @@ class Language * @param bool $assoc Return values in ['en' => '.en.md', ...] format. * @return array Key is the language code, value is the file extension to be used. */ - public function getFallbackPageExtensions(string $fileExtension = null, string $languageCode = null, bool $assoc = false) + public function getFallbackPageExtensions(?string $fileExtension = null, ?string $languageCode = null, bool $assoc = false) { $fileExtension = $fileExtension ?: CONTENT_EXT; $key = $fileExtension . '-' . ($languageCode ?? 'default') . '-' . (int)$assoc; @@ -411,7 +411,7 @@ class Language * @param bool $includeDefault If true, list contains '', which can be used for default * @return array */ - public function getFallbackLanguages(string $languageCode = null, bool $includeDefault = false) + public function getFallbackLanguages(?string $languageCode = null, bool $includeDefault = false) { // Handle default. if ($languageCode === '' || !$this->enabled()) { @@ -489,7 +489,7 @@ class Language * @param bool $html_out * @return string|string[] */ - public function translate($args, array $languages = null, $array_support = false, $html_out = false) + public function translate($args, ?array $languages = null, $array_support = false, $html_out = false) { if (is_array($args)) { $lookup = array_shift($args); diff --git a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php index a326e12cb..58452f060 100644 --- a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php +++ b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php @@ -105,7 +105,7 @@ interface MediaCollectionInterface extends \Grav\Framework\Media\Interfaces\Medi * @param Blueprint|null $blueprint * @return Medium|null */ - public function createFromArray(array $items = [], Blueprint $blueprint = null); + public function createFromArray(array $items = [], ?Blueprint $blueprint = null); /** * @param MediaObjectInterface $mediaObject diff --git a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php index 7d0d18894..f4a70001a 100644 --- a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php +++ b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php @@ -32,7 +32,7 @@ interface MediaUploadInterface * @return string * @throws RuntimeException */ - public function checkUploadedFile(UploadedFileInterface $uploadedFile, string $filename = null, array $settings = null): string; + public function checkUploadedFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?array $settings = null): string; /** * Copy uploaded file to the media collection. @@ -51,7 +51,7 @@ interface MediaUploadInterface * @return void * @throws RuntimeException */ - public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, array $settings = null): void; + public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, ?array $settings = null): void; /** * Delete real file from the media collection. @@ -60,7 +60,7 @@ interface MediaUploadInterface * @param array|null $settings * @return void */ - public function deleteFile(string $filename, array $settings = null): void; + public function deleteFile(string $filename, ?array $settings = null): void; /** * Rename file inside the media collection. @@ -69,5 +69,5 @@ interface MediaUploadInterface * @param string $to * @param array|null $settings */ - public function renameFile(string $from, string $to, array $settings = null): void; + public function renameFile(string $from, string $to, ?array $settings = null): void; } diff --git a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php index 2b1c3bbee..45d5208af 100644 --- a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php +++ b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php @@ -71,7 +71,7 @@ trait MediaUploadTrait * @return string * @throws RuntimeException */ - public function checkUploadedFile(UploadedFileInterface $uploadedFile, string $filename = null, array $settings = null): string + public function checkUploadedFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?array $settings = null): string { // Check if there is an upload error. switch ($uploadedFile->getError()) { @@ -115,7 +115,7 @@ trait MediaUploadTrait * @return string * @throws RuntimeException */ - public function checkFileMetadata(array $metadata, string $filename = null, array $settings = null): string + public function checkFileMetadata(array $metadata, ?string $filename = null, ?array $settings = null): string { // Add the defaults to the settings. $settings = $this->getUploadSettings($settings); @@ -252,7 +252,7 @@ trait MediaUploadTrait * @return void * @throws RuntimeException */ - public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, array $settings = null): void + public function copyUploadedFile(UploadedFileInterface $uploadedFile, string $filename, ?array $settings = null): void { // Add the defaults to the settings. $settings = $this->getUploadSettings($settings); @@ -329,7 +329,7 @@ trait MediaUploadTrait * @return void * @throws RuntimeException */ - public function deleteFile(string $filename, array $settings = null): void + public function deleteFile(string $filename, ?array $settings = null): void { // Add the defaults to the settings. $settings = $this->getUploadSettings($settings); @@ -371,7 +371,7 @@ trait MediaUploadTrait * @param string $to * @param array|null $settings */ - public function renameFile(string $from, string $to, array $settings = null): void + public function renameFile(string $from, string $to, ?array $settings = null): void { // Add the defaults to the settings. $settings = $this->getUploadSettings($settings); diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 8a625558c..90d3346fd 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -43,7 +43,7 @@ class Collection extends Iterator implements PageCollectionInterface * @param array $params * @param Pages|null $pages */ - public function __construct($items = [], array $params = [], Pages $pages = null) + public function __construct($items = [], array $params = [], ?Pages $pages = null) { parent::__construct($items); diff --git a/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php b/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php index 29002660c..b2f6d409c 100644 --- a/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php +++ b/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php @@ -133,7 +133,7 @@ interface PageRoutableInterface * @param PageInterface|null $var the parent page object * @return PageInterface|null the parent page object if it exists. */ - public function parent(PageInterface $var = null); + public function parent(?PageInterface $var = null); /** * Gets the top parent object for this page. Can return page itself. diff --git a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php index d28f103f9..467d42a14 100644 --- a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php +++ b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php @@ -52,5 +52,5 @@ interface PagesSourceInterface // extends \Iterator * @param array|null $options * @return array */ - public function getChildren(string $route, array $options = null): array; + public function getChildren(string $route, ?array $options = null): array; } diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php index d613c790e..406b4a479 100644 --- a/system/src/Grav/Common/Page/Markdown/Excerpts.php +++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php @@ -42,7 +42,7 @@ class Excerpts * @param PageInterface|null $page * @param array|null $config */ - public function __construct(PageInterface $page = null, array $config = null) + public function __construct(?PageInterface $page = null, ?array $config = null) { $this->page = $page ?? Grav::instance()['page'] ?? null; diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index b29bbf348..6478528e5 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -38,7 +38,7 @@ class Media extends AbstractMedia * @param array|null $media_order * @param bool $load */ - public function __construct($path, array $media_order = null, $load = true) + public function __construct($path, ?array $media_order = null, $load = true) { $this->setPath($path); $this->media_order = $media_order; diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php index 906d0447a..3efe735ac 100644 --- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php +++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php @@ -229,7 +229,7 @@ abstract class AbstractMedia implements ExportInterface, MediaCollectionInterfac * @param Blueprint|null $blueprint * @return Medium|null */ - public function createFromArray(array $items = [], Blueprint $blueprint = null) + public function createFromArray(array $items = [], ?Blueprint $blueprint = null) { return MediumFactory::fromArray($items, $blueprint); } diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 580e9f586..5539d9fb0 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -46,7 +46,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate * @param array $items * @param Blueprint|null $blueprint */ - public function __construct($items = [], Blueprint $blueprint = null) + public function __construct($items = [], ?Blueprint $blueprint = null) { parent::__construct($items, $blueprint); diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index a17f68a66..ede2a7441 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -43,7 +43,7 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface * @param array $items * @param Blueprint|null $blueprint */ - public function __construct($items = [], Blueprint $blueprint = null) + public function __construct($items = [], ?Blueprint $blueprint = null) { parent::__construct($items, $blueprint); diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php index 0796a8395..3f555969c 100644 --- a/system/src/Grav/Common/Page/Medium/MediumFactory.php +++ b/system/src/Grav/Common/Page/Medium/MediumFactory.php @@ -150,7 +150,7 @@ class MediumFactory * @param Blueprint|null $blueprint * @return Medium */ - public static function fromArray(array $items = [], Blueprint $blueprint = null) + public static function fromArray(array $items = [], ?Blueprint $blueprint = null) { $type = $items['type'] ?? null; diff --git a/system/src/Grav/Common/Page/Medium/VectorImageMedium.php b/system/src/Grav/Common/Page/Medium/VectorImageMedium.php index bf0beae4f..0e5aac1a5 100644 --- a/system/src/Grav/Common/Page/Medium/VectorImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/VectorImageMedium.php @@ -24,7 +24,7 @@ class VectorImageMedium extends StaticImageMedium * @param array $items * @param Blueprint|null $blueprint */ - public function __construct($items = [], Blueprint $blueprint = null) + public function __construct($items = [], ?Blueprint $blueprint = null) { parent::__construct($items, $blueprint); diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 90b8c0570..2883b6ff8 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -2395,7 +2395,7 @@ class Page implements PageInterface * @param PageInterface|null $var the parent page object * @return PageInterface|null the parent page object if it exists. */ - public function parent(PageInterface $var = null) + public function parent(?PageInterface $var = null) { if ($var) { $this->parent = $var->path(); diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 49d0f57c7..a0b0506dc 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -645,7 +645,7 @@ class Pages * @param PageInterface|null $self * @return Collection */ - protected function evaluate($value, PageInterface $self = null) + protected function evaluate($value, ?PageInterface $self = null) { // Parse command. if (is_string($value)) { @@ -1160,7 +1160,7 @@ class Pages * @param PageInterface|null $current * @return Collection */ - public function all(PageInterface $current = null) + public function all(?PageInterface $current = null) { $all = new Collection(); @@ -1234,7 +1234,7 @@ class Pages * @param bool $limitLevels * @return array */ - public function getList(PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false) + public function getList(?PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false) { if (!$current) { if ($level) { @@ -1822,7 +1822,7 @@ class Pages * @throws RuntimeException * @internal */ - protected function recurse(string $directory, PageInterface $parent = null) + protected function recurse(string $directory, ?PageInterface $parent = null) { $directory = rtrim($directory, DS); $page = new Page; diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 7b74c8ffd..f6235141d 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -72,7 +72,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess * @param Grav $grav * @param Config|null $config */ - public function __construct($name, Grav $grav, Config $config = null) + public function __construct($name, Grav $grav, ?Config $config = null) { $this->name = $name; $this->grav = $grav; @@ -414,7 +414,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess return true; } - public static function inheritedConfigOption(string $plugin, string $var, PageInterface $page = null, $default = null) + public static function inheritedConfigOption(string $plugin, string $var, ?PageInterface $page = null, $default = null) { if (Utils::isAdminPlugin()) { $page = Grav::instance()['admin']->page() ?? null; diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 2c5035beb..417f6c543 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -415,7 +415,7 @@ class InitializeProcessor extends ProcessorBase $this->stopTimer('_init_uri'); } - protected function handleRedirectRequest(RequestInterface $request, int $code = null): ?ResponseInterface + protected function handleRedirectRequest(RequestInterface $request, ?int $code = null): ?ResponseInterface { if (!in_array($request->getMethod(), ['GET', 'HEAD'])) { return null; diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php index 3b119f434..a5a5e6087 100644 --- a/system/src/Grav/Common/Scheduler/Job.php +++ b/system/src/Grav/Common/Scheduler/Job.php @@ -188,7 +188,7 @@ class Job * @param DateTime|null $date * @return bool */ - public function isDue(DateTime $date = null) + public function isDue(?DateTime $date = null) { // The execution time is being defaulted if not defined if (!$this->executionTime) { @@ -259,7 +259,7 @@ class Job * @param callable|null $whenOverlapping A callback to ignore job overlapping * @return self */ - public function onlyOne($tempDir = null, callable $whenOverlapping = null) + public function onlyOne($tempDir = null, ?callable $whenOverlapping = null) { if ($tempDir === null || !is_dir($tempDir)) { $tempDir = $this->tempDir; diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php index d3cefb0f3..8e0f9e1d6 100644 --- a/system/src/Grav/Common/Scheduler/Scheduler.php +++ b/system/src/Grav/Common/Scheduler/Scheduler.php @@ -188,7 +188,7 @@ class Scheduler * @param DateTime|null $runTime Optional, run at specific moment * @param bool $force force run even if not due */ - public function run(DateTime $runTime = null, $force = false) + public function run(?DateTime $runTime = null, $force = false) { $this->loadSavedJobs(); diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 6fabf4eec..491a61c01 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -30,7 +30,7 @@ class Security * @param array|null $options * @return string|null */ - public static function detectXssFromSvgFile(string $filepath, array $options = null): ?string + public static function detectXssFromSvgFile(string $filepath, ?array $options = null): ?string { if (file_exists($filepath) && Grav::instance()['config']->get('security.sanitize_svg')) { $content = file_get_contents($filepath); @@ -95,7 +95,7 @@ class Security * @param callable|null $status * @return array */ - public static function detectXssFromPages(Pages $pages, $route = true, callable $status = null) + public static function detectXssFromPages(Pages $pages, $route = true, ?callable $status = null) { $routes = $pages->getList(null, 0, true); @@ -145,7 +145,7 @@ class Security * @param string $prefix Prefix for returned values. * @return array Returns flatten list of potentially dangerous input values, such as 'data.content'. */ - public static function detectXssFromArray(array $array, string $prefix = '', array $options = null) + public static function detectXssFromArray(array $array, string $prefix = '', ?array $options = null) { if (null === $options) { $options = static::getXssDefaults(); @@ -176,7 +176,7 @@ class Security * * Copies the code from: https://github.com/symphonycms/xssfilter/blob/master/extension.driver.php#L138 */ - public static function detectXss($string, array $options = null): ?string + public static function detectXss($string, ?array $options = null): ?string { // Skip any null or non string values if (null === $string || !is_string($string) || empty($string)) { diff --git a/system/src/Grav/Common/Twig/Extension/GravExtension.php b/system/src/Grav/Common/Twig/Extension/GravExtension.php index 3e30a0292..8e159ac86 100644 --- a/system/src/Grav/Common/Twig/Extension/GravExtension.php +++ b/system/src/Grav/Common/Twig/Extension/GravExtension.php @@ -932,7 +932,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface * @param bool $html_out * @return string */ - public function translateLanguage($args, array $languages = null, $array_support = false, $html_out = false) + public function translateLanguage($args, ?array $languages = null, $array_support = false, $html_out = false) { /** @var Language $language */ $language = $this->grav['language']; diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php index 8dcc9ddb9..b7de4bbef 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php @@ -26,7 +26,7 @@ class TwigNodeSwitch extends Node * @param int $lineno * @param string|null $tag */ - public function __construct(Node $value, Node $cases, Node $default = null, $lineno = 0, $tag = null) + public function __construct(Node $value, Node $cases, ?Node $default = null, $lineno = 0, $tag = null) { $nodes = ['value' => $value, 'cases' => $cases, 'default' => $default]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php index ddaf49d33..d83786170 100644 --- a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php +++ b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php @@ -26,7 +26,7 @@ class TwigNodeTryCatch extends Node * @param int $lineno * @param string|null $tag */ - public function __construct(Node $try, Node $catch = null, $lineno = 0, $tag = null) + public function __construct(Node $try, ?Node $catch = null, $lineno = 0, $tag = null) { $nodes = ['try' => $try, 'catch' => $catch]; $nodes = array_filter($nodes); diff --git a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php index 104552232..d65c098ce 100644 --- a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php +++ b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php @@ -22,5 +22,5 @@ interface AuthorizeInterface * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool; + public function authorize(string $action, ?string $scope = null): ?bool; } diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php index 8afcac0ac..085de03eb 100644 --- a/system/src/Grav/Common/User/Traits/UserTrait.php +++ b/system/src/Grav/Common/User/Traits/UserTrait.php @@ -76,7 +76,7 @@ trait UserTrait * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool + public function authorize(string $action, ?string $scope = null): ?bool { // User needs to be enabled. if ($this->get('state', 'enabled') !== 'enabled') { diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 582fe5e3d..f106a64e7 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -1005,7 +1005,7 @@ abstract class Utils * @param int|null $flags * @return array|string */ - public static function pathinfo($path, int $flags = null) + public static function pathinfo($path, ?int $flags = null) { $path = str_replace(['%2F', '%5C'], ['/', '\\'], rawurlencode($path)); @@ -1618,7 +1618,7 @@ abstract class Utils * @return string * @throws RuntimeException */ - public static function getPagePathFromToken($path, PageInterface $page = null) + public static function getPagePathFromToken($path, ?PageInterface $page = null) { return static::getPathFromToken($path, $page); } @@ -1947,7 +1947,7 @@ abstract class Utils * @param array|null $defaults * @return array */ - public static function getSupportPageTypes(array $defaults = null) + public static function getSupportPageTypes(?array $defaults = null) { $types = Grav::instance()['config']->get('system.pages.types', $defaults); if (!is_array($types)) { diff --git a/system/src/Grav/Console/Application/PluginApplication.php b/system/src/Grav/Console/Application/PluginApplication.php index e74801877..c671b7b6d 100644 --- a/system/src/Grav/Console/Application/PluginApplication.php +++ b/system/src/Grav/Console/Application/PluginApplication.php @@ -65,7 +65,7 @@ class PluginApplication extends Application * @return int * @throws Throwable */ - public function run(InputInterface $input = null, OutputInterface $output = null): int + public function run(?InputInterface $input = null, ?OutputInterface $output = null): int { if (null === $input) { $argv = $_SERVER['argv'] ?? []; diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php index 51fd16c33..fce40a10e 100644 --- a/system/src/Grav/Console/Cli/InstallCommand.php +++ b/system/src/Grav/Console/Cli/InstallCommand.php @@ -173,7 +173,7 @@ class InstallCommand extends GravCommand * @param string|null $type * @return int */ - private function symlink(string $name = null, string $type = null): int + private function symlink(?string $name = null, ?string $type = null): int { $io = $this->getIO(); diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php index f3728fc38..a514e88a2 100644 --- a/system/src/Grav/Console/ConsoleTrait.php +++ b/system/src/Grav/Console/ConsoleTrait.php @@ -140,7 +140,7 @@ trait ConsoleTrait * @param string|null $code * @return $this */ - final protected function setLanguage(string $code = null) + final protected function setLanguage(?string $code = null) { $this->initializeGrav(); diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index e3bb901f3..adbfea9de 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -573,7 +573,7 @@ class InstallCommand extends GpmCommand * @param string|null $license * @return string|null */ - private function downloadPackage(Package $package, string $license = null) + private function downloadPackage(Package $package, ?string $license = null) { $io = $this->getIO(); diff --git a/system/src/Grav/Framework/Acl/Access.php b/system/src/Grav/Framework/Acl/Access.php index 2355da7cb..408fa046e 100644 --- a/system/src/Grav/Framework/Acl/Access.php +++ b/system/src/Grav/Framework/Acl/Access.php @@ -45,7 +45,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable * @param array|null $rules * @param string $name */ - public function __construct($acl = null, array $rules = null, string $name = '') + public function __construct($acl = null, ?array $rules = null, string $name = '') { $this->name = $name; $this->rules = $rules ?? []; @@ -70,7 +70,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable * @param string|null $name * @return void */ - public function inherit(Access $parent, string $name = null) + public function inherit(Access $parent, ?string $name = null) { // Remove cached null actions from acl. $acl = $this->getAllActions(); @@ -88,7 +88,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable * @param string|null $scope * @return bool|null */ - public function authorize(string $action, string $scope = null): ?bool + public function authorize(string $action, ?string $scope = null): ?bool { if (null !== $scope) { $action = $scope !== 'test' ? "{$scope}.{$action}" : $action; diff --git a/system/src/Grav/Framework/Acl/Permissions.php b/system/src/Grav/Framework/Acl/Permissions.php index a07f7ebbc..63c0141c7 100644 --- a/system/src/Grav/Framework/Acl/Permissions.php +++ b/system/src/Grav/Framework/Acl/Permissions.php @@ -156,7 +156,7 @@ class Permissions implements ArrayAccess, Countable, IteratorAggregate * @param array|null $access * @return Access */ - public function getAccess(array $access = null): Access + public function getAccess(?array $access = null): Access { return new Access($access ?? []); } diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php index 1c2da8cdd..be5d5c5c6 100644 --- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php +++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php @@ -551,14 +551,14 @@ abstract class AbstractIndexCollection implements CollectionInterface * @return array * @phpstan-return array */ - abstract protected function loadElements(array $entries = null): array; + abstract protected function loadElements(?array $entries = null): array; /** * @param array|null $entries * @return CollectionInterface * @phpstan-return C */ - abstract protected function loadCollection(array $entries = null): CollectionInterface; + abstract protected function loadCollection(?array $entries = null): CollectionInterface; /** * @param mixed $value diff --git a/system/src/Grav/Framework/Collection/FileCollection.php b/system/src/Grav/Framework/Collection/FileCollection.php index 8fe254d7c..5ec8fa6c9 100644 --- a/system/src/Grav/Framework/Collection/FileCollection.php +++ b/system/src/Grav/Framework/Collection/FileCollection.php @@ -66,7 +66,7 @@ class FileCollection extends AbstractFileCollection * @param callable|null $filterFunction * @return $this */ - public function setFilter(callable $filterFunction = null) + public function setFilter(?callable $filterFunction = null) { $this->filterFunction = $filterFunction; @@ -88,7 +88,7 @@ class FileCollection extends AbstractFileCollection * @param callable|null $objectFunction * @return $this */ - public function setObjectBuilder(callable $objectFunction = null) + public function setObjectBuilder(?callable $objectFunction = null) { $this->createObjectFunction = $objectFunction ?: [$this, 'createObject']; diff --git a/system/src/Grav/Framework/Contracts/Relationships/RelationshipInterface.php b/system/src/Grav/Framework/Contracts/Relationships/RelationshipInterface.php index c0a7edfe4..3e2445f47 100644 --- a/system/src/Grav/Framework/Contracts/Relationships/RelationshipInterface.php +++ b/system/src/Grav/Framework/Contracts/Relationships/RelationshipInterface.php @@ -53,7 +53,7 @@ interface RelationshipInterface extends Countable, IteratorAggregate, JsonSerial * @return bool * @phpstan-pure */ - public function has(string $id, string $type = null): bool; + public function has(string $id, ?string $type = null): bool; /** * @param T $identifier @@ -72,7 +72,7 @@ interface RelationshipInterface extends Countable, IteratorAggregate, JsonSerial * @param T|null $identifier * @return bool */ - public function removeIdentifier(IdentifierInterface $identifier = null): bool; + public function removeIdentifier(?IdentifierInterface $identifier = null): bool; /** * @return iterable diff --git a/system/src/Grav/Framework/Contracts/Relationships/ToManyRelationshipInterface.php b/system/src/Grav/Framework/Contracts/Relationships/ToManyRelationshipInterface.php index 723bef690..785928c44 100644 --- a/system/src/Grav/Framework/Contracts/Relationships/ToManyRelationshipInterface.php +++ b/system/src/Grav/Framework/Contracts/Relationships/ToManyRelationshipInterface.php @@ -25,7 +25,7 @@ interface ToManyRelationshipInterface extends RelationshipInterface * @return T|null * @phpstan-pure */ - public function getIdentifier(string $id, string $type = null): ?IdentifierInterface; + public function getIdentifier(string $id, ?string $type = null): ?IdentifierInterface; /** * @param string $id @@ -33,7 +33,7 @@ interface ToManyRelationshipInterface extends RelationshipInterface * @return T|null * @phpstan-pure */ - public function getObject(string $id, string $type = null): ?object; + public function getObject(string $id, ?string $type = null): ?object; /** * @param iterable $identifiers diff --git a/system/src/Grav/Framework/Contracts/Relationships/ToOneRelationshipInterface.php b/system/src/Grav/Framework/Contracts/Relationships/ToOneRelationshipInterface.php index 0e6aeb973..94e969c1c 100644 --- a/system/src/Grav/Framework/Contracts/Relationships/ToOneRelationshipInterface.php +++ b/system/src/Grav/Framework/Contracts/Relationships/ToOneRelationshipInterface.php @@ -19,7 +19,7 @@ interface ToOneRelationshipInterface extends RelationshipInterface * @return T|null * @phpstan-pure */ - public function getIdentifier(string $id = null, string $type = null): ?IdentifierInterface; + public function getIdentifier(?string $id = null, ?string $type = null): ?IdentifierInterface; /** * @param string|null $id @@ -27,11 +27,11 @@ interface ToOneRelationshipInterface extends RelationshipInterface * @return T|null * @phpstan-pure */ - public function getObject(string $id = null, string $type = null): ?object; + public function getObject(?string $id = null, ?string $type = null): ?object; /** * @param T|null $identifier * @return bool */ - public function replaceIdentifier(IdentifierInterface $identifier = null): bool; + public function replaceIdentifier(?IdentifierInterface $identifier = null): bool; } diff --git a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php index 084028377..a50c6d18b 100644 --- a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php +++ b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php @@ -49,7 +49,7 @@ trait ControllerResponseTrait * @param array|null $headers * @return Response */ - protected function createHtmlResponse(string $content, int $code = null, array $headers = null): ResponseInterface + protected function createHtmlResponse(string $content, ?int $code = null, ?array $headers = null): ResponseInterface { $code = $code ?? 200; if ($code < 100 || $code > 599) { @@ -66,7 +66,7 @@ trait ControllerResponseTrait * @param array|null $headers * @return Response */ - protected function createJsonResponse(array $content, int $code = null, array $headers = null): ResponseInterface + protected function createJsonResponse(array $content, ?int $code = null, ?array $headers = null): ResponseInterface { $code = $code ?? $content['code'] ?? 200; if (null === $code || $code < 100 || $code > 599) { @@ -87,7 +87,7 @@ trait ControllerResponseTrait * @param array|null $options * @return ResponseInterface */ - protected function createDownloadResponse(string $filename, $resource, array $headers = null, array $options = null): ResponseInterface + protected function createDownloadResponse(string $filename, $resource, ?array $headers = null, ?array $options = null): ResponseInterface { // Required for IE, otherwise Content-Disposition may be ignored if (ini_get('zlib.output_compression')) { @@ -134,7 +134,7 @@ trait ControllerResponseTrait * @param int|null $code * @return Response */ - protected function createRedirectResponse(string $url, int $code = null): ResponseInterface + protected function createRedirectResponse(string $url, ?int $code = null): ResponseInterface { if (null === $code || $code < 301 || $code > 307) { $code = (int)$this->getConfig()->get('system.pages.redirect_default_code', 302); diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php index e81c419ba..f49112b03 100644 --- a/system/src/Grav/Framework/File/AbstractFile.php +++ b/system/src/Grav/Framework/File/AbstractFile.php @@ -46,7 +46,7 @@ class AbstractFile implements FileInterface * @param string $filepath * @param Filesystem|null $filesystem */ - public function __construct(string $filepath, Filesystem $filesystem = null) + public function __construct(string $filepath, ?Filesystem $filesystem = null) { $this->filesystem = $filesystem ?? Filesystem::getInstance(); $this->setFilepath($filepath); diff --git a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php index 4ab0e62ac..83a444dce 100644 --- a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php @@ -106,7 +106,7 @@ abstract class AbstractFormatter implements FileFormatterInterface * @param string|null $name Configuration option (optional) * @return mixed */ - protected function getConfig(string $name = null) + protected function getConfig(?string $name = null) { if (null !== $name) { return $this->config[$name] ?? null; diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php index cf16cf7b3..46976d731 100644 --- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php @@ -23,7 +23,7 @@ class MarkdownFormatter extends AbstractFormatter /** @var FileFormatterInterface */ private $headerFormatter; - public function __construct(array $config = [], FileFormatterInterface $headerFormatter = null) + public function __construct(array $config = [], ?FileFormatterInterface $headerFormatter = null) { $config += [ 'file_extension' => '.md', diff --git a/system/src/Grav/Framework/Filesystem/Filesystem.php b/system/src/Grav/Framework/Filesystem/Filesystem.php index a46ce2a0f..20b42c8d0 100644 --- a/system/src/Grav/Framework/Filesystem/Filesystem.php +++ b/system/src/Grav/Framework/Filesystem/Filesystem.php @@ -40,7 +40,7 @@ class Filesystem implements FilesystemInterface * @param bool|null $normalize See $this->setNormalization() * @return Filesystem */ - public static function getInstance(bool $normalize = null): Filesystem + public static function getInstance(?bool $normalize = null): Filesystem { if ($normalize === true) { $instance = &static::$safe; @@ -63,7 +63,7 @@ class Filesystem implements FilesystemInterface * @param bool|null $normalize * @internal */ - protected function __construct(bool $normalize = null) + protected function __construct(?bool $normalize = null) { $this->normalize = $normalize; } @@ -78,7 +78,7 @@ class Filesystem implements FilesystemInterface * @param bool|null $normalize * @return Filesystem */ - public function setNormalization(bool $normalize = null): self + public function setNormalization(?bool $normalize = null): self { return static::getInstance($normalize); } diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php index c78a42c46..f51a4c84c 100644 --- a/system/src/Grav/Framework/Flex/Flex.php +++ b/system/src/Grav/Framework/Flex/Flex.php @@ -94,7 +94,7 @@ class Flex implements FlexInterface * @param bool $keepMissing * @return array */ - public function getDirectories(array $types = null, bool $keepMissing = false): array + public function getDirectories(?array $types = null, bool $keepMissing = false): array { if ($types === null) { return $this->types; @@ -125,7 +125,7 @@ class Flex implements FlexInterface * @return FlexCollectionInterface|null * @phpstan-return FlexCollectionInterface|null */ - public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface + public function getCollection(string $type, ?array $keys = null, ?string $keyField = null): ?FlexCollectionInterface { $directory = $type ? $this->getDirectory($type) : null; @@ -271,7 +271,7 @@ class Flex implements FlexInterface * @param string|null $keyField * @return FlexObjectInterface|null */ - public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface + public function getObject(string $key, ?string $type = null, ?string $keyField = null): ?FlexObjectInterface { if (null === $type && null === $keyField) { // Special handling for quick Flex key lookups. @@ -303,7 +303,7 @@ class Flex implements FlexInterface * @param string|null $type * @return array */ - protected function resolveKeyAndType(string $flexKey, string $type = null): array + protected function resolveKeyAndType(string $flexKey, ?string $type = null): array { $guess = false; if (strpos($flexKey, ':') !== false) { @@ -323,7 +323,7 @@ class Flex implements FlexInterface * @param string|null $type * @return string */ - protected function resolveType(string $type = null): string + protected function resolveType(?string $type = null): string { if (null !== $type && strpos($type, '.') !== false) { return preg_replace('|\.obj$|', '', $type) ?? $type; diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php index 3e9302cb8..7984719fc 100644 --- a/system/src/Grav/Framework/Flex/FlexCollection.php +++ b/system/src/Grav/Framework/Flex/FlexCollection.php @@ -84,7 +84,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * {@inheritdoc} * @see FlexCollectionInterface::createFromArray() */ - public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null) + public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null) { $instance = new static($entries, $directory); $instance->setKeyField($keyField); @@ -96,7 +96,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * {@inheritdoc} * @see FlexCollectionInterface::__construct() */ - public function __construct(array $entries = [], FlexDirectory $directory = null) + public function __construct(array $entries = [], ?FlexDirectory $directory = null) { // @phpstan-ignore-next-line if (get_class($this) === __CLASS__) { @@ -145,7 +145,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * {@inheritdoc} * @see FlexCollectionInterface::search() */ - public function search(string $search, $properties = null, array $options = null) + public function search(string $search, $properties = null, ?array $options = null) { $directory = $this->getFlexDirectory(); $properties = $directory->getSearchProperties($properties); @@ -298,7 +298,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * @param string|null $separator Separator, defaults to '.' * @return array */ - public function getDistinctValues(string $property, string $separator = null): array + public function getDistinctValues(string $property, ?string $separator = null): array { $list = []; @@ -320,7 +320,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * {@inheritdoc} * @see FlexCollectionInterface::withKeyField() */ - public function withKeyField(string $keyField = null) + public function withKeyField(?string $keyField = null) { $keyField = $keyField ?: 'key'; if ($keyField === $this->getKeyField()) { @@ -366,7 +366,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * {@inheritdoc} * @see FlexCollectionInterface::render() */ - public function render(string $layout = null, array $context = []) + public function render(?string $layout = null, array $context = []) { if (!$layout) { $config = $this->getTemplateConfig(); @@ -485,7 +485,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * @param string|null $namespace * @return CacheInterface */ - public function getCache(string $namespace = null) + public function getCache(?string $namespace = null) { return $this->_flexDirectory->getCache($namespace); } @@ -505,7 +505,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface * @return static * @phpstan-return static */ - public function isAuthorized(string $action, string $scope = null, UserInterface $user = null) + public function isAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null) { $list = $this->call('isAuthorized', [$action, $scope, $user]); $list = array_filter($list); diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index 0d920c48b..3fb2f30bb 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectory.php +++ b/system/src/Grav/Framework/Flex/FlexDirectory.php @@ -156,7 +156,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param mixed $default * @return mixed */ - public function getConfig(string $name = null, $default = null) + public function getConfig(?string $name = null, $default = null) { if (null === $this->config) { $config = $this->getBlueprintInternal()->get('config', []); @@ -198,7 +198,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param array|null $options * @return array */ - public function getSearchOptions(array $options = null): array + public function getSearchOptions(?array $options = null): array { if (empty($options['merge'])) { return $options ?? (array)$this->getConfig('data.search.options'); @@ -215,7 +215,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexFormInterface * @internal */ - public function getDirectoryForm(string $name = null, array $options = []) + public function getDirectoryForm(?string $name = null, array $options = []) { $name = $name ?: $this->getConfig('admin.views.configure.form', '') ?: $this->getConfig('admin.configure.form', ''); @@ -312,7 +312,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $name * @return string */ - public function getDirectoryConfigUri(string $name = null): string + public function getDirectoryConfigUri(?string $name = null): string { $name = $name ?: $this->getFlexType(); $blueprint = $this->getBlueprint(); @@ -324,7 +324,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $name * @return array */ - protected function getDirectoryConfig(string $name = null): array + protected function getDirectoryConfig(?string $name = null): array { $grav = Grav::instance(); @@ -373,7 +373,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface + public function getCollection(?array $keys = null, ?string $keyField = null): FlexCollectionInterface { // Get all selected entries. $index = $this->getIndex($keys, $keyField); @@ -400,7 +400,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexIndexInterface * @phpstan-return FlexIndexInterface */ - public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface + public function getIndex(?array $keys = null, ?string $keyField = null): FlexIndexInterface { $keyField = $keyField ?? ''; $index = $this->indexes[$keyField] ?? $this->loadIndex($keyField); @@ -423,7 +423,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $keyField Field to be used as the key. * @return FlexObjectInterface|null */ - public function getObject($key = null, string $keyField = null): ?FlexObjectInterface + public function getObject($key = null, ?string $keyField = null): ?FlexObjectInterface { if (null === $key) { return $this->createObject([], ''); @@ -439,7 +439,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $namespace * @return CacheInterface */ - public function getCache(string $namespace = null) + public function getCache(?string $namespace = null) { $namespace = $namespace ?: 'index'; $cache = $this->cache[$namespace] ?? null; @@ -508,7 +508,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $key * @return string|null */ - public function getStorageFolder(string $key = null): ?string + public function getStorageFolder(?string $key = null): ?string { return $this->getStorage()->getStoragePath($key); } @@ -517,7 +517,7 @@ class FlexDirectory implements FlexDirectoryInterface * @param string|null $key * @return string|null */ - public function getMediaFolder(string $key = null): ?string + public function getMediaFolder(?string $key = null): ?string { return $this->getStorage()->getMediaPath($key); } @@ -557,7 +557,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface + public function createCollection(array $entries, ?string $keyField = null): FlexCollectionInterface { /** phpstan-var class-string $className */ $className = $this->collectionClassName ?: $this->getCollectionClass(); @@ -574,7 +574,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexIndexInterface * @phpstan-return FlexIndexInterface */ - public function createIndex(array $entries, string $keyField = null): FlexIndexInterface + public function createIndex(array $entries, ?string $keyField = null): FlexIndexInterface { /** @phpstan-var class-string $className */ $className = $this->indexClassName ?: $this->getIndexClass(); @@ -628,7 +628,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface + public function loadCollection(array $entries, ?string $keyField = null): FlexCollectionInterface { return $this->createCollection($this->loadObjects($entries), $keyField); } @@ -1122,7 +1122,7 @@ class FlexDirectory implements FlexDirectoryInterface * @return FlexObjectInterface * @deprecated 1.7 Use $object->update()->save() instead. */ - public function update(array $data, string $key = null): FlexObjectInterface + public function update(array $data, ?string $key = null): FlexObjectInterface { user_error(__CLASS__ . '::' . __FUNCTION__ . '() should not be used anymore: use $object->update()->save() instead.', E_USER_DEPRECATED); diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php index 459fb499f..01041f711 100644 --- a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php +++ b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php @@ -83,7 +83,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable * @param FlexDirectory $directory * @param array|null $options */ - public function __construct(string $name, FlexDirectory $directory, array $options = null) + public function __construct(string $name, FlexDirectory $directory, ?array $options = null) { $this->name = $name; $this->setDirectory($directory); @@ -350,7 +350,7 @@ class FlexDirectoryForm implements FlexDirectoryFormInterface, JsonSerializable * @param string|null $extension * @return string */ - public function getMediaTaskRoute(array $params = [], string $extension = null): string + public function getMediaTaskRoute(array $params = [], ?string $extension = null): string { return ''; } diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php index f3a0d1fc0..2d00b9d67 100644 --- a/system/src/Grav/Framework/Flex/FlexForm.php +++ b/system/src/Grav/Framework/Flex/FlexForm.php @@ -100,7 +100,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable * @param FlexObjectInterface $object * @param array|null $options */ - public function __construct(string $name, FlexObjectInterface $object, array $options = null) + public function __construct(string $name, FlexObjectInterface $object, ?array $options = null) { $this->name = $name; $this->setObject($object); @@ -428,7 +428,7 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable * @param string|null $extension * @return string */ - public function getMediaTaskRoute(array $params = [], string $extension = null): string + public function getMediaTaskRoute(array $params = [], ?string $extension = null): string { $grav = Grav::instance(); /** @var Flex $flex */ diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index 2c87d590d..a7b05e7f0 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -66,7 +66,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * {@inheritdoc} * @see FlexCollectionInterface::createFromArray() */ - public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null) + public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null) { $instance = new static($entries, $directory); $instance->setKeyField($keyField); @@ -106,7 +106,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @param array $entries * @param FlexDirectory|null $directory */ - public function __construct(array $entries = [], FlexDirectory $directory = null) + public function __construct(array $entries = [], ?FlexDirectory $directory = null) { // @phpstan-ignore-next-line if (get_class($this) === __CLASS__) { @@ -161,7 +161,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * {@inheritdoc} * @see FlexCollectionInterface::search() */ - public function search(string $search, $properties = null, array $options = null) + public function search(string $search, $properties = null, ?array $options = null) { $directory = $this->getFlexDirectory(); $properties = $directory->getSearchProperties($properties); @@ -283,7 +283,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * {@inheritdoc} * @see FlexIndexInterface::withKeyField() */ - public function withKeyField(string $keyField = null) + public function withKeyField(?string $keyField = null) { $keyField = $keyField ?: 'key'; if ($keyField === $this->getKeyField()) { @@ -329,7 +329,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * {@inheritdoc} * @see FlexCollectionInterface::render() */ - public function render(string $layout = null, array $context = []) + public function render(?string $layout = null, array $context = []) { return $this->__call('render', [$layout, $context]); } @@ -338,7 +338,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * {@inheritdoc} * @see FlexIndexInterface::getFlexKeys() */ - public function getIndexMap(string $indexKey = null) + public function getIndexMap(?string $indexKey = null) { if (null === $indexKey) { return $this->getEntries(); @@ -374,7 +374,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @param string|null $namespace * @return CacheInterface */ - public function getCache(string $namespace = null) + public function getCache(?string $namespace = null) { return $this->getFlexDirectory()->getCache($namespace); } @@ -558,7 +558,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @return static * @phpstan-return static */ - protected function createFrom(array $entries, string $keyField = null) + protected function createFrom(array $entries, ?string $keyField = null) { /** @phpstan-var static $index */ $index = new static($entries, $this->getFlexDirectory()); @@ -571,7 +571,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @param string|null $keyField * @return void */ - protected function setKeyField(string $keyField = null) + protected function setKeyField(?string $keyField = null) { $this->_keyField = $keyField ?? 'storage_key'; } @@ -642,7 +642,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @return ObjectInterface[] * @phpstan-return T[] */ - protected function loadElements(array $entries = null): array + protected function loadElements(?array $entries = null): array { /** @phpstan-var T[] $objects */ $objects = $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries()); @@ -655,7 +655,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface * @return CollectionInterface * @phpstan-return C */ - protected function loadCollection(array $entries = null): CollectionInterface + protected function loadCollection(?array $entries = null): CollectionInterface { /** @var C $collection */ $collection = $this->getFlexDirectory()->loadCollection($entries ?? $this->getEntries(), $this->_keyField); diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 14f28f9b6..8be308189 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -285,7 +285,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::search() */ - public function search(string $search, $properties = null, array $options = null): float + public function search(string $search, $properties = null, ?array $options = null): float { $directory = $this->getFlexDirectory(); $properties = $directory->getSearchProperties($properties); @@ -362,7 +362,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param array|null $options * @return float */ - public function searchProperty(string $property, string $search, array $options = null): float + public function searchProperty(string $property, string $search, ?array $options = null): float { $options = $options ?? (array)$this->getFlexDirectory()->getConfig('data.search.options'); $value = $this->getProperty($property); @@ -376,7 +376,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param array|null $options * @return float */ - public function searchNestedProperty(string $property, string $search, array $options = null): float + public function searchNestedProperty(string $property, string $search, ?array $options = null): float { $options = $options ?? (array)$this->getFlexDirectory()->getConfig('data.search.options'); if ($property === 'key') { @@ -395,7 +395,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param array|null $options * @return float */ - protected function searchValue(string $name, $value, string $search, array $options = null): float + protected function searchValue(string $name, $value, string $search, ?array $options = null): float { $options = $options ?? []; @@ -515,7 +515,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param string|null $namespace * @return CacheInterface */ - public function getCache(string $namespace = null) + public function getCache(?string $namespace = null) { return $this->_flexDirectory->getCache($namespace); } @@ -546,7 +546,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::render() */ - public function render(string $layout = null, array $context = []) + public function render(?string $layout = null, array $context = []) { if (!$layout) { $config = $this->getTemplateConfig(); @@ -714,7 +714,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::create() */ - public function create(string $key = null) + public function create(?string $key = null) { if ($key) { $this->setStorageKey($key); @@ -731,7 +731,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param string|null $key * @return FlexObject|FlexObjectInterface */ - public function createCopy(string $key = null) + public function createCopy(?string $key = null) { $this->markAsCopy(); @@ -741,7 +741,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface /** * @param UserInterface|null $user */ - public function check(UserInterface $user = null): void + public function check(?UserInterface $user = null): void { // If user has been provided, check if the user has permissions to save this object. if ($user && !$this->isAuthorized('save', null, $user)) { @@ -865,7 +865,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::getForm() */ - public function getForm(string $name = '', array $options = null) + public function getForm(string $name = '', ?array $options = null) { $hash = $name . '-' . md5(json_encode($options, JSON_THROW_ON_ERROR)); if (!isset($this->_forms[$hash])) { @@ -879,7 +879,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::getDefaultValue() */ - public function getDefaultValue(string $name, string $separator = null) + public function getDefaultValue(string $name, ?string $separator = null) { $separator = $separator ?: '.'; $path = explode($separator, $name); @@ -920,7 +920,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * {@inheritdoc} * @see FlexObjectInterface::getFormValue() */ - public function getFormValue(string $name, $default = null, string $separator = null) + public function getFormValue(string $name, $default = null, ?string $separator = null) { if ($name === 'storage_key') { return $this->getStorageKey(); @@ -1018,7 +1018,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param FlexDirectory|null $directory * @return void */ - protected function doUnserialize(array $serialized, FlexDirectory $directory = null): void + protected function doUnserialize(array $serialized, ?FlexDirectory $directory = null): void { $type = $serialized['type'] ?? 'unknown'; @@ -1106,7 +1106,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface * @param array|null $options Form optiosn * @return FlexFormInterface */ - protected function createFormObject(string $name, array $options = null) + protected function createFormObject(string $name, ?array $options = null) { return new FlexForm($name, $this, $options); } diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php index 9561f59d9..a4603b74b 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php @@ -29,5 +29,5 @@ interface FlexAuthorizeInterface * @param UserInterface|null $user * @return bool|null */ - public function isAuthorized(string $action, string $scope = null, UserInterface $user = null): ?bool; + public function isAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null): ?bool; } diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php index acfede55b..3fd050734 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php @@ -37,7 +37,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI * @param string|null $keyField Key field used to index the collection. * @return static Returns a new Flex Collection. */ - public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null); + public static function createFromArray(array $entries, FlexDirectory $directory, ?string $keyField = null); /** * Creates a new Flex Collection. @@ -48,7 +48,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI * @param FlexDirectory|null $directory Flex Directory where all the objects belong into. * @throws InvalidArgumentException */ - public function __construct(array $entries = [], FlexDirectory $directory = null); + public function __construct(array $entries = [], ?FlexDirectory $directory = null); /** * Search a string from the collection. @@ -60,7 +60,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI * @phpstan-return static * @api */ - public function search(string $search, $properties = null, array $options = null); + public function search(string $search, $properties = null, ?array $options = null); /** * Sort the collection. @@ -116,7 +116,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI * @phpstan-return static * @api */ - public function withKeyField(string $keyField = null); + public function withKeyField(?string $keyField = null); /** * Get Flex Index from the Flex Collection. diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php index 918feead3..bea37ee8d 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php @@ -49,7 +49,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @param mixed $default * @return mixed */ - public function getConfig(string $name = null, $default = null); + public function getConfig(?string $name = null, $default = null); /** * @param string|null $name @@ -57,7 +57,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexFormInterface * @internal */ - public function getDirectoryForm(string $name = null, array $options = []); + public function getDirectoryForm(?string $name = null, array $options = []); /** * @return Blueprint @@ -78,7 +78,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @param string|null $name * @return string */ - public function getDirectoryConfigUri(string $name = null): string; + public function getDirectoryConfigUri(?string $name = null): string; /** * Returns a new uninitialized instance of blueprint. @@ -107,7 +107,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface; + public function getCollection(?array $keys = null, ?string $keyField = null): FlexCollectionInterface; /** * Get the full collection of all stored objects. @@ -119,7 +119,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexIndexInterface * @phpstan-return FlexIndexInterface */ - public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface; + public function getIndex(?array $keys = null, ?string $keyField = null): FlexIndexInterface; /** * Returns an object if it exists. If no arguments are passed (or both of them are null), method creates a new empty object. @@ -130,13 +130,13 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @param string|null $keyField Field to be used as the key. * @return FlexObjectInterface|null */ - public function getObject($key = null, string $keyField = null): ?FlexObjectInterface; + public function getObject($key = null, ?string $keyField = null): ?FlexObjectInterface; /** * @param string|null $namespace * @return CacheInterface */ - public function getCache(string $namespace = null); + public function getCache(?string $namespace = null); /** * @return $this @@ -147,13 +147,13 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @param string|null $key * @return string|null */ - public function getStorageFolder(string $key = null): ?string; + public function getStorageFolder(?string $key = null): ?string; /** * @param string|null $key * @return string|null */ - public function getMediaFolder(string $key = null): ?string; + public function getMediaFolder(?string $key = null): ?string; /** * @return FlexStorageInterface @@ -174,7 +174,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface; + public function createCollection(array $entries, ?string $keyField = null): FlexCollectionInterface; /** * @param array $entries @@ -182,7 +182,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexIndexInterface * @phpstan-return FlexIndexInterface */ - public function createIndex(array $entries, string $keyField = null): FlexIndexInterface; + public function createIndex(array $entries, ?string $keyField = null): FlexIndexInterface; /** * @return string @@ -205,7 +205,7 @@ interface FlexDirectoryInterface extends FlexAuthorizeInterface * @return FlexCollectionInterface * @phpstan-return FlexCollectionInterface */ - public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface; + public function loadCollection(array $entries, ?string $keyField = null): FlexCollectionInterface; /** * @param array $entries diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php index fe7846575..7d62822eb 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php @@ -54,11 +54,11 @@ interface FlexIndexInterface extends FlexCollectionInterface * @phpstan-return static * @api */ - public function withKeyField(string $keyField = null); + public function withKeyField(?string $keyField = null); /** * @param string|null $indexKey * @return array */ - public function getIndexMap(string $indexKey = null); + public function getIndexMap(?string $indexKey = null); } diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php index 3c9de4972..6952ad559 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php @@ -46,7 +46,7 @@ interface FlexInterface extends Countable * @param bool $keepMissing * @return array */ - public function getDirectories(array $types = null, bool $keepMissing = false): array; + public function getDirectories(?array $types = null, bool $keepMissing = false): array; /** * @param string $type @@ -61,7 +61,7 @@ interface FlexInterface extends Countable * @return FlexCollectionInterface|null * @phpstan-return FlexCollectionInterface|null */ - public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface; + public function getCollection(string $type, ?array $keys = null, ?string $keyField = null): ?FlexCollectionInterface; /** * @param array $keys @@ -91,7 +91,7 @@ interface FlexInterface extends Countable * @param string|null $keyField * @return FlexObjectInterface|null */ - public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface; + public function getObject(string $key, ?string $type = null, ?string $keyField = null): ?FlexObjectInterface; /** * @return int diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php index 826db3f66..5893c23de 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php @@ -55,7 +55,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface * @return float Returns a weight between 0 and 1. * @api */ - public function search(string $search, $properties = null, array $options = null): float; + public function search(string $search, $properties = null, ?array $options = null): float; /** * Returns true if object has a key. @@ -136,7 +136,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface * @throws RuntimeException if object already exists. * @api */ - public function create(string $key = null); + public function create(?string $key = null); /** * Save object into the storage. @@ -175,7 +175,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface * @return FlexFormInterface Returns a Form. * @api */ - public function getForm(string $name = '', array $options = null); + public function getForm(string $name = '', ?array $options = null); /** * Returns default value suitable to be used in a form for the given property. @@ -186,7 +186,7 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface * @param string|null $separator Optional nested property separator. * @return mixed|null Returns default value of the field, null if there is no default value. */ - public function getDefaultValue(string $name, string $separator = null); + public function getDefaultValue(string $name, ?string $separator = null); /** * Returns default values suitable to be used in a form for the given property. @@ -207,5 +207,5 @@ interface FlexObjectInterface extends FlexCommonInterface, NestedObjectInterface * @param string|null $separator Optional nested property separator. * @return mixed Returns value of the field. */ - public function getFormValue(string $name, $default = null, string $separator = null); + public function getFormValue(string $name, $default = null, ?string $separator = null); } diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php index 4980696ed..d78a8af69 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php @@ -78,7 +78,7 @@ interface FlexStorageInterface * @param array|null $fetched Optional reference to store only fetched items. * @return array Returns rows. Note that non-existing rows will have `null` as their value. */ - public function readRows(array $rows, array &$fetched = null): array; + public function readRows(array $rows, ?array &$fetched = null): array; /** * Update existing rows in the storage. @@ -126,7 +126,7 @@ interface FlexStorageInterface * @param string|null $key Optional storage key. * @return string|null Path in the filesystem. Can be URI or null if storage is not filesystem based. */ - public function getStoragePath(string $key = null): ?string; + public function getStoragePath(?string $key = null): ?string; /** * Get filesystem path for the collection or object media. @@ -134,5 +134,5 @@ interface FlexStorageInterface * @param string|null $key Optional storage key. * @return string|null Path in the filesystem. Can be URI or null if media isn't supported. */ - public function getMediaPath(string $key = null): ?string; + public function getMediaPath(?string $key = null): ?string; } diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php index 1ae8b7e38..c3a488dc4 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php @@ -23,7 +23,7 @@ interface FlexTranslateInterface * @param bool|null $fallback * @return bool */ - public function hasTranslation(string $languageCode = null, bool $fallback = null): bool; + public function hasTranslation(?string $languageCode = null, ?bool $fallback = null): bool; /** * Get translation. @@ -32,7 +32,7 @@ interface FlexTranslateInterface * @param bool|null $fallback * @return static|null */ - public function getTranslation(string $languageCode = null, bool $fallback = null); + public function getTranslation(?string $languageCode = null, ?bool $fallback = null); /** * Returns all translated languages. diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php index 2fd793a3c..1e49734f8 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php @@ -186,7 +186,7 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI /** * @inheritdoc */ - public function getFormValue(string $name, $default = null, string $separator = null) + public function getFormValue(string $name, $default = null, ?string $separator = null) { $test = new stdClass(); @@ -241,7 +241,7 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI * @param string|null $key * @return FlexObjectInterface */ - public function createCopy(string $key = null) + public function createCopy(?string $key = null) { $this->copy(); diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php index 1061cbb25..878c5cba6 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php @@ -116,7 +116,7 @@ trait PageAuthorsTrait * @param bool $isAuthor * @return bool|null */ - public function isParentAuthorized(string $action, string $scope = null, UserInterface $user = null, bool $isAuthor = false): ?bool + public function isParentAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null, bool $isAuthor = false): ?bool { $scope = $scope ?? $this->getAuthorizeScope(); diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index 461fb5146..37bca5e5a 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php @@ -294,7 +294,7 @@ trait PageLegacyTrait * @param PageInterface|null $parent New parent page. * @return $this */ - public function copy(PageInterface $parent = null) + public function copy(?PageInterface $parent = null) { $this->storeOriginal(); diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php index 918ad67ba..b5b3f899e 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php @@ -409,7 +409,7 @@ trait PageRoutableTrait * @param PageInterface|null $var the parent page object * @return PageInterface|null the parent page object if it exists. */ - public function parent(PageInterface $var = null) + public function parent(?PageInterface $var = null) { if (null !== $var) { // TODO: diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php index 2bdfa8756..6fc09fb0e 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php @@ -39,7 +39,7 @@ trait PageTranslateTrait * @param bool|null $fallback * @return bool */ - public function hasTranslation(string $languageCode = null, bool $fallback = null): bool + public function hasTranslation(?string $languageCode = null, ?bool $fallback = null): bool { $code = $this->findTranslation($languageCode, $fallback); @@ -51,7 +51,7 @@ trait PageTranslateTrait * @param bool|null $fallback * @return FlexObjectInterface|PageInterface|null */ - public function getTranslation(string $languageCode = null, bool $fallback = null) + public function getTranslation(?string $languageCode = null, ?bool $fallback = null) { if ($this->root()) { return $this; @@ -147,7 +147,7 @@ trait PageTranslateTrait * @param bool|null $fallback * @return string|null */ - public function findTranslation(string $languageCode = null, bool $fallback = null): ?string + public function findTranslation(?string $languageCode = null, ?bool $fallback = null): ?string { $translated = $this->getLanguageTemplates(); @@ -270,7 +270,7 @@ trait PageTranslateTrait * @param bool|null $fallback * @return array */ - protected function getFallbackLanguages(string $languageCode = null, bool $fallback = null): array + protected function getFallbackLanguages(?string $languageCode = null, ?bool $fallback = null): array { $fallback = $fallback ?? true; if (!$fallback && null !== $languageCode) { diff --git a/system/src/Grav/Framework/Flex/Storage/FileStorage.php b/system/src/Grav/Framework/Flex/Storage/FileStorage.php index 27701282e..4ed0660fd 100644 --- a/system/src/Grav/Framework/Flex/Storage/FileStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/FileStorage.php @@ -42,7 +42,7 @@ class FileStorage extends FolderStorage * {@inheritdoc} * @see FlexStorageInterface::getMediaPath() */ - public function getMediaPath(string $key = null): ?string + public function getMediaPath(?string $key = null): ?string { $path = $this->getStoragePath(); if (!$path) { diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php index 157449d36..790eafdc4 100644 --- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php @@ -135,7 +135,7 @@ class FolderStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::readRows() */ - public function readRows(array $rows, array &$fetched = null): array + public function readRows(array $rows, ?array &$fetched = null): array { $list = []; foreach ($rows as $key => $row) { @@ -277,7 +277,7 @@ class FolderStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::getStoragePath() */ - public function getStoragePath(string $key = null): ?string + public function getStoragePath(?string $key = null): ?string { if (null === $key || $key === '') { $path = $this->dataFolder; @@ -301,7 +301,7 @@ class FolderStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::getMediaPath() */ - public function getMediaPath(string $key = null): ?string + public function getMediaPath(?string $key = null): ?string { return $this->getStoragePath($key); } diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php index 5a92023eb..4ffddd3b2 100644 --- a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php @@ -148,7 +148,7 @@ class SimpleStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::readRows() */ - public function readRows(array $rows, array &$fetched = null): array + public function readRows(array $rows, ?array &$fetched = null): array { if (null === $this->data) { $this->buildIndex(); @@ -305,7 +305,7 @@ class SimpleStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::getStoragePath() */ - public function getStoragePath(string $key = null): ?string + public function getStoragePath(?string $key = null): ?string { return $this->dataFolder . '/' . $this->dataPattern; } @@ -314,7 +314,7 @@ class SimpleStorage extends AbstractFilesystemStorage * {@inheritdoc} * @see FlexStorageInterface::getMediaPath() */ - public function getMediaPath(string $key = null): ?string + public function getMediaPath(?string $key = null): ?string { return null; } diff --git a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php index a82130041..17b3212b5 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php @@ -34,7 +34,7 @@ trait FlexAuthorizeTrait * @return bool|null * @final */ - public function isAuthorized(string $action, string $scope = null, UserInterface $user = null): ?bool + public function isAuthorized(string $action, ?string $scope = null, ?UserInterface $user = null): ?bool { $action = $this->getAuthorizeAction($action); $scope = $scope ?? $this->getAuthorizeScope(); diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php index a4d9a7e41..e87b87886 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php @@ -241,7 +241,7 @@ trait FlexMediaTrait * @return void * @internal */ - public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile, string $filename = null, string $field = null) + public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?string $field = null) { $media = $this->getMedia(); if (!$media instanceof MediaUploadInterface) { @@ -258,7 +258,7 @@ trait FlexMediaTrait * @return void * @internal */ - public function uploadMediaFile(UploadedFileInterface $uploadedFile, string $filename = null, string $field = null): void + public function uploadMediaFile(UploadedFileInterface $uploadedFile, ?string $filename = null, ?string $field = null): void { $settings = $this->getMediaFieldSettings($field ?? ''); @@ -305,7 +305,7 @@ trait FlexMediaTrait * @param MediaObjectInterface|null $image * @return MediaObject|UploadedMediaObject */ - protected function buildMediaObject(?string $field, string $filename, MediaObjectInterface $image = null) + protected function buildMediaObject(?string $field, string $filename, ?MediaObjectInterface $image = null) { if (!$image) { $media = $field ? $this->getMediaField($field) : null; diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php index db1d8d4c9..8de758890 100644 --- a/system/src/Grav/Framework/Form/FormFlash.php +++ b/system/src/Grav/Framework/Form/FormFlash.php @@ -320,7 +320,7 @@ class FormFlash implements FormFlashInterface /** * @inheritDoc */ - public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string + public function addUploadedFile(UploadedFileInterface $upload, ?string $field = null, ?array $crop = null): string { $tmp_dir = $this->getTmpDir(); $tmp_name = Utils::generateRandomString(12); @@ -348,7 +348,7 @@ class FormFlash implements FormFlashInterface /** * @inheritDoc */ - public function addFile(string $filename, string $field, array $crop = null): bool + public function addFile(string $filename, string $field, ?array $crop = null): bool { if (!file_exists($filename)) { throw new RuntimeException("File not found: {$filename}"); @@ -369,7 +369,7 @@ class FormFlash implements FormFlashInterface /** * @inheritDoc */ - public function removeFile(string $name, string $field = null): bool + public function removeFile(string $name, ?string $field = null): bool { if (!$name) { return false; @@ -447,7 +447,7 @@ class FormFlash implements FormFlashInterface * @param UserInterface|null $user * @return $this */ - public function setUser(UserInterface $user = null) + public function setUser(?UserInterface $user = null) { if ($user && $user->username) { $this->user = [ @@ -465,7 +465,7 @@ class FormFlash implements FormFlashInterface * @param string|null $username * @return $this */ - public function setUserName(string $username = null): self + public function setUserName(?string $username = null): self { $this->user['username'] = $username; @@ -476,7 +476,7 @@ class FormFlash implements FormFlashInterface * @param string|null $email * @return $this */ - public function setUserEmail(string $email = null): self + public function setUserEmail(?string $email = null): self { $this->user['email'] = $email; @@ -538,7 +538,7 @@ class FormFlash implements FormFlashInterface * @param array|null $crop * @return void */ - protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void + protected function addFileInternal(?string $field, string $name, array $data, ?array $crop = null): void { if (!($this->folder && $this->uniqueId)) { throw new RuntimeException('Cannot upload files: form flash folder not defined'); diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php index a834994e1..d01956b3c 100644 --- a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php +++ b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php @@ -146,7 +146,7 @@ interface FormFlashInterface extends \JsonSerializable * @param array|null $crop * @return string Return name of the file */ - public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string; + public function addUploadedFile(UploadedFileInterface $upload, ?string $field = null, ?array $crop = null): string; /** * Add existing file to the form flash. @@ -156,7 +156,7 @@ interface FormFlashInterface extends \JsonSerializable * @param array|null $crop * @return bool */ - public function addFile(string $filename, string $field, array $crop = null): bool; + public function addFile(string $filename, string $field, ?array $crop = null): bool; /** * Remove any file from form flash. @@ -165,7 +165,7 @@ interface FormFlashInterface extends \JsonSerializable * @param string|null $field * @return bool */ - public function removeFile(string $name, string $field = null): bool; + public function removeFile(string $name, ?string $field = null): bool; /** * Clear form flash from all uploaded files. diff --git a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php index 5d60965f6..79beae153 100644 --- a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php +++ b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php @@ -140,7 +140,7 @@ interface FormInterface extends RenderInterface, \Serializable * @param UploadedFileInterface[]|null $files * @return $this */ - public function submit(array $data, array $files = null): FormInterface; + public function submit(array $data, ?array $files = null): FormInterface; /** * @return bool diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php index 4bcae673e..b64dd9a9b 100644 --- a/system/src/Grav/Framework/Form/Traits/FormTrait.php +++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php @@ -194,7 +194,7 @@ trait FormTrait * @param string|null $name * @return mixed */ - public function getData(string $name = null) + public function getData(?string $name = null) { return null !== $name ? $this->data[$name] : $this->data; } @@ -366,7 +366,7 @@ trait FormTrait * @param UploadedFileInterface[]|null $files * @return FormInterface|$this */ - public function submit(array $data, array $files = null): FormInterface + public function submit(array $data, ?array $files = null): FormInterface { try { if ($this->isSubmitted()) { @@ -502,7 +502,7 @@ trait FormTrait * {@inheritdoc} * @see FormInterface::render() */ - public function render(string $layout = null, array $context = []) + public function render(?string $layout = null, array $context = []) { if (null === $layout) { $layout = 'default'; diff --git a/system/src/Grav/Framework/Interfaces/RenderInterface.php b/system/src/Grav/Framework/Interfaces/RenderInterface.php index 0cefae3ad..5a2397a88 100644 --- a/system/src/Grav/Framework/Interfaces/RenderInterface.php +++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php @@ -34,5 +34,5 @@ interface RenderInterface * @return ContentBlockInterface|HtmlBlock Returns `HtmlBlock` containing the rendered output. * @api */ - public function render(string $layout = null, array $context = []); + public function render(?string $layout = null, array $context = []); } diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php index 5b28ab0bb..d62253825 100644 --- a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php +++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php @@ -135,7 +135,7 @@ class ObjectExpressionVisitor extends ClosureExpressionVisitor * * @return Closure */ - public static function sortByField($name, $orientation = 1, Closure $next = null) + public static function sortByField($name, $orientation = 1, ?Closure $next = null) { if (!$next) { $next = function ($a, $b) { diff --git a/system/src/Grav/Framework/Pagination/AbstractPagination.php b/system/src/Grav/Framework/Pagination/AbstractPagination.php index 084fb1d49..401b1662b 100644 --- a/system/src/Grav/Framework/Pagination/AbstractPagination.php +++ b/system/src/Grav/Framework/Pagination/AbstractPagination.php @@ -121,7 +121,7 @@ class AbstractPagination implements PaginationInterface * @param string|null $label * @return PaginationPage|null */ - public function getPage(int $page, string $label = null): ?PaginationPage + public function getPage(int $page, ?string $label = null): ?PaginationPage { if ($page < 1 || $page > $this->pages) { return null; @@ -163,7 +163,7 @@ class AbstractPagination implements PaginationInterface * @param int $count * @return PaginationPage|null */ - public function getFirstPage(string $label = null, int $count = 0): ?PaginationPage + public function getFirstPage(?string $label = null, int $count = 0): ?PaginationPage { return $this->getPage(1 + $count, $label ?? $this->getOptions()['label_first'] ?? null); } @@ -173,7 +173,7 @@ class AbstractPagination implements PaginationInterface * @param int $count * @return PaginationPage|null */ - public function getPrevPage(string $label = null, int $count = 1): ?PaginationPage + public function getPrevPage(?string $label = null, int $count = 1): ?PaginationPage { return $this->getPage($this->page - $count, $label ?? $this->getOptions()['label_prev'] ?? null); } @@ -183,7 +183,7 @@ class AbstractPagination implements PaginationInterface * @param int $count * @return PaginationPage|null */ - public function getNextPage(string $label = null, int $count = 1): ?PaginationPage + public function getNextPage(?string $label = null, int $count = 1): ?PaginationPage { return $this->getPage($this->page + $count, $label ?? $this->getOptions()['label_next'] ?? null); } @@ -193,7 +193,7 @@ class AbstractPagination implements PaginationInterface * @param int $count * @return PaginationPage|null */ - public function getLastPage(string $label = null, int $count = 0): ?PaginationPage + public function getLastPage(?string $label = null, int $count = 0): ?PaginationPage { return $this->getPage($this->pages - $count, $label ?? $this->getOptions()['label_last'] ?? null); } @@ -289,7 +289,7 @@ class AbstractPagination implements PaginationInterface * @param array|null $options * @return $this */ - protected function setOptions(array $options = null) + protected function setOptions(?array $options = null) { $this->options = $options ? array_merge($this->defaultOptions, $options) : $this->defaultOptions; @@ -300,7 +300,7 @@ class AbstractPagination implements PaginationInterface * @param int|null $page * @return $this */ - protected function setPage(int $page = null) + protected function setPage(?int $page = null) { $this->page = (int)max($page, 1); $this->start = null; @@ -312,7 +312,7 @@ class AbstractPagination implements PaginationInterface * @param int|null $start * @return $this */ - protected function setStart(int $start = null) + protected function setStart(?int $start = null) { $this->start = (int)max($start, 0); $this->page = null; @@ -324,7 +324,7 @@ class AbstractPagination implements PaginationInterface * @param int|null $limit * @return $this */ - protected function setLimit(int $limit = null) + protected function setLimit(?int $limit = null) { $this->limit = (int)max($limit ?? $this->getOptions()['limit'], 0); @@ -353,7 +353,7 @@ class AbstractPagination implements PaginationInterface * @param array|null $options * @return void */ - protected function initialize(Route $route, int $total, int $pos = null, int $limit = null, array $options = null) + protected function initialize(Route $route, int $total, ?int $pos = null, ?int $limit = null, ?array $options = null) { $this->setRoute($route); $this->setOptions($options); diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php index b329c53d4..5dbf21805 100644 --- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php +++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php @@ -72,33 +72,33 @@ interface PaginationInterface extends Countable, IteratorAggregate * @param string|null $label * @return PaginationPage|null */ - public function getPage(int $page, string $label = null): ?PaginationPage; + public function getPage(int $page, ?string $label = null): ?PaginationPage; /** * @param string|null $label * @param int $count * @return PaginationPage|null */ - public function getFirstPage(string $label = null, int $count = 0): ?PaginationPage; + public function getFirstPage(?string $label = null, int $count = 0): ?PaginationPage; /** * @param string|null $label * @param int $count * @return PaginationPage|null */ - public function getPrevPage(string $label = null, int $count = 1): ?PaginationPage; + public function getPrevPage(?string $label = null, int $count = 1): ?PaginationPage; /** * @param string|null $label * @param int $count * @return PaginationPage|null */ - public function getNextPage(string $label = null, int $count = 1): ?PaginationPage; + public function getNextPage(?string $label = null, int $count = 1): ?PaginationPage; /** * @param string|null $label * @param int $count * @return PaginationPage|null */ - public function getLastPage(string $label = null, int $count = 0): ?PaginationPage; + public function getLastPage(?string $label = null, int $count = 0): ?PaginationPage; } diff --git a/system/src/Grav/Framework/Pagination/Pagination.php b/system/src/Grav/Framework/Pagination/Pagination.php index 99c6661a0..76f55a6aa 100644 --- a/system/src/Grav/Framework/Pagination/Pagination.php +++ b/system/src/Grav/Framework/Pagination/Pagination.php @@ -25,7 +25,7 @@ class Pagination extends AbstractPagination * @param int|null $limit * @param array|null $options */ - public function __construct(Route $route, int $total, int $pos = null, int $limit = null, array $options = null) + public function __construct(Route $route, int $total, ?int $pos = null, ?int $limit = null, ?array $options = null) { $this->initialize($route, $total, $pos, $limit, $options); } diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php index 4126ff8e6..b7ed93e38 100644 --- a/system/src/Grav/Framework/Psr7/Response.php +++ b/system/src/Grav/Framework/Psr7/Response.php @@ -35,7 +35,7 @@ class Response implements ResponseInterface * @param string $version Protocol version * @param string|null $reason Reason phrase (optional) */ - public function __construct(int $status = 200, array $headers = [], $body = null, string $version = '1.1', string $reason = null) + public function __construct(int $status = 200, array $headers = [], $body = null, string $version = '1.1', ?string $reason = null) { $this->message = new \Nyholm\Psr7\Response($status, $headers, $body, $version, $reason); } @@ -55,7 +55,7 @@ class Response implements ResponseInterface * @return static * @phpstan-param positive-int $depth */ - public function withJson($data, int $status = null, int $options = 0, int $depth = 512): ResponseInterface + public function withJson($data, ?int $status = null, int $options = 0, int $depth = 512): ResponseInterface { $json = (string) json_encode($data, $options, $depth); diff --git a/system/src/Grav/Framework/Psr7/Uri.php b/system/src/Grav/Framework/Psr7/Uri.php index 263887622..01af4021c 100644 --- a/system/src/Grav/Framework/Psr7/Uri.php +++ b/system/src/Grav/Framework/Psr7/Uri.php @@ -128,7 +128,7 @@ class Uri implements UriInterface * @return bool * @link https://tools.ietf.org/html/rfc3986#section-4.4 */ - public function isSameDocumentReference(UriInterface $base = null): bool + public function isSameDocumentReference(?UriInterface $base = null): bool { return GuzzleUri::isSameDocumentReference($this, $base); } diff --git a/system/src/Grav/Framework/Relationships/ToManyRelationship.php b/system/src/Grav/Framework/Relationships/ToManyRelationship.php index 3ea501b29..64e2e3a5c 100644 --- a/system/src/Grav/Framework/Relationships/ToManyRelationship.php +++ b/system/src/Grav/Framework/Relationships/ToManyRelationship.php @@ -83,7 +83,7 @@ class ToManyRelationship implements ToManyRelationshipInterface * @return bool * @phpstan-pure */ - public function has(string $id, string $type = null): bool + public function has(string $id, ?string $type = null): bool { return $this->getIdentifier($id, $type) !== null; } @@ -109,7 +109,7 @@ class ToManyRelationship implements ToManyRelationshipInterface * @return IdentifierInterface|null * @phpstan-pure */ - public function getIdentifier(string $id, string $type = null): ?IdentifierInterface + public function getIdentifier(string $id, ?string $type = null): ?IdentifierInterface { if (null === $type) { $type = $this->getType(); @@ -130,7 +130,7 @@ class ToManyRelationship implements ToManyRelationshipInterface * @param string|null $type * @return T|null */ - public function getObject(string $id, string $type = null): ?object + public function getObject(string $id, ?string $type = null): ?object { $identifier = $this->getIdentifier($id, $type); if ($identifier && is_callable([$identifier, 'getObject'])) { @@ -153,7 +153,7 @@ class ToManyRelationship implements ToManyRelationshipInterface * @param IdentifierInterface|null $identifier * @return bool */ - public function removeIdentifier(IdentifierInterface $identifier = null): bool + public function removeIdentifier(?IdentifierInterface $identifier = null): bool { return !$identifier || $this->removeIdentifiers([$identifier]); } diff --git a/system/src/Grav/Framework/Relationships/ToOneRelationship.php b/system/src/Grav/Framework/Relationships/ToOneRelationship.php index 9b0965143..4f7e23f11 100644 --- a/system/src/Grav/Framework/Relationships/ToOneRelationship.php +++ b/system/src/Grav/Framework/Relationships/ToOneRelationship.php @@ -25,7 +25,7 @@ class ToOneRelationship implements ToOneRelationshipInterface /** @var IdentifierInterface|null */ protected $identifier = null; - public function __construct(IdentifierInterface $parent, string $name, array $options, IdentifierInterface $identifier = null) + public function __construct(IdentifierInterface $parent, string $name, array $options, ?IdentifierInterface $identifier = null) { $this->parent = $parent; $this->name = $name; @@ -74,7 +74,7 @@ class ToOneRelationship implements ToOneRelationshipInterface * @return bool * @phpstan-pure */ - public function has(string $id = null, string $type = null): bool + public function has(?string $id = null, ?string $type = null): bool { return $this->getIdentifier($id, $type) !== null; } @@ -85,7 +85,7 @@ class ToOneRelationship implements ToOneRelationshipInterface * @return IdentifierInterface|null * @phpstan-pure */ - public function getIdentifier(string $id = null, string $type = null): ?IdentifierInterface + public function getIdentifier(?string $id = null, ?string $type = null): ?IdentifierInterface { if ($id && $this->getType() === 'media' && !str_contains($id, '/')) { $name = $this->name; @@ -105,7 +105,7 @@ class ToOneRelationship implements ToOneRelationshipInterface * @param string|null $type * @return T|null */ - public function getObject(string $id = null, string $type = null): ?object + public function getObject(?string $id = null, ?string $type = null): ?object { $identifier = $this->getIdentifier($id, $type); if ($identifier && is_callable([$identifier, 'getObject'])) { @@ -131,7 +131,7 @@ class ToOneRelationship implements ToOneRelationshipInterface * @param IdentifierInterface|null $identifier * @return bool */ - public function replaceIdentifier(IdentifierInterface $identifier = null): bool + public function replaceIdentifier(?IdentifierInterface $identifier = null): bool { if ($identifier === null) { $this->identifier = null; @@ -147,7 +147,7 @@ class ToOneRelationship implements ToOneRelationshipInterface * @param IdentifierInterface|null $identifier * @return bool */ - public function removeIdentifier(IdentifierInterface $identifier = null): bool + public function removeIdentifier(?IdentifierInterface $identifier = null): bool { if (null === $identifier || $this->has($identifier->getId(), $identifier->getType())) { $this->identifier = null; diff --git a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php index e6d084b27..4ca59541a 100644 --- a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php +++ b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php @@ -30,7 +30,7 @@ class InvalidArgumentException extends \InvalidArgumentException * @param int $code * @param Throwable|null $previous */ - public function __construct($message = '', $invalidMiddleware = null, $code = 0, Throwable $previous = null) + public function __construct($message = '', $invalidMiddleware = null, $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php index 9d6a55aff..ebfcbbe81 100644 --- a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php +++ b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php @@ -26,7 +26,7 @@ class NotFoundException extends RequestException * @param ServerRequestInterface $request * @param Throwable|null $previous */ - public function __construct(ServerRequestInterface $request, Throwable $previous = null) + public function __construct(ServerRequestInterface $request, ?Throwable $previous = null) { if (in_array(strtoupper($request->getMethod()), ['PUT', 'PATCH', 'DELETE'])) { parent::__construct($request, 'Method Not Allowed', 405, $previous); diff --git a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php index 75317d979..30495da00 100644 --- a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php +++ b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php @@ -25,7 +25,7 @@ class PageExpiredException extends RequestException * @param ServerRequestInterface $request * @param Throwable|null $previous */ - public function __construct(ServerRequestInterface $request, Throwable $previous = null) + public function __construct(ServerRequestInterface $request, ?Throwable $previous = null) { parent::__construct($request, 'Page Expired', 400, $previous); // 419 } diff --git a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php index 945a591c0..bd894fe58 100644 --- a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php +++ b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php @@ -73,7 +73,7 @@ class RequestException extends \RuntimeException * @param int $code * @param Throwable|null $previous */ - public function __construct(ServerRequestInterface $request, string $message, int $code = 500, Throwable $previous = null) + public function __construct(ServerRequestInterface $request, string $message, int $code = 500, ?Throwable $previous = null) { $this->request = $request; diff --git a/system/src/Grav/Framework/RequestHandler/RequestHandler.php b/system/src/Grav/Framework/RequestHandler/RequestHandler.php index 44fb7f939..7af26b691 100644 --- a/system/src/Grav/Framework/RequestHandler/RequestHandler.php +++ b/system/src/Grav/Framework/RequestHandler/RequestHandler.php @@ -33,7 +33,7 @@ class RequestHandler implements RequestHandlerInterface * @param callable $default * @param ContainerInterface|null $container */ - public function __construct(array $middleware, callable $default, ContainerInterface $container = null) + public function __construct(array $middleware, callable $default, ?ContainerInterface $container = null) { $this->middleware = $middleware; $this->handler = $default; diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php index c65a82769..8d009890f 100644 --- a/system/src/Grav/Framework/Route/Route.php +++ b/system/src/Grav/Framework/Route/Route.php @@ -92,7 +92,7 @@ class Route * @param string|null $language * @return string */ - public function getBase(string $language = null): string + public function getBase(?string $language = null): string { $parts = [$this->root]; diff --git a/system/src/Grav/Framework/Session/Messages.php b/system/src/Grav/Framework/Session/Messages.php index 66a72c4bb..a0d19979f 100644 --- a/system/src/Grav/Framework/Session/Messages.php +++ b/system/src/Grav/Framework/Session/Messages.php @@ -50,7 +50,7 @@ class Messages implements \Serializable * @param string|null $scope * @return $this */ - public function clear(string $scope = null): Messages + public function clear(?string $scope = null): Messages { if ($scope === null) { if ($this->messages !== []) { @@ -83,7 +83,7 @@ class Messages implements \Serializable * @param string|null $scope * @return array */ - public function all(string $scope = null): array + public function all(?string $scope = null): array { if ($scope === null) { return array_values($this->messages); @@ -105,7 +105,7 @@ class Messages implements \Serializable * @param string|null $scope * @return array */ - public function fetch(string $scope = null): array + public function fetch(?string $scope = null): array { $messages = $this->all($scope); $this->clear($scope); diff --git a/system/src/Grav/Framework/Session/Session.php b/system/src/Grav/Framework/Session/Session.php index e30b03b2e..5867c1513 100644 --- a/system/src/Grav/Framework/Session/Session.php +++ b/system/src/Grav/Framework/Session/Session.php @@ -477,7 +477,7 @@ class Session implements SessionInterface * @param int|null $lifetime * @return array */ - public function getCookieOptions(int $lifetime = null): array + public function getCookieOptions(?int $lifetime = null): array { $params = session_get_cookie_params(); diff --git a/system/src/Grav/Framework/Uri/Uri.php b/system/src/Grav/Framework/Uri/Uri.php index d31937cae..a4b3060bc 100644 --- a/system/src/Grav/Framework/Uri/Uri.php +++ b/system/src/Grav/Framework/Uri/Uri.php @@ -209,7 +209,7 @@ class Uri extends AbstractUri * @return bool * @link https://tools.ietf.org/html/rfc3986#section-4.4 */ - public function isSameDocumentReference(UriInterface $base = null) + public function isSameDocumentReference(?UriInterface $base = null) { return GuzzleUri::isSameDocumentReference($this, $base); } diff --git a/system/src/Grav/Installer/VersionUpdater.php b/system/src/Grav/Installer/VersionUpdater.php index 75a3b042f..be28ebf4a 100644 --- a/system/src/Grav/Installer/VersionUpdater.php +++ b/system/src/Grav/Installer/VersionUpdater.php @@ -85,7 +85,7 @@ final class VersionUpdater * @param string|null $name * @return string|null */ - public function getExtensionVersion(string $name = null): ?string + public function getExtensionVersion(?string $name = null): ?string { return $this->versions->getVersion($name ?? $this->name); } @@ -94,7 +94,7 @@ final class VersionUpdater * @param string|null $name * @return string|null */ - public function getExtensionSchema(string $name = null): ?string + public function getExtensionSchema(?string $name = null): ?string { return $this->versions->getSchema($name ?? $this->name); } @@ -103,7 +103,7 @@ final class VersionUpdater * @param string|null $name * @return array */ - public function getExtensionHistory(string $name = null): array + public function getExtensionHistory(?string $name = null): array { return $this->versions->getHistory($name ?? $this->name); } diff --git a/system/src/Grav/Installer/Versions.php b/system/src/Grav/Installer/Versions.php index 201b9e85c..f3f4ef987 100644 --- a/system/src/Grav/Installer/Versions.php +++ b/system/src/Grav/Installer/Versions.php @@ -34,7 +34,7 @@ final class Versions * @param string|null $filename * @return self */ - public static function instance(string $filename = null): self + public static function instance(?string $filename = null): self { $filename = $filename ?? USER_DIR . 'config/versions.yaml';