2013-08-17 22:51
浏览 21


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');

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


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dsfw2154
    dsfw2154 2013-08-17 22:59

    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").

    点赞 评论
  • dongwei7245
    dongwei7245 2013-08-17 22:59

    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

    点赞 评论