mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-04 19:16:13 +01:00
Integrate phpstan
This commit is contained in:
parent
d769e74027
commit
ded93e0d8e
17 changed files with 60 additions and 69 deletions
5
.github/workflows/ci.yaml
vendored
5
.github/workflows/ci.yaml
vendored
|
@ -14,7 +14,6 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- 7.3
|
||||
- 7.4
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -143,7 +142,6 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- 7.3
|
||||
- 7.4
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -182,7 +180,6 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- 7.3
|
||||
- 7.4
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -231,7 +228,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "7.3"
|
||||
php-version: "7.4"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
|
|
|
@ -44,7 +44,7 @@ abstract class AbstractController extends ActionController
|
|||
*/
|
||||
protected $defaultViewObjectName = BackendTemplateView::class;
|
||||
|
||||
protected function initializeView(ViewInterface $view)
|
||||
protected function initializeView(ViewInterface $view): void
|
||||
{
|
||||
if ($view instanceof BackendTemplateView) {
|
||||
$this->getMenu()->addMenu(
|
||||
|
|
|
@ -29,11 +29,13 @@ use WerkraumMedia\ThueCat\Domain\Import\Converter\Registry;
|
|||
|
||||
class ConverterPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
public const TAG = 'thuecat.converter';
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$registry = $container->findDefinition(Registry::class);
|
||||
|
||||
foreach ($container->findTaggedServiceIds('thuecat.converter') as $id => $tags) {
|
||||
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
|
||||
$definition = $container->findDefinition($id);
|
||||
if (!$definition->isAutoconfigured() || $definition->isAbstract()) {
|
||||
continue;
|
||||
|
|
|
@ -29,11 +29,13 @@ use WerkraumMedia\ThueCat\Domain\Import\UrlProvider\Registry;
|
|||
|
||||
class UrlProvidersPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
public const TAG = 'thuecat:urlprovider';
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$registry = $container->findDefinition(Registry::class);
|
||||
|
||||
foreach ($container->findTaggedServiceIds('thuecat.urlprovider') as $id => $tags) {
|
||||
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
|
||||
$definition = $container->findDefinition($id);
|
||||
if (!$definition->isAutoconfigured() || $definition->isAbstract()) {
|
||||
continue;
|
||||
|
|
|
@ -29,6 +29,7 @@ use WerkraumMedia\ThueCat\Domain\Import\Converter\Registry as ConverterRegistry;
|
|||
use WerkraumMedia\ThueCat\Domain\Import\Importer\FetchData;
|
||||
use WerkraumMedia\ThueCat\Domain\Import\Importer\SaveData;
|
||||
use WerkraumMedia\ThueCat\Domain\Import\UrlProvider\Registry as UrlProviderRegistry;
|
||||
use WerkraumMedia\ThueCat\Domain\Import\UrlProvider\UrlProvider;
|
||||
use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
|
||||
use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLog;
|
||||
use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository;
|
||||
|
@ -61,6 +62,10 @@ class Importer
|
|||
$this->importLog = GeneralUtility::makeInstance(ImportLog::class, $configuration);
|
||||
|
||||
$urlProvider = $this->urls->getProviderForConfiguration($configuration);
|
||||
if (!$urlProvider instanceof UrlProvider) {
|
||||
return $this->importLog;
|
||||
}
|
||||
|
||||
foreach ($urlProvider->getUrls() as $url) {
|
||||
$this->importResourceByUrl($url);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ use Psr\Http\Message\RequestFactoryInterface;
|
|||
|
||||
class FetchData
|
||||
{
|
||||
private RequestFactoryInterface $requestFactory;
|
||||
private ClientInterface $httpClient;
|
||||
|
||||
public function __construct(
|
||||
RequestFactoryInterface $requestFactory,
|
||||
ClientInterface $httpClient
|
||||
|
|
|
@ -39,7 +39,6 @@ class SaveData
|
|||
ConnectionPool $connectionPool
|
||||
) {
|
||||
$this->dataHandler = $dataHandler;
|
||||
$this->dataHandler->stripslashes_values = 0;
|
||||
$this->connectionPool = $connectionPool;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class RequestFactory extends Typo3RequestFactory
|
|||
{
|
||||
public function createRequest(string $method, $uri): RequestInterface
|
||||
{
|
||||
$uri = new Uri($uri);
|
||||
$uri = new Uri((string) $uri);
|
||||
$uri = $uri->withQuery('?format=jsonId');
|
||||
|
||||
// TODO: Add api key from site
|
||||
|
|
|
@ -37,9 +37,6 @@ class Registry
|
|||
$this->provider[] = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UrlProvider[]
|
||||
*/
|
||||
public function getProviderForConfiguration(ImportConfiguration $configuration): ?UrlProvider
|
||||
{
|
||||
foreach ($this->provider as $provider) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class StaticUrlProvider implements UrlProvider
|
|||
|
||||
public function createWithConfiguration(
|
||||
ImportConfiguration $configuration
|
||||
): UrlProvider {
|
||||
): StaticUrlProvider {
|
||||
return GeneralUtility::makeInstance(self::class, $configuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class ImportLog extends Typo3AbstractEntity
|
|||
/**
|
||||
* @var ObjectStorage<ImportLogEntry>
|
||||
*/
|
||||
protected $logEntries = [];
|
||||
protected $logEntries;
|
||||
|
||||
/**
|
||||
* @var ImportConfiguration
|
||||
|
|
|
@ -42,7 +42,6 @@ class ImportLogRepository extends Repository
|
|||
parent::__construct($objectManager);
|
||||
|
||||
$this->dataHandler = $dataHandler;
|
||||
$this->dataHandler->stripslashes_values = 0;
|
||||
|
||||
$querySettings->setRespectStoragePage(false);
|
||||
$this->setDefaultQuerySettings($querySettings);
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;
|
|||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
|
||||
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||
use WerkraumMedia\ThueCat\Domain\Model\Backend\Organisation;
|
||||
|
||||
/**
|
||||
* @method Organisation|null findOneByRemoteId(string $remoteId)
|
||||
|
|
|
@ -10,9 +10,9 @@ use WerkraumMedia\ThueCat\Domain\Import\Converter\Converter;
|
|||
use WerkraumMedia\ThueCat\Domain\Import\UrlProvider\UrlProvider;
|
||||
|
||||
return function (ContainerConfigurator $container, ContainerBuilder $containerBuilder) {
|
||||
$containerBuilder->registerForAutoconfiguration(UrlProvider::class)->addTag('thuecat.urlprovider');
|
||||
$containerBuilder->addCompilerPass(new DependencyInjection\UrlProvidersPass('thuecat.urlprovider'));
|
||||
$containerBuilder->registerForAutoconfiguration(UrlProvider::class)->addTag(DependencyInjection\UrlProvidersPass::TAG);
|
||||
$containerBuilder->addCompilerPass(new DependencyInjection\UrlProvidersPass());
|
||||
|
||||
$containerBuilder->registerForAutoconfiguration(Converter::class)->addTag('thuecat.converter');
|
||||
$containerBuilder->addCompilerPass(new DependencyInjection\ConverterPass('thuecat.converter'));
|
||||
$containerBuilder->registerForAutoconfiguration(Converter::class)->addTag(DependencyInjection\ConverterPass::TAG);
|
||||
$containerBuilder->addCompilerPass(new DependencyInjection\ConverterPass());
|
||||
};
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WerkraumMedia\ThueCat\Tests\Functional\Domain\Import;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
|
||||
|
||||
/**
|
||||
* @covers WerkraumMedia\ThueCat\Domain\Import\Importer
|
||||
*/
|
||||
class ImporterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function importsNewEntity(): void
|
||||
{
|
||||
$command = new CommandTester();
|
||||
$command->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function updatesExistingEntity(): void
|
||||
{
|
||||
}
|
||||
}
|
|
@ -38,8 +38,12 @@
|
|||
"typo3/cms-extbase": "^10.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsoftypo3/phpstan-typo3": "^0.6.0",
|
||||
"jangregor/phpstan-prophecy": "^0.8.1",
|
||||
"maglnet/composer-require-checker": "^2.1",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^0.12.71",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symplify/easy-coding-standard": "^9.0",
|
||||
"typo3/testing-framework": "^6.6"
|
||||
|
@ -49,6 +53,9 @@
|
|||
"TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"typo3/cms": {
|
||||
"cms-package-dir": "{$vendor-dir}/typo3/cms",
|
||||
|
|
27
phpstan.neon
Normal file
27
phpstan.neon
Normal file
|
@ -0,0 +1,27 @@
|
|||
includes:
|
||||
- vendor/friendsoftypo3/phpstan-typo3/extension.neon
|
||||
parameters:
|
||||
level: max
|
||||
paths:
|
||||
- Classes
|
||||
- Configuration
|
||||
- Tests
|
||||
checkMissingIterableValueType: false
|
||||
reportUnmatchedIgnoredErrors: true
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Cannot call method fetchColumn\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\Statement\\|int\\.$#"
|
||||
count: 1
|
||||
path: Classes/Domain/Import/Importer/SaveData.php
|
||||
-
|
||||
message: "#^Property WerkraumMedia\\\\ThueCat\\\\Domain\\\\Model\\\\Backend\\\\ImportLog\\:\\:\\$logEntries \\(iterable\\<WerkraumMedia\\\\ThueCat\\\\Domain\\\\Model\\\\Backend\\\\ImportLogEntry\\>&TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\) does not accept TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\.$#"
|
||||
count: 1
|
||||
path: Classes/Domain/Model/Backend/ImportLog.php
|
||||
-
|
||||
message: "#^Cannot call method getFirst\\(\\) on array\\|TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryResultInterface\\.$#"
|
||||
count: 1
|
||||
path: Classes/Domain/Repository/Backend/TownRepository.php
|
||||
-
|
||||
message: "#^Method WerkraumMedia\\\\ThueCat\\\\Domain\\\\Repository\\\\Backend\\\\TownRepository\\:\\:findOneByRemoteIds\\(\\) should return WerkraumMedia\\\\ThueCat\\\\Domain\\\\Model\\\\Backend\\\\Town\\|null but returns object\\.$#"
|
||||
count: 1
|
||||
path: Classes/Domain/Repository/Backend/TownRepository.php
|
Loading…
Reference in a new issue