Re: RFC Proposal - Types for Inline Variables

From: Date: Tue, 07 Feb 2023 20:20:58 +0000
Subject: Re: RFC Proposal - Types for Inline Variables
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-119482@lists.php.net to get a copy of this message
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

« previous php.internals (#119482) next »