Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the factory keyword #729

Merged
merged 9 commits into from
May 9, 2017
Merged

Conversation

theofidry
Copy link
Member

@theofidry theofidry commented May 7, 2017

Tackles the __factory part of #388.

Todo:

  • Deprecate the usage of __construct in favour of __factory
  • Fix the confusing case. With __construct with only 1 named param, it is not clear if the param is an argument key or a constructor name. In __factory the ambiguity is non existent
  • Tests (coverage + usage statements + Symfony bridge)
  • Doc

@theofidry theofidry changed the title Add the factory keyword [WIP] Add the factory keyword May 7, 2017
@theofidry theofidry added this to the 3.0.0 milestone May 7, 2017
@theofidry theofidry mentioned this pull request May 7, 2017
5 tasks
@theofidry theofidry changed the title [WIP] Add the factory keyword Add the factory keyword May 9, 2017
@theofidry
Copy link
Member Author

@ogizanagi would you mind doing a quick review on that one?

Copy link
Contributor

@ogizanagi ogizanagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ✨✨

@@ -64,6 +66,24 @@ public function denormalize(FixtureInterface $scope, FlagParserInterface $parser
if ('__construct' === $unparsedPropertyName) {
$constructor = $this->denormalizeConstructor($value, $scope, $parser);

if (false === ($constructor instanceof NoMethodCall) && '__construct' !== $constructor->getMethod()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- if (false === ($constructor instanceof NoMethodCall) && '__construct' !== $constructor->getMethod()) {
+ if (!$constructor instanceof NoMethodCall && '__construct' !== $constructor->getMethod()) {

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda prefer being explicit instead of using !, as it's the current convention I would prefer not to change it at that point :)

$this->assertSame($expected, $actual);
}

public function testDenormalizesConstructorWithTheDecoratedConstructorDenormalizerIfCannotDenormalizeWithTheFactoryDenormalizer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm breathless and stuttering just by reading this in my head 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I would like to switch to snake case as for php spec, this would already be somewhat more readable... but I don't have the will to update all the tests for that^^

@theofidry theofidry merged commit 2507f18 into nelmio:master May 9, 2017
@theofidry theofidry deleted the feature/factory branch May 9, 2017 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants