For the people still wondering why the error message is nonsensical, I’ve looked it up.
It’s just php being “helpful”. Unqualified names of functions and constants (names without any slash) used inside of a namespace are searched first in the namespace; then, when not found, PHP looks for them in global space.
So if you are in Kirby\Toolkit
and just write ctype_digit()
, it formally means Kirby\Toolkit\ctype_digit()
, but since that doesn’t exist, php falls back to global ctype_digit()
and therefore it still works, even if it formally doesn’t exist.
If you want to explicitly use global ctype_digit()
, you should write \ctype_digit()
.
https://www.php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.shortname2
PS: to be even more helpful, the same fallback mechanism doesn’t work for global class names.