vendredi 13 mai 2016

PHP: Is there a way to get the return type of a method?

Given the following code structure is there a way that I can get the return type of FooFactory->createService method with PHP 5.6? I've tried ReflectionClass and ReflectionMethod classes but couldn't find a way.Thanks in advance.

class FooFactory implements FactoryInterface {
    public function createService(/*args*/)
    {
        $foo = new Foo();
        // ...
        //inject dependencies
        // ...
        return $foo;
    }
}

class Foo {
    /*...methods...*/
}

Edit: I need to get the class name without creating an instance of the FooFactory.





Aucun commentaire:

Enregistrer un commentaire