Skip to content

Commit

Permalink
void
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus committed Feb 19, 2019
1 parent ca26811 commit 3f07eb4
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ add_filter('the_content', [$foo, 'filterSomething'])
In WordPress plus container, the above is similar to:

```php
add_action('admin_init', function ($arg) use ($container): void {
add_action('admin_init', function ($arg) use ($container) {
$bar = $container->get('bar');
$bar->doSomething($arg);
})
Expand Down
2 changes: 1 addition & 1 deletion src/ContainerAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ContainerAwareInterface
*
* @return void
*/
public function setContainer(ContainerInterface $container): void;
public function setContainer(ContainerInterface $container);

/**
* Get the container.
Expand Down
2 changes: 1 addition & 1 deletion src/ContainerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getContainer(): ContainerInterface
*
* @return void
*/
public function setContainer(ContainerInterface $container): void
public function setContainer(ContainerInterface $container)
{
$this->container = $container;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Hooks/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Action extends AbstractHook
/**
* {@inheritdoc}
*/
public function register(): void
public function register()
{
add_action(
$this->hook,
Expand All @@ -26,11 +26,11 @@ public function register(): void
*
* @return void
*/
public function run(...$args): void
public function run(...$args)
{
$container = $this->getContainer();
$instance = $container->get($this->classIdentifier);

call_user_func_array([$instance, $this->callbackMethod], $args);
$instance->{$this->callbackMethod}(...$args);
}
}
4 changes: 2 additions & 2 deletions src/Hooks/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Filter extends AbstractHook
/**
* {@inheritdoc}
*/
public function register(): void
public function register()
{
add_filter(
$this->hook,
Expand All @@ -31,6 +31,6 @@ public function run(...$args)
$container = $this->getContainer();
$instance = $container->get($this->classIdentifier);

return call_user_func_array([$instance, $this->callbackMethod], $args);
return $instance->{$this->callbackMethod}(...$args);
}
}
2 changes: 1 addition & 1 deletion src/Hooks/HookInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface HookInterface extends ContainerAwareInterface
*
* @return void
*/
public function register(): void;
public function register();

/**
* The actual callback that WordPress going to fire.
Expand Down
4 changes: 2 additions & 2 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(ContainerInterface $container)
*
* @return void
*/
public function add(HookInterface ...$hooks): void
public function add(HookInterface ...$hooks)
{
$this->hooks = array_values(
array_unique(
Expand All @@ -57,7 +57,7 @@ public function add(HookInterface ...$hooks): void
*
* @return void
*/
public function run(): void
public function run()
{
foreach ($this->hooks as $hook) {
$hook->setContainer($this->container);
Expand Down

0 comments on commit 3f07eb4

Please sign in to comment.