note 52705 added to language.oop5.typehinting

From: Date: Tue, 10 May 2005 14:41:11 +0000
Subject: note 52705 added to language.oop5.typehinting
Groups: php.notes 
Request: Send a blank email to php-notes+get-89211@lists.php.net to get a copy of this message
If wrong object is given, error points to method definition instead of place where method has been called. Because of that type hinting is not really useful. Instead use: <?php function($foo) { assert('$foo instanceof ClassRequired'); // ... } ?> and use your custom error handler that dumps debug_backtrace() -- this will allow you to find caller that passes wrong object. Works in PHP4 as well. ---- Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52705 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52705&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52705&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52705&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52705&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52705&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52705&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89211) next »