Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Correctly mark nullable method parameters as nullable #3427

Open
wants to merge 1 commit into
base: 8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/AbstractBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -61,7 +62,7 @@ abstract class AbstractBackend implements BackendInterface
* @param array $options Configuration options - depends on the actual backend
* @api
*/
public function __construct(EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
public function __construct(?EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
{
$this->environmentConfiguration = $environmentConfiguration;

Expand Down Expand Up @@ -144,7 +145,7 @@ public function setDefaultLifetime($defaultLifetime): void
* @param integer $lifetime The lifetime in seconds
* @return \DateTime The expiry time
*/
protected function calculateExpiryTime(int $lifetime = null): \DateTime
protected function calculateExpiryTime(?int $lifetime = null): \DateTime
{
if ($lifetime === self::UNLIMITED_LIFETIME || ($lifetime === null && $this->defaultLifetime === self::UNLIMITED_LIFETIME)) {
return new \DateTime(self::DATETIME_EXPIRYTIME_UNLIMITED, new \DateTimeZone('UTC'));
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Backend/ApcuBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -117,7 +118,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string
* @throws \InvalidArgumentException if the identifier is not valid
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if (!$this->cache instanceof FrontendInterface) {
throw new Exception('No cache frontend has been set yet via setCache().', 1232986818);
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Backend/BackendInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string;
* @throws \InvalidArgumentException if the identifier is not valid
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void;
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void;

/**
* Loads data from the cache.
Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/FileBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -148,7 +149,7 @@ public function setCache(FrontendInterface $cache): void
* @throws \InvalidArgumentException
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
Expand Down Expand Up @@ -476,6 +477,6 @@ protected function getEntryIdentifierFromFilename(string $filename): string
{
$cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);

return $cacheEntryFileExtensionLength === 0 ? $filename : substr($filename, 0, - strlen($this->cacheEntryFileExtension));
return $cacheEntryFileExtensionLength === 0 ? $filename : substr($filename, 0, -strlen($this->cacheEntryFileExtension));
}
}
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Backend/MemcachedBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -199,7 +200,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string
* @throws \InvalidArgumentException if the identifier is not valid or the final memcached key is longer than 250 characters
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if (strlen($this->getPrefixedIdentifier($entryIdentifier)) > 250) {
throw new \InvalidArgumentException('Could not set value. Key more than 250 characters (' . $this->getPrefixedIdentifier($entryIdentifier) . ').', 1232969508);
Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/MultiBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -41,7 +42,7 @@ class MultiBackend extends AbstractBackend
protected ?LoggerInterface $logger = null;
protected ?ThrowableStorageInterface $throwableStorage = null;

public function __construct(EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
public function __construct(?EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
{
parent::__construct($environmentConfiguration, $options);

Expand Down Expand Up @@ -96,7 +97,7 @@ protected function buildSubBackend(string $backendClassName, array $backendOptio
/**
* @throws Throwable
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
$this->prepareBackends();
foreach ($this->backends as $backend) {
Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/NullBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -31,7 +32,7 @@ class NullBackend extends AbstractCacheBackend implements PhpCapableBackendInter
* @param mixed $propertyValue
* @return boolean TRUE
*/
protected function setProperty(string $propertyName, $propertyValue) : bool
protected function setProperty(string $propertyName, $propertyValue): bool
{
return true;
}
Expand All @@ -46,7 +47,7 @@ protected function setProperty(string $propertyName, $propertyValue) : bool
* @return void
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
}

Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/PdoBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -182,7 +183,7 @@ protected function setBatchSize(int $batchSize): void
* @throws FilesException
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
$this->connect();

Expand Down Expand Up @@ -406,7 +407,7 @@ public function flushByTags(array $tags): int
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier" FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag" IN (' . $tagPlaceholders . ')');
$statementHandle->execute(array_merge([$this->context(), $this->cacheIdentifier], $tagList));
$result = $statementHandle->fetchAll();
$identifiers[]= array_column($result, 'identifier');
$identifiers[] = array_column($result, 'identifier');
}
$identifiers = array_merge([], ...$identifiers);

Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/RedisBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -109,7 +110,7 @@ public function __construct(EnvironmentConfiguration $environmentConfiguration,
* @throws CacheException
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if ($this->isFrozen()) {
throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
Expand Down Expand Up @@ -493,7 +494,7 @@ public function setBatchSize(int|string $batchSize): void
$this->batchSize = (int)$batchSize;
}

public function setRedis(\Redis $redis = null): void
public function setRedis(?\Redis $redis = null): void
{
if ($redis !== null) {
$this->redis = $redis;
Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/SimpleFileBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -145,7 +146,7 @@ public function getCacheDirectory(): string
* @throws \InvalidArgumentException
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
Expand Down Expand Up @@ -493,7 +494,7 @@ protected function verifyCacheDirectory(): void
* @param int|null $maxlen
* @return string|false The contents of the cache file or false on error
*/
protected function readCacheFile(string $cacheEntryPathAndFilename, int $offset = 0, int $maxlen = null)
protected function readCacheFile(string $cacheEntryPathAndFilename, int $offset = 0, ?int $maxlen = null)
{
for ($i = 0; $i < 3; $i++) {
$data = false;
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Backend/TransientMemoryBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Backend;
Expand Down Expand Up @@ -45,7 +46,7 @@ class TransientMemoryBackend extends IndependentAbstractBackend implements Tagga
* @throws Exception if no cache frontend has been set.
* @api
*/
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null): void
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
if (!$this->cache instanceof FrontendInterface) {
throw new Exception('No cache frontend has been set yet via setCache().', 1238244992);
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Frontend/FrontendInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Frontend;
Expand Down Expand Up @@ -56,7 +57,7 @@ public function getBackend();
* @return void
* @api
*/
public function set(string $entryIdentifier, $data, array $tags = [], int $lifetime = null);
public function set(string $entryIdentifier, $data, array $tags = [], ?int $lifetime = null);

/**
* Finds and returns data from the cache.
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Frontend/PhpFrontend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Frontend;
Expand Down Expand Up @@ -92,7 +93,7 @@ public function getWrapped(string $entryIdentifier)
* @throws \Neos\Cache\Exception
* @api
*/
public function set(string $entryIdentifier, $sourceCode, array $tags = [], int $lifetime = null)
public function set(string $entryIdentifier, $sourceCode, array $tags = [], ?int $lifetime = null)
{
if (!$this->isValidEntryIdentifier($entryIdentifier)) {
throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1264023823);
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Frontend/StringFrontend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Frontend;
Expand Down Expand Up @@ -37,7 +38,7 @@ class StringFrontend extends AbstractFrontend
* @throws \Neos\Cache\Exception
* @api
*/
public function set(string $entryIdentifier, $string, array $tags = [], int $lifetime = null)
public function set(string $entryIdentifier, $string, array $tags = [], ?int $lifetime = null)
{
if (!$this->isValidEntryIdentifier($entryIdentifier)) {
throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057566);
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Classes/Frontend/VariableFrontend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Frontend;
Expand Down Expand Up @@ -56,7 +57,7 @@ public function initializeObject()
* @throws \Neos\Cache\Exception
* @api
*/
public function set(string $entryIdentifier, $variable, array $tags = [], int $lifetime = null)
public function set(string $entryIdentifier, $variable, array $tags = [], ?int $lifetime = null)
{
if (!$this->isValidEntryIdentifier($entryIdentifier)) {
throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058264);
Expand Down
1 change: 1 addition & 0 deletions Neos.Cache/Classes/Psr/SimpleCache/SimpleCache.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Neos\Cache\Psr\SimpleCache;
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Tests/Unit/Backend/AbstractBackendTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Neos\Cache\Tests\Unit\Backend;

include_once(__DIR__ . '/../../BaseTestCase.php');
Expand Down Expand Up @@ -37,7 +38,7 @@ class_exists(AbstractBackend::class);
$className = 'ConcreteBackend_' . md5(uniqid(mt_rand(), true));
eval('
class ' . $className . ' extends \Neos\Cache\Backend\AbstractBackend {
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = NULL): void {}
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = NULL): void {}
public function get(string $entryIdentifier): string {}
public function has(string $entryIdentifier): bool {}
public function remove(string $entryIdentifier): bool {}
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Tests/Unit/Backend/SimpleFileBackendTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Neos\Cache\Tests\Unit\Backend;

include_once(__DIR__ . '/../../BaseTestCase.php');
Expand Down Expand Up @@ -61,7 +62,7 @@ protected function setUp(): void
* @param FrontendInterface $mockCacheFrontend
* @return SimpleFileBackend
*/
protected function getSimpleFileBackend(array $options = [], FrontendInterface $mockCacheFrontend = null)
protected function getSimpleFileBackend(array $options = [], ?FrontendInterface $mockCacheFrontend = null)
{
$simpleFileBackend = new SimpleFileBackend($this->mockEnvironmentConfiguration, $options);

Expand Down
2 changes: 1 addition & 1 deletion Neos.Eel/Classes/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function reduce(iterable $array, callable $callback, $initialValue = null
* @param callable $callback Callback for testing if an element should be included in the result, current value and key will be passed as arguments
* @return array The array with elements where callback returned true
*/
public function filter(iterable $array, callable $callback = null): array
public function filter(iterable $array, ?callable $callback = null): array
{
if ($array instanceof \Traversable) {
$array = iterator_to_array($array);
Expand Down
Loading
Loading