psalm: glob wrong return type

https://psalm.dev/r/726b2ba5b5

Result is not list<non-empty-string> when the argument is empty string and no flags are present. (but should be array<never, never>) Glob needs a return type provider added to ensure the “non-empty-string” is not lost when a valid pattern is passed.

Bug added in https://github.com/vimeo/psalm/pull/9814 @Hanmac

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 28 (21 by maintainers)

Commits related to this issue

Most upvoted comments

GLOB_ERR

Would guess that is the one. GLOB_ERR - Stop on read errors (like unreadable directories), by default errors are ignored. (php.net)

Edit: Or it may be GLOB_ONLYDIR , needs testing…

my current testing shows exactly that:

  • glob( '' , GLOB_NOCHECK) => ['']
  • glob( '' , GLOB_NOCHECK | GLOB_ONLYDIR) => []