Skip to content

Commit

Permalink
total
Browse files Browse the repository at this point in the history
  • Loading branch information
schpill committed Jun 30, 2017
1 parent 32808d7 commit f660a4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@

class Container extends Ghost
{
protected static function called()
{
return actual('container.class', maker(get_called_class()));
}

public function __construct(array $values = [])
{
parent::__construct($values, 'container');
}

public function build($class, $args = [], $single = true)
{
if (!isset($this->$class) || !$single) {
$this->$class = maker($class, $args);
}

return $this->$class;
}

public static function __callStatic($m, $a)
{
$i = new static;
$i = static::called();

return call_user_func_array();
return call_user_func_array([$i, $m], $a);
}
}
4 changes: 4 additions & 0 deletions lib/inner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace Octo;

class Inner extends Container {};
12 changes: 12 additions & 0 deletions lib/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -6574,3 +6574,15 @@ public function __call($m, $a)
throw new \BadMethodCallException("Method {$m} does not exist.");
}
}

function inner()
{
$args = func_get_args();

if (class_exists($args[0])) {
$args = array_shift($args);
$args = array_shift($args);

return call_user_func_array($args[0], $args[1]);
}
}

0 comments on commit f660a4d

Please sign in to comment.