Skip to content

Commit

Permalink
Introduce coding standard checking
Browse files Browse the repository at this point in the history
  • Loading branch information
nicwortel committed Jun 27, 2020
1 parent a203617 commit 7c69f66
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
.phpunit.result.cache
composer.lock
/.phpcs-cache
/.phpunit.result.cache
/composer.lock
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
check: vendor
vendor/bin/phpstan analyse
vendor/bin/phpunit --testdox
vendor/bin/phpcs
composer validate

vendor: composer.lock
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"behat/behat": "^3.0"
},
"require-dev": {
"nicwortel/coding-standard": "^2.0",
"phpstan/phpstan": "^0.12.10",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^5.0"
},
"config": {
Expand Down
21 changes: 21 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>

<!-- Show progress and sniff names -->
<arg value="p" />

<file>src/</file>

<rule ref="NicWortel"/>

<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
</rule>
</ruleset>
1 change: 1 addition & 0 deletions src/Extension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace NicWortel\BehatUnusedStepDefinitionsExtension;
Expand Down
12 changes: 8 additions & 4 deletions src/UnusedStepDefinitionsChecker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace NicWortel\BehatUnusedStepDefinitionsExtension;
Expand All @@ -9,7 +10,10 @@
use Behat\Behat\EventDispatcher\Event\AfterStepTested;
use Behat\Testwork\EventDispatcher\Event\AfterSuiteTested;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use function array_diff;
use function sprintf;

use const PHP_EOL;

final class UnusedStepDefinitionsChecker implements EventSubscriberInterface
Expand Down Expand Up @@ -72,10 +76,10 @@ public function checkUnusedStepDefinitions(AfterSuiteTested $event): void

foreach ($unusedDefinitions as $unusedDefinition) {
echo sprintf(
'Unused definition: %s %s',
$unusedDefinition->getType(),
$unusedDefinition->getPattern()
) . PHP_EOL;
'Unused definition: %s %s',
$unusedDefinition->getType(),
$unusedDefinition->getPattern()
) . PHP_EOL;
}
}
}

0 comments on commit 7c69f66

Please sign in to comment.