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

PersistentCollection::removeElement() returns object or NULL instead of boolean #5745

Closed
holtkamp opened this issue Mar 29, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@holtkamp
Copy link
Contributor

When using strict typing in PHP 7.0.4: declare (strict_types = 1); , I noticed that an error is returned for userland code like

public function removeUser(User $user) : bool
{
    return $this->users->removeElement($user);
}

This results in an error message like:

Return value of Project\Entity::removeUser() must be of the type boolean, object returned

I had a look at all removeElement() functions used in the project and I suspect this section

Will try to come up with a test but already wanted to register this issue so I will not forget it.

UPDATE
It appears that this can be tested in ExtraLazyCollectionTest::testRemoveElementManyToMany():

        $result = $user->groups->removeElement($group);
        $this->assertTrue($result);

However, this made me wonder, why does this part returns NULL while the Collection interface indicates it should return a boolean? Is returning the element/null on purpose?

@holtkamp holtkamp changed the title PersistentCollection::removeElement() returns object instead of boolean PersistentCollection::removeElement() returns object or NULL instead of boolean Mar 30, 2016
@holtkamp
Copy link
Contributor Author

Anything else I can do to resolve this issue?

@Ocramius
Copy link
Member

@holtkamp see #6550

@Ocramius Ocramius added the Bug label Jul 13, 2017
@Ocramius Ocramius added this to the 2.5.7 milestone Jul 13, 2017
Ocramius pushed a commit that referenced this issue Jul 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants