phpDocumentor/Reflection

Php\File::getFunctions() is always empty

othercorey opened this issue · 2 comments

This is using 4.0.0-beta.

I am unable to find any global functions via File::getFunctions().

I added some logging to ElementNameResolver::enterNode() and there are Function_ nodes being passed in with the proper names. However, nothing seems to create Php\Function_ instances anywhere.

For example, in a 'basics.php' file, there is this definition.

    function stackTrace(array $options = []): void
    {
        if (!Configure::read('debug')) {
            return;
        }

        $options += ['start' => 0];
        $options['start']++;

        /** @var string $trace */
        $trace = Debugger::trace($options);
        echo $trace;
    }

Hi @othercorey,

I have been trying to reproduce your issue using a component test but so far it works on master. Maybe that we fixed the issue in the meantime without correlating it to this.

Can you check the code in 23b5112 to see how it differs from yours? And can you post a reproduction sample if you still run into the issue?

It looks like the functions are not created if there is an if() check around them. I think the same for constants.

All of the global functions in this library have something like this around them.

if (!function_exists('h')) {
    function h()
    {
    }
}