4.0.x Remove name property from Phalcon\Di\Service so that it can be used as a better closure wrapper #13590
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current design of the Service class doesn't make it well suited for acting as a closure wrapper and the name property is unnecessary. There is only one place where the name property is used and that is in the DI and it already has access to the name of the service due to having just having received the name via a method parameter. I added a single exception class that is to be thrown when this one situation occurs. I think that this is a good use of an exception since it is an exceptional event. Otherwise the design of Phalcon suffers only to satisfy this one moment.
Accepting this pull request will allow frameworks to use one service per file designs.
In addition to the following two options;
and
and then later by an additional pull request:
If this pull request is not accepted then it must be done like:
and then hoping to not create a collision. However for purposes of sanity this entire use of
Service
is essentially unavailable and for no good reasonThis pull request is derived from an old pull request that I pulled down from before when Phalcon was in its neglected state. I relied on the actual PR to run the tests for me and if I missed something here or something changed then I'll fix it and then if the fix or fixes become too messy then I will resubmit with a local copy-paste of the completed passing code. Obviously that isn't an ideal development process and is already being addressed elsewhere by the Team.