Skip to content

Support parameter binding

Latest
Compare
Choose a tag to compare
@basuke basuke released this 26 Apr 05:22
· 5 commits to master since this release

With parameter binding, the parameters of task function are automatically pulled from container, options or arguments.

example:

$app->task(function(\PDO $db, array $args) {
    // $db will be pulled from container
    // equivalent to
    // /** @var \PDO $db */
    // $db = $this->db;
});

For $options and $arguments which is the parameters for task prior to 1.5.0, there must be a special rule for them.

  • $options and $opts are reserved argument for array $options
  • $arguments and $args are reserved argument for array $arguments
  • $context are reserved argument for Context $context
  • It's possible to specify those should be array or Hash or whatever classes accept array to its constructor. The default is array.