Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace provider file content #51419

Closed

Conversation

markwalet
Copy link
Contributor

In one of my projects I'm enforcing declare(strict_types=1); with a QA rule.

That's how I found out that ServiceProvider::addProviderToBootstrapFile() replaces the whole file. After adding a provider, the strict type declaration was removed from the file and making my QA fail.

This PR improves on this, by only replacing the relevant part of the file (the array part). It does so by using regex. It isn't a perfect solution, but at least everything around the array would stay untouched. Because bootstrap/providers.php normally doesn't contain a lot of other code, I think this is fine for most general use-cases.

@taylorotwell
Copy link
Member

Could you maybe exclude this file from your QA rule?

@markwalet
Copy link
Contributor Author

Oh yes, that's definitely possible. In my specific case I just added the statement back in and it was fine. Not a big problem.

I just thought it would be helpful if adding a provider wouldn't reset the whole file. And because I could do it without changing the api, I thought it would be a useful contribution.

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.

None yet

2 participants