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

Manual merge #6689

Merged
merged 10 commits into from
Dec 9, 2020
Merged

Manual merge #6689

merged 10 commits into from
Dec 9, 2020

Conversation

franmomu
Copy link
Member

@franmomu franmomu commented Dec 9, 2020

No description provided.

@franmomu franmomu requested a review from a team December 9, 2020 20:15
$this->prefix = $prefix ?? $formBuilder->getName();
$this->prefix = $prefix ?: $formBuilder->getName();
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if ?? is not better than ?: in this case...

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 guess not:

$this->prefix = $prefix ?? $formBuilder->getName(); // will always return $prefix ($prefix is not null)
$this->prefix = $prefix ?: $formBuilder->getName(); // will return $formBuilder->getName(); in case $prefix is false

Copy link
Member

Choose a reason for hiding this comment

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

$prefix is null or a string.

If someone pass '', shouldn't we use '' as a prefix instead of overriding the prefix to $formBuilder->getName() ?
IMHO we should only override the prefix if null is passed. That's the job of ??

Copy link
Member Author

Choose a reason for hiding this comment

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

My comment was based on the phpdoc:

/**
 * @param bool $prefix
 */
public function __construct(FormBuilderInterface $formBuilder, $prefix = false)
{

I haven't check the usages to see if it can be a string, if so, the phpdoc should be updated.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the usages, the only place where the $prefix was passed is:

return new self($this->formBuilder->get($this->iterator->current()), $this->current());

In master that argument was removed in #6533, I don't know what was the use of this, but looks like it should have been deprecated in 3.x and removed in master.

@franmomu franmomu merged commit 1ea158b into sonata-project:master Dec 9, 2020
@franmomu franmomu deleted the master branch December 9, 2020 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants