Skip to content

fix: clean up scoped autoloaders during arch scans#40

Open
nkgotcode wants to merge 1 commit into
pestphp:4.xfrom
nkgotcode:fix/rector-scoped-autoloader-leak
Open

fix: clean up scoped autoloaders during arch scans#40
nkgotcode wants to merge 1 commit into
pestphp:4.xfrom
nkgotcode:fix/rector-scoped-autoloader-leak

Conversation

@nkgotcode

Copy link
Copy Markdown

Fix arch object scanning so temporary Composer autoloaders registered while resolving object descriptions are cleaned up after the callback completes.

This prevents Rector-related autoload state discovered during an arch scan from leaking into later tests in the same process.

Fixes pestphp/pest#1732.

Validation:

docker run --rm -e COMPOSER_ROOT_VERSION=4.x-dev -v "$PWD":/app -w /app composer:2 sh -lc 'git config --global --add safe.directory /app && composer install --no-interaction --prefer-dist'
docker run --rm -e COMPOSER_ROOT_VERSION=4.x-dev -v "$PWD":/app -w /app php:8.4-cli php vendor/bin/pest tests/Composer.php --filter 'removes composer loaders registered during a callback' --compact
docker run --rm -e COMPOSER_ROOT_VERSION=4.x-dev -v "$PWD":/app -w /app php:8.4-cli php vendor/bin/pint --test src/Support/Composer.php src/Factories/ObjectDescriptionFactory.php tests/Composer.php
docker run --rm -e COMPOSER_ROOT_VERSION=4.x-dev -v "$PWD":/app -w /app php:8.4-cli php -d memory_limit=-1 vendor/bin/phpstan analyse --ansi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: arch() tests still break TestCase::createApplication for subsequent tests when the codebase references Rector (reproducible follow-up to #1423)

1 participant