Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Fix symfony polyfills in scoper #2998

Merged
Show file tree
Hide file tree
Changes from 5 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
21 changes: 19 additions & 2 deletions packages/easy-coding-standard/scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\*',
Expand All @@ -16,5 +32,6 @@
'SlevomatCodingStandard\*',
'Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator',
'Symfony\Component\DependencyInjection\Extension\ExtensionInterface',
'Symfony\Polyfill\*',
],
];
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,9 @@ parameters:
- packages/git-wrapper/src
- packages/set-config-resolver/src/ConfigResolver.php
- packages/set-config-resolver/src/SetAwareConfigResolver.php

# needed as `humbug/php-scoper` provides `Isolated\Symfony\Component\Finder\Finder`
Copy link
Contributor Author

@pdelre pdelre Feb 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I've taken a liberty here, but I was unable to find a way to address humbug/php-scoper's expected Isolated\Symfony\Component\Finder\Finder usage.

-
message: '#Call to static method create\(\) on an unknown class Isolated\\Symfony\\Component\\Finder\\Finder#'
paths:
- packages/easy-coding-standard/scoper.inc.php