note 67015 added to language.oop5.reflection

From: Date: Fri, 02 Jun 2006 08:09:12 +0000
Subject: note 67015 added to language.oop5.reflection
Groups: php.notes 
Request: Send a blank email to php-notes+get-112899@lists.php.net to get a copy of this message
I have written a function which returns the value of a given DocComment tag. Full example: <?php header('Content-Type: text/plain'); class Example { /** * This is my DocComment! * * @DocTag: prints Hello World! */ public function myMethod() { echo 'Hello World!'; } } function getDocComment($str, $tag = '') { if (empty($tag)) { return $str; } $matches = array(); preg_match("/".$tag.":(.*)(\\r\\n|\\r|\\n)/U", $str, $matches); if (isset($matches[1])) { return trim($matches[1]); } return ''; } $method = new ReflectionMethod('Example', 'myMethod'); // will return Hello World! echo getDocComment($method->getDocComment(), '@DocTag'); ?> Maybe you can add this functionality to the getDocComment methods of the reflection classes. ---- Server IP: 66.163.161.117 Probable Submitter: 84.182.180.180 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php Edit -- http://master.php.net/note/edit/67015 Del: integrated -- http://master.php.net/note/delete/67015/integrated Del: useless -- http://master.php.net/note/delete/67015/useless Del: bad code -- http://master.php.net/note/delete/67015/bad+code Del: spam -- http://master.php.net/note/delete/67015/spam Del: non-english -- http://master.php.net/note/delete/67015/non-english Del: in docs -- http://master.php.net/note/delete/67015/in+docs Del: other reasons-- http://master.php.net/note/delete/67015 Reject -- http://master.php.net/note/reject/67015 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112899) next »