note 94692 added to language.oop5.typehinting
| From: | Theriault at osu1 dot php dot net | Date: | Wed, 18 Nov 2009 21:35:54 +0000 |
| Subject: | note 94692 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163044@lists.php.net to get a copy of this message | ||
To get a slightly better performance using Bantam's version of Daniel's idea, one can
switch to strpos instead of using preg_match.
<?php
public static function typehint($level, $message) {
if($level == E_RECOVERABLE_ERROR) {
$Pos = strpos($message, 'must be an instance of ', 24);
if ($Pos !== false) {
$Pos += 23;
$Type1 = strpos($message, ',', $Pos);
if ($Type1 !== false) {
$Type1 += 2;
$Type2 = strpos($message, 'given,', $Type1);
if ($Type2 !== false) {
$TypeA = substr($Msg, $Pos, $Type1 - $Pos - 2);
$TypeB = substr($Msg, $Type1, $Type2 - $Type1 - 1);
if ($TypeA === $TypeB) {
return true;
}
}
}
}
}
return false;
}
?>
----
Server IP: 192.41.40.227
Probable Submitter: 76.25.107.41
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php
Edit -- https://master.php.net/note/edit/94692
Del: integrated -- https://master.php.net/note/delete/94692/integrated
Del: useless -- https://master.php.net/note/delete/94692/useless
Del: bad code -- https://master.php.net/note/delete/94692/bad+code
Del: spam -- https://master.php.net/note/delete/94692/spam
Del: non-english -- https://master.php.net/note/delete/94692/non-english
Del: in docs -- https://master.php.net/note/delete/94692/in+docs
Del: other reasons-- https://master.php.net/note/delete/94692
Reject -- https://master.php.net/note/reject/94692
Search -- https://master.php.net/manage/user-notes.php