Log1x / navi

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

Docblocks indicate `Navi->items` should be array but can be null #62

Closed thunderdw closed 1 year ago

thunderdw commented 1 year ago

Hi, thanks for the package!

Noticed a very minor issue. The docblocks for Log1x\Navi\Navi->items indicate that the property should be an array, and instantiates it as an array.

When you build a menu (new Navi())->build('menu_name'), if that menu doesn't have items, the builder function returns void instead and items is set to null. See line 66 below: https://github.com/Log1x/navi/blob/555653bf69b3de99812b6da99e342b5585a64002/src/MenuBuilder.php#L56-L73

I could see two approaches:

The latter option seems to make more sense to me but is potentially a breaking change if anyone is using strict comparison for null checking, e.g. Navi->toArray() === null or Navi->getItems() === null

Happy to submit a PR if there's a preferred approach.