Skip to content

Fix autoload preload on PHPUnit 12+ on global installation#7468

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-autoload
Oct 11, 2025
Merged

Fix autoload preload on PHPUnit 12+ on global installation#7468
TomasVotruba merged 1 commit into
mainfrom
fix-autoload

Conversation

@samsonasik

@samsonasik samsonasik commented Oct 11, 2025

Copy link
Copy Markdown
Member

@TomasVotruba this is my original alternative solution which previously you closed it at:

with check inside AbstractLazyTestCase instead of global bootstrap.php that included on composer.json -> files.

This to cover:

This is safer, with the following reason:

  • Doesn't enforce load our preload.php when it doesn't run rector phpunit
  • Only load preload.php on phpunit < 12, when on PHPUnit >=12, the preload already checked, since classmap is loaded by next check

if (\file_exists(__DIR__ . '/../../../vendor/scoper-autoload.php')) {
require_once __DIR__ . '/../../../vendor/scoper-autoload.php';
}

  • Rector bin already use it in bin/rector.php, so unrelated to it

rector-src/bin/rector.php

Lines 116 to 118 in d0866a8

if (file_exists(__DIR__ . '/../preload.php') && is_dir(__DIR__ . '/../vendor')) {
require_once __DIR__ . '/../preload.php';
}

@samsonasik

Copy link
Copy Markdown
Member Author

We can verify preload-split-package.php when we require PHPUnit 12 on rector-* packages, only on use of main preload.php for now.

@samsonasik

Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba

Copy link
Copy Markdown
Member

Let's give it a go then 👍

@TomasVotruba
TomasVotruba merged commit 2df5ab0 into main Oct 11, 2025
53 checks passed
@TomasVotruba
TomasVotruba deleted the fix-autoload branch October 11, 2025 10:55
@samsonasik

samsonasik commented Oct 11, 2025

Copy link
Copy Markdown
Member Author

/cc @nikophil you should can use bamarni/composer-bin-plugin again by this on next rector release :)

try dev-main

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba wait, just tested on laminas/laminas-servicemanager-migration and it seems cause issue as StmtsAwareInterface not detected ...

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba I will add some check...

@samsonasik

Copy link
Copy Markdown
Member Author

I create new PR:

to cover both global and local autoload

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants