Skip to content

Commit

Permalink
make scoper work with prefixed and instanceof classes in symfony di c…
Browse files Browse the repository at this point in the history
…ompiler
  • Loading branch information
TomasVotruba committed Jun 11, 2023
1 parent d734468 commit 556e2f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
$content
),

// fix autoconfigure instanceof child to non child class magic conversion
static function (string $filePath, string $prefix, string $content): string {
if (! \str_ends_with($filePath, 'vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php')) {
return $content;
}

$content = str_replace('\'53\'', "'72'", $content);
return str_replace(", 44,", ", 63, ", $content);
},

// fix symfony deprecation reports, @see https://github.com/rectorphp/rector/issues/7434
static function (string $filePath, string $prefix, string $content): string {
if (! \str_ends_with($filePath, 'vendor/symfony/contracts/Deprecation/function.php')) {
Expand Down

1 comment on commit 556e2f2

@TomasVotruba
Copy link
Member Author

Choose a reason for hiding this comment

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

This is triyng to fix symfony magic class replacement: https://github.com/rectorphp/rector/blob/f5d1aaae419da55d6ce66a8f3dc6602ad67295b2/vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php#L96-L98

Is uses unserialize and fixed lenght of string. The prefixed classes has Rector123456\\ extra part in the name, so both lines has to be 13 lines higher.

Please sign in to comment.