8000 [Workflow] Added DefinitionBuilder::setMetadataStore(). by vudaltsov · Pull Request #27190 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Workflow] Added DefinitionBuilder::setMetadataStore(). #27190

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

Merged
merged 1 commit into from
May 11, 2018

Conversation

vudaltsov
Copy link
Contributor
Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

This PR complements #26092.

@vudaltsov vudaltsov requested a review from lyrixx as a code owner May 7, 2018 20:15
@vudaltsov vudaltsov changed the title Added DefinitionBuilder::setMetadataStore(). [Workflow] Added DefinitionBuilder::setMetadataStore(). May 7, 2018
@vudaltsov vudaltsov changed the base branch from master to 4.1 May 7, 2018 20:30
@vudaltsov vudaltsov force-pushed the workflow-builder-metadata-store branch from 04d528b to 675e6fd Compare May 7, 2018 20:35
* @param string[] $places
* @param Transition[] $transitions
* @param string|null $initialPlace
* @param MetadataStoreInterface|null $metadataStore
Copy link
Member

Choose a reason for hiding this comment

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

We prefer doing partial docblocks, keeping them only when they provide something over the signature:
instead of adding this, I'd suggest to remove the one for initialPlace

@@ -113,6 +117,8 @@ public function addTransitions(array $transitions)
}

/**
* @param Transition $transition
Copy link
Member

Choose a reason for hiding this comment

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

should be removed (see previous comment)

@@ -122,6 +128,18 @@ public function addTransition(Transition $transition)
return $this;
}

/**
* @param MetadataStoreInterface $metadataStore
Copy link
Member

Choose a reason for hiding this comment

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

should be removed

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone May 7, 2018
@vudaltsov
Copy link
Contributor Author

@nicolas-grekas , thank you for explanations, done.

@lyrixx lyrixx added the Workflow label May 8, 2018
Copy link
Member
@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. I left a tiny comment ;)

@vudaltsov
Copy link
Contributor Author

@lyrixx , can't see it...

@@ -122,6 +126,16 @@ public function addTransition(Transition $transition)
return $this;
}

/**
* @return $this
Copy link
Member

Choose a reason for hiding this comment

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

I would use a type hint instead of a php doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What type hint? : self?

Copy link
Member

Choose a reason for hiding this comment

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

yes ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose NewDefinitionBuilder extends our non-final DefinitionBuilder. Then return type of $newDefinitionBuilder->setMetadataStore() will be DefinitionBuilder, not NewDefinitionBuilder.

Copy link
Member

Choose a reason for hiding this comment

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

Yes indeed. And it's not an issue ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

@lyrixx But method autocompletion in IDE for methods from the inherited class will stop after a call to a method with self as return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typehinting fluent pattern with : self is okay in a fluent interface because you are not supposed to add any new public methods in it's implementations. And probably in a final class for the same reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

found some relevant occurrences in symfony code:
image
but I still don't agree it is correct...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With : self it is actually correct to do this:

<?php

class A
{
    public function foo(): self
    {
        return $this;
    }
}

class B extends A
{
    public function foo(): A
    {
        return new A();
    }
}

It does not contradict the contract.

While @return $this indicates that the returned value should be the same instance.

Copy link
Member
@nicolas-grekas nicolas-grekas May 9, 2018

Choose a reason for hiding this comment

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

Makes sense to keep it as this provides more than just the return type.
In the code base, we use both return static and $this, dunno if there is a difference thought here.

@@ -122,6 +126,16 @@ public function addTransition(Transition $transition)
return $this;
}

/**
* @return $this
Copy link
Member
@nicolas-grekas nicolas-grekas May 9, 2018

Choose a reason for hiding this comment

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

Makes sense to keep it as this provides more than just the return type.
In the code base, we use both return static and $this, dunno if there is a difference thought here.

@fabpot fabpot force-pushed the workflow-builder-metadata-store branch from 62b352c to 2882f8d Compare May 11, 2018 16:37
@fabpot
Copy link
Member
fabpot commented May 11, 2018

Thank you @vudaltsov.

@fabpot fabpot merged commit 2882f8d into symfony:4.1 May 11, 2018
fabpot added a commit that referenced this pull request May 11, 2018
…(vudaltsov)

This PR was squashed before being merged into the 4.1 branch (closes #27190).

Discussion
----------

[Workflow] Added DefinitionBuilder::setMetadataStore().

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This PR complements #26092.

Commits
-------

2882f8d [Workflow] Added DefinitionBuilder::setMetadataStore().
@vudaltsov vudaltsov deleted the workflow-builder-metadata-store branch May 11, 2018 16:39
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.

6 participants
0