-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
An interface allows more flexibility to implementers/consumers. The setter/getter for parameter name is polluting the instance's state and this information is not really needed. It's the job of the resolver to provide the name/injection link.
src/Resolver/AbstractInjection.php
Outdated
@@ -20,6 +28,11 @@ | |||
*/ | |||
public function setParameterName(string $name) : self | |||
{ | |||
trigger_error( |
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.
To be documented in CHANGELOG.md
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.
Cahngelog updates will follow. this is still WIP
src/Resolver/InjectionInterface.php
Outdated
public function export() : string; | ||
|
||
/** | ||
* @return bool |
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.
Not needed
use Zend\Di\CodeGenerator\FactoryInterface; | ||
use ZendTest\Di\TestAsset\InvokableInterface; | ||
|
||
final class FactoryProphecy implements FactoryInterface |
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.
Urgh, would be better to avoid prophecy at all if it needs to become this complex to please the tool: why do traditional mocks not work here?
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.
Yeah, I don't like it either. Not sure how to replace it. The scenario:
Expect that if the $factories[$key] value is a string, this string is treated as class name and instanciated. But maybe I'm thinking too complex here.
This may be time to get rid of the zend-code dependency
PHP will export NULL, which conflicts with the ZF coding standard.
use function is_array; | ||
|
||
final class MixedArgumentsFactory implements FactoryInterface | ||
{ |
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.
This is how the output should finally look like. To achieve this I'd remove zend-code. This simplifies the generator, docs and consumers do no longer need zend-code for AoT
Adding a strict return type and throw exceptions on failure makes the implementation predictable.
This will not trigger a warning as file_put_contents would. Instead it will throw when opening the file for read access fails.
public function __construct(string $namespace) | ||
{ | ||
$this->namespace = $namespace; | ||
} | ||
|
||
private function generateAutoloaderClass(array &$classmap) | ||
private function writeFile(string $filename, string $code): void |
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.
Only a short notice: space before colon is missing.
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.
Strange, why didn't the cs-check complain about it? Maybe an outdated version. Thanks for pointing this out. 👍
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.
@froschdesign I ran composer update
. The locked version of zend-coding-standard was not out of date. cs-check is still not complaining. Worth a bug report on zendframework/zend-coding-standard? For the sake of consistency I'd argue to leave it this way for the moment and fix this in a separate pull request. Is this OK for you?
(edit: fix link)
Thanks a lot, @Ocramius Do you mean the What kind of documentation do you have in mind? This is mostly internal and only relevant when somebody wants to implement a custom Resolver. It's not a common use case. |
@tux-rampage even if it is internal, so then it should:
|
@Ocramius, sorry if I expressed this incorrectly, my comment was not about if this should be documented. It was more a question about how. I hesitate marking this internal. Even though implementing a custom resolver is a rare use case I'd like to give users the freedom with an explicit contract when they know what they're doing. That's the reason why it's not covered in the doc book, yet: It's not something you need to do to get zend-di working and it's something you should consider twice before doing it (i.e. it's better to write a service factory instead of putting additional magic into the auto wiring implementation). I added some additional PHPDoc. Would that be sufficient for advanced users? |
@weierophinney I walked through the topics. I thought I had adressed your remarks previously, but I seem to have missed to push them from my notebook. Anyways I made sure this time ;-) As for your remarks on the templates, these are test covered to ensure specific results. I double checked these expectaions in I also opened Issue #39 to adress the upcomming coding standard v2. The current one may haunt us with any PR since the tooling does not even complain - which is as frustrating for contributors as for reviewers. |
You said it's internal: if you aren't ready for it to be If you don't know exactly how to document it, then it is probably not ready for the wider audience either. Give it your best shot for now. Maybe even rename the methods, if you think that would aid clarity, but don't make it a public interface if it's not ready. |
For now this is an option until it's stable enough to become part of the public api.
Yes, that sounds like the best way to go, thanks. When I find the time I'll review the resolver parts and check if this has a stable api via interfaces, so that we can cover it an advanced documentation section - when this is the case
I already added a lot of PHPDoc explaining the purpose of this interface to the maintainers. It now also has the Thaks again for your support on this, @Ocramius 👍 |
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.
Honestly, this looks great! There's some CS consistency, but you have another PR open for that.
As I've noted below, the only thing I think needs changes is the CHANGELOG: you need to elaborate a bit on which contract is being defined, and why, as that's the user-facing aspect.
CHANGELOG.md
Outdated
@@ -14,6 +14,15 @@ All notable changes to this project will be documented in this file, in reverse | |||
factory `Zend\Di\Container\GeneratorFactory` for creating a | |||
`Zend\Di\CodeGenerator\InjectorGenerator` instance with zend-servicemanager. | |||
|
|||
- [#38](https://github.com/zendframework/zend-di/pull/38) adds `Zend\Di\Resolver\InjectionInterface` | |||
to define the contract |
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.
Define which contract? Elaborate here, as this is where users get the information they need to determine the impact of the changes.
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.
Right, that's related to the discussion above. This will need a change indeed.
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.
Besides this little bit, this is ready to 🚢
CHANGELOG.md
Outdated
@@ -14,6 +14,15 @@ All notable changes to this project will be documented in this file, in reverse | |||
factory `Zend\Di\Container\GeneratorFactory` for creating a | |||
`Zend\Di\CodeGenerator\InjectorGenerator` instance with zend-servicemanager. | |||
|
|||
- [#38](https://github.com/zendframework/zend-di/pull/38) adds `Zend\Di\Resolver\InjectionInterface` | |||
to define the contract |
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.
Besides this little bit, this is ready to 🚢
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.
🚢
All feedback handled
🙌 Thank you all for your support on this. I'm prepping the merge as soon as Travis and coveralls finished. |
Thank's @Ocramius - that was quick 😃 |
Thank YOU for the patience in following this. We should likely decide whether to close off |
Indeed I was also going to suggest this. I can take care of it to learn how to do it. To do so I would first do the release steps as described in the Maintainers guideline and push it to my repo so one of you can have a look if I did it correctly. |
I can verify that later today - remember to sign any tags you create. |
@Ocramius ready: https://github.com/tux-rampage/zend-di - Was this correct? |
Hmm, the tag can't be recognised. Did you try uploading your public GPG key? |
My mobile phone shows verified as well: https://github.com/tux-rampage/zend-di/tags |
This PR intends to provide the following QA improvements:
toValue()
to obtain the value to injectinstanceof
checksI will add comments to the diff to clarify my indentations
TODOs:
CHANGELOG.md
entries