From 9a268f6a013c11b48566cedef100ca1661594bcc Mon Sep 17 00:00:00 2001 From: jbelien Date: Sun, 18 Mar 2018 12:09:44 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/config.php | 4 ++-- config/pipeline.php | 3 +-- public/index.php | 2 +- src/ConfigProvider.php | 6 +++--- src/Handler/WebhookHandler.php | 11 ++++++----- src/Middleware/ConfigMiddleware.php | 12 +++++------- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/config/config.php b/config/config.php index ac594b6..b88b0cd 100644 --- a/config/config.php +++ b/config/config.php @@ -31,10 +31,10 @@ // - `*.global.php` // - `local.php` // - `*.local.php` - new PhpFileProvider(realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php'), + new PhpFileProvider(realpath(__DIR__).'/autoload/{{,*.}global,{,*.}local}.php'), // Load development config if it exists - new PhpFileProvider(realpath(__DIR__) . '/development.config.php'), + new PhpFileProvider(realpath(__DIR__).'/development.config.php'), ], $cacheConfig['config_cache_path']); return $aggregator->getMergedConfig(); diff --git a/config/pipeline.php b/config/pipeline.php index 6acff3a..14cd0ff 100644 --- a/config/pipeline.php +++ b/config/pipeline.php @@ -17,8 +17,7 @@ use Zend\Expressive\Router\Middleware\RouteMiddleware; use Zend\Stratigility\Middleware\ErrorHandler; - -/** +/* * Setup middleware pipeline: */ return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void { diff --git a/public/index.php b/public/index.php index 93ea117..51c13f3 100644 --- a/public/index.php +++ b/public/index.php @@ -15,7 +15,7 @@ use Zend\ServiceManager\Config; use Zend\ServiceManager\ServiceManager; -/** +/* * Self-called anonymous function that creates its own scope and keep the global namespace clean. */ (function () { diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 0748b7a..c1178c2 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -5,14 +5,14 @@ namespace App; /** - * The configuration provider for the App module + * The configuration provider for the App module. * * @see https://docs.zendframework.com/zend-component-installer/ */ class ConfigProvider { /** - * Returns the configuration array + * Returns the configuration array. */ public function __invoke() : array { @@ -22,7 +22,7 @@ public function __invoke() : array } /** - * Returns the container dependencies + * Returns the container dependencies. */ public function getDependencies() : array { diff --git a/src/Handler/WebhookHandler.php b/src/Handler/WebhookHandler.php index 3dac02e..34e099b 100644 --- a/src/Handler/WebhookHandler.php +++ b/src/Handler/WebhookHandler.php @@ -32,7 +32,7 @@ public function handle(ServerRequestInterface $request) : ResponseInterface $this->signature = $headers['x-hub-signature'][0] ?? ''; if (isset($this->config['token']) && !empty($this->config['token'])) { - $sha1 = hash_hmac('sha1', (string)$request->getBody(), $this->config['token']); + $sha1 = hash_hmac('sha1', (string) $request->getBody(), $this->config['token']); if (hash_equals('sha1='.$sha1, $this->signature) !== true) { return new TextResponse('ERROR: Invalid signature!', 401); @@ -54,15 +54,17 @@ public function handle(ServerRequestInterface $request) : ResponseInterface } } - private function ping() { + private function ping() + { return new TextResponse('pong'); } - private function push() { + private function push() + { $repository = $this->payload['repository']['full_name']; $branch = substr($this->payload['ref'], 11); - $out = 'DELIVERY: '.$this->delivery.PHP_EOL; + $out = 'DELIVERY: '.$this->delivery.PHP_EOL; $out .= 'BY: '.$this->payload['pusher']['name'].PHP_EOL; $out .= '--------------------------------------------------'.PHP_EOL; @@ -95,7 +97,6 @@ private function push() { $out .= '--------------------------------------------------'.PHP_EOL; } - return new TextResponse($out, $status); } } diff --git a/src/Middleware/ConfigMiddleware.php b/src/Middleware/ConfigMiddleware.php index 3c79efc..b489d03 100644 --- a/src/Middleware/ConfigMiddleware.php +++ b/src/Middleware/ConfigMiddleware.php @@ -4,15 +4,13 @@ namespace App\Middleware; -use Psr\Http\Server\MiddlewareInterface; -use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\MiddlewareInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\ConfigAggregator\ConfigAggregator; -use Zend\ConfigAggregator\PhpFileProvider; use Zend\ConfigAggregator\ZendConfigProvider; - class ConfigMiddleware implements MiddlewareInterface { public const CONFIG_ATTRIBUTE = 'config'; @@ -24,10 +22,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface ]; $config = new ConfigAggregator([ - new ZendConfigProvider(realpath(dirname(dirname(__DIR__))) . '/composer.json'), - new ZendConfigProvider(realpath(dirname(dirname(__DIR__))) . '/config/application/*.{php,ini,xml,json,yaml}'), + new ZendConfigProvider(realpath(dirname(dirname(__DIR__))).'/composer.json'), + new ZendConfigProvider(realpath(dirname(dirname(__DIR__))).'/config/application/*.{php,ini,xml,json,yaml}'), ], $cacheConfig['config_cache_path']); return $handler->handle($request->withAttribute(self::CONFIG_ATTRIBUTE, $config->getMergedConfig())); } -} \ No newline at end of file +}