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

NullArgument false-positive on ArrayCollection #66

Closed
fluffycondor opened this issue Aug 26, 2020 · 0 comments · Fixed by #67
Closed

NullArgument false-positive on ArrayCollection #66

fluffycondor opened this issue Aug 26, 2020 · 0 comments · Fixed by #67

Comments

@fluffycondor
Copy link
Contributor

Psalm 3.14.2@3538fe1955d47f6ee926c0769d71af6db08aa488 + weirdan/doctrine-psalm-plugin

ERROR: NullArgument - src/Entity/Organization.php:155:13 - Argument 1 of Doctrine\Common\Collections\ArrayCollection::offsetSet cannot be null, null value provided to parameter with type int|string (see https://psalm.dev/057)
$this->staff[] = $staff;

But offsetSet can be null:

    /**
     * Required by interface ArrayAccess.
     *
     * {@inheritDoc}
     */
    public function offsetSet($offset, $value)
    {
        if (! isset($offset)) {
            $this->add($value);

            return;
        }

        $this->set($offset, $value);
    }

If I turn off the plugin, the errors are disappeared.

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 a pull request may close this issue.

1 participant