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

Fix type error #351

Closed

Conversation

abnegate
Copy link
Member

@abnegate abnegate commented Nov 2, 2023

  • Force return an empty string when $id, $internalId, or $collection are explicitly set to null to avoid a type error

…e explicitly set to null to avoid a type error
@eldadfux
Copy link
Member

Isn't the getAttribute $default is designed to do exactly that?

/**
     * Get Attribute.
     *
     * Method for getting a specific fields attribute. If $name is not found $default value will be returned.
     *
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    public function getAttribute(string $name, mixed $default = null): mixed
    {
        if (isset($this[$name])) {
            return $this[$name];
        }

        return $default;
    }

@abnegate abnegate marked this pull request as draft November 16, 2023 02:12
@abnegate
Copy link
Member Author

abnegate commented Nov 16, 2023

Isn't the getAttribute $default is designed to do exactly that?

/**
     * Get Attribute.
     *
     * Method for getting a specific fields attribute. If $name is not found $default value will be returned.
     *
     * @param string $name
     * @param mixed $default
     *
     * @return mixed
     */
    public function getAttribute(string $name, mixed $default = null): mixed
    {
        if (isset($this[$name])) {
            return $this[$name];
        }

        return $default;
    }

@eldadfux Yeah this was a band-aid for the getId() on null error, somewhere the value for $collection must be explicitly set to null $document->setAttribute('$collection', null);, that's the only possible way you could get null here. Needs more investigation to find the root cause though

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.

2 participants