Rector up to PHP 8.1

This commit is contained in:
Daniel Siepmann 2023-12-04 15:37:57 +01:00
parent dcc9c911ae
commit 65898e97e0
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
46 changed files with 130 additions and 228 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
/.Build/ /.Build/
/.phpunit.cache
/composer.lock /composer.lock
/.phpunit.cache
/Tests/Acceptance/Support/_generated
/vendor/ /vendor/

View file

@ -29,7 +29,7 @@ use WerkraumMedia\ThueCat\Domain\Import\Typo3Converter\Registry;
class ConverterPass implements CompilerPassInterface class ConverterPass implements CompilerPassInterface
{ {
public const TAG = 'thuecat.typo3.converter'; final public const TAG = 'thuecat.typo3.converter';
public function process(ContainerBuilder $container): void public function process(ContainerBuilder $container): void
{ {

View file

@ -29,7 +29,7 @@ use WerkraumMedia\ThueCat\Domain\Import\EntityMapper\EntityRegistry;
class EntityPass implements CompilerPassInterface class EntityPass implements CompilerPassInterface
{ {
public const TAG = 'thuecat.entity'; final public const TAG = 'thuecat.entity';
public function process(ContainerBuilder $container): void public function process(ContainerBuilder $container): void
{ {

View file

@ -29,7 +29,7 @@ use WerkraumMedia\ThueCat\Domain\Import\UrlProvider\Registry;
class UrlProvidersPass implements CompilerPassInterface class UrlProvidersPass implements CompilerPassInterface
{ {
public const TAG = 'thuecat:urlprovider'; final public const TAG = 'thuecat:urlprovider';
public function process(ContainerBuilder $container): void public function process(ContainerBuilder $container): void
{ {

View file

@ -25,11 +25,8 @@ namespace WerkraumMedia\ThueCat\Domain\Import\Entity\Properties;
class DayOfWeek class DayOfWeek
{ {
protected string $dayOfWeek = '';
public function __construct( public function __construct(
string $dayOfWeek protected string $dayOfWeek
) { ) {
$this->dayOfWeek = $dayOfWeek;
} }
} }

View file

@ -58,7 +58,7 @@ class Offer extends Minimum
} }
$this->offerTypes = array_map( $this->offerTypes = array_map(
[PropertyValues::class, 'removePrefixFromEntry'], PropertyValues::removePrefixFromEntry(...),
$offerType $offerType
); );
} }

View file

@ -27,9 +27,9 @@ use DateTimeImmutable;
class OpeningHour class OpeningHour
{ {
protected ?DateTimeImmutable $validFrom; protected ?DateTimeImmutable $validFrom = null;
protected ?DateTimeImmutable $validThrough; protected ?DateTimeImmutable $validThrough = null;
protected DateTimeImmutable $opens; protected DateTimeImmutable $opens;

View file

@ -51,7 +51,7 @@ class EntityMapper
try { try {
return $serializer->deserialize( return $serializer->deserialize(
json_encode($jsonLD), json_encode($jsonLD, JSON_THROW_ON_ERROR),
$targetClassName, $targetClassName,
'json', 'json',
$context $context

View file

@ -54,26 +54,26 @@ use Symfony\Component\PropertyInfo\Util\PhpDocTypeHelper;
*/ */
class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface, PropertyTypeExtractorInterface, ConstructorArgumentTypeExtractorInterface class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface, PropertyTypeExtractorInterface, ConstructorArgumentTypeExtractorInterface
{ {
public const PROPERTY = 0; final public const PROPERTY = 0;
public const ACCESSOR = 1; final public const ACCESSOR = 1;
public const MUTATOR = 2; final public const MUTATOR = 2;
/** /**
* @var array<string, array{DocBlock|null, int|null, string|null}> * @var array<string, array{DocBlock|null, int|null, string|null}>
*/ */
private $docBlocks = []; private array $docBlocks = [];
/** /**
* @var Context[] * @var Context[]
*/ */
private $contexts = []; private array $contexts = [];
private $docBlockFactory; private readonly \phpDocumentor\Reflection\DocBlockFactoryInterface $docBlockFactory;
private $contextFactory; private readonly \phpDocumentor\Reflection\Types\ContextFactory $contextFactory;
private $phpDocTypeHelper; private readonly \Symfony\Component\PropertyInfo\Util\PhpDocTypeHelper $phpDocTypeHelper;
private $mutatorPrefixes; private readonly array $mutatorPrefixes;
private $accessorPrefixes; private readonly array $accessorPrefixes;
private $arrayMutatorPrefixes; private readonly array $arrayMutatorPrefixes;
/** /**
* @param string[]|null $mutatorPrefixes * @param string[]|null $mutatorPrefixes
@ -83,7 +83,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null) public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
{ {
if (!class_exists(DocBlockFactory::class)) { if (!class_exists(DocBlockFactory::class)) {
throw new LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__)); throw new LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', self::class));
} }
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance(); $this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();
@ -246,7 +246,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
$docBlock = $this->docBlockFactory->create($reflectionConstructor, $this->contextFactory->createFromReflector($reflectionConstructor)); $docBlock = $this->docBlockFactory->create($reflectionConstructor, $this->contextFactory->createFromReflector($reflectionConstructor));
return $this->filterDocBlockParams($docBlock, $property); return $this->filterDocBlockParams($docBlock, $property);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException) {
return null; return null;
} }
} }
@ -320,7 +320,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
try { try {
return $this->docBlockFactory->create($reflectionProperty, $this->createFromReflector($reflector)); return $this->docBlockFactory->create($reflectionProperty, $this->createFromReflector($reflector));
} catch (InvalidArgumentException|RuntimeException $e) { } catch (InvalidArgumentException|RuntimeException) {
return null; return null;
} }
} }
@ -348,7 +348,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
) { ) {
break; break;
} }
} catch (ReflectionException $e) { } catch (ReflectionException) {
// Try the next prefix if the method doesn't exist // Try the next prefix if the method doesn't exist
} }
} }
@ -367,7 +367,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
try { try {
return [$this->docBlockFactory->create($reflectionMethod, $this->createFromReflector($reflector)), $prefix]; return [$this->docBlockFactory->create($reflectionMethod, $this->createFromReflector($reflector)), $prefix];
} catch (InvalidArgumentException|RuntimeException $e) { } catch (InvalidArgumentException|RuntimeException) {
return null; return null;
} }
} }

View file

@ -33,7 +33,7 @@ use Symfony\Component\Serializer\Encoder\JsonDecode as SymfonyJsonDecode;
*/ */
class JsonDecode extends SymfonyJsonDecode class JsonDecode extends SymfonyJsonDecode
{ {
public const ACTIVE_LANGUAGE = 'active_language'; final public const ACTIVE_LANGUAGE = 'active_language';
/** /**
* @var array[] * @var array[]
@ -92,12 +92,11 @@ class JsonDecode extends SymfonyJsonDecode
* *
* This decode will resolve the list to a single value based on current language settings from context. * This decode will resolve the list to a single value based on current language settings from context.
* *
* @param mixed $value
* *
* @return mixed * @return mixed
*/ */
private function decodeLanguageSpecificValue( private function decodeLanguageSpecificValue(
&$value, mixed &$value,
string $activeLanguage string $activeLanguage
) { ) {
if (is_array($value) === false) { if (is_array($value) === false) {
@ -154,12 +153,11 @@ class JsonDecode extends SymfonyJsonDecode
* *
* This decode will resolve single values wrapped in array with extra info. * This decode will resolve single values wrapped in array with extra info.
* *
* @param mixed $value
* *
* @return mixed * @return mixed
*/ */
private function decodeSingleValues( private function decodeSingleValues(
&$value mixed &$value
) { ) {
if (is_array($value) === false) { if (is_array($value) === false) {
return $value; return $value;
@ -189,12 +187,11 @@ class JsonDecode extends SymfonyJsonDecode
/** /**
* Prepare data structure for PHP \DateTimeImmutable. * Prepare data structure for PHP \DateTimeImmutable.
* *
* @param mixed $value
* *
* @return mixed * @return mixed
*/ */
private function decodeDateTime( private function decodeDateTime(
&$value mixed &$value
) { ) {
$supportedTypes = [ $supportedTypes = [
'schema:Time', 'schema:Time',
@ -214,11 +211,9 @@ class JsonDecode extends SymfonyJsonDecode
} }
/** /**
* @param mixed $key
*
* @return mixed * @return mixed
*/ */
private function mapKey($key) private function mapKey(mixed $key)
{ {
if (is_string($key) === false) { if (is_string($key) === false) {
return $key; return $key;
@ -240,7 +235,7 @@ class JsonDecode extends SymfonyJsonDecode
private function doesRuleMatch(array $rule, string $type): bool private function doesRuleMatch(array $rule, string $type): bool
{ {
if ($rule['type'] === 'beginsWith') { if ($rule['type'] === 'beginsWith') {
return str_starts_with($type, $rule['comparisonValue']); return str_starts_with($type, (string) $rule['comparisonValue']);
} }
return false; return false;

View file

@ -28,13 +28,9 @@ use Throwable;
class MappingException extends Exception class MappingException extends Exception
{ {
protected array $jsonLD = [];
protected string $targetClassName = '';
public function __construct( public function __construct(
array $jsonLD, protected array $jsonLD,
string $targetClassName, protected string $targetClassName,
Throwable $previous Throwable $previous
) { ) {
parent::__construct( parent::__construct(
@ -42,8 +38,6 @@ class MappingException extends Exception
1628157659, 1628157659,
$previous $previous
); );
$this->jsonLD = $jsonLD;
$this->targetClassName = $targetClassName;
} }
public function getUrl(): string public function getUrl(): string

View file

@ -36,7 +36,7 @@ class PropertyValues
public static function removePrefixFromEntries(array $entriesWithPrefix): array public static function removePrefixFromEntries(array $entriesWithPrefix): array
{ {
return array_map( return array_map(
[PropertyValues::class, 'removePrefixFromEntry'], PropertyValues::removePrefixFromEntry(...),
$entriesWithPrefix $entriesWithPrefix
); );
} }

View file

@ -43,9 +43,9 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository;
class Importer class Importer
{ {
private Logger $logger; private readonly Logger $logger;
private Import $import; private readonly Import $import;
public function __construct( public function __construct(
private readonly UrlProviderRegistry $urls, private readonly UrlProviderRegistry $urls,
@ -58,7 +58,7 @@ class Importer
private readonly SaveData $saveData, private readonly SaveData $saveData,
LogManager $logManager LogManager $logManager
) { ) {
$this->logger = $logManager->getLogger(__CLASS__); $this->logger = $logManager->getLogger(self::class);
$this->import = new Import(); $this->import = new Import();
} }
@ -143,7 +143,7 @@ class Importer
} }
if (!$mappedEntity instanceof MapsToType) { if (!$mappedEntity instanceof MapsToType) {
$this->logger->error('Mapping did not result in an MapsToType instance.', ['class' => get_class($mappedEntity)]); $this->logger->error('Mapping did not result in an MapsToType instance.', ['class' => $mappedEntity::class]);
continue; continue;
} }

View file

@ -70,7 +70,7 @@ class FetchData
$this->handleInvalidResponse($response, $request); $this->handleInvalidResponse($response, $request);
$jsonLD = json_decode((string)$response->getBody(), true); $jsonLD = json_decode((string)$response->getBody(), true, 512, JSON_THROW_ON_ERROR);
if (is_array($jsonLD)) { if (is_array($jsonLD)) {
$this->cache->set($cacheIdentifier, $jsonLD); $this->cache->set($cacheIdentifier, $jsonLD);
return $jsonLD; return $jsonLD;

View file

@ -33,7 +33,7 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLogEntry\SavingEntity;
class SaveData class SaveData
{ {
/** /**
* @var mixed[] * @var string[]
*/ */
private array $errorLog; private array $errorLog;

View file

@ -25,35 +25,20 @@ namespace WerkraumMedia\ThueCat\Domain\Import\Model;
class GenericEntity implements Entity class GenericEntity implements Entity
{ {
private int $typo3StoragePid;
private string $typo3DatabaseTableName;
private int $typo3SystemLanguageUid;
private bool $created = false; private bool $created = false;
private int $typo3Uid = 0; private int $typo3Uid = 0;
private string $remoteId;
/** /**
* @var mixed[] * @param mixed[] $data
*/ */
private array $data;
public function __construct( public function __construct(
int $typo3StoragePid, private readonly int $typo3StoragePid,
string $typo3DatabaseTableName, private readonly string $typo3DatabaseTableName,
int $typo3SystemLanguageUid, private readonly int $typo3SystemLanguageUid,
string $remoteId, private readonly string $remoteId,
array $data private readonly array $data
) { ) {
$this->typo3StoragePid = $typo3StoragePid;
$this->typo3DatabaseTableName = $typo3DatabaseTableName;
$this->typo3SystemLanguageUid = $typo3SystemLanguageUid;
$this->remoteId = $remoteId;
$this->data = $data;
} }
public function getTypo3StoragePid(): int public function getTypo3StoragePid(): int

View file

@ -56,7 +56,7 @@ class RequestFactory implements RequestFactoryInterface
try { try {
$query['api_key'] = $this->extensionConfiguration->get('thuecat', 'apiKey'); $query['api_key'] = $this->extensionConfiguration->get('thuecat', 'apiKey');
} catch (ExtensionConfigurationExtensionNotConfiguredException $e) { } catch (ExtensionConfigurationExtensionNotConfiguredException) {
// Nothing todo, not configured, don't add. // Nothing todo, not configured, don't add.
} }

View file

@ -51,7 +51,7 @@ class ResolveForeignReference
): ?object { ): ?object {
try { try {
$jsonLD = $this->fetchData->jsonLDFromUrl($foreignReference->getId()); $jsonLD = $this->fetchData->jsonLDFromUrl($foreignReference->getId());
} catch (InvalidResponseException $e) { } catch (InvalidResponseException) {
return null; return null;
} }

View file

@ -51,7 +51,7 @@ class Typo3Converter implements Converter
$concreteConverter = $this->registry->getConverterBasedOnType($mapped); $concreteConverter = $this->registry->getConverterBasedOnType($mapped);
if (!$concreteConverter instanceof Typo3ConcreteConverter) { if (!$concreteConverter instanceof Typo3ConcreteConverter) {
throw new Exception( throw new Exception(
'No TYPO3 Converter registered for given Entity "' . get_class($mapped) . '".', 'No TYPO3 Converter registered for given Entity "' . $mapped::class . '".',
1628244329 1628244329
); );
} }

View file

@ -53,7 +53,7 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\TownRepository;
class GeneralConverter implements Converter class GeneralConverter implements Converter
{ {
private Logger $logger; private readonly Logger $logger;
private ImportConfiguration $importConfiguration; private ImportConfiguration $importConfiguration;
@ -79,7 +79,7 @@ class GeneralConverter implements Converter
private readonly NameExtractor $nameExtractor, private readonly NameExtractor $nameExtractor,
LogManager $logManager LogManager $logManager
) { ) {
$this->logger = $logManager->getLogger(__CLASS__); $this->logger = $logManager->getLogger(self::class);
} }
public function convert( public function convert(
@ -95,7 +95,7 @@ class GeneralConverter implements Converter
$converted = new GenericEntity( $converted = new GenericEntity(
$importConfiguration->getStoragePid(), $importConfiguration->getStoragePid(),
$this->getTableNameByEntityClass(get_class($entity)), $this->getTableNameByEntityClass($entity::class),
$this->languageHandling->getLanguageUidForString( $this->languageHandling->getLanguageUidForString(
$importConfiguration->getStoragePid(), $importConfiguration->getStoragePid(),
$language $language
@ -120,12 +120,12 @@ class GeneralConverter implements Converter
ImportConfiguration $importConfiguration, ImportConfiguration $importConfiguration,
string $language string $language
): bool { ): bool {
$tableName = $this->getTableNameByEntityClass(get_class($entity)); $tableName = $this->getTableNameByEntityClass($entity::class);
if (!$entity instanceof Minimum) { if (!$entity instanceof Minimum) {
$this->logger->info('Skipped conversion of entity, got unexpected type', [ $this->logger->info('Skipped conversion of entity, got unexpected type', [
'expectedType' => Minimum::class, 'expectedType' => Minimum::class,
'actualType' => get_class($entity), 'actualType' => $entity::class,
]); ]);
return false; return false;
} }
@ -313,6 +313,7 @@ class GeneralConverter implements Converter
if ($result === false || $result === '[]') { if ($result === false || $result === '[]') {
return '{}'; return '{}';
} }
return $result; return $result;
} }
@ -346,7 +347,7 @@ class GeneralConverter implements Converter
} }
} }
return json_encode($data) ?: ''; return json_encode($data, JSON_THROW_ON_ERROR) ?: '';
} }
private function getSingleMedia( private function getSingleMedia(
@ -386,7 +387,7 @@ class GeneralConverter implements Converter
]); ]);
} }
return json_encode($data) ?: ''; return json_encode($data, JSON_THROW_ON_ERROR) ?: '';
} }
private function getAddress(Place $entity): string private function getAddress(Place $entity): string
@ -415,7 +416,7 @@ class GeneralConverter implements Converter
]; ];
} }
return json_encode($data) ?: ''; return json_encode($data, JSON_THROW_ON_ERROR) ?: '';
} }
private function getOffers(Place $entity): string private function getOffers(Place $entity): string
@ -426,11 +427,11 @@ class GeneralConverter implements Converter
'types' => $offer->getOfferTypes(), 'types' => $offer->getOfferTypes(),
'title' => $offer->getName(), 'title' => $offer->getName(),
'description' => $offer->getDescription(), 'description' => $offer->getDescription(),
'prices' => array_map([$this, 'getPrice'], $offer->getPrices()), 'prices' => array_map($this->getPrice(...), $offer->getPrices()),
]; ];
} }
return json_encode($data) ?: ''; return json_encode($data, JSON_THROW_ON_ERROR) ?: '';
} }
private function getPrice(PriceSpecification $priceSpecification): array private function getPrice(PriceSpecification $priceSpecification): array

View file

@ -28,12 +28,9 @@ use WerkraumMedia\ThueCat\Domain\Import\ResolveForeignReference;
class NameExtractor class NameExtractor
{ {
private ResolveForeignReference $resolveForeignReference;
public function __construct( public function __construct(
ResolveForeignReference $resolveForeignReference private readonly ResolveForeignReference $resolveForeignReference
) { ) {
$this->resolveForeignReference = $resolveForeignReference;
} }
/** /**
@ -62,7 +59,7 @@ class NameExtractor
} }
if ($name === '' && method_exists($remote, 'getName')) { if ($name === '' && method_exists($remote, 'getName')) {
$name = trim($remote->getName()); $name = trim((string) $remote->getName());
} }
return $name; return $name;

View file

@ -34,7 +34,7 @@ class AbstractEntity extends Typo3AbstractEntity
protected string $description = ''; protected string $description = '';
protected ?DateTimeImmutable $tstamp; protected ?DateTimeImmutable $tstamp = null;
public function getRemoteId(): string public function getRemoteId(): string
{ {

View file

@ -41,7 +41,7 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
protected string $configuration = ''; protected string $configuration = '';
protected ?DateTimeImmutable $tstamp; protected ?DateTimeImmutable $tstamp = null;
/** /**
* @var ObjectStorage<ImportLog> * @var ObjectStorage<ImportLog>
@ -51,7 +51,7 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
/** /**
* @var string[]|null * @var string[]|null
*/ */
protected ?array $urls; protected ?array $urls = null;
/** /**
* @var string[] * @var string[]

View file

@ -35,15 +35,12 @@ class ImportLog extends Typo3AbstractEntity
*/ */
protected ObjectStorage $logEntries; protected ObjectStorage $logEntries;
protected ?ImportConfiguration $configuration; protected ?DateTimeImmutable $crdate = null;
protected ?DateTimeImmutable $crdate;
public function __construct( public function __construct(
?ImportConfiguration $configuration = null protected ?ImportConfiguration $configuration = null
) { ) {
$this->logEntries = new ObjectStorage(); $this->logEntries = new ObjectStorage();
$this->configuration = $configuration;
} }
public function addEntry(ImportLogEntry $entry): void public function addEntry(ImportLogEntry $entry): void

View file

@ -37,7 +37,7 @@ class MappingError extends ImportLogEntry
MappingException $exception MappingException $exception
) { ) {
$this->remoteId = $exception->getUrl(); $this->remoteId = $exception->getUrl();
$this->errors = json_encode([$exception->getMessage()]) ?: ''; $this->errors = json_encode([$exception->getMessage()], JSON_THROW_ON_ERROR) ?: '';
} }
public function getRemoteId(): string public function getRemoteId(): string
@ -47,7 +47,7 @@ class MappingError extends ImportLogEntry
public function getErrors(): array public function getErrors(): array
{ {
$errors = json_decode($this->errors, true); $errors = json_decode($this->errors, true, 512, JSON_THROW_ON_ERROR);
if (is_array($errors) === false) { if (is_array($errors) === false) {
throw new Exception('Could not parse errors.', 1671097690); throw new Exception('Could not parse errors.', 1671097690);
} }

View file

@ -42,20 +42,17 @@ class SavingEntity extends ImportLogEntry
protected string $errors = ''; protected string $errors = '';
/** /**
* @var string[] * @param string[] $errorsAsArray
*/ */
protected array $errorsAsArray = [];
public function __construct( public function __construct(
Entity $entity, Entity $entity,
array $dataHandlerErrorLog protected array $errorsAsArray
) { ) {
$this->remoteId = $entity->getRemoteId(); $this->remoteId = $entity->getRemoteId();
$this->insertion = $entity->wasCreated(); $this->insertion = $entity->wasCreated();
$this->recordUid = $entity->getTypo3Uid(); $this->recordUid = $entity->getTypo3Uid();
$this->recordPid = $entity->getTypo3StoragePid(); $this->recordPid = $entity->getTypo3StoragePid();
$this->tableName = $entity->getTypo3DatabaseTableName(); $this->tableName = $entity->getTypo3DatabaseTableName();
$this->errorsAsArray = $dataHandlerErrorLog;
} }
public function getRemoteId(): string public function getRemoteId(): string
@ -81,7 +78,7 @@ class SavingEntity extends ImportLogEntry
public function getErrors(): array public function getErrors(): array
{ {
if ($this->errorsAsArray === [] && $this->errors !== '') { if ($this->errorsAsArray === [] && $this->errors !== '') {
$errorsAsArray = json_decode($this->errors, true); $errorsAsArray = json_decode($this->errors, true, 512, JSON_THROW_ON_ERROR);
if (is_array($errorsAsArray) === false) { if (is_array($errorsAsArray) === false) {
throw new Exception('Could not parse errors.', 1671097690); throw new Exception('Could not parse errors.', 1671097690);
} }

View file

@ -27,17 +27,15 @@ use TYPO3\CMS\Core\Type\TypeInterface;
class AccessiblitySpecification implements TypeInterface class AccessiblitySpecification implements TypeInterface
{ {
private string $serialized;
/** /**
* @var mixed[] * @var mixed[]
*/ */
private array $data; private array $data;
public function __construct(string $serialized) public function __construct(
{ private readonly string $serialized
$this->serialized = $serialized; ) {
$this->data = json_decode($serialized, true); $this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
} }
public function getCertificationStatus(): string public function getCertificationStatus(): string

View file

@ -27,17 +27,15 @@ use TYPO3\CMS\Core\Type\TypeInterface;
class Address implements TypeInterface class Address implements TypeInterface
{ {
private string $serialized;
/** /**
* @var mixed[] * @var mixed[]
*/ */
private array $data; private array $data;
public function __construct(string $serialized) public function __construct(
{ private readonly string $serialized
$this->serialized = $serialized; ) {
$this->data = json_decode($serialized, true); $this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
} }
public function getStreet(): string public function getStreet(): string

View file

@ -31,7 +31,7 @@ abstract class Base extends AbstractEntity
protected string $description = ''; protected string $description = '';
protected ?Media $media; protected ?Media $media = null;
public function getTitle(): string public function getTitle(): string
{ {

View file

@ -28,22 +28,20 @@ use TYPO3\CMS\Core\Type\TypeInterface;
class Media implements TypeInterface class Media implements TypeInterface
{ {
private string $serialized;
/** /**
* @var array[] * @var array[]
*/ */
private array $data; private readonly array $data;
/** /**
* @var FileReference[] * @var FileReference[]
*/ */
protected array $editorialImages = []; protected array $editorialImages = [];
public function __construct(string $serialized) public function __construct(
{ private readonly string $serialized
$this->serialized = $serialized; ) {
$data = json_decode($serialized, true); $data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
$this->data = $this->prepareData(is_array($data) ? $data : []); $this->data = $this->prepareData(is_array($data) ? $data : []);
} }

View file

@ -32,9 +32,9 @@ class MergedOpeningHour
*/ */
private array $weekDays = []; private array $weekDays = [];
private ?DateTimeImmutabl $from; private readonly ?DateTimeImmutable $from;
private ?DateTimeImmutabl $through; private readonly ?DateTimeImmutable $through;
public function __construct( public function __construct(
array $weekDays, array $weekDays,

View file

@ -27,20 +27,11 @@ use WerkraumMedia\ThueCat\Domain\TimingFormat;
class MergedOpeningHourWeekDay class MergedOpeningHourWeekDay
{ {
private string $opens;
private string $closes;
private string $dayOfWeek;
public function __construct( public function __construct(
string $opens, private readonly string $opens,
string $closes, private readonly string $closes,
string $dayOfWeek private readonly string $dayOfWeek
) { ) {
$this->opens = $opens;
$this->closes = $closes;
$this->dayOfWeek = $dayOfWeek;
} }
public function getOpens(): string public function getOpens(): string

View file

@ -27,39 +27,19 @@ use TYPO3\CMS\Core\Utility\ArrayUtility;
class Offer class Offer
{ {
private string $title;
/**
* @var string[]
*/
private array $types;
private string $description;
/**
* @var mixed[]
*/
private array $prices;
/** /**
* @param string[] $types * @param string[] $types
* @param mixed[] $prices
*/ */
private function __construct( private function __construct(
string $title, private readonly string $title,
array $types, private array $types,
string $description, private readonly string $description,
array $prices private readonly array $prices
) { ) {
$this->title = $title;
$this->types = $types;
$this->description = $description;
$this->prices = $prices;
} }
/** public static function createFromArray(array $rawData): Offer
* @return Offer
*/
public static function createFromArray(array $rawData)
{ {
$prices = []; $prices = [];

View file

@ -32,8 +32,6 @@ use TYPO3\CMS\Core\Type\TypeInterface;
*/ */
class Offers implements TypeInterface, Iterator, Countable class Offers implements TypeInterface, Iterator, Countable
{ {
private string $serialized = '';
/** /**
* @var mixed[] * @var mixed[]
*/ */
@ -41,10 +39,10 @@ class Offers implements TypeInterface, Iterator, Countable
private int $position = 0; private int $position = 0;
public function __construct(string $serialized) public function __construct(
{ private readonly string $serialized
$this->serialized = $serialized; ) {
$array = json_decode($serialized, true); $array = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
if (is_array($array)) { if (is_array($array)) {
$array = array_map([Offer::class, 'createFromArray'], $array); $array = array_map([Offer::class, 'createFromArray'], $array);
usort($array, function (Offer $offerA, Offer $offerB) { usort($array, function (Offer $offerA, Offer $offerB) {

View file

@ -29,37 +29,19 @@ use WerkraumMedia\ThueCat\Domain\TimingFormat;
class OpeningHour class OpeningHour
{ {
private string $opens;
private string $closes;
/** /**
* @var mixed[] * @param mixed[] $daysOfWeek
*/ */
private array $daysOfWeek;
private ?DateTimeImmutable $from;
private ?DateTimeImmutable $through;
private function __construct( private function __construct(
string $opens, private readonly string $opens,
string $closes, private readonly string $closes,
array $daysOfWeek, private array $daysOfWeek,
?DateTimeImmutable $from, private readonly ?DateTimeImmutable $from,
?DateTimeImmutable $through private readonly ?DateTimeImmutable $through
) { ) {
$this->opens = $opens;
$this->closes = $closes;
$this->daysOfWeek = $daysOfWeek;
$this->from = $from;
$this->through = $through;
} }
/** public static function createFromArray(array $rawData): OpeningHour
* @return OpeningHour
*/
public static function createFromArray(array $rawData)
{ {
$from = null; $from = null;
if (isset($rawData['from'])) { if (isset($rawData['from'])) {

View file

@ -31,12 +31,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use WerkraumMedia\ThueCat\Service\DateBasedFilter; use WerkraumMedia\ThueCat\Service\DateBasedFilter;
/** /**
* @implements \Iterator<int, OpeningHour> * @implements Iterator<int, OpeningHour>
*/ */
class OpeningHours implements TypeInterface, Iterator, Countable class OpeningHours implements TypeInterface, Iterator, Countable
{ {
private string $serialized = '';
/** /**
* @var mixed[] * @var mixed[]
*/ */
@ -44,9 +42,9 @@ class OpeningHours implements TypeInterface, Iterator, Countable
private int $position = 0; private int $position = 0;
public function __construct(string $serialized) public function __construct(
{ private readonly string $serialized
$this->serialized = $serialized; ) {
$this->array = $this->createArray($serialized); $this->array = $this->createArray($serialized);
} }
@ -54,7 +52,7 @@ class OpeningHours implements TypeInterface, Iterator, Countable
{ {
$array = array_map( $array = array_map(
[OpeningHour::class, 'createFromArray'], [OpeningHour::class, 'createFromArray'],
json_decode($serialized, true) ?? [] json_decode($serialized, true, 512, JSON_THROW_ON_ERROR) ?? []
); );
$array = GeneralUtility::makeInstance(DateBasedFilter::class) $array = GeneralUtility::makeInstance(DateBasedFilter::class)

View file

@ -28,13 +28,13 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
abstract class Place extends Base abstract class Place extends Base
{ {
protected ?Address $address; protected ?Address $address = null;
protected string $url = ''; protected string $url = '';
protected ?OpeningHours $openingHours; protected ?OpeningHours $openingHours = null;
protected ?OpeningHours $specialOpeningHours; protected ?OpeningHours $specialOpeningHours = null;
/** /**
* @var ObjectStorage<ParkingFacility> * @var ObjectStorage<ParkingFacility>
@ -51,7 +51,7 @@ abstract class Place extends Base
protected string $distanceToPublicTransport = ''; protected string $distanceToPublicTransport = '';
protected ?AccessiblitySpecification $accessibilitySpecification; protected ?AccessiblitySpecification $accessibilitySpecification = null;
public function initializeObject(): void public function initializeObject(): void
{ {

View file

@ -29,9 +29,9 @@ class TouristAttraction extends Place
{ {
protected string $slogan = ''; protected string $slogan = '';
protected ?Offers $offers; protected ?Offers $offers = null;
protected ?Town $town; protected ?Town $town = null;
protected string $startOfConstruction = ''; protected string $startOfConstruction = '';

View file

@ -75,7 +75,7 @@ class ImportLogRepository extends Repository
'import_log' => 'NEW0', 'import_log' => 'NEW0',
'type' => $entry->getType(), 'type' => $entry->getType(),
'remote_id' => $entry->getRemoteId(), 'remote_id' => $entry->getRemoteId(),
'errors' => json_encode($entry->getErrors()), 'errors' => json_encode($entry->getErrors(), JSON_THROW_ON_ERROR),
] ]
); );
} }

View file

@ -30,13 +30,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
class Extension class Extension
{ {
public const EXTENSION_KEY = 'thuecat'; final public const EXTENSION_KEY = 'thuecat';
public const EXTENSION_NAME = 'Thuecat'; final public const EXTENSION_NAME = 'Thuecat';
public const TCA_SELECT_GROUP_IDENTIFIER = 'thuecat'; final public const TCA_SELECT_GROUP_IDENTIFIER = 'thuecat';
public const PAGE_DOKTYPE_TOURIST_ATTRACTION = 950; final public const PAGE_DOKTYPE_TOURIST_ATTRACTION = 950;
public static function getLanguagePath(): string public static function getLanguagePath(): string
{ {

View file

@ -33,7 +33,7 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
class ResolveEntities implements DataProcessorInterface class ResolveEntities implements DataProcessorInterface
{ {
private TypoScriptFrontendController $tsfe; private readonly TypoScriptFrontendController $tsfe;
public function __construct( public function __construct(
private readonly ConnectionPool $connectionPool, private readonly ConnectionPool $connectionPool,

View file

@ -77,7 +77,7 @@ class AfterObjectThawedHandler
private function getTableNameForObject(Base $object): string private function getTableNameForObject(Base $object): string
{ {
return $this->dataMapFactory return $this->dataMapFactory
->buildDataMap(get_class($object)) ->buildDataMap($object::class)
->getTableName() ->getTableName()
; ;
} }

View file

@ -44,7 +44,7 @@ return (static function (string $extensionKey, string $tableName) {
[ [
'label' => '', 'label' => '',
'value' => 0, 'value' => 0,
] ],
], ],
'foreign_table' => $tableName, 'foreign_table' => $tableName,
'foreign_table_where' => 'AND ' . $tableName . '.pid=###CURRENT_PID### AND ' . $tableName . '.sys_language_uid IN (-1,0)', 'foreign_table_where' => 'AND ' . $tableName . '.pid=###CURRENT_PID### AND ' . $tableName . '.sys_language_uid IN (-1,0)',

View file

@ -44,7 +44,7 @@ return (static function (string $extensionKey, string $tableName) {
[ [
'label' => '', 'label' => '',
'value' => 0, 'value' => 0,
] ],
], ],
'foreign_table' => $tableName, 'foreign_table' => $tableName,
'foreign_table_where' => 'AND ' . $tableName . '.pid=###CURRENT_PID### AND ' . $tableName . '.sys_language_uid IN (-1,0)', 'foreign_table_where' => 'AND ' . $tableName . '.pid=###CURRENT_PID### AND ' . $tableName . '.sys_language_uid IN (-1,0)',

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -11,10 +11,7 @@ use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class GuzzleClientFaker class GuzzleClientFaker
{ {
/** private static ?MockHandler $mockHandler = null;
* @var MockHandler
*/
private static $mockHandler;
public static function registerClient(): void public static function registerClient(): void
{ {