Replace phpcs with ecs

This combines phpcs and php-cs-fixer and provides handy configuration.
This commit is contained in:
Daniel Siepmann 2021-02-23 11:41:18 +01:00
parent 00a9516ae9
commit 6fff1efe49
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
5 changed files with 38 additions and 25 deletions

View file

@ -85,9 +85,6 @@ jobs:
- name: PHPUnit configuration file - name: PHPUnit configuration file
run: xmllint --schema vendor/phpunit/phpunit/phpunit.xsd --noout phpunit.xml.dist run: xmllint --schema vendor/phpunit/phpunit/phpunit.xsd --noout phpunit.xml.dist
- name: PHPCodeSniffer configuration file
run: xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd --noout phpcs.xml.dist
- name: Fetch schema for xliff - name: Fetch schema for xliff
run: wget https://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd --output-document=.Build/xliff-core-1.2-strict.xsd run: wget https://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd --output-document=.Build/xliff-core-1.2-strict.xsd
@ -121,7 +118,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest run: composer install --prefer-dist --no-progress --no-suggest
- name: Coding Guideline - name: Coding Guideline
run: ./vendor/bin/phpcs run: ./vendor/bin/ecs
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -21,10 +21,10 @@ namespace WerkraumMedia\Calendar\Tests\Unit\Domain\Model;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use WerkraumMedia\Calendar\Domain\Model\Day; use WerkraumMedia\Calendar\Domain\Model\Day;
use WerkraumMedia\Calendar\Domain\Model\NullDataFactory; use WerkraumMedia\Calendar\Domain\Model\NullDataFactory;
use PHPUnit\Framework\TestCase;
/** /**
* @covers WerkraumMedia\Calendar\Domain\Model\NullDataFactory * @covers WerkraumMedia\Calendar\Domain\Model\NullDataFactory

View file

@ -32,7 +32,7 @@
"maglnet/composer-require-checker": "^2.1", "maglnet/composer-require-checker": "^2.1",
"phpspec/prophecy-phpunit": "^2.0", "phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5" "symplify/easy-coding-standard": "^9.2"
}, },
"extra": { "extra": {
"typo3/cms": { "typo3/cms": {

35
ecs.php Normal file
View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/Classes',
__DIR__ . '/Tests',
__DIR__ . '/ext_emconf.php',
__DIR__ . '/ecs.php',
]);
$parameters->set(Option::SETS, [
// run and fix, one by one
// SetList::SPACES,
// SetList::ARRAY,
// SetList::DOCBLOCK,
// SetList::NAMESPACES,
// SetList::CONTROL_STRUCTURES,
// SetList::CLEAN_CODE,
SetList::PSR_12,
]);
$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]]);
};

View file

@ -1,19 +0,0 @@
<?xml version="1.0"?>
<ruleset name="project">
<description>This project coding standard</description>
<file>Classes/</file>
<file>Tests/</file>
<!-- Set default settings -->
<arg value="sp"/>
<arg name="colors"/>
<arg name="encoding" value="utf-8" />
<arg name="extensions" value="php" />
<!-- Base rules -->
<rule ref="PSR12" />
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/Tests/*</exclude-pattern>
</rule>
</ruleset>