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

Uncaught reflection exception #58

Open
flip111 opened this issue Jun 12, 2014 · 1 comment
Open

Uncaught reflection exception #58

flip111 opened this issue Jun 12, 2014 · 1 comment
Labels

Comments

@flip111
Copy link

flip111 commented Jun 12, 2014

It would be nice if ladybug could catch this Exception and make some more descriptive information rather then letting PHP crash on a Fatal Error.

<?php
class Foo {
    public function publicFunction() {
        $this->privateFunction($this, null);
    }

    private function privateFunction($that, Bar $undefinedObject = null) {
ldd($that);
    }
}

$b = new Foo();
$b->publicFunction();

Fatal error: Uncaught exception 'ReflectionException' with message 'Class Bar does not exist'

Relevant documentation: http:https://www.php.net/manual/en/reflectionparameter.getclass.php

@raulfraile raulfraile added the DX label Aug 20, 2014
@ricardclau
Copy link
Contributor

I have looked into this and we can definitely detect this issue in runtime but I am not sure about how to alert the user in the dump process

I have been able to intercept the problem with this dirty hack around https://github.com/raulfraile/ladybug/blob/master/src/Ladybug/Type/Object/Container.php#L389:

                try {
                    $class = $methodParameterReflected->getClass();
                } catch (\ReflectionException $e) {
                    // This happens if the Class does not exist
                    $methodParameter->setType('Wrong_Typehint!');
                }

With this, ldd works just fine and when dumping the signatures of the method, this Wrong_Typehint! warning appears but I am not sure about how to make it more relevant to the user

Ideas @raulfraile ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants