From d62c1e81864936ee77b5d4878c1e6a3427a760ed Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Sat, 2 Mar 2024 13:24:04 +0000 Subject: [PATCH 1/2] GH-2538: Disable the include walker --- .../Core/Inference/Walker/IncludeWalker.php | 4 ++++ lib/WorseReflection/Core/ServiceLocator.php | 12 +----------- lib/WorseReflection/Tests/Inference/SelfTest.php | 9 +++++++++ .../Core/Inference/FrameWalker/IncludeWalkerTest.php | 3 +++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/WorseReflection/Core/Inference/Walker/IncludeWalker.php b/lib/WorseReflection/Core/Inference/Walker/IncludeWalker.php index f9b3f1f9d8..093e49b7fc 100644 --- a/lib/WorseReflection/Core/Inference/Walker/IncludeWalker.php +++ b/lib/WorseReflection/Core/Inference/Walker/IncludeWalker.php @@ -17,6 +17,10 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Filesystem\Path; +/** + * This walker doesn't seem to work properly, and in addition it can cause massive performance + * problems on legacy projects that use lots of `includes`. + */ class IncludeWalker implements Walker { private Parser $parser; diff --git a/lib/WorseReflection/Core/ServiceLocator.php b/lib/WorseReflection/Core/ServiceLocator.php index ca16810efd..aac7fa52f0 100644 --- a/lib/WorseReflection/Core/ServiceLocator.php +++ b/lib/WorseReflection/Core/ServiceLocator.php @@ -61,7 +61,7 @@ public function __construct( private array $memberContextResolvers, Cache $cache, private CacheForDocument $cacheForDocument, - bool $enableContextualLocation = false + bool $enableContextualLocation = false, ) { $sourceReflector = $reflectorFactory->create($this); @@ -148,16 +148,6 @@ public function frameBuilder(): FrameResolver new FunctionLikeWalker(), new PassThroughWalker(), new VariableWalker($this->docblockFactory), - - // enable subset of frame walkers to enable include variables - // to be merged into current frame - new IncludeWalker($this->logger, FrameResolver::create( - $this->nodeContextResolver(), - [ - new VariableWalker($this->docblockFactory), - new PassThroughWalker(), - ] - )), ], $this->frameWalkers), ); } diff --git a/lib/WorseReflection/Tests/Inference/SelfTest.php b/lib/WorseReflection/Tests/Inference/SelfTest.php index 56dbd26bd6..6ad0a31c4d 100644 --- a/lib/WorseReflection/Tests/Inference/SelfTest.php +++ b/lib/WorseReflection/Tests/Inference/SelfTest.php @@ -8,6 +8,12 @@ class SelfTest extends IntegrationTestCase { + public const DISABLED_TESTS = [ + // disabling the includeWalker because it barely works + // and it causes severe performance issues. + 'require_and_include', + ]; + /** * @dataProvider provideSelf */ @@ -29,6 +35,9 @@ public function provideSelf(): Generator { foreach ((array)glob(__DIR__ . '/*/*.test') as $fname) { $dirName = basename(dirname((string)$fname)); + if (in_array($dirName, self::DISABLED_TESTS)) { + continue; + } yield $dirName .' ' . basename((string)$fname) => [ $fname ]; diff --git a/lib/WorseReflection/Tests/Integration/Core/Inference/FrameWalker/IncludeWalkerTest.php b/lib/WorseReflection/Tests/Integration/Core/Inference/FrameWalker/IncludeWalkerTest.php index b04bb4bb96..bb5993ccb7 100644 --- a/lib/WorseReflection/Tests/Integration/Core/Inference/FrameWalker/IncludeWalkerTest.php +++ b/lib/WorseReflection/Tests/Integration/Core/Inference/FrameWalker/IncludeWalkerTest.php @@ -18,6 +18,9 @@ public function setUp(): void public function provideWalk(): Generator { + // disabled this walker for now due to perforamnce and behavioral + // issues. + return; yield 'Require relative' => [ <<<'EOT' Date: Sat, 2 Mar 2024 13:25:12 +0000 Subject: [PATCH 2/2] Update CL --- CHANGELOG.md | 2 ++ lib/WorseReflection/Core/ServiceLocator.php | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9dcc7278b..82b5806635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ Improvements: - Skip parent parameters on complete constructor #2471 @mamazu - Support generics on `@mixin` #2463 - Remove "on develop warning" service #2533 + - Disable the processing of includes/requires, it doesn't work very well but + it has massive performance impact on certain projects #2580 Bug fixes: diff --git a/lib/WorseReflection/Core/ServiceLocator.php b/lib/WorseReflection/Core/ServiceLocator.php index aac7fa52f0..76031565e2 100644 --- a/lib/WorseReflection/Core/ServiceLocator.php +++ b/lib/WorseReflection/Core/ServiceLocator.php @@ -13,7 +13,6 @@ use Phpactor\WorseReflection\Core\Inference\Walker\DiagnosticsWalker; use Phpactor\WorseReflection\Core\Inference\Walker\PassThroughWalker; use Phpactor\WorseReflection\Core\Inference\Walker\FunctionLikeWalker; -use Phpactor\WorseReflection\Core\Inference\Walker\IncludeWalker; use Phpactor\WorseReflection\Core\Inference\Walker\VariableWalker; use Phpactor\WorseReflection\Core\Inference\NodeToTypeConverter; use Phpactor\WorseReflection\Core\Inference\NodeContextResolver;