Exemple #1
0
$Injector->define("A", ["DependencyA" => new DependencyA("LOOOVE"), ":doing" => "Cradt"]);
$Injector->share('A');
echo $Injector->make("A") === $Injector->make("A");
$Injector->make("A");
$Injector->define("E", [":bar" => "Great Rocket", ":call" => "jimmy"]);
class NoConstructor
{
    function callMe()
    {
        echo "baby" . PHP_EOL;
    }
}
class CallMe
{
    public function onConstruct()
    {
        echo "onConstruct" . PHP_EOL;
    }
    function maybe($name = "Dan", NoConstructor $NoConstructor)
    {
        $NoConstructor->callMe();
        echo $name;
    }
}
$start = microtime();
$Injector->saveReflection("CallMe");
$CallMe = $Injector->make("CallMe");
$Injector->callMethod("A", "sayHello");
$Injector->callMethod("A", "bye");
echo (microtime() - $start) * 6.0E-6;
//var_dump(get_defined_vars());