From 9602382fd0c03a646459ba87e630270fea4716c4 Mon Sep 17 00:00:00 2001 From: Tang Rufus Date: Tue, 19 Feb 2019 12:39:52 +0000 Subject: [PATCH] Downgrade to PHP 7.0 Because wp.org svn pre-commit hook rejects PHP 7.1 syntax. --- .travis.yml | 2 ++ README.md | 2 +- composer.json | 2 +- src/ContainerAwareInterface.php | 2 +- src/ContainerAwareTrait.php | 2 +- src/Hooks/AbstractHook.php | 20 ++++++++++---------- src/Hooks/Action.php | 4 ++-- src/Hooks/Filter.php | 2 +- src/Hooks/HookInterface.php | 2 +- src/Loader.php | 4 ++-- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93da593..a1be51d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 171df0e..3fe774d 100644 --- a/README.md +++ b/README.md @@ -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); }) diff --git a/composer.json b/composer.json index 9d02ed4..3c8cd5b 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } ], "require": { - "php": "^7.1", + "php": "^7.0", "psr/container": "^1.0", "psr/container-implementation": "^1.0" }, diff --git a/src/ContainerAwareInterface.php b/src/ContainerAwareInterface.php index e0654d1..0af5107 100644 --- a/src/ContainerAwareInterface.php +++ b/src/ContainerAwareInterface.php @@ -16,7 +16,7 @@ interface ContainerAwareInterface * * @return void */ - public function setContainer(ContainerInterface $container): void; + public function setContainer(ContainerInterface $container); /** * Get the container. diff --git a/src/ContainerAwareTrait.php b/src/ContainerAwareTrait.php index 87c7f7f..4696747 100644 --- a/src/ContainerAwareTrait.php +++ b/src/ContainerAwareTrait.php @@ -39,7 +39,7 @@ public function getContainer(): ContainerInterface * * @return void */ - public function setContainer(ContainerInterface $container): void + public function setContainer(ContainerInterface $container) { $this->container = $container; } diff --git a/src/Hooks/AbstractHook.php b/src/Hooks/AbstractHook.php index 65a2812..7d437db 100644 --- a/src/Hooks/AbstractHook.php +++ b/src/Hooks/AbstractHook.php @@ -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); } } diff --git a/src/Hooks/Action.php b/src/Hooks/Action.php index 39e5041..5fd42c2 100644 --- a/src/Hooks/Action.php +++ b/src/Hooks/Action.php @@ -9,7 +9,7 @@ class Action extends AbstractHook /** * {@inheritdoc} */ - public function register(): void + public function register() { add_action( $this->hook, @@ -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); diff --git a/src/Hooks/Filter.php b/src/Hooks/Filter.php index da6978f..ef633aa 100644 --- a/src/Hooks/Filter.php +++ b/src/Hooks/Filter.php @@ -9,7 +9,7 @@ class Filter extends AbstractHook /** * {@inheritdoc} */ - public function register(): void + public function register() { add_filter( $this->hook, diff --git a/src/Hooks/HookInterface.php b/src/Hooks/HookInterface.php index 4c4c5c9..1e0f875 100644 --- a/src/Hooks/HookInterface.php +++ b/src/Hooks/HookInterface.php @@ -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. diff --git a/src/Loader.php b/src/Loader.php index bbe86f6..27d4977 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -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( @@ -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);