[Scoper] Try fix InstalledVersions autoload in docker with env definition check (#5855)

This commit is contained in:
Abdul Malik Ikhsan 2021-03-15 01:30:02 +07:00 committed by GitHub
parent 0207942086
commit 52d94dd8d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -30,6 +30,8 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build images
env:
IMAGES: docker
run: |
DOCKER_TAGS=""

View File

@ -29,6 +29,18 @@ return [
ScoperOption::PATCHERS => [
// [BEWARE] $filePath is absolute!
// fixes https://github.com/rectorphp/rector-prefixed/runs/2103759172
// and https://github.com/rectorphp/rector-prefixed/blob/0cc433e746b645df5f905fa038573c3a1a9634f0/vendor/jean85/pretty-package-versions/src/PrettyVersions.php#L6
function (string $filePath, string $prefix, string $content): string {
if (getenv('IMAGES') !== 'docker') {
return $content;
}
// return Composer\InstalledVersions;
// see https://regex101.com/r/v8zRMm/1
return Strings::replace($content, '#' . $prefix . '\\\\Composer\\\\InstalledVersions#', 'Composer\InstalledVersions');
},
// unprefix string classes, as they're string on purpose - they have to be checked in original form, not prefixed
function (string $filePath, string $prefix, string $content): string {
// skip vendor