mirror of
https://github.com/DanielSiepmann/tracking.git
synced 2024-11-25 06:36:12 +01:00
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:
parent
165b110e01
commit
adb73eeffc
19 changed files with 37 additions and 26 deletions
7
.github/workflows/ci.yaml
vendored
7
.github/workflows/ci.yaml
vendored
|
@ -140,9 +140,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
|
||||||
|
|
||||||
|
@ -151,8 +148,6 @@ jobs:
|
||||||
|
|
||||||
coding-guideline:
|
coding-guideline:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- xml-linting
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
@ -177,7 +172,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 check
|
||||||
|
|
||||||
tests-sqlite-TYPO3-v10:
|
tests-sqlite-TYPO3-v10:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -92,7 +92,7 @@ class NewestPageviews implements ListDataProviderInterface
|
||||||
->setMaxResults($this->maxResults);
|
->setMaxResults($this->maxResults);
|
||||||
|
|
||||||
if ($constraints !== []) {
|
if ($constraints !== []) {
|
||||||
$this->queryBuilder->where(... $constraints);
|
$this->queryBuilder->where(...$constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = $this->queryBuilder->execute()->fetchAll();
|
$items = $this->queryBuilder->execute()->fetchAll();
|
||||||
|
|
|
@ -103,7 +103,7 @@ class PageviewsPerDay implements ChartDataProviderInterface
|
||||||
for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) {
|
for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) {
|
||||||
$timeForLabel = (int) strtotime('-' . $daysBefore . ' day');
|
$timeForLabel = (int) strtotime('-' . $daysBefore . ' day');
|
||||||
$startPeriod = (int) strtotime('-' . $daysBefore . ' day 0:00:00');
|
$startPeriod = (int) strtotime('-' . $daysBefore . ' day 0:00:00');
|
||||||
$endPeriod = (int) strtotime('-' . $daysBefore . ' day 23:59:59');
|
$endPeriod = (int) strtotime('-' . $daysBefore . ' day 23:59:59');
|
||||||
|
|
||||||
$labels[] = date($this->dateFormat, $timeForLabel);
|
$labels[] = date($this->dateFormat, $timeForLabel);
|
||||||
$data[] = $this->getPageviewsInPeriod($startPeriod, $endPeriod);
|
$data[] = $this->getPageviewsInPeriod($startPeriod, $endPeriod);
|
||||||
|
@ -145,7 +145,7 @@ class PageviewsPerDay implements ChartDataProviderInterface
|
||||||
return (int)$this->queryBuilder
|
return (int)$this->queryBuilder
|
||||||
->count('*')
|
->count('*')
|
||||||
->from('tx_tracking_pageview')
|
->from('tx_tracking_pageview')
|
||||||
->where(... $constraints)
|
->where(...$constraints)
|
||||||
->execute()
|
->execute()
|
||||||
->fetchColumn();
|
->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
|
||||||
->selectLiteral('count(operating_system) as total')
|
->selectLiteral('count(operating_system) as total')
|
||||||
->addSelect('operating_system')
|
->addSelect('operating_system')
|
||||||
->from('tx_tracking_pageview')
|
->from('tx_tracking_pageview')
|
||||||
->where(... $constraints)
|
->where(...$constraints)
|
||||||
->groupBy('tx_tracking_pageview.operating_system')
|
->groupBy('tx_tracking_pageview.operating_system')
|
||||||
->orderBy('total', 'desc')
|
->orderBy('total', 'desc')
|
||||||
->addOrderBy('operating_system', 'asc')
|
->addOrderBy('operating_system', 'asc')
|
||||||
|
|
|
@ -131,7 +131,7 @@ class PageviewsPerPage implements ChartDataProviderInterface
|
||||||
)
|
)
|
||||||
->addSelect('pid')
|
->addSelect('pid')
|
||||||
->from('tx_tracking_pageview')
|
->from('tx_tracking_pageview')
|
||||||
->where(... $constraints)
|
->where(...$constraints)
|
||||||
->groupBy('pid')
|
->groupBy('pid')
|
||||||
->orderBy('total', 'desc')
|
->orderBy('total', 'desc')
|
||||||
->addOrderBy('latest', 'desc')
|
->addOrderBy('latest', 'desc')
|
||||||
|
|
|
@ -193,7 +193,7 @@ class Recordviews implements ChartDataProviderInterface
|
||||||
)
|
)
|
||||||
->addSelect('record_uid', 'record_table_name')
|
->addSelect('record_uid', 'record_table_name')
|
||||||
->from('tx_tracking_recordview')
|
->from('tx_tracking_recordview')
|
||||||
->where(... $constraints)
|
->where(...$constraints)
|
||||||
->groupBy('record', 'record_uid', 'record_table_name')
|
->groupBy('record', 'record_uid', 'record_table_name')
|
||||||
->orderBy('total', 'desc')
|
->orderBy('total', 'desc')
|
||||||
->addOrderBy('latest', 'desc')
|
->addOrderBy('latest', 'desc')
|
||||||
|
|
|
@ -189,7 +189,7 @@ class PageviewsPerPageTest extends TestCase
|
||||||
GeneralUtility::makeInstance(PageRepository::class),
|
GeneralUtility::makeInstance(PageRepository::class),
|
||||||
31,
|
31,
|
||||||
6,
|
6,
|
||||||
[1,2,3,4,5,6]
|
[1, 2, 3, 4, 5, 6]
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $subject->getChartData();
|
$result = $subject->getChartData();
|
||||||
|
|
|
@ -229,7 +229,7 @@ class RecordviewsTest extends TestCase
|
||||||
$connectionPool->getQueryBuilderForTable('tx_tracking_recordview'),
|
$connectionPool->getQueryBuilderForTable('tx_tracking_recordview'),
|
||||||
31,
|
31,
|
||||||
6,
|
6,
|
||||||
[1,2,3,4,5]
|
[1, 2, 3, 4, 5]
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $subject->getChartData();
|
$result = $subject->getChartData();
|
||||||
|
@ -320,7 +320,7 @@ class RecordviewsTest extends TestCase
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
['1',2]
|
['1', 2]
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $subject->getChartData();
|
$result = $subject->getChartData();
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
|
||||||
|
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Extractor;
|
use DanielSiepmann\Tracking\Domain\Model\Extractor;
|
||||||
use DanielSiepmann\Tracking\Domain\Model\HasUserAgent;
|
use DanielSiepmann\Tracking\Domain\Model\HasUserAgent;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Model\Extractor
|
* @covers DanielSiepmann\Tracking\Domain\Model\Extractor
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Pageview;
|
use DanielSiepmann\Tracking\Domain\Model\Pageview;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Model\Pageview
|
* @covers DanielSiepmann\Tracking\Domain\Model\Pageview
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Recordview;
|
use DanielSiepmann\Tracking\Domain\Model\Recordview;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Model\Recordview
|
* @covers DanielSiepmann\Tracking\Domain\Model\Recordview
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview;
|
||||||
|
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Pageview;
|
use DanielSiepmann\Tracking\Domain\Model\Pageview;
|
||||||
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
|
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Prophecy\Prophet;
|
use Prophecy\Prophet;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
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\Site;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Pageview\Factory
|
* @covers DanielSiepmann\Tracking\Domain\Pageview\Factory
|
||||||
|
|
|
@ -25,11 +25,11 @@ use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
|
||||||
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
|
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
|
||||||
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
|
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
|
||||||
use Doctrine\DBAL\Statement;
|
use Doctrine\DBAL\Statement;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use TYPO3\CMS\Core\Database\Connection;
|
use TYPO3\CMS\Core\Database\Connection;
|
||||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Repository\Pageview
|
* @covers DanielSiepmann\Tracking\Domain\Repository\Pageview
|
||||||
|
|
|
@ -23,10 +23,10 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
|
||||||
|
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
|
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
|
||||||
use DanielSiepmann\Tracking\Domain\Repository\Recordview;
|
use DanielSiepmann\Tracking\Domain\Repository\Recordview;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use TYPO3\CMS\Core\Database\Connection;
|
use TYPO3\CMS\Core\Database\Connection;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Domain\Repository\Recordview
|
* @covers DanielSiepmann\Tracking\Domain\Repository\Recordview
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Middleware;
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
|
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
|
||||||
use DanielSiepmann\Tracking\Domain\Repository\Pageview as Repository;
|
use DanielSiepmann\Tracking\Domain\Repository\Pageview as Repository;
|
||||||
use DanielSiepmann\Tracking\Middleware\Pageview;
|
use DanielSiepmann\Tracking\Middleware\Pageview;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -33,6 +32,7 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||||
use TYPO3\CMS\Core\Context\Context;
|
use TYPO3\CMS\Core\Context\Context;
|
||||||
use TYPO3\CMS\Core\Routing\PageArguments;
|
use TYPO3\CMS\Core\Routing\PageArguments;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Middleware\Pageview
|
* @covers DanielSiepmann\Tracking\Middleware\Pageview
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Middleware;
|
||||||
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
|
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
|
||||||
use DanielSiepmann\Tracking\Domain\Repository\Recordview as Repository;
|
use DanielSiepmann\Tracking\Domain\Repository\Recordview as Repository;
|
||||||
use DanielSiepmann\Tracking\Middleware\Recordview;
|
use DanielSiepmann\Tracking\Middleware\Recordview;
|
||||||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -33,6 +32,7 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||||
use TYPO3\CMS\Core\Context\Context;
|
use TYPO3\CMS\Core\Context\Context;
|
||||||
use TYPO3\CMS\Core\Routing\PageArguments;
|
use TYPO3\CMS\Core\Routing\PageArguments;
|
||||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||||
|
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers DanielSiepmann\Tracking\Middleware\Recordview
|
* @covers DanielSiepmann\Tracking\Middleware\Recordview
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
"typo3/cms-dashboard": "^10.4 || ~11.2"
|
"typo3/cms-dashboard": "^10.4 || ~11.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"squizlabs/php_codesniffer": "^3.5",
|
|
||||||
"phpunit/phpunit": "^9.0",
|
"phpunit/phpunit": "^9.0",
|
||||||
"phpstan/phpstan": "^0.12.18",
|
"phpstan/phpstan": "^0.12.18",
|
||||||
"phpstan/extension-installer": "^1.0",
|
"phpstan/extension-installer": "^1.0",
|
||||||
|
@ -47,7 +46,8 @@
|
||||||
"maglnet/composer-require-checker": "^3.2",
|
"maglnet/composer-require-checker": "^3.2",
|
||||||
"phpspec/prophecy-phpunit": "^2.0",
|
"phpspec/prophecy-phpunit": "^2.0",
|
||||||
"typo3/testing-framework": "^6.8.2",
|
"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",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"scan-files": [
|
"scan-files": [
|
||||||
"*.php",
|
"ext_*.php",
|
||||||
"Configuration/*php",
|
"Configuration/*php",
|
||||||
"Configuration/Backend/*.php",
|
"Configuration/Backend/*.php",
|
||||||
"Configuration/TCA/*.php"
|
"Configuration/TCA/*.php"
|
||||||
|
|
16
ecs.php
Normal file
16
ecs.php
Normal 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',
|
||||||
|
]);
|
||||||
|
};
|
Loading…
Reference in a new issue