From 6720e1a66b550800aa37f8ebf6b65cdf2da5ddeb Mon Sep 17 00:00:00 2001 From: John Koster Date: Sun, 24 Oct 2021 00:57:46 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/DirectiveFactory.php | 28 ++++++++++++++-------------- tests/ParserTest.php | 17 ++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/DirectiveFactory.php b/src/DirectiveFactory.php index 14e9089..480b5b5 100644 --- a/src/DirectiveFactory.php +++ b/src/DirectiveFactory.php @@ -3,14 +3,13 @@ namespace Stillat\BladeDirectives; use Illuminate\Support\Facades\Blade; +use ReflectionException; use ReflectionFunction; use ReflectionParameter; -use ReflectionException; use Stillat\Primitives\Parser; class DirectiveFactory { - /** * The Parser instance. * @@ -28,8 +27,8 @@ public function __construct(Parser $parser) * * Directive handlers will have access to the provided parameters through $this->parameters. * - * @param string $name - * @param callable $handler + * @param string $name + * @param callable $handler */ public function params($name, callable $handler) { @@ -39,8 +38,8 @@ public function params($name, callable $handler) /** * Register a handler for a custom Blade directive. * - * @param string $name - * @param callable $handler + * @param string $name + * @param callable $handler */ public function make($name, callable $handler) { @@ -50,8 +49,8 @@ public function make($name, callable $handler) /** * Register a handler for a custom compiled Blade directive. * - * @param string $name - * @param callable $handler + * @param string $name + * @param callable $handler */ public function compile($name, $handler) { @@ -89,7 +88,7 @@ private function getFactoryClosure($handler, $compileResult) $paramCompiler->setParameters($associatedParams); $handler = $handler->bindTo($paramCompiler); - $result = call_user_func_array($handler, $associatedParams); + $result = call_user_func_array($handler, $associatedParams); if ($compileResult) { return $paramCompiler->compile($result); @@ -102,10 +101,11 @@ private function getFactoryClosure($handler, $compileResult) /** * Associates the reflected parameters with their parsed values. * - * @param ReflectionParameter[] $directiveParameters - * @param string[] $expressionParameters - * @param bool $returnOnlyExpressionArgs + * @param ReflectionParameter[] $directiveParameters + * @param string[] $expressionParameters + * @param bool $returnOnlyExpressionArgs * @return array + * * @throws ReflectionException */ private function associateParameters($directiveParameters, $expressionParameters, $returnOnlyExpressionArgs = false) @@ -145,7 +145,7 @@ private function associateParameters($directiveParameters, $expressionParameters } } - if (!$didFind) { + if (! $didFind) { $argsToUse[] = $this->getDefaultExpression($callbackArg); } } @@ -195,4 +195,4 @@ private function getDefaultExpression(ReflectionParameter $parameter) return $defaultExpression; } -} \ No newline at end of file +} diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 84f0064..79f44a0 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -1,18 +1,17 @@ [1, env('something', 'default')]], 'six') @@ -30,7 +29,6 @@ public function test_param_directives_receives_expression_but_has_access_to_para Directive::params('test', function ($expression) use (&$directiveExpression, &$directiveParams) { /** @var $this DirectiveContainer */ - $directiveExpression = $expression; $directiveParams = $this->parameters; @@ -63,12 +61,10 @@ public function test_directives_can_define_default_values() $this->assertSame('$varName---((null) ?? (\'1234\'))', $result); - $result = Blade::compileString('@test($varName, $anotherVarName)'); $this->assertSame('$varName---(($anotherVarName) ?? (\'1234\'))', $result); - Directive::make('test', function ($name, $default = '1234', $another = 1234) { return $name.'---'.$default.'---'.$another; }); @@ -77,7 +73,6 @@ public function test_directives_can_define_default_values() $this->assertSame('$varName---((null) ?? (\'1234\'))---((null) ?? (1234))', $result); - $result = Blade::compileString('@test($varName, "test")'); $this->assertSame('$varName---(("test") ?? (\'1234\'))---((null) ?? (1234))', $result); @@ -89,7 +84,7 @@ public function test_directives_can_define_default_values() public function test_parameters_can_be_compiled() { Directive::compile('test', function ($value = []) { - return '