Skip to content

Make PHPStan DI-Container available in bootstrap files#8190

Merged
TomasVotruba merged 11 commits into
rectorphp:mainfrom
staabm:container
Jul 20, 2026
Merged

Make PHPStan DI-Container available in bootstrap files#8190
TomasVotruba merged 11 commits into
rectorphp:mainfrom
staabm:container

Conversation

@staabm

@staabm staabm commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Comment thread src/Autoloading/BootstrapFilesIncluder.php
@staabm
staabm marked this pull request as ready for review July 16, 2026 12:00
@staabm

staabm commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@TomasVotruba should be ready to review

}

require $bootstrapFile;
// mimic PHPStan bootstrap file inclusion (bootstrap files have access to the global $container variable)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

imo, I am thinking if this can be configurable via RectorConfig/RectorConfigBuilder, eg: enableForwardPHPStanBootstrap() config, whether it enable by default or not is fine, but should be configurable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure whether hiding this "feature" behind a feature-flag is a good idea. @TomasVotruba wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep it simple and compatible with PHPStan way 👍

@TomasVotruba
TomasVotruba merged commit d8e259e into rectorphp:main Jul 20, 2026
66 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

Thank you, I'll merge this to give it roun of testing for edge cases 👍

@staabm
staabm deleted the container branch July 20, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

PHPStan bootstrap files cannot be re-used for rector

3 participants