propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 398 forks source link

add type-safe access to StandardServiceContainer #1872

Closed mringler closed 2 years ago

mringler commented 2 years ago

When using Propel::getServiceContainer(), an instance of ServiceContainerInterface is returned, and users can implement their own service container against this interface.

However, almost all users do not do that, and instead use the StandardServiceContainer, which offers crucial functionality, particularly enabling and configuring the logger.

But since the additional functionality of StandardServiceContainer is not part of the interface, they have to find those methods without IDE support, and if they use type checkers, those will complain because unknown methods are accessed. See for example this discussion.

Since there are no generics in PHP, a feasible workaround is to add a new method to the Propel runtime object, which allows type-safe access to the StandardServiceContainer.

If there is a better solution, I'd be happy to find out!

codecov-commenter commented 2 years ago

Codecov Report

Merging #1872 (86cca56) into master (ba9abb9) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master    #1872   +/-   ##
=========================================
  Coverage     87.61%   87.61%           
- Complexity     7807     7809    +2     
=========================================
  Files           227      227           
  Lines         21144    21149    +5     
=========================================
+ Hits          18525    18530    +5     
  Misses         2619     2619           
Flag Coverage Δ
5-max 87.61% <100.00%> (+<0.01%) :arrow_up:
7.4 87.61% <100.00%> (+<0.01%) :arrow_up:
agnostic 66.97% <100.00%> (+<0.01%) :arrow_up:
mysql 68.89% <0.00%> (-0.02%) :arrow_down:
pgsql 68.90% <0.00%> (-0.02%) :arrow_down:
sqlite 66.73% <0.00%> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Propel/Runtime/Propel.php 53.52% <100.00%> (+3.52%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ba9abb9...86cca56. Read the comment docs.