#26780 [Opn->Sus]: Undefined variables cause type hints to become useless

From: Date: Sun, 04 Jan 2004 10:12:14 +0000
Subject: #26780 [Opn->Sus]: Undefined variables cause type hints to become useless
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-52767@lists.php.net to get a copy of this message
ID: 26780 Updated by: helly@php.net Reported By: jebmc at iprimus dot com dot au -Status: Open +Status: Suspended Bug Type: Zend Engine 2 problem -Operating System: Windows XP Pro w/SP1 +Operating System: * -PHP Version: 5.0.0b3 (beta3) +PHP Version: 5.0.* New Comment: The undefined variable is a NULL value when passed to the functionand at the moment type hints accept NULL values. I strongly disagreee here and we are still discussing about a notation to decide whether to accpet or block NULL values with type hints. Previous Comments: ------------------------------------------------------------------------ [2004-01-04 02:00:15] jebmc at iprimus dot com dot au Description: ------------ If you pass an undefined variable as the value of a type-hinted argument, the type-hint checking appears to be skipped. Rather, a notice error is printed for the undefined variable (as it should be) and the function or method happily continues on. Reproduce code: --------------- <?php class Foo { } function myFunc($param1, Foo $bar) { echo $param1; } myFunc('This is a test',$badVariable); ?> Expected result: ---------------- "Notice: Undefined variable: badVariable in foo.php on line 11 Fatal error: Argument 2 must be an object of class foo in foo.php on line 6" Actual result: -------------- "Notice: Undefined variable: badVariable in foo.php on line 11 This is a test" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26780&edit=1

« previous php.bugs (#52767) next »