jeudi 29 octobre 2015

Dynamic type-hinting in Laravel

I was wondering if it is possible to use type-hinting dynamically.

Example:

class Foo {
    __construct(Baz $baz) {
    }
}

class Bar {
    __construct() {
    }

    action() {
        $baz = new Baz;
        return new Foo($baz);
    }
}

class Baz {
    __construct() {
    }
}

I am intending to do it in a generic way so the class will be reusable but in the same time to keep the type hinting:

class Foo {
        __construct(Object $object) {
        }
}





Aucun commentaire:

Enregistrer un commentaire