inpsyde / modularity

A PSR-11 implementation for WordPress Plugins, Themes or Libraries.
https://inpsyde.github.io/modularity/
GNU General Public License v2.0
44 stars 4 forks source link

Fix status check in `PackageProxyContainer` #49

Closed gmazzap closed 1 week ago

gmazzap commented 3 months ago

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix.

What is the current behavior? (You can also link to an open issue here)

A connected package's services can not be accessed if the package is "built"

What is the new behavior (if this is a feature change)?

A connected package's services can be accessed if the package is "built".

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No.

Other information:

The implementation of Package::connect() predates the implementation of Package::built().

Before Package::built() was introduced in 1.7.0 it was only safe to access a Package's container after having called Package::boot().

Now, we can do $package->build()->container() without issues.

The implementation of PackageProxyContainer was not updated when we introduced Package::built(), so we can still not access services from connected packages if they are not booted.

This means using built() early and boot() later, which is the reason why we introduced built() in the first place is "dangerous" because if someone connects a built package and tries to access its services they will get an exception.

I committed a test to master that tests there the bug, and this test is merged back into this branch to prove this is now solved.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.42%. Comparing base (bd65297) to head (5c6b990). Report is 6 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #49 +/- ## ============================================ - Coverage 98.93% 98.42% -0.52% - Complexity 234 238 +4 ============================================ Files 10 10 Lines 566 570 +4 ============================================ + Hits 560 561 +1 - Misses 6 9 +3 ``` | [Flag](https://app.codecov.io/gh/inpsyde/modularity/pull/49/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=inpsyde) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/inpsyde/modularity/pull/49/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=inpsyde) | `98.42% <100.00%> (-0.52%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=inpsyde#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.