Make compatible with PHP 7.3

As some projects still might run on PHP 7.3 and supported TYPO3 version
still supports 7.3.
This commit is contained in:
Daniel Siepmann 2021-04-13 14:43:04 +02:00
parent 3bcddd94bb
commit c91f665d98
38 changed files with 485 additions and 107 deletions

View file

@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
php-version:
- 7.3
- 7.4
steps:
- name: Checkout
@ -104,7 +105,7 @@ jobs:
coding-guideline:
runs-on: ubuntu-latest
needs:
needs:
- check-dependencies
- xml-linting
steps:
@ -176,6 +177,7 @@ jobs:
strategy:
matrix:
php-version:
- 7.3
- 7.4
steps:
- uses: actions/checkout@v2

View file

@ -33,10 +33,25 @@ use WerkraumMedia\ThueCat\View\Backend\Menu;
class ImportController extends AbstractController
{
private Importer $importer;
private ImportLogRepository $repository;
private TranslationService $translation;
private Menu $menu;
/**
* @var Importer
*/
private $importer;
/**
* @var ImportLogRepository
*/
private $repository;
/**
* @var TranslationService
*/
private $translation;
/**
* @var Menu
*/
private $menu;
public function __construct(
Importer $importer,

View file

@ -29,9 +29,20 @@ use WerkraumMedia\ThueCat\View\Backend\Menu;
class OverviewController extends AbstractController
{
private OrganisationRepository $organisationRepository;
private ImportConfigurationRepository $importConfigurationRepository;
private Menu $menu;
/**
* @var OrganisationRepository
*/
private $organisationRepository;
/**
* @var ImportConfigurationRepository
*/
private $importConfigurationRepository;
/**
* @var Menu
*/
private $menu;
public function __construct(
OrganisationRepository $organisationRepository,

View file

@ -32,8 +32,15 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
class Organisation implements Converter
{
private Parser $parser;
private LanguageHandling $language;
/**
* @var Parser
*/
private $parser;
/**
* @var LanguageHandling
*/
private $language;
public function __construct(
Parser $parser,

View file

@ -28,7 +28,10 @@ namespace WerkraumMedia\ThueCat\Domain\Import\Converter;
*/
class Registry
{
private array $converters = [];
/**
* @var Converter[]
*/
private $converters = [];
public function registerConverter(Converter $converter): void
{

View file

@ -35,11 +35,30 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\TownRepository;
class TouristAttraction implements Converter
{
private Parser $parser;
private Offers $parserForOffers;
private LanguageHandling $language;
private OrganisationRepository $organisationRepository;
private TownRepository $townRepository;
/**
* @var Parser
*/
private $parser;
/**
* @var Offers
*/
private $parserForOffers;
/**
* @var LanguageHandling
*/
private $language;
/**
* @var OrganisationRepository
*/
private $organisationRepository;
/**
* @var TownRepository
*/
private $townRepository;
public function __construct(
Parser $parser,

View file

@ -34,10 +34,25 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\TownRepository;
class TouristInformation implements Converter
{
private Parser $parser;
private LanguageHandling $language;
private OrganisationRepository $organisationRepository;
private TownRepository $townRepository;
/**
* @var Parser
*/
private $parser;
/**
* @var LanguageHandling
*/
private $language;
/**
* @var OrganisationRepository
*/
private $organisationRepository;
/**
* @var TownRepository
*/
private $townRepository;
public function __construct(
Parser $parser,

View file

@ -33,9 +33,20 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\OrganisationRepository;
class Town implements Converter
{
private Parser $parser;
private LanguageHandling $language;
private OrganisationRepository $organisationRepository;
/**
* @var Parser
*/
private $parser;
/**
* @var LanguageHandling
*/
private $language;
/**
* @var OrganisationRepository
*/
private $organisationRepository;
public function __construct(
Parser $parser,

View file

@ -36,13 +36,40 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository;
class Importer
{
private UrlProviderRegistry $urls;
private ConverterRegistry $converter;
private FetchData $fetchData;
private SaveData $saveData;
private ImportLog $importLog;
private ImportLogRepository $importLogRepository;
private ImportConfiguration $configuration;
/**
* @var UrlProviderRegistry
*/
private $urls;
/**
* @var ConverterRegistry
*/
private $converter;
/**
* @var FetchData
*/
private $fetchData;
/**
* @var SaveData
*/
private $saveData;
/**
* @var ImportLog
*/
private $importLog;
/**
* @var ImportLogRepository
*/
private $importLogRepository;
/**
* @var ImportConfiguration
*/
private $configuration;
public function __construct(
UrlProviderRegistry $urls,

View file

@ -29,9 +29,20 @@ use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface as CacheFrontendInterface;
class FetchData
{
private RequestFactoryInterface $requestFactory;
private ClientInterface $httpClient;
private CacheFrontendInterface $cache;
/**
* @var RequestFactoryInterface
*/
private $requestFactory;
/**
* @var ClientInterface
*/
private $httpClient;
/**
* @var CacheFrontendInterface
*/
private $cache;
public function __construct(
RequestFactoryInterface $requestFactory,

View file

@ -26,7 +26,10 @@ use TYPO3\CMS\Core\Site\SiteFinder;
class LanguageHandling
{
private SiteFinder $siteFinder;
/**
* @var SiteFinder
*/
private $siteFinder;
public function __construct(
SiteFinder $siteFinder

View file

@ -32,9 +32,20 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLogEntry;
class SaveData
{
private DataHandler $dataHandler;
private ConnectionPool $connectionPool;
private array $errorLog;
/**
* @var DataHandler
*/
private $dataHandler;
/**
* @var ConnectionPool
*/
private $connectionPool;
/**
* @var mixed[]
*/
private $errorLog;
public function __construct(
DataHandler $dataHandler,

View file

@ -31,10 +31,25 @@ use WerkraumMedia\ThueCat\Domain\Import\JsonLD\Parser\OpeningHours;
class Parser
{
private GenericFields $genericFields;
private OpeningHours $openingHours;
private Address $address;
private Media $media;
/**
* @var GenericFields
*/
private $genericFields;
/**
* @var OpeningHours
*/
private $openingHours;
/**
* @var Address
*/
private $address;
/**
* @var Media
*/
private $media;
public function __construct(
GenericFields $genericFields,

View file

@ -72,8 +72,8 @@ class Address
private function getGeo(array $geo): array
{
return [
'latitude' => floatval($geo['schema:latitude']['@value'] ?? 0.00),
'longitude' => floatval($geo['schema:longitude']['@value'] ?? 0.00),
'latitude' => floatval($geo['schema:latitude']['@value'] ?? 0.0),
'longitude' => floatval($geo['schema:longitude']['@value'] ?? 0.0),
];
}
}

View file

@ -25,7 +25,10 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class GenericFields
{
private LanguageValues $languageValues;
/**
* @var LanguageValues
*/
private $languageValues;
public function __construct(
LanguageValues $languageValues

View file

@ -25,7 +25,10 @@ use WerkraumMedia\ThueCat\Domain\Import\Importer\FetchData;
class Media
{
private FetchData $fetchData;
/**
* @var FetchData
*/
private $fetchData;
public function __construct(
FetchData $fetchData

View file

@ -25,7 +25,10 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class Offers
{
private GenericFields $genericFields;
/**
* @var GenericFields
*/
private $genericFields;
public function __construct(
GenericFields $genericFields

View file

@ -28,7 +28,7 @@ class EntityCollection
/**
* @var Entity[]
*/
private array $entities = [];
private $entities = [];
public function add(Entity $entity): void
{

View file

@ -25,13 +25,40 @@ namespace WerkraumMedia\ThueCat\Domain\Import\Model;
class GenericEntity implements Entity
{
private int $typo3StoragePid;
private string $typo3DatabaseTableName;
private int $typo3SystemLanguageUid;
private bool $created = false;
private int $typo3Uid = 0;
private string $remoteId;
private array $data;
/**
* @var int
*/
private $typo3StoragePid;
/**
* @var string
*/
private $typo3DatabaseTableName;
/**
* @var int
*/
private $typo3SystemLanguageUid;
/**
* @var bool
*/
private $created = false;
/**
* @var int
*/
private $typo3Uid = 0;
/**
* @var string
*/
private $remoteId;
/**
* @var mixed[]
*/
private $data;
public function __construct(
int $typo3StoragePid,

View file

@ -30,7 +30,10 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
*/
class Registry
{
private array $provider = [];
/**
* @var UrlProvider[]
*/
private $provider = [];
public function registerProvider(UrlProvider $provider): void
{

View file

@ -28,7 +28,10 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
class StaticUrlProvider implements UrlProvider
{
private array $urls = [];
/**
* @var string[]
*/
private $urls = [];
public function __construct(
ImportConfiguration $configuration
@ -46,7 +49,7 @@ class StaticUrlProvider implements UrlProvider
public function createWithConfiguration(
ImportConfiguration $configuration
): StaticUrlProvider {
): UrlProvider {
return GeneralUtility::makeInstance(self::class, $configuration);
}

View file

@ -27,10 +27,25 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity as Typo3AbstractEntity;
class AbstractEntity extends Typo3AbstractEntity
{
protected string $remoteId = '';
protected string $title = '';
protected string $description = '';
protected ?\DateTimeImmutable $tstamp = null;
/**
* @var string
*/
protected $remoteId = '';
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $description = '';
/**
* @var \DateTimeImmutable|null
*/
protected $tstamp = null;
public function getRemoteId(): string
{

View file

@ -29,10 +29,25 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class ImportConfiguration extends AbstractEntity
{
protected string $title = '';
protected string $type = '';
protected string $configuration = '';
protected ?\DateTimeImmutable $tstamp = null;
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $type = '';
/**
* @var string
*/
protected $configuration = '';
/**
* @var \DateTimeImmutable|null
*/
protected $tstamp = null;
public function getTitle(): string
{

View file

@ -53,7 +53,10 @@ class ImportLogEntry extends Typo3AbstractEntity
*/
protected $errors = '';
protected array $errorsAsArray = [];
/**
* @var string[]
*/
protected $errorsAsArray = [];
public function __construct(
Entity $entity,

View file

@ -27,8 +27,15 @@ use TYPO3\CMS\Core\Type\TypeInterface;
class Address implements TypeInterface
{
private string $serialized;
private array $data;
/**
* @var string
*/
private $serialized;
/**
* @var mixed[]
*/
private $data;
public function __construct(string $serialized)
{

View file

@ -27,8 +27,15 @@ use TYPO3\CMS\Core\Type\TypeInterface;
class Media implements TypeInterface
{
private string $serialized;
private array $data;
/**
* @var string
*/
private $serialized;
/**
* @var mixed[]
*/
private $data;
public function __construct(string $serialized)
{

View file

@ -25,9 +25,20 @@ namespace WerkraumMedia\ThueCat\Domain\Model\Frontend;
class Offer
{
private string $title;
private string $description;
private array $prices;
/**
* @var string
*/
private $title;
/**
* @var string
*/
private $description;
/**
* @var mixed[]
*/
private $prices;
private function __construct(
string $title,
@ -39,7 +50,10 @@ class Offer
$this->prices = $prices;
}
public static function createFromArray(array $rawData): self
/**
* @return $this
*/
public static function createFromArray(array $rawData)
{
$prices = [];
foreach ($rawData['prices'] as $price) {

View file

@ -30,9 +30,20 @@ use TYPO3\CMS\Core\Type\TypeInterface;
*/
class Offers implements TypeInterface, \Iterator
{
private string $serialized = '';
private array $array = [];
private int $position = 0;
/**
* @var string
*/
private $serialized = '';
/**
* @var mixed[]
*/
private $array = [];
/**
* @var int
*/
private $position = 0;
public function __construct(string $serialized)
{

View file

@ -25,11 +25,30 @@ namespace WerkraumMedia\ThueCat\Domain\Model\Frontend;
class OpeningHour
{
private string $opens;
private string $closes;
private array $daysOfWeek;
private ?\DateTimeImmutable $from;
private ?\DateTimeImmutable $through;
/**
* @var string
*/
private $opens;
/**
* @var string
*/
private $closes;
/**
* @var mixed[]
*/
private $daysOfWeek;
/**
* @var \DateTimeImmutable|null
*/
private $from;
/**
* @var \DateTimeImmutable|null
*/
private $through;
private function __construct(
string $opens,
@ -45,7 +64,10 @@ class OpeningHour
$this->through = $through;
}
public static function createFromArray(array $rawData): self
/**
* @return $this
*/
public static function createFromArray(array $rawData)
{
$from = null;
if (isset($rawData['from'])) {

View file

@ -30,9 +30,20 @@ use TYPO3\CMS\Core\Type\TypeInterface;
*/
class OpeningHours implements TypeInterface, \Iterator
{
private string $serialized = '';
private array $array = [];
private int $position = 0;
/**
* @var string
*/
private $serialized = '';
/**
* @var mixed[]
*/
private $array = [];
/**
* @var int
*/
private $position = 0;
public function __construct(string $serialized)
{

View file

@ -25,11 +25,30 @@ namespace WerkraumMedia\ThueCat\Domain\Model\Frontend;
class Price
{
private string $title;
private string $description;
private float $price;
private string $currency;
private string $rule;
/**
* @var string
*/
private $title;
/**
* @var string
*/
private $description;
/**
* @var float
*/
private $price;
/**
* @var string
*/
private $currency;
/**
* @var string
*/
private $rule;
private function __construct(
string $title,
@ -45,7 +64,10 @@ class Price
$this->rule = $rule;
}
public static function createFromArray(array $rawData): self
/**
* @return $this
*/
public static function createFromArray(array $rawData)
{
return new self(
$rawData['title'],

View file

@ -27,13 +27,40 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class TouristAttraction extends AbstractEntity
{
protected string $title = '';
protected string $description = '';
protected ?OpeningHours $openingHours = null;
protected ?Offers $offers = null;
protected ?Address $address = null;
protected ?Town $town = null;
protected ?Media $media = null;
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $description = '';
/**
* @var OpeningHours|null
*/
protected $openingHours = null;
/**
* @var Offers|null
*/
protected $offers = null;
/**
* @var Address|null
*/
protected $address = null;
/**
* @var Town|null
*/
protected $town = null;
/**
* @var Media|null
*/
protected $media = null;
public function getTitle(): string
{

View file

@ -27,8 +27,15 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Town extends AbstractEntity
{
protected string $title = '';
protected string $description = '';
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $description = '';
public function getTitle(): string
{

View file

@ -32,7 +32,10 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLog;
class ImportLogRepository extends Repository
{
private DataHandler $dataHandler;
/**
* @var DataHandler
*/
private $dataHandler;
public function __construct(
ObjectManagerInterface $objectManager,

View file

@ -33,9 +33,20 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
class ResolveEntities implements DataProcessorInterface
{
private ConnectionPool $connectionPool;
private DataMapper $dataMapper;
private TypoScriptFrontendController $tsfe;
/**
* @var ConnectionPool
*/
private $connectionPool;
/**
* @var DataMapper
*/
private $dataMapper;
/**
* @var TypoScriptFrontendController
*/
private $tsfe;
public function __construct(
ConnectionPool $connectionPool,

View file

@ -32,7 +32,10 @@ use WerkraumMedia\ThueCat\Typo3Wrapper\TranslationService;
class Menu
{
private TranslationService $translation;
/**
* @var TranslationService
*/
private $translation;
public function __construct(
TranslationService $translation

View file

@ -26,7 +26,7 @@
}
},
"require": {
"php": "^7.4",
"php": "^7.3",
"ext-json": "*",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
@ -50,4 +51,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(PhpUnitTestAnnotationFixer::class)->call('configure', [[
'style' => 'annotation',
]]);
$services->set(ClassAttributesSeparationFixer::class)->call('configure', [[
'elements' => [
'const' => ClassAttributesSeparationFixer::SPACING_ONE,
'method' => ClassAttributesSeparationFixer::SPACING_ONE,
'property' => ClassAttributesSeparationFixer::SPACING_ONE,
],
]]);
};