Skip to content

[DI] Add compiler pass and command to check that services wiring matches type declarations #32256

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

Merged
merged 3 commits into from
Nov 4, 2019

Conversation

GuilhemN
Copy link
Contributor

@GuilhemN GuilhemN commented Jun 28, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27744
License MIT
Doc PR

PR replacing #27825.

It adds a lint:container command asserting the type hints used in your code are correct.

@GuilhemN
Copy link
Contributor Author

The failure is expected (the pass is not available yet when executing the Framework bundle tests).

@Simperfit
Copy link
Contributor

Nice feature !

@nicolas-grekas nicolas-grekas force-pushed the check-type-hint branch 2 times, most recently from 0eb486f to c0743cb Compare October 12, 2019 12:46
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

PR is now able to lint the container of the Symfony Demo app successfully.
The core of the PR is the new CheckTypeDeclarationsPass.
The feature is totally opt-in so that it's totally safe merging:

  • the pass is not wired by default - it runs only if one enables it in their Kernel (ppl from the strict camp will like doing so)
  • the logic runs on-demand also when executing the lint:container command

I enabled the pass in functional tests, for dogfooding :)

@nicolas-grekas nicolas-grekas changed the title [DI] Add compiler pass to check arguments type hint [DI] Add compiler pass and command to check that services wiring matches type declarations Oct 13, 2019
@@ -17,7 +17,7 @@
</service>
<service id="Symfony\Component\Validator\Validator\ValidatorInterface" alias="validator" />

<service id="validator.builder" class="Symfony\Component\Validator\ValidatorBuilderInterface">
<service id="validator.builder" class="Symfony\Component\Validator\ValidatorBuilder">
Copy link
Member

Choose a reason for hiding this comment

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

relevant for lower branches?

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
@nicolas-grekas
Copy link
Member

Thank you @GuilhemN.

nicolas-grekas added a commit that referenced this pull request Nov 4, 2019
…ces wiring matches type declarations (alcalyn, GuilhemN, nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DI] Add compiler pass and command to check that services wiring matches type declarations

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27744
| License       | MIT
| Doc PR        |

PR replacing #27825.

It adds a `lint:container` command asserting the type hints used in your code are correct.

Commits
-------

8230a15 Make it really work on real apps
4b3e9d4 Fix comments, improve the feature
a6292b9 [DI] Add compiler pass to check arguments type hint
@nicolas-grekas
Copy link
Member

And thank you @alcalyn too!

@nicolas-grekas nicolas-grekas merged commit 8230a15 into symfony:4.4 Nov 4, 2019
This was referenced Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants