Updating the docblocks for Navi->items (and related functions like Navi->toArray() and MenuBuilder->build()) to indicate that the value can be null, or:
Updating MenuBuilder->build() line 66 to return [] instead of return
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.
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 returnsvoid
instead anditems
is set to null. See line 66 below: https://github.com/Log1x/navi/blob/555653bf69b3de99812b6da99e342b5585a64002/src/MenuBuilder.php#L56-L73I could see two approaches:
Navi->items
(and related functions likeNavi->toArray()
andMenuBuilder->build()
) to indicate that the value can benull
, or:MenuBuilder->build()
line 66 toreturn []
instead ofreturn
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
orNavi->getItems() === null
Happy to submit a PR if there's a preferred approach.