diff --git a/composer.json b/composer.json index 83863d1cca12c..bf01b9bf966cd 100644 --- a/composer.json +++ b/composer.json @@ -94,7 +94,7 @@ "pdepend/pdepend": "~2.7.1", "phpcompatibility/php-compatibility": "^9.3", "phpmd/phpmd": "^2.8.0", - "phpstan/phpstan": "^0.12.3", + "phpstan/phpstan": "^0.12.77", "phpunit/phpunit": "^9", "sebastian/phpcpd": "~5.0.0", "squizlabs/php_codesniffer": "~3.5.4" diff --git a/composer.lock b/composer.lock index fcac88f57ca29..7c55f61fa5f74 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "67df124b58eb4b4739a5ce279b8890de", + "content-hash": "29aafca383e30f1694b328f024116caf", "packages": [ { "name": "aws/aws-sdk-php", @@ -9604,16 +9604,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.76", + "version": "0.12.77", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7aaaf9a759a29795e8f46d48041af1c1f1b23d38" + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7aaaf9a759a29795e8f46d48041af1c1f1b23d38", - "reference": "7aaaf9a759a29795e8f46d48041af1c1f1b23d38", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1f10b8c8d118d01e7b492f9707999d456be5812c", + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c", "shasum": "" }, "require": { @@ -9656,7 +9656,7 @@ "type": "tidelift" } ], - "time": "2021-02-13T11:47:44+00:00" + "time": "2021-02-17T16:22:19+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/dev/tests/static/framework/Magento/PhpStan/Formatters/FilteredErrorFormatter.php b/dev/tests/static/framework/Magento/PhpStan/Formatters/FilteredErrorFormatter.php index 3da08f324d761..dc27b019f4c55 100644 --- a/dev/tests/static/framework/Magento/PhpStan/Formatters/FilteredErrorFormatter.php +++ b/dev/tests/static/framework/Magento/PhpStan/Formatters/FilteredErrorFormatter.php @@ -9,6 +9,7 @@ use PHPStan\Command\AnalysisResult; use PHPStan\Command\ErrorFormatter\TableErrorFormatter; +use PHPStan\Command\ErrorFormatter\ErrorFormatter; use PHPStan\Command\Output; /** @@ -37,37 +38,45 @@ * * @see \Magento\PhpStan\Formatters\Fixtures\ClassWithIgnoreAnnotation */ -class FilteredErrorFormatter extends TableErrorFormatter +class FilteredErrorFormatter implements ErrorFormatter { private const MUTE_ERROR_ANNOTATION = 'phpstan:ignore'; - private const NO_ERRORS = 0; + /** + * @var TableErrorFormatter + */ + private $tableErrorFormatter; + + /** + * @param TableErrorFormatter $tableErrorFormatter + */ + public function __construct(TableErrorFormatter $tableErrorFormatter) + { + $this->tableErrorFormatter = $tableErrorFormatter; + } + /** * @inheritdoc */ public function formatErrors(AnalysisResult $analysisResult, Output $output): int { if (!$analysisResult->hasErrors()) { - $style = $output->getStyle(); - $style->success('No errors'); + $output->getStyle()->success('No errors'); return self::NO_ERRORS; } - $fileSpecificErrorsWithoutIgnoredErrors = $this->clearIgnoredErrors( - $analysisResult->getFileSpecificErrors() - ); - $clearedAnalysisResult = new AnalysisResult( - $fileSpecificErrorsWithoutIgnoredErrors, + $this->clearIgnoredErrors($analysisResult->getFileSpecificErrors()), $analysisResult->getNotFileSpecificErrors(), + $analysisResult->getInternalErrors(), $analysisResult->getWarnings(), $analysisResult->isDefaultLevelUsed(), - $analysisResult->hasInferrablePropertyTypesFromConstructor(), - $analysisResult->getProjectConfigFile() + $analysisResult->getProjectConfigFile(), + $analysisResult->isResultCacheSaved() ); - return parent::formatErrors($clearedAnalysisResult, $output); + return $this->tableErrorFormatter->formatErrors($clearedAnalysisResult, $output); } /** diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon index 0bdb5861dbf33..aba7d0b46d297 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon @@ -9,11 +9,11 @@ parameters: - %rootDir%/../../../dev/tests/*/tmp/* - %rootDir%/../../../dev/tests/*/_generated/* - %rootDir%/../../../pub/* - autoload_directories: + scanDirectories: - %rootDir%/../../../dev/tests/static/framework/tests/unit/testsuite/Magento - %rootDir%/../../../dev/tests/integration/framework/tests/unit/testsuite/Magento - %rootDir%/../../../dev/tests/api-functional/_files/Magento - autoload_files: + bootstrapFiles: - %rootDir%/../../../dev/tests/static/framework/autoload.php - %rootDir%/../../../dev/tests/integration/framework/autoload.php - %rootDir%/../../../dev/tests/api-functional/framework/autoload.php @@ -46,7 +46,4 @@ services: errorFormatter.filtered: class: Magento\PhpStan\Formatters\FilteredErrorFormatter arguments: - showTipsOfTheDay: false - checkThisOnly: false - inferPrivatePropertyTypeFromConstructor: true - checkMissingTypehints: %checkMissingTypehints% + tableErrorFormatter: @errorFormatter.table