Skip to content

Releases: ytake/hh-container

for hhvm3.28

07 Oct 17:52
6381eb5
Compare
Choose a tag to compare
Merge pull request #13 from ytake/feature/patch-hhvm3.28

Feature/patch hhvm3.28

fixed type

23 Aug 08:48
cfdffd4
Compare
Choose a tag to compare
Merge pull request #12 from ytake/feature/patch-1

oops

fixed unbound name for HHVM3.26

07 May 17:33
8a94eb7
Compare
Choose a tag to compare
Merge pull request #9 from ytake/fixed/hhvm3.26-unbound-name-patch

fixed unbound names

0.5.1

06 Mar 18:53
Compare
Choose a tag to compare
remove join

changed async function

07 Jan 03:29
3ad3627
Compare
Choose a tag to compare
Merge pull request #8 from ytake/feature/added-async-resolver

changed imp

added method "callable", bugfixed

04 Nov 18:18
3efd9f2
Compare
Choose a tag to compare

callable

returns the value of a callable with parameters supplied at calltime.

final class TestingInvokable {
  public function __invoke(FactoryContainer $container): int {
    return 1;
  }
}

$container = new \Ytake\HHContainer\FactoryContainer();
$container->set(TestingInvokable::class, $container ==> 
  $container->callable(
    new \Ytake\HHContainer\Invokable(
      new TestingInvokable(), '__invoke', $container
    )
  )
);

for zend expressive, and more

dependency component version up

31 Oct 17:22
5a7bfce
Compare
Choose a tag to compare

usage

Dependency Injection

set parameters

$container->parameters(string className, 'parameter name', function ($container) {
  return 'parameter value';
});

sample class

final class MessageClass {
  public function __construct(protected string $message) {
  }
  public function message(): string {
    return $this->message;
  }
}

final class MessageClient {
  public function __construct(protected MessageClass $message) {

  }
  public function message(): MessageClass {
    return $this->message;
  }
}

Inject

$container = new \Headacke\FactoryContainer();
$container->set('message.class', function ($container) {
  return new MessageClass('testing');
});
$container->parameters(MessageClient::class, 'message', function ($container) {
  return $container->get('message.class');
});
$instance = $container->get(MessageClient::class);

not supported auto wiring