Switch to ECS for coding style

This allows configuration via PHP.
It also combines code sniffer and php cs fixer.

Used commands:

composer remove --dev squizlabs/php_codesniffer
composer req --dev symplify/easy-coding-standard
./vendor/bin/ecs --fix
This commit is contained in:
Daniel Siepmann 2021-05-21 18:49:38 +02:00
parent 165b110e01
commit adb73eeffc
19 changed files with 37 additions and 26 deletions

View file

@ -140,9 +140,6 @@ jobs:
- name: PHPUnit configuration file
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
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
@ -151,8 +148,6 @@ jobs:
coding-guideline:
runs-on: ubuntu-latest
needs:
- xml-linting
steps:
- uses: actions/checkout@v2
@ -177,7 +172,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest
- name: Coding Guideline
run: ./vendor/bin/phpcs
run: ./vendor/bin/ecs check
tests-sqlite-TYPO3-v10:
runs-on: ubuntu-latest

View file

@ -92,7 +92,7 @@ class NewestPageviews implements ListDataProviderInterface
->setMaxResults($this->maxResults);
if ($constraints !== []) {
$this->queryBuilder->where(... $constraints);
$this->queryBuilder->where(...$constraints);
}
$items = $this->queryBuilder->execute()->fetchAll();

View file

@ -145,7 +145,7 @@ class PageviewsPerDay implements ChartDataProviderInterface
return (int)$this->queryBuilder
->count('*')
->from('tx_tracking_pageview')
->where(... $constraints)
->where(...$constraints)
->execute()
->fetchColumn();
}

View file

@ -105,7 +105,7 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
->selectLiteral('count(operating_system) as total')
->addSelect('operating_system')
->from('tx_tracking_pageview')
->where(... $constraints)
->where(...$constraints)
->groupBy('tx_tracking_pageview.operating_system')
->orderBy('total', 'desc')
->addOrderBy('operating_system', 'asc')

View file

@ -131,7 +131,7 @@ class PageviewsPerPage implements ChartDataProviderInterface
)
->addSelect('pid')
->from('tx_tracking_pageview')
->where(... $constraints)
->where(...$constraints)
->groupBy('pid')
->orderBy('total', 'desc')
->addOrderBy('latest', 'desc')

View file

@ -193,7 +193,7 @@ class Recordviews implements ChartDataProviderInterface
)
->addSelect('record_uid', 'record_table_name')
->from('tx_tracking_recordview')
->where(... $constraints)
->where(...$constraints)
->groupBy('record', 'record_uid', 'record_table_name')
->orderBy('total', 'desc')
->addOrderBy('latest', 'desc')

View file

@ -189,7 +189,7 @@ class PageviewsPerPageTest extends TestCase
GeneralUtility::makeInstance(PageRepository::class),
31,
6,
[1,2,3,4,5,6]
[1, 2, 3, 4, 5, 6]
);
$result = $subject->getChartData();

View file

@ -229,7 +229,7 @@ class RecordviewsTest extends TestCase
$connectionPool->getQueryBuilderForTable('tx_tracking_recordview'),
31,
6,
[1,2,3,4,5]
[1, 2, 3, 4, 5]
);
$result = $subject->getChartData();
@ -320,7 +320,7 @@ class RecordviewsTest extends TestCase
[],
[],
[],
['1',2]
['1', 2]
);
$result = $subject->getChartData();

View file

@ -23,8 +23,8 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
use DanielSiepmann\Tracking\Domain\Model\Extractor;
use DanielSiepmann\Tracking\Domain\Model\HasUserAgent;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Extractor

View file

@ -22,9 +22,9 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
*/
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Pageview

View file

@ -22,9 +22,9 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
*/
use DanielSiepmann\Tracking\Domain\Model\Recordview;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Recordview

View file

@ -23,7 +23,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview;
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophet;
use Psr\Http\Message\ServerRequestInterface;
@ -31,6 +30,7 @@ use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Pageview\Factory

View file

@ -25,11 +25,11 @@ use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
use Doctrine\DBAL\Statement;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Repository\Pageview

View file

@ -23,10 +23,10 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
use DanielSiepmann\Tracking\Domain\Repository\Recordview;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Repository\Recordview

View file

@ -24,7 +24,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Middleware;
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
use DanielSiepmann\Tracking\Domain\Repository\Pageview as Repository;
use DanielSiepmann\Tracking\Middleware\Pageview;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ResponseInterface;
@ -33,6 +32,7 @@ use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Middleware\Pageview

View file

@ -24,7 +24,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Middleware;
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
use DanielSiepmann\Tracking\Domain\Repository\Recordview as Repository;
use DanielSiepmann\Tracking\Middleware\Recordview;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ResponseInterface;
@ -33,6 +32,7 @@ use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Middleware\Recordview

View file

@ -39,7 +39,6 @@
"typo3/cms-dashboard": "^10.4 || ~11.2"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9.0",
"phpstan/phpstan": "^0.12.18",
"phpstan/extension-installer": "^1.0",
@ -47,7 +46,8 @@
"maglnet/composer-require-checker": "^3.2",
"phpspec/prophecy-phpunit": "^2.0",
"typo3/testing-framework": "^6.8.2",
"saschaegerer/phpstan-typo3": "^0.13.1"
"saschaegerer/phpstan-typo3": "^0.13.1",
"symplify/easy-coding-standard": "^9.3"
},
"minimum-stability": "dev",
"prefer-stable": true,

View file

@ -1,6 +1,6 @@
{
"scan-files": [
"*.php",
"ext_*.php",
"Configuration/*php",
"Configuration/Backend/*.php",
"Configuration/TCA/*.php"

16
ecs.php Normal file
View file

@ -0,0 +1,16 @@
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::PSR_12);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/Classes',
__DIR__ . '/Tests',
]);
};