-
Notifications
You must be signed in to change notification settings - Fork 89
Conversation
- Continue zendframework/zendframework#3508 removing ZendTest
Conflicts: tests/ZendTest/Code/Generator/AbstractGeneratorTest.php tests/ZendTest/Code/Generator/ClassGeneratorTest.php tests/ZendTest/Code/Generator/DocBlock/Tag/AuthorTagTest.php tests/ZendTest/Code/Generator/DocBlock/Tag/LicenseTagTest.php tests/ZendTest/Code/Generator/DocBlock/Tag/ParamTagTest.php tests/ZendTest/Code/Generator/DocBlock/Tag/ReturnTagTest.php tests/ZendTest/Code/Generator/DocBlock/TagTest.php tests/ZendTest/Code/Generator/DocBlockGeneratorTest.php tests/ZendTest/Code/Generator/FileGeneratorTest.php tests/ZendTest/Code/Generator/MethodGeneratorTest.php tests/ZendTest/Code/Generator/ParameterGeneratorTest.php tests/ZendTest/Code/Generator/PropertyGeneratorTest.php tests/ZendTest/Code/Generator/PropertyValueGeneratorTest.php tests/ZendTest/Code/Generator/ValueGeneratorTest.php
done: * move delegator logic from create() to separate method * remove automatic invokable service for delegator factories * add delegator factory class validation * update tests
…sm-cyclic-alias-ref [ServiceManager] Implemented circular alias reference detection
- one argument per line (sprintf call)
…si/fix/pm-delegators fix delegators to allow usage in plugin managers Conflicts: tests/ZendTest/ServiceManager/ServiceManagerTest.php
…ix/serviceManager-trollAbstractFactories(4285) ServiceManager - fix AbstractFactories performance and service waiting
*/ | ||
public function __invoke(ServiceLocatorInterface $serviceLocator, $requestedName, array $options = []) | ||
{ | ||
// @TODO: in ZF3 we should have a FQCN key for config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? :)
Seriously, requiring a FQCN seems like a massive break for no clear benefit. The Config we currently have in ZF2 is an array; if we give it a FQCN, folks will look for a class matching that name. Additionally, it means every. single. factory. that uses configuration in ZF2 cannot be cleanly migrated to ZF3 due to the fact that the well-known Config service is now… no longer well-known.
Again: I'm fine with BC breaks for ZF3. But we really, really, really, really (I can't repeat that word enough) need to keep a constant eye on migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, I'm okay for keeping Config here.
@bakura10 Overall, a very nice vision, and I'm impressed by how slim the code is! My main concern is migration, and I've outlined the various places where I have specific concerns. The migration scripts can be part of a later pull request, but the specific BC breaks MUST be outlined, either as part of a README or part of a "migration" document (we'll be adding component-specific docs to all component repos soon, and this could be part of that) before acceptance for merge. (If you go the route of a migration document, push it into a Finally, I'd really like to see the PR synopsis updated to show the final status of the PR before we merge. Since we're now using the keep a changelog format, for many people, the PR will be the first, most comprehensive place to understand the changes, so having the information up front will help aid comprehension of the changes. Thanks a ton; again, this is stellar work! |
Hi, Sorry for the late reply, I won't be able to work on that until next week, but here are a few answers.
Yes, the idea is that factory (or delegator factory, or abstract factory) are just callable. This allow to remove all the check (no need any more to check if instance of FactoryInterface then call createService...).
That's not a problem, because you still need to register factories, abstract factories... separately into the SM. So first the SM will iterate through factories, so it knows the expected order (it's part of the interface), then traverses all the delegators, then the abstract factories.
The idea is that the creation itself is made through the __invoke. The method that check is still called canCreateServiceWithName. Not really a problem.
For now I didn't write one, but to be honest it's less dramatic than the EVM.
Same, I didn't write one, and while I can undertsand the need for this I'm really not interested in taking time for writing this. So it will depend on my motivation. |
@weierophinney , I've made some changes, specifically:
I still need to update the tests. The only thing that I'm still highly unsure is the options thing. What is your opinion on this @weierophinney ? |
@bakura10 @weierophinney You are not alone. If this will be accepted, I think somebody can write a migration tool. That's not the problem. Maybe it could be usefull to write PHPCS sniffs which detects BC breaks? |
@@ -0,0 +1,195 @@ | |||
# CHANGELOG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for adding this; I think it will be a fantastic reference.
This PR now adds support for Interop container. As it will be v3 and allow BC, I was unsure if I shouldn't just remove ServiceLocatorInterface, and make the SM implement ContainerInterface only? |
should related with #4 that merged to develop |
You should rebase; I just merged #4 a short bit ago to the develop branch, and it already does this. :) In terms of |
Okay, I'll change that tomorrow. It seems that the interop also has exception interface. I've updated this PR but I'm a bit unsure of the hierarchy |
But actually i find it a bit strange to keep both interface. If serviceLocatorInterface extends containerInterface it will just have the same methods. If ServiceManager implement both, it will implement two interfaces that have the exact same content. Isn't it a bit redundant actually? |
rebasing will little bit hard as it should be pointed to develop, the reason it was pointed to master because develop didn't exists yet. Probably the only way is create new PR... |
Replaced by #6 |
Initial adjustment of readme.md
Hi everyone,
This is my first PR for ZF3. It is a direct backport of my PR on ZF2 repo.
Component is not yet fully tested but coverage should be already quite good.
Let me quickly recap the major changes of this refactor.
Motivation
The initial motivation was to dramatically increase the performance of this core component, while making it easier to use.
Performance wise, this refactor is dramatically faster, consume less memory (benchmark can be found on ZF2 repo).
Breaking changes
Removal of invokables
The concept of invokables no longer exist. Now, everything is a factory. This simplifies the creation code by having a single main way to create object.
A built-in factory to create invokables has been added.
ZF2 code:
ZF3 code:
Factories are invokables
To increase the performance and reduce branching, most interfaces (FactoryInterface, DelegatorFactory, AbstractFactory and Initializer) must be callable by implementing __invoke.
This offer a unified way to create objects and dramatically increase performance be removing a lot of instanceof checks.
Removal of aliases
Now that this component is 5.5+, we can take advantage of ::class, and we should encourage this usage.
The usage of aliases has been removed from the main service locator where ::class must be encouraged.
For plugin managers, a specialized plugin manager that supports alias has been introduced (
AbstractAliasedPluginManager
) while a more efficient, alias-freeAbstractPluginManager
is still here.Ability to map multiple class to same factory
This was previously possible in ZF2 but in a hacky way. Now you can map multiple class names to the same factory, and it will be supported by default in the interface signature.
Plugin manager change
Previously, a plugin manager had a method
getServiceLocator
to retrieve the main service locator.This was confusing for new-comers, and could lead to hard to debug error because the constructor didn't neforce the need to pass a service locator as a dependency.
Now, what you receive in the factory is ALWAYS the main service manager, not the plugin manager one.
If you create an object through a plugin manager in ZF2 and want to retrieve a dependency in the main service locator you had to do:
In ZF3:
Unified way of having options
In ZF2 it was very hard to have options on factories. This is made easy now, because each interface have a last parameter called options.
Usage:
Thanks