On 07/02/2023 20:53, Olle Härstedt wrote:
No not really. I'd expect it behave similar to function argument
type-hinting in PHP, that is, runtime checks, but where the notation
can be used by external tools.

The big difference is that the current checking for function arguments is only necessary when a function is called; but that checking for local-scoped variables would be required on every assignment to a variable, or operation that can change a variable value; and that becomes more problematic with the potential need for union types.


$mystring = 'I love elephants';
$findme   = 'php';
int $pos = strpos($mystring, $findme); // $pos can be an integer or false


or when a type can legitimately change


int $result = PHP_MAX_INT;

++$i; // $i is now a float



--
Mark Baker

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

Reply via email to