From 9d58e236119bf51754b1d1dd0062c930c72423ed Mon Sep 17 00:00:00 2001 From: Paul DelRe Date: Mon, 1 Mar 2021 06:48:59 -0500 Subject: [PATCH] Fix symfony polyfills in scoper (#2998) --- packages/easy-coding-standard/scoper.inc.php | 21 ++++++++++++++++++-- phpstan.neon | 8 +++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/easy-coding-standard/scoper.inc.php b/packages/easy-coding-standard/scoper.inc.php index cbbe04a60a..afda5f2322 100644 --- a/packages/easy-coding-standard/scoper.inc.php +++ b/packages/easy-coding-standard/scoper.inc.php @@ -2,12 +2,28 @@ declare(strict_types=1); +use Isolated\Symfony\Component\Finder\Finder; + +$symfonyPolyfillPhpFilesFinder = Finder::create(); +$symfonyPolyfillPhpFilesFinder = $symfonyPolyfillPhpFilesFinder->files(); +$symfonyPolyfillPhpFilesFinder = $symfonyPolyfillPhpFilesFinder->in(__DIR__ . '/vendor/symfony/polyfill-*'); +$symfonyPolyfillPhpFilesFinder = $symfonyPolyfillPhpFilesFinder->name('*.php'); + +$symfonyPolyfillPhpFilesArray = \iterator_to_array($symfonyPolyfillPhpFilesFinder); +$symfonyPolyfillPhpFilenames = \array_values($symfonyPolyfillPhpFilesArray); +$symfonyPolyfillAllowlist = \array_map( + static function ($file) { + return $file->getPathName(); + }, + $symfonyPolyfillPhpFilenames +); + return [ 'files-whitelist' => [ - // do not prefix "trigger_deprecatoin" from symfony - https://github.com/symfony/symfony/commit/0032b2a2893d3be592d4312b7b098fb9d71aca03 + // do not prefix "trigger_deprecation" from symfony - https://github.com/symfony/symfony/commit/0032b2a2893d3be592d4312b7b098fb9d71aca03 // these paths are relative to this file location, so it should be in the root directory 'vendor/symfony/deprecation-contracts/function.php', - ], + ] + $symfonyPolyfillAllowlist, 'whitelist' => [ // needed for autoload, that is not prefixed, since it's in bin/* file 'Symplify\*', @@ -16,5 +32,6 @@ 'SlevomatCodingStandard\*', 'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', + 'Symfony\Polyfill\*', ], ]; diff --git a/phpstan.neon b/phpstan.neon index 929dc95a4e..3f7b07abd8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -474,4 +474,10 @@ parameters: - packages/set-config-resolver/src/ConfigResolver.php - packages/set-config-resolver/src/SetAwareConfigResolver.php - - '#Content of method "create\(\)" is duplicated with method "create\(\)" in "Symplify\\ConsoleColorDiff\\Diff\\Output\\CompleteUnifiedDiffOutputBuilderFactory" class\. Use unique content or service instead#' + # needed as `humbug/php-scoper` provides `Isolated\Symfony\Component\Finder\Finder` + - + message: '#Call to static method create\(\) on an unknown class Isolated\\Symfony\\Component\\Finder\\Finder#' + paths: + - packages/easy-coding-standard/scoper.inc.php + +- '#Content of method "create\(\)" is duplicated with method "create\(\)" in "Symplify\\ConsoleColorDiff\\Diff\\Output\\CompleteUnifiedDiffOutputBuilderFactory" class\. Use unique content or service instead#'