Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing $file in custom error handler #4625

Closed
dg opened this issue Jan 12, 2015 · 3 comments
Closed

Missing $file in custom error handler #4625

dg opened this issue Jan 12, 2015 · 3 comments

Comments

@dg
Copy link

dg commented Jan 12, 2015

In this case (http://3v4l.org/dWuvG) is $file empty string:

namespace X;

class Test
{
    public static function invoke()
    {
        set_error_handler(function($severity, $message, $file) {
            var_dump($file);
        });

        // E_WARNING trim() expects parameter 1 to be string, array give
        call_user_func_array('trim', array(array()));
    }

}

Test::invoke();

If you remove a namespace declaration, the problem will disappear (see http://3v4l.org/dETSj)

@noony
Copy link
Contributor

noony commented Nov 27, 2015

printing backtrace content here shows that we have an empty content at 0 when we declare a namespace :

bt[7] | file :  , line : 0
bt[6] | file :  , line : 0
bt[5] | file :  , line : 0
bt[4] | file :  , line : 0
bt[3] | file :  , line : 0
bt[2] | file : /home/tcolomb/hhvm/hphp/test.php , line : 19
bt[1] | file : /home/tcolomb/hhvm/hphp/test.php , line : 14
bt[0] | file :  , line : 0

dg added a commit to nette/utils that referenced this issue Dec 3, 2015
@jesseschalken
Copy link
Contributor

If you replace the call_user_func_array('trim', array(array())) with \trim(array()), it produces the same result as Zend: https://3v4l.org/AHPHU

If you keep the call_user_func_array, for some reason HHVM behaves as though strict_types=1 and throws a TypeError, which I have filed separately: #7834

@lexidor
Copy link
Collaborator

lexidor commented May 20, 2020

I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.

I have tested your repro, but with an explicit \trigger_error() and the filename was printed correctly.

<?hh // partial
namespace X;

class Test {
    public static function invoke() {
        \set_error_handler(function($severity, $message, $file) {
            \var_dump($file);
        });

        \trigger_error('array given', \E_USER_WARNING);
    }

}

Test::invoke();

@lexidor lexidor closed this as completed May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants