Permalink
Browse files

update docblocks

  • Loading branch information...
1 parent 10a3b2a commit 1094e8a4a43bcc66377acaadd6e60f2c1e4a3b9e @pmjones pmjones committed Apr 8, 2013
Showing with 79 additions and 7 deletions.
  1. +25 −6 src/Aura/Di/Container.php
  2. +54 −1 src/Aura/Di/Factory.php
View
@@ -428,8 +428,17 @@ public function lazyInclude($file)
});
}
- // we can't necessarily typehint this as callable, because if we use a
- // Lazy, it won't have the method on the object it's wrapped around.
+ /**
+ *
+ * Returns a Lazy that invokes a callable (e.g., to call a method on an
+ * object).
+ *
+ * @param callable The callable. Params after this one are treated as
+ * params for the call.
+ *
+ * @return Lazy
+ *
+ */
public function lazyCall($callable)
{
// get params, if any, after removing $callable
@@ -463,10 +472,20 @@ public function lazyCall($callable)
return $this->lazy($call);
}
- // returns a factory that creates an object over and over again (as vs
- // creating it one time like the lazyNew() or newInstance() methods).
- // we don't want this to be a Lazy because we don't want the Forge to
- // recognize and invoke it when passed as a param or setter value.
+ /**
+ *
+ * Returns a Factory that creates an object over and over again (as vs
+ * creating it one time like the lazyNew() or newInstance() methods).
+ *
+ * @param string $class THe factory will create an instance of this class.
+ *
+ * @param array $params Override parameters for the instance.
+ *
+ * @param array $setters Override setters for the instance.
+ *
+ * @return Factory
+ *
+ */
public function newFactory($class, array $params = [], array $setters = [])
{
return new Factory($this->forge, $class, $params, $setters);
View
@@ -19,14 +19,55 @@
*/
class Factory
{
+ /**
+ *
+ * An object forge.
+ *
+ * @var ForgeInterface
+ *
+ */
protected $forge;
+ /**
+ *
+ * The class to create.
+ *
+ * @var string
+ *
+ */
protected $class;
+ /**
+ *
+ * Override params for the class.
+ *
+ * @var array
+ *
+ */
protected $params;
+ /**
+ *
+ * Override setters for the class.
+ *
+ * @var array
+ *
+ */
protected $setter;
+ /**
+ *
+ * Constructor.
+ *
+ * @param ForgeInterface $forge
+ *
+ * @param string $class The class to create.
+ *
+ * @param array $params Override params for the class.
+ *
+ * @param array $setter Override setters for the class.
+ *
+ */
public function __construct(
ForgeInterface $forge,
$class,
@@ -39,7 +80,19 @@ public function __construct(
$this->setter = $setter;
}
- // func_get_args() are overrides to the overrides
+ /**
+ *
+ * Invoke this Factory object as a function to use the Forge to create a
+ * new instance of the specified class; pass sequential parameters as
+ * as yet another set of constructor parameter overrides.
+ *
+ * Why the overrides for the overrides? So that any package that needs a
+ * factory can make its own, using sequential params in a function; then
+ * the factory call can be replaced by a call to this Factory.
+ *
+ * @return object
+ *
+ */
public function __invoke()
{
$params = array_merge($this->params, func_get_args());

0 comments on commit 1094e8a

Please sign in to comment.