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

PHP 8.1 warnings for Meta::offsetGet #119

Open
vesper8 opened this issue Mar 3, 2022 · 2 comments
Open

PHP 8.1 warnings for Meta::offsetGet #119

vesper8 opened this issue Mar 3, 2022 · 2 comments

Comments

@vesper8
Copy link
Contributor

vesper8 commented Mar 3, 2022

Starting getting these warnings running PHP 8.1


Return type of Collective\Annotations\Routing\Meta::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/laravelcollective/annotations/src/Routing/Meta.php on line 75

Just a warning but would be nice if this was updated soon

@vesper8
Copy link
Contributor Author

vesper8 commented Mar 3, 2022

Warnings also apply to Meta::offsetSet and Meta:offsetUnset

@vesper8
Copy link
Contributor Author

vesper8 commented Apr 4, 2022

It appears that adding return types to these 3 methods makes the warnings go away:


    /**
     * Get the value at a given offset.
     *
     * @param string $offset
     *
     * @return mixed
     */
    public function offsetGet($offset): mixed
    {
        return $this->values[$offset];
    }

    /**
     * Set the value at a given offset.
     *
     * @param string $offset
     * @param mixed  $value
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        $this->values[$offset] = $value;
    }

    /**
     * Remove the value at a given offset.
     *
     * @param string $offset
     *
     * @return void
     */
    public function offsetUnset($offset): void
    {
        unset($this->values[$offset]);
    }

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

No branches or pull requests

1 participant