diff --git a/.travis.yml b/.travis.yml index 51b8646..be74667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,10 @@ jobs: script: - vendor/bin/composer-require-checker + - stage: coding standards + script: + - vendor/bin/phpcs --standard=phpcs.xml + - stage: coverage script: - vendor/bin/phpunit --coverage-clover=coverage.xml diff --git a/composer.json b/composer.json index 5107894..4fe1967 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "duncan3dc/object-intruder": "^0.3.0", "maglnet/composer-require-checker": "^1.1", "mockery/mockery": "^1.2", + "squizlabs/php_codesniffer": "^3.4", "phpunit/phpunit": "^7.3" }, "autoload": { diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..b61c940 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,17 @@ + + + + src + tests + + .blade.php + + + + + + + 0 + + + diff --git a/src/Blade.php b/src/Blade.php index a450acd..f0363d7 100644 --- a/src/Blade.php +++ b/src/Blade.php @@ -76,7 +76,7 @@ public static function registerDirectives(CompilerInterface $blade): void { \trigger_error('Blade::registerDirectives() is deprecated in favour of using the Directives class', \E_USER_DEPRECATED); - $directives = new Directives; + $directives = new Directives(); $directives->register($blade); } } diff --git a/src/BladeInstance.php b/src/BladeInstance.php index 32d63b2..4935f91 100644 --- a/src/BladeInstance.php +++ b/src/BladeInstance.php @@ -63,7 +63,7 @@ public function __construct(string $path, string $cache, DirectivesInterface $di $this->cache = $cache; if ($directives === null) { - $directives = new Directives; + $directives = new Directives(); } $this->directives = $directives; } @@ -77,7 +77,7 @@ public function __construct(string $path, string $cache, DirectivesInterface $di private function getViewFinder(): FileViewFinder { if (!$this->finder) { - $this->finder = new FileViewFinder(new Filesystem, [$this->path]); + $this->finder = new FileViewFinder(new Filesystem(), [$this->path]); } return $this->finder; @@ -95,20 +95,20 @@ private function getViewFactory(): FactoryInterface return $this->factory; } - $resolver = new EngineResolver; + $resolver = new EngineResolver(); $resolver->register("blade", function () { if (!is_dir($this->cache)) { mkdir($this->cache, 0777, true); } - $blade = new BladeCompiler(new Filesystem, $this->cache); + $blade = new BladeCompiler(new Filesystem(), $this->cache); $this->directives->register($blade); return new CompilerEngine($blade); }); - $this->factory = new Factory($resolver, $this->getViewFinder(), new Dispatcher); + $this->factory = new Factory($resolver, $this->getViewFinder(), new Dispatcher()); return $this->factory; } @@ -175,7 +175,7 @@ public function directive(string $name, callable $handler): BladeInterface public function if(string $name, callable $handler): BladeInterface { if (!$this->conditionHandler) { - $this->conditionHandler = new ConditionHandler; + $this->conditionHandler = new ConditionHandler(); $this->share("_condition_handler", $this->conditionHandler); } diff --git a/tests/AbstractTest.php b/tests/AbstractTest.php index 4706579..258e33c 100644 --- a/tests/AbstractTest.php +++ b/tests/AbstractTest.php @@ -14,9 +14,9 @@ abstract class AbstractTest extends TestCase public function setUp() { - $this->blade = new BladeCompiler(new Filesystem, "/tmp/phpunit/cache/views"); + $this->blade = new BladeCompiler(new Filesystem(), "/tmp/phpunit/cache/views"); - $this->directives = new Directives; + $this->directives = new Directives(); } public function assertTemplateString($expected, $template) diff --git a/tests/ConditionHandlerTest.php b/tests/ConditionHandlerTest.php index 6cd1e80..d39a704 100644 --- a/tests/ConditionHandlerTest.php +++ b/tests/ConditionHandlerTest.php @@ -12,7 +12,7 @@ class ConditionHandlerTest extends TestCase public function setUp() { - $this->handler = new ConditionHandler; + $this->handler = new ConditionHandler(); } diff --git a/tests/DirectivesTest.php b/tests/DirectivesTest.php index ed46eea..51dd44a 100644 --- a/tests/DirectivesTest.php +++ b/tests/DirectivesTest.php @@ -13,7 +13,7 @@ class DirectivesTest extends TestCase public function setUp() { - $this->directives = (new Directives) + $this->directives = (new Directives()) ->withoutNamespace() ->withoutUse() ->withoutCss() @@ -31,7 +31,7 @@ public function tearDown() public function testDefaults() { - $directives = new Directives; + $directives = new Directives(); $this->compiler->shouldReceive("directive")->with("namespace", Mockery::any()); $this->compiler->shouldReceive("directive")->with("use", Mockery::any());