Skip to content

Commit

Permalink
Merge pull request #3261 from mhsdesign/task/phpStanLevel3
Browse files Browse the repository at this point in the history
TASK: *PLING PLING* phpstan level 3
  • Loading branch information
mhsdesign authored Mar 5, 2024
2 parents 5b8bcba + 9766acc commit f42c75f
Show file tree
Hide file tree
Showing 97 changed files with 161 additions and 148 deletions.
2 changes: 1 addition & 1 deletion Neos.Cache/Classes/Backend/BackendInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string;
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
* @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @param integer|null $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws \Neos\Cache\Exception if no cache frontend has been set.
* @throws \InvalidArgumentException if the identifier is not valid
Expand Down
2 changes: 1 addition & 1 deletion Neos.Cache/Classes/Backend/FileBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FileBackend extends SimpleFileBackend implements PhpCapableBackendInterfac
protected $cacheEntryFileExtension = '';

/**
* @var array
* @var array<string>
*/
protected $cacheEntryIdentifiers = [];

Expand Down
4 changes: 2 additions & 2 deletions Neos.Cache/Classes/Psr/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CacheItem implements CacheItemInterface


/**
* @var \DateTime|null
* @var \DateTimeInterface|null
*/
protected $expirationDate;

Expand Down Expand Up @@ -127,7 +127,7 @@ public function expiresAfter(int|\DateInterval|null $time): static
}

/**
* @return \DateTime|null
* @return \DateTimeInterface|null
*/
public function getExpirationDate()
{
Expand Down
8 changes: 4 additions & 4 deletions Neos.Eel/Classes/FlowQuery/FlowQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ public function setOperationResolver(OperationResolverInterface $operationResolv
}

/**
* Add a new operation to the operation list and return the new FlowQuery
* object. If the operation is final, we directly compute the result and
* return the value.
* Add a new operation to the operation list and return the new FlowQuery object.
*
* If the operation is final, we directly compute the result and return the value.
*
* @param string $operationName
* @param array $arguments
* @return FlowQuery
* @return FlowQuery|mixed
*/
public function __call($operationName, array $arguments)
{
Expand Down
2 changes: 1 addition & 1 deletion Neos.Eel/Classes/FlowQuery/OperationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function canEvaluate($context);
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation
* @return mixed|null if the operation is final, the return value
* @return mixed if the operation is final, the return value
*/
public function evaluate(FlowQuery $flowQuery, array $arguments);
}
3 changes: 2 additions & 1 deletion Neos.Eel/Classes/FlowQuery/Operations/IsOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IsOperation extends AbstractOperation
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the filter arguments
* @return void|boolean
* @return mixed
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
Expand All @@ -49,6 +49,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
} else {
$flowQuery->pushOperation('is', []);
$flowQuery->pushOperation('filter', $arguments);
return null;
}
}
}
2 changes: 1 addition & 1 deletion Neos.Eel/Classes/Helper/MathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public function round($subject, $precision = 0)
* Get the sign of the given number, indicating whether the number is positive, negative or zero
*
* @param integer|float $x The value
* @return integer -1, 0, 1 depending on the sign or NAN if the given value was not numeric
* @return integer|float -1, 0, 1 depending on the sign or NAN if the given value was not numeric
*/
public function sign($x)
{
Expand Down
9 changes: 5 additions & 4 deletions Neos.Error.Messages/Classes/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function hasMessages(): bool
* where the key is the property path where the error occurred, and the
* value is a list of all errors (stored as array)
*
* @return array<Error>
* @return array<string, array<int, Error>>
* @api
*/
public function getFlattenedErrors(): array
Expand All @@ -361,7 +361,7 @@ public function getFlattenedErrors(): array
* value is a list of all errors (stored as array)
*
* @param string $type
* @return array<Error>
* @return array<string, array<int, Error>>
* @api
*/
public function getFlattenedErrorsOfType(string $type): array
Expand All @@ -376,7 +376,7 @@ public function getFlattenedErrorsOfType(string $type): array
* where the key is the property path where the warning occurred, and the
* value is a list of all warnings (stored as array)
*
* @return array<Warning>
* @return array<string, array<int, Warning>>
* @api
*/
public function getFlattenedWarnings(): array
Expand All @@ -391,7 +391,7 @@ public function getFlattenedWarnings(): array
* where the key is the property path where the notice occurred, and the
* value is a list of all notices (stored as array)
*
* @return array<Notice>
* @return array<string, array<int, Notice>>
* @api
*/
public function getFlattenedNotices(): array
Expand All @@ -408,6 +408,7 @@ public function getFlattenedNotices(): array
* @param array $result The current result to be flattened
* @param array $level The property path in the format array('level1', 'level2', ...) for recursion
* @param string $messageTypeFilter If specified only messages implementing the given class name are taken into account
* @param-out array<string, array<int, mixed>> $result
* @return void
*/
public function flattenTree(string $propertyName, array &$result, array $level = [], string $messageTypeFilter = null)
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow.Log/Classes/PlainTextFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function format($spaces = 4)
* @param mixed $var The variable
* @param integer $spaces Indent for this var dump
* @param int $continuationSpaces Running total indentation (INTERNAL)
* @return string text output
* @return string|null text output
*/
protected function renderVariableAsPlaintext($var, $spaces = 4, $continuationSpaces = 0)
{
Expand Down
5 changes: 2 additions & 3 deletions Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* source code.
*/

use Neos\Cache\Frontend\StringFrontend;
use Neos\Cache\Frontend\FrontendInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\Cache\CacheManager;
Expand All @@ -28,7 +28,7 @@
class RuntimeExpressionEvaluator
{
/**
* @var StringFrontend
* @var FrontendInterface
*/
protected $runtimeExpressionsCache;

Expand All @@ -54,7 +54,6 @@ public function injectObjectManager(ObjectManagerInterface $objectManager): void
{
if ($this->objectManager === null) {
$this->objectManager = $objectManager;
/** @var CacheManager $cacheManager */
$cacheManager = $this->objectManager->get(CacheManager::class);
$this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
}
Expand Down
8 changes: 4 additions & 4 deletions Neos.Flow/Classes/Cli/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
class ConsoleOutput
{
/**
* @var SymfonyConsoleOutput
* @var OutputInterface
*/
protected $output;

/**
* @var SymfonyStringInput
* @var InputInterface
*/
protected $input;

Expand Down Expand Up @@ -158,7 +158,7 @@ public function outputTable(array $rows, array $headers = null, string $headerTi
*
* @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question
* @param array $choices List of choices to pick from
* @param mixed|null $default The default answer if the user enters nothing
* @param string|bool|int|float|null $default The default answer if the user enters nothing
* @param boolean $multiSelect If true the result will be an array with the selected options. Multiple options can be given separated by commas
* @param integer|null $attempts Max number of times to ask before giving up (null by default, which means infinite)
* @return integer|string|array Either the value for indexed arrays, the key for associative arrays or an array for multiple selections
Expand Down Expand Up @@ -291,7 +291,7 @@ public function askHiddenResponseAndValidate($question, callable $validator, int
/**
* Starts the progress output
*
* @param integer $max Maximum steps. If NULL an indeterminate progress bar is rendered
* @param integer|null $max Maximum steps. If NULL an indeterminate progress bar is rendered
* @return void
*/
public function progressStart(int $max = null): void
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Cli/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Request
protected $controllerCommandName = 'default';

/**
* @var Command
* @var Command|null
*/
protected $command;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Cli/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Response
private $content = '';

/**
* @var bool|null
* @var bool|null true, false or NULL (= autodetection)
*/
private $colorSupport;

Expand Down
3 changes: 1 addition & 2 deletions Neos.Flow/Classes/Command/CacheCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Core\LockManager;
use Neos\Flow\Mvc\Exception\StopActionException;
use Neos\Flow\ObjectManagement\ObjectManager;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use Neos\Flow\Package\PackageManager;
use Neos\Flow\Utility\Environment;
Expand Down Expand Up @@ -61,7 +60,7 @@ class CacheCommandController extends CommandController
protected $bootstrap;

/**
* @var ObjectManager
* @var ObjectManagerInterface
*/
protected $objectManager;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Command/RoutingCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function listCommand(): void
*/
public function showCommand(int $index): void
{
$route = $this->routesProvider->getRoutes()[$index - 1] ?? null;
$route = iterator_to_array($this->routesProvider->getRoutes())[$index - 1] ?? null;
if ($route === null) {
$this->outputLine('<error>Route %d was not found!</error>', [$index]);
$this->outputLine('Run <i>./flow routing:list</i> to show all registered routes');
Expand Down
4 changes: 2 additions & 2 deletions Neos.Flow/Classes/Command/SecurityCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* source code.
*/

use Neos\Cache\Frontend\FrontendInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cache\CacheManager;
use Neos\Cache\Frontend\VariableFrontend;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\Configuration\Exception\InvalidConfigurationTypeException;
use Neos\Flow\Mvc\Controller\AbstractController;
Expand Down Expand Up @@ -60,7 +60,7 @@ class SecurityCommandController extends CommandController
protected $policyService;

/**
* @var VariableFrontend
* @var FrontendInterface
*/
protected $methodPermissionCache;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Http/ContentStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class ContentStream implements StreamInterface
{
/**
* @var resource
* @var resource|null
*/
protected $resource;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Http/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function __construct($name, $value = null, $expires = 0, $maximumAge = nu
* rather than the created cookie.
*
* @param string $header The Set-Cookie string without the actual "Set-Cookie:" part
* @return Cookie
* @return Cookie|null
* @see http://tools.ietf.org/html/rfc6265
*/
public static function createFromRawSetCookieHeader($header)
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Http/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getRaw(string $name): array
* Dates are returned as DateTime objects with the timezone set to GMT.
*
* @param string $name Name of the header, for example "Location", "Content-Description" etc.
* @return array|string An array of field values if multiple headers of that name exist, a string value if only one value exists and NULL if there is no such header.
* @return array|string|null An array of field values if multiple headers of that name exist, a string value if only one value exists and NULL if there is no such header.
* @api
*/
public function get($name)
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/I18n/Cldr/CldrRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function injectLocalizationService(I18n\Service $localizationService)
* file.
*
* @param string $filename Relative (from CLDR root) path to existing CLDR file
* @return CldrModel|boolean A CldrModel instance or false on failure
* @return CldrModel|false A CldrModel instance or false on failure
*/
public function getModel($filename)
{
Expand Down
4 changes: 2 additions & 2 deletions Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ protected function doFormattingForSubpattern(\DateTimeInterface $dateTime, $subf
case 'd':
return $this->padString($dateTime->format('j'), $formatLengthOfSubformat);
case 'D':
return $this->padString((int)($dateTime->format('z') + 1), $formatLengthOfSubformat);
return $this->padString(((int)$dateTime->format('z') + 1), $formatLengthOfSubformat);
case 'F':
return (int)(($dateTime->format('j') + 6) / 7);
return (string)(int)(((int)$dateTime->format('j') + 6) / 7);
case 'M':
case 'L':
$month = (int)$dateTime->format('n');
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/I18n/LocaleTypeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class LocaleTypeConverter extends AbstractTypeConverter
{
/**
* @var string
* @var array<string>
*/
protected $sourceTypes = ['string'];

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/I18n/Parser/DatetimeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function doParsingWithParsedFormat($datetimeToParse, array $parsedForm
* @param string $datetimeToParse Date/time to be parsed
* @param array $parsedFormat Format parsed by DatesReader
* @param array $localizedLiterals Array of date / time literals from CLDR
* @return array Array of parsed date and / or time elements, false on failure
* @return array|false Array of parsed date and / or time elements, false on failure
* @throws InvalidArgumentException When unexpected symbol found in format
* @see DatesReader
*/
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Log/PsrLoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function get(string $identifier): \Psr\Log\LoggerInterface
* Create a new instance of this PsrLoggerFactory
*
* @param array $configuration
* @return static
* @return PsrLoggerFactory
* @api
*/
public static function create(array $configuration): PsrLoggerFactory
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Monitor/FileMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FileMonitor
/**
* Array of directories and files that were cached on the last run.
*
* @var array
* @var array|null
*/
protected $directoriesAndFiles = null;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Mvc/Controller/Argument.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Argument

/**
* Actual value of this argument
* @var object
* @var object|null
*/
protected $value = null;

Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Mvc/Controller/Arguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function __call($methodName, array $arguments)
* string is returned.
*
* @param string $argumentName argument name
* @return string long argument name or empty string
* @return string|false long argument name or empty string
*/
protected function validateArgumentExistence($argumentName)
{
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Mvc/Routing/DynamicRoutePart.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ final public function resolveWithParameters(array &$routeValues, RouteParameters
* This method can be overridden by custom RoutePartHandlers to implement custom resolving mechanisms.
*
* @param array $routeValues An array with key/value pairs to be resolved by Dynamic Route Parts.
* @return string|array value to resolve.
* @return string|array|null value to resolve.
* @api
*/
protected function findValueToResolve(array $routeValues)
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Mvc/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Route
* Contains the routing results (indexed by "package", "controller" and
* "action") after a successful call of matches()
*
* @var array
* @var array|null
*/
protected $matchResults = [];

Expand Down
Loading

0 comments on commit f42c75f

Please sign in to comment.