fixes for PHP 8.4 - Implicitly nullable parameter declarations deprecated

This commit is contained in:
Andy Miller
2024-10-25 18:20:41 +01:00
parent 46736ce256
commit 85c4b8279e
117 changed files with 353 additions and 293 deletions

View File

@@ -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": [
{

63
composer.lock generated
View File

@@ -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"
},

View File

@@ -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();

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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...');

View File

@@ -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);

View File

@@ -766,7 +766,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
* @return static
* @phpstan-return static<T>
*/
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);
}

View File

@@ -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<T,C>
*/
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<T,C>
*/
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;

View File

@@ -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);

View File

@@ -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();

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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'];

View File

@@ -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();

View File

@@ -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.)');

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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)) {

View File

@@ -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'];

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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') {

View File

@@ -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)) {

View File

@@ -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'] ?? [];

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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;

View File

@@ -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 ?? []);
}

View File

@@ -551,14 +551,14 @@ abstract class AbstractIndexCollection implements CollectionInterface
* @return array
* @phpstan-return array<TKey,T>
*/
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

View File

@@ -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'];

View File

@@ -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<T>

View File

@@ -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<T> $identifiers

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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',

View File

@@ -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);
}

View File

@@ -94,7 +94,7 @@ class Flex implements FlexInterface
* @param bool $keepMissing
* @return array<FlexDirectory|null>
*/
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<FlexObjectInterface>|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;

View File

@@ -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<T>
*/
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);

View File

@@ -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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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);

View File

@@ -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 '';
}

View File

@@ -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 */

View File

@@ -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<T,C>
*/
protected function createFrom(array $entries, string $keyField = null)
protected function createFrom(array $entries, ?string $keyField = null)
{
/** @phpstan-var static<T,C> $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);

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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<T>
* @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<T>
* @api
*/
public function withKeyField(string $keyField = null);
public function withKeyField(?string $keyField = null);
/**
* Get Flex Index from the Flex Collection.

View File

@@ -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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
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<FlexObjectInterface>
*/
public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface;
public function loadCollection(array $entries, ?string $keyField = null): FlexCollectionInterface;
/**
* @param array $entries

View File

@@ -54,11 +54,11 @@ interface FlexIndexInterface extends FlexCollectionInterface
* @phpstan-return static<T>
* @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);
}

View File

@@ -46,7 +46,7 @@ interface FlexInterface extends Countable
* @param bool $keepMissing
* @return array<FlexDirectory|null>
*/
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<FlexObjectInterface>|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

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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:

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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;

View File

@@ -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');

View File

@@ -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.

View File

@@ -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

View File

@@ -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';

View File

@@ -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 = []);
}

View File

@@ -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) {

View File

@@ -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);

Some files were not shown because too many files have changed in this diff Show More