Log1x / navi

A developer-friendly alternative to the WordPress NavWalker.
https://github.com/Log1x/navi
MIT License
311 stars 29 forks source link

PHP 8.1 deprecation notices #54

Closed tedw closed 1 year ago

tedw commented 2 years ago

FYI after upgrading to PHP 8.1. I started seeing these deprecation notices:

Return type of Log1x\Navi\Navi::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Here’s a screenshot from Query Monitor:

Screen Shot 2022-07-09 at 2 35 55 PM

More info here https://stackoverflow.com/questions/71133749/reference-return-type-of-should-either-be-compatible-with-or-the-re

Not urgent, still works fine, just wanted to let you know. Thanks for all your work on Navi and all your other packages!

Log1x commented 2 years ago

This is 8.0 or 8.1?

tedw commented 2 years ago

Sorry, this was introduced in 8.1. I just updated the title to reflect that.

More info here: https://php.watch/versions/8.1/internal-method-return-types

Log1x commented 2 years ago

Care to do a PR? 😄 If not I will try to get to it ASAP.

tedw commented 2 years ago

@Log1x Sure thing! I added return types to the offending functions in this PR https://github.com/Log1x/navi/pull/55

However, it would probably be best to add types to all functions at some point. I’ll defer to you on that. Thanks!