On 02.12.2020 at 17:34, Silvio Sparapano wrote:

> Hello,
> IMHO it’s only a declaration issue.
>
> In other terms, if documentation of strlen says:
>
> strlen ( string $string ) : int
>
> then I mean that $string MUST be a string, and return value MUST be an int.
>
> But then we found that if $string is null, zero is returned. If $string is an 
> array, null is returned …
> We simply need consistency between how a function is documented, and how it 
> really works.
> I mean, it may also be convenient for strlen to accept a parameter type other 
> than string (such as null), but it must be well documented.

It is reasonably well documented:

| If the parameters given to a function are not what it expects, such as
| passing an array where a string is expected, the return value of the
| function is undefined. In this case it will likely return NULL but
| this is just a convention, and cannot be relied upon.

[1] <https://www.php.net/manual/en/functions.internal.php>

Regards,
Christoph

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to