Commit aa832f15 authored by Wouter Wolters's avatar Wouter Wolters Committed by Christian Kuhn
Browse files

[TASK] Upgrade phpstan to latest version

composer req --dev phpstan/phpstan:^0.12.98

Resolves: #94839
Releases: master
Change-Id: I8ca57073436b695e340aae0e1fd5846e3fdc1271
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70439

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 28c1f8cc
......@@ -14,6 +14,10 @@ rules:
- PHPStan\Rules\Variables\ThrowTypeRule
- PHPStan\Rules\Variables\VariableCloningRule
conditionalTags:
PHPStan\Rules\Arrays\ArrayDestructuringRule:
phpstan.rules.rule: %featureToggles.arrayDestructuring%
parameters:
checkPhpDocMethodSignatures: true
......@@ -26,6 +30,9 @@ services:
tags:
- phpstan.rules.rule
-
class: PHPStan\Rules\Arrays\ArrayDestructuringRule
-
class: PHPStan\Rules\Arrays\InvalidKeyInArrayDimFetchRule
arguments:
......
......@@ -8,16 +8,28 @@ rules:
# - PHPStan\Rules\DeadCode\UnreachableStatementRule
- PHPStan\Rules\Exceptions\DeadCatchRule
# - PHPStan\Rules\Functions\CallToFunctionStamentWithoutSideEffectsRule
- PHPStan\Rules\Methods\CallToConstructorStatementWithoutSideEffectsRule
- PHPStan\Rules\Methods\CallToMethodStamentWithoutSideEffectsRule
- PHPStan\Rules\Methods\CallToStaticMethodStamentWithoutSideEffectsRule
- PHPStan\Rules\Methods\NullsafeMethodCallRule
- PHPStan\Rules\Properties\NullsafePropertyFetchRule
- PHPStan\Rules\TooWideTypehints\TooWideArrowFunctionReturnTypehintRule
- PHPStan\Rules\TooWideTypehints\TooWideClosureReturnTypehintRule
- PHPStan\Rules\TooWideTypehints\TooWideFunctionReturnTypehintRule
conditionalTags:
PHPStan\Rules\Exceptions\CatchWithUnthrownExceptionRule:
phpstan.rules.rule: %featureToggles.preciseExceptionTracking%
PHPStan\Rules\Exceptions\OverwrittenExitPointByFinallyRule:
phpstan.rules.rule: %featureToggles.preciseExceptionTracking%
PHPStan\Rules\DeadCode\UnusedPrivateConstantRule:
phpstan.rules.rule: %featureToggles.unusedClassElements%
PHPStan\Rules\DeadCode\UnusedPrivateMethodRule:
phpstan.rules.rule: %featureToggles.unusedClassElements%
PHPStan\Rules\DeadCode\UnusedPrivatePropertyRule:
phpstan.rules.rule: %featureToggles.unusedClassElements%
PHPStan\Rules\Variables\IssetRule:
phpstan.rules.rule: %featureToggles.nullCoalesce%
PHPStan\Rules\Variables\NullCoalesceRule:
phpstan.rules.rule: %featureToggles.nullCoalesce%
......@@ -55,6 +67,19 @@ services:
# tags:
# - phpstan.rules.rule
-
class: PHPStan\Rules\DeadCode\UnusedPrivateConstantRule
-
class: PHPStan\Rules\DeadCode\UnusedPrivateMethodRule
-
class: PHPStan\Rules\DeadCode\UnusedPrivatePropertyRule
arguments:
alwaysWrittenTags: %propertyAlwaysWrittenTags%
alwaysReadTags: %propertyAlwaysReadTags%
checkUninitializedProperties: %checkUninitializedProperties%
# -
# class: PHPStan\Rules\Comparison\ElseIfConstantConditionRule
# arguments:
......@@ -98,6 +123,13 @@ services:
tags:
- phpstan.rules.rule
-
class: PHPStan\Rules\Comparison\MatchExpressionRule
arguments:
checkAlwaysTrueStrictComparison: %checkAlwaysTrueStrictComparison%
tags:
- phpstan.rules.rule
# -
# class: PHPStan\Rules\Comparison\StrictComparisonOfDifferentTypesRule
# arguments:
......@@ -130,6 +162,12 @@ services:
# tags:
# - phpstan.rules.rule
-
class: PHPStan\Rules\Exceptions\CatchWithUnthrownExceptionRule
-
class: PHPStan\Rules\Exceptions\OverwrittenExitPointByFinallyRule
-
class: PHPStan\Rules\TooWideTypehints\TooWideMethodReturnTypehintRule
arguments:
......
......@@ -4,6 +4,8 @@ includes:
conditionalTags:
PHPStan\Rules\Functions\RandomIntParametersRule:
phpstan.rules.rule: %featureToggles.randomIntParameters%
PHPStan\Rules\DateTimeInstantiationRule:
phpstan.rules.rule: %featureToggles.dateTimeInstantiation%
parameters:
checkFunctionArgumentTypes: true
......@@ -14,3 +16,5 @@ services:
class: PHPStan\Rules\Functions\RandomIntParametersRule
arguments:
reportMaybes: %reportMaybes%
-
class: PHPStan\Rules\DateTimeInstantiationRule
......@@ -97,6 +97,16 @@ if (PHP_MAJOR_VERSION === 7) {
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
],
[
'message' => '#^Access to undefined constant ReflectionAttribute\\:\\:IS_INSTANCEOF\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/DependencyInjection/LoggerAwarePass.php',
'count' => 1
],
[
'message' => '#^Access to undefined constant ReflectionAttribute\\:\\:IS_INSTANCEOF\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/DependencyInjection/LoggerInterfacePass.php',
'count' => 2
],
];
}
......
......@@ -51,11 +51,6 @@ if (PHP_MAJOR_VERSION === 8) {
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
'count' => 1,
],
[
'message' => '#^Parameter \\#2 \\$color of function imagecolortransparent expects int\\|null, int\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
'count' => 1
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parse expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
......@@ -81,6 +76,17 @@ if (PHP_MAJOR_VERSION === 8) {
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
],
[
'message' => '#^Parameter \\#1 \\$separator of function explode expects non-empty-string, string given\\.$#',
'path' => '%currentWorkingDirectory%/',
'count' => 8
],
[
'message' => '#^Ternary operator condition is always true.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/Utility/GeneralUtility.php',
'count' => 3
],
];
}
......
......@@ -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": "18ea3bdb0b178493cdea36487bc21934",
"content-hash": "998214dd9b838926602cc1d2d5038aa9",
"packages": [
{
"name": "bacon/bacon-qr-code",
......@@ -6435,16 +6435,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.84",
"version": "0.12.98",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5"
"reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c43f15da8798c8f30a4b099e6a94530a558cfd5",
"reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3bb7cc246c057405dd5e290c3ecc62ab51d57e00",
"reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00",
"shasum": ""
},
"require": {
......@@ -6475,13 +6475,17 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.84"
"source": "https://github.com/phpstan/phpstan/tree/0.12.98"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://www.patreon.com/phpstan",
"type": "patreon"
......@@ -6491,7 +6495,7 @@
"type": "tidelift"
}
],
"time": "2021-04-19T17:10:54+00:00"
"time": "2021-09-02T12:33:01+00:00"
},
{
"name": "phpunit/php-code-coverage",
......
......@@ -28,6 +28,10 @@ parameters:
paths:
- %currentWorkingDirectory%/typo3/sysext/
earlyTerminatingMethodCalls:
TYPO3\CMS\Core\Resource\InaccessibleFolder:
- throwInaccessibleException
excludes_analyse:
- %currentWorkingDirectory%/typo3/sysext/*/Tests/*
- %currentWorkingDirectory%/typo3/sysext/*/Documentation/*
......@@ -186,22 +190,6 @@ parameters:
message: "#^Parameter \\#1 \\$node of function dom_import_simplexml expects SimpleXMLElement, SimpleXMLElement\\|false given\\.$#"
count: 1
path: typo3/sysext/frontend/Classes/ContentObject/ScalableVectorGraphicsContentObject.php
-
message: "#^Parameter \\#1 \\$(array_arg|array) of function current expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$(array_arg|array) of function key expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$(array_arg|array) of function next expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$array of function reset expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$currentRequest of static method TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Dispatcher\\:\\:buildRequestFromCurrentRequestAndForwardResponse\\(\\) expects TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Request, TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\RequestInterface given\\.$#"
count: 1
......
......@@ -33,12 +33,4 @@ abstract class AbstractTreeDataProvider
* @return \TYPO3\CMS\Backend\Tree\TreeNode
*/
abstract public function getRoot();
/**
* Fetches the subnodes of the given node
*
* @param \TYPO3\CMS\Backend\Tree\TreeNode $node
* @return \TYPO3\CMS\Backend\Tree\TreeNodeCollection
*/
abstract public function getNodes(TreeNode $node);
}
......@@ -2617,7 +2617,7 @@ class DataHandler implements LoggerAwareInterface
if ($negative) {
$value *= -1;
}
$value = number_format($value, 2, '.', '');
$value = number_format((float)$value, 2, '.', '');
break;
case 'md5':
if (strlen($value) !== 32) {
......
......@@ -927,7 +927,7 @@ class DataMapProcessor
if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['translationSource'])) {
$fieldNames['source'] = $GLOBALS['TCA'][$tableName]['ctrl']['translationSource'];
}
$fieldNamesMap = array_combine($fieldNames, $fieldNames) ?: [];
$fieldNamesMap = array_combine($fieldNames, $fieldNames);
$persistedIds = $this->filterNumericIds($ids);
$createdIds = array_diff($ids, $persistedIds);
......
......@@ -116,7 +116,7 @@ class SchemaColumnDefinitionListener
$valuesDefinition
) ?? '';
$values = explode($quoteChar . ',' . $quoteChar, substr($valuesDefinition, 1, -1)) ?: [];
$values = explode($quoteChar . ',' . $quoteChar, substr($valuesDefinition, 1, -1));
return array_map(
function (string $value) use ($quoteChar) {
......
......@@ -52,8 +52,9 @@ class DisabledFormProtection extends AbstractFormProtection
/**
* Dummy implementation
*/
protected function retrieveSessionToken()
protected function retrieveSessionToken(): string
{
return '';
}
/**
......
......@@ -62,7 +62,7 @@ class InstallToolFormProtection extends AbstractFormProtection
/**
* Retrieves or generates the session token.
*/
protected function retrieveSessionToken()
protected function retrieveSessionToken(): string
{
if (isset($_SESSION['installToolFormToken']) && !empty($_SESSION['installToolFormToken'])) {
$this->sessionToken = $_SESSION['installToolFormToken'];
......@@ -70,6 +70,7 @@ class InstallToolFormProtection extends AbstractFormProtection
$this->sessionToken = $this->generateSessionToken();
$this->persistSessionToken();
}
return $this->sessionToken;
}
/**
......
......@@ -225,8 +225,11 @@ class Rfc822AddressesParser
} elseif (isset($this->error)) {
return false;
}
if ($split_char === '') {
return false;
}
// Split the string based on the above ten or so lines.
$parts = explode($split_char, $address) ?: [];
$parts = explode($split_char, $address);
$string = $this->_splitCheck($parts, $split_char);
// If a group...
if ($is_group) {
......@@ -382,7 +385,10 @@ class Rfc822AddressesParser
*/
protected function _hasUnclosedBracketsSub($string, &$num, $char)
{
$parts = explode($char, $string) ?: [];
if ($char === '') {
return $num;
}
$parts = explode($char, $string);
$partsCounter = count($parts);
for ($i = 0; $i < $partsCounter; $i++) {
if (substr($parts[$i], -1) === '\\' || $this->_hasUnclosedQuotes($parts[$i])) {
......
......@@ -43,14 +43,15 @@ class ImageCropScaleMaskTask extends AbstractGraphicalTask
* are given, within the boundaries and don't conflict with each other.
*
* @param array $configuration
* @return bool
*/
protected function isValidConfiguration(array $configuration)
protected function isValidConfiguration(array $configuration): bool
{
// @todo Implement isValidConfiguration() method.
return true;
}
public function fileNeedsProcessing()
public function fileNeedsProcessing(): bool
{
// @todo Implement fileNeedsProcessing() method.
return false;
}
}
......@@ -46,12 +46,13 @@ class ImagePreviewTask extends AbstractGraphicalTask
*
* @param array $configuration
*/
protected function isValidConfiguration(array $configuration)
protected function isValidConfiguration(array $configuration): bool
{
/**
* Checks to perform:
* - width and/or height given, integer values?
*/
return true;
}
/**
......@@ -61,7 +62,7 @@ class ImagePreviewTask extends AbstractGraphicalTask
* This check is done in ProcessedFile::isOutdated().
* @todo isOutdated()/needsReprocessing()?
*/
public function fileNeedsProcessing()
public function fileNeedsProcessing(): bool
{
// @todo Implement fileNeedsProcessing() method.
......@@ -69,5 +70,6 @@ class ImagePreviewTask extends AbstractGraphicalTask
* Checks to perform:
* - width/height smaller than image, keeping aspect ratio?
*/
return false;
}
}
......@@ -206,7 +206,7 @@ class PasswordRecoveryController extends AbstractLoginFormController
* @param string $newPass
* @param string $hash
*
* @return ResponseInterface|string|ForwardResponse
* @return ResponseInterface|string|ForwardResponse|null
*
* @throws StopActionException
* @throws AspectNotFoundException
......
......@@ -1285,11 +1285,10 @@ class SearchController extends ActionController
{
$allOptions = [];
if (count($this->availableResultsNumbers) > 1) {
$allOptions = array_combine($this->availableResultsNumbers, $this->availableResultsNumbers) ?: [];
$allOptions = array_combine($this->availableResultsNumbers, $this->availableResultsNumbers);
}
// disable single entries by TypoScript
$allOptions = $this->removeOptionsFromOptionList($allOptions, $this->settings['blind']['numberOfResults']);
return $allOptions;
return $this->removeOptionsFromOptionList((array)$allOptions, $this->settings['blind']['numberOfResults']);
}
/**
......
......@@ -664,7 +664,7 @@ class RecordListController
$languageService = $this->getLanguageService();
if (isset($arguments['table'])) {
$tableTitle = ': ' . $languageService->sL($GLOBALS['TCA'][$arguments['table']]['ctrl']['title'] ?? '') ?: $arguments['table'];
$tableTitle = ': ' . (isset($GLOBALS['TCA'][$arguments['table']]['ctrl']['title']) ? $languageService->sL($GLOBALS['TCA'][$arguments['table']]['ctrl']['title']) : $arguments['table']);
}
if ($this->pageInfo !== []) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment