Re: type hinting throwing a fatal error

From: Date: Mon, 08 Aug 2005 12:17:32 +0000
Subject: Re: type hinting throwing a fatal error
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-17593@lists.php.net to get a copy of this message
 Hmm,
I was complaining about inusaability ot type hinting because of this fatal
errors but nobody seems heard me :(. One better do a check in the code than
risking a fatal error which is unstoppable...
I call this showstopper if we say that we are proud with the type-hinting.

Andrey


Quoting Derick Rethans <derick@php.net>:

Hei, currently if you pass a wrong object's type to a typehinted parameter: derick@kossu:~$ cat /tmp/foo.php <?php class foo {
	        function bar(foo $a)
	        {
	        }
} $a = new foo; $a->bar(new stdClass); ?> derick@kossu:~$ php /tmp/foo.php Fatal error: Argument 1 must be an instance of foo in /tmp/foo.php on line 3 As type hinting is a new OO thing, it might perhaps make some sense to make this an exception instead - as this error might also happen for dynamic things by people who use the classes you designed. In that case having this fatal error to stop the whole application can be annoying. Opinions? Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


Thread (125 messages)

« previous php.internals (#17593) next »