ReflectionFunction是如何工作的?
I'm trying to use the following function to loop through loaded files and find depreciated functions.
//loads all files
include dirname(__FILE__) . '/loader.php';
$functions = get_defined_functions();
foreach ($functions['user'] as $func) {
$rf = new ReflectionFunction('$func');
var_dump($rf->isDeprecated());
}
Some functions have markup like the following, yet it's still return false
. In fact every single function returns false
yet there are a lot with markup stating @deprecated
.
**
*
* @since 0.71
* @deprecated 1.5.1
* @deprecated Use get_post()
*
* @param int $postid
* @return array
*/
ref: http://www.php.net/manual/en/class.reflectionfunction.php
ReflectionFunction::isDeprecated
does not check documentation comments; it only checks an internal flag that can be set by PHP extensions on the functions they expose.
For example, here is the part of the source for the ereg
extension where its functions are declared and marked as deprecated (the DEP
part in PHP_DEP_FE
stands for "deprecated").
Looking at the source code for Reflection, it applies only to built-in functions that have the ZEND_ACC_DEPRECATED flag set, so it's not applicable to userland methods or functions