note 88015 added to language.oop5.typehinting
| From: | bantam at banime dot com | Date: | Tue, 06 Jan 2009 10:53:01 +0000 |
| Subject: | note 88015 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148880@lists.php.net to get a copy of this message | ||
Daniel's typehint implementation was just what I was looking for but performance in production
wasn't going to cut it. Calling a backtrace every time hurts performance. For my implementation
I didn't use it, after all, PHP tells us what the data type is in the error message, I
don't feel I need to evaluate the argument where I am using typehinting. Here is the cut down
version I use in my error handling class:
<?
public static function typehint($level, $message)
{
if($level == E_RECOVERABLE_ERROR)
{
if(preg_match('/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an
instance of (\w+), (\w+) given/', $message, $match))
{
if($match[4] == $match[5])
return true;
}
}
return false;
}
?>
Hope this can be of use to somebody.
----
Server IP: 194.153.94.10
Probable Submitter: 68.50.45.180
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php
Edit -- https://master.php.net/note/edit/88015
Del: integrated -- https://master.php.net/note/delete/88015/integrated
Del: useless -- https://master.php.net/note/delete/88015/useless
Del: bad code -- https://master.php.net/note/delete/88015/bad+code
Del: spam -- https://master.php.net/note/delete/88015/spam
Del: non-english -- https://master.php.net/note/delete/88015/non-english
Del: in docs -- https://master.php.net/note/delete/88015/in+docs
Del: other reasons-- https://master.php.net/note/delete/88015
Reject -- https://master.php.net/note/reject/88015
Search -- https://master.php.net/manage/user-notes.php