Skip to content

Commit

Permalink
Ensure code conforms to the PSR coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Jan 19, 2019
1 parent 673ffc2 commit 4252974
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 17 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset name="duncan3dc">

<file>src</file>
<file>tests</file>

<exclude-pattern>.blade.php</exclude-pattern>

<rule ref="PSR1" />
<rule ref="PSR2" />
<rule ref="PSR12" />

<rule ref="Generic.Files.LineLength">
<severity>0</severity>
</rule>

</ruleset>
2 changes: 1 addition & 1 deletion src/Blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 6 additions & 6 deletions src/BladeInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/ConditionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ConditionHandlerTest extends TestCase

public function setUp()
{
$this->handler = new ConditionHandler;
$this->handler = new ConditionHandler();
}


Expand Down
4 changes: 2 additions & 2 deletions tests/DirectivesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DirectivesTest extends TestCase

public function setUp()
{
$this->directives = (new Directives)
$this->directives = (new Directives())
->withoutNamespace()
->withoutUse()
->withoutCss()
Expand All @@ -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());
Expand Down

0 comments on commit 4252974

Please sign in to comment.