Skip to content

Commit

Permalink
Downgrade to PHP 7.0
Browse files Browse the repository at this point in the history
Because wp.org svn pre-commit hook rejects PHP 7.1 syntax.
  • Loading branch information
tangrufus committed Feb 19, 2019
1 parent 0601190 commit 9602382
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ jobs:
after_success: bash <(curl -s https://codecov.io/bash) -s "$TRAVIS_BUILD_DIR/tests/_output/"
- stage: test
php: 7.1
- stage: test
php: 7.0
- stage: test
php: nightly
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.0",
"psr/container": "^1.0",
"psr/container-implementation": "^1.0"
},
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
20 changes: 10 additions & 10 deletions src/Hooks/AbstractHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ abstract class AbstractHook implements HookInterface
/**
* Filter constructor.
*
* @param string $hook The name of the WordPress hook that is being registered.
* @param string $classIdentifier Identifier of the entry to look for from container.
* @param string $callbackMethod The callback method name.
* @param int|null $priority Optional.The priority at which the function should be fired. Default is 10.
* @param int|null $acceptedArgs Optional. The number of arguments that should be passed to the $callback.
* Default is 1.
* @param string $hook The name of the WordPress hook that is being registered.
* @param string $classIdentifier Identifier of the entry to look for from container.
* @param string $callbackMethod The callback method name.
* @param int $priority Optional.The priority at which the function should be fired. Default is 10.
* @param int $acceptedArgs Optional. The number of arguments that should be passed to the $callback.
* Default is 1.
*/
public function __construct(
string $hook,
string $classIdentifier,
string $callbackMethod,
?int $priority = null,
?int $acceptedArgs = null
$priority = null,
$acceptedArgs = null
) {
$this->hook = $hook;
$this->classIdentifier = $classIdentifier;
$this->callbackMethod = $callbackMethod;
$this->priority = $priority ?? 10;
$this->acceptedArgs = $acceptedArgs ?? 1;
$this->priority = (int) ($priority ?? 10);
$this->acceptedArgs = (int) ($acceptedArgs ?? 1);
}
}
4 changes: 2 additions & 2 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,7 +26,7 @@ public function register(): void
*
* @return void
*/
public function run(...$args): void
public function run(...$args)
{
$container = $this->getContainer();
$instance = $container->get($this->classIdentifier);
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
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 9602382

Please sign in to comment.