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/
/.phpunit.cache
/composer.lock
/.phpunit.cache
/Tests/Acceptance/Support/_generated
/vendor/

View file

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

View file

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

View file

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

View file

@ -25,11 +25,8 @@ namespace WerkraumMedia\ThueCat\Domain\Import\Entity\Properties;
class DayOfWeek
{
protected string $dayOfWeek = '';
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(
[PropertyValues::class, 'removePrefixFromEntry'],
PropertyValues::removePrefixFromEntry(...),
$offerType
);
}

View file

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

View file

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

View file

@ -54,26 +54,26 @@ use Symfony\Component\PropertyInfo\Util\PhpDocTypeHelper;
*/
class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface, PropertyTypeExtractorInterface, ConstructorArgumentTypeExtractorInterface
{
public const PROPERTY = 0;
public const ACCESSOR = 1;
public const MUTATOR = 2;
final public const PROPERTY = 0;
final public const ACCESSOR = 1;
final public const MUTATOR = 2;
/**
* @var array<string, array{DocBlock|null, int|null, string|null}>
*/
private $docBlocks = [];
private array $docBlocks = [];
/**
* @var Context[]
*/
private $contexts = [];
private array $contexts = [];
private $docBlockFactory;
private $contextFactory;
private $phpDocTypeHelper;
private $mutatorPrefixes;
private $accessorPrefixes;
private $arrayMutatorPrefixes;
private readonly \phpDocumentor\Reflection\DocBlockFactoryInterface $docBlockFactory;
private readonly \phpDocumentor\Reflection\Types\ContextFactory $contextFactory;
private readonly \Symfony\Component\PropertyInfo\Util\PhpDocTypeHelper $phpDocTypeHelper;
private readonly array $mutatorPrefixes;
private readonly array $accessorPrefixes;
private readonly array $arrayMutatorPrefixes;
/**
* @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)
{
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();
@ -246,7 +246,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
$docBlock = $this->docBlockFactory->create($reflectionConstructor, $this->contextFactory->createFromReflector($reflectionConstructor));
return $this->filterDocBlockParams($docBlock, $property);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
return null;
}
}
@ -320,7 +320,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
try {
return $this->docBlockFactory->create($reflectionProperty, $this->createFromReflector($reflector));
} catch (InvalidArgumentException|RuntimeException $e) {
} catch (InvalidArgumentException|RuntimeException) {
return null;
}
}
@ -348,7 +348,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
) {
break;
}
} catch (ReflectionException $e) {
} catch (ReflectionException) {
// Try the next prefix if the method doesn't exist
}
}
@ -367,7 +367,7 @@ class CustomAnnotationExtractor implements PropertyDescriptionExtractorInterface
try {
return [$this->docBlockFactory->create($reflectionMethod, $this->createFromReflector($reflector)), $prefix];
} catch (InvalidArgumentException|RuntimeException $e) {
} catch (InvalidArgumentException|RuntimeException) {
return null;
}
}

View file

@ -33,7 +33,7 @@ use Symfony\Component\Serializer\Encoder\JsonDecode as SymfonyJsonDecode;
*/
class JsonDecode extends SymfonyJsonDecode
{
public const ACTIVE_LANGUAGE = 'active_language';
final public const ACTIVE_LANGUAGE = 'active_language';
/**
* @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.
*
* @param mixed $value
*
* @return mixed
*/
private function decodeLanguageSpecificValue(
&$value,
mixed &$value,
string $activeLanguage
) {
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.
*
* @param mixed $value
*
* @return mixed
*/
private function decodeSingleValues(
&$value
mixed &$value
) {
if (is_array($value) === false) {
return $value;
@ -189,12 +187,11 @@ class JsonDecode extends SymfonyJsonDecode
/**
* Prepare data structure for PHP \DateTimeImmutable.
*
* @param mixed $value
*
* @return mixed
*/
private function decodeDateTime(
&$value
mixed &$value
) {
$supportedTypes = [
'schema:Time',
@ -214,11 +211,9 @@ class JsonDecode extends SymfonyJsonDecode
}
/**
* @param mixed $key
*
* @return mixed
*/
private function mapKey($key)
private function mapKey(mixed $key)
{
if (is_string($key) === false) {
return $key;
@ -240,7 +235,7 @@ class JsonDecode extends SymfonyJsonDecode
private function doesRuleMatch(array $rule, string $type): bool
{
if ($rule['type'] === 'beginsWith') {
return str_starts_with($type, $rule['comparisonValue']);
return str_starts_with($type, (string) $rule['comparisonValue']);
}
return false;

View file

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

View file

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

View file

@ -43,9 +43,9 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository;
class Importer
{
private Logger $logger;
private readonly Logger $logger;
private Import $import;
private readonly Import $import;
public function __construct(
private readonly UrlProviderRegistry $urls,
@ -58,7 +58,7 @@ class Importer
private readonly SaveData $saveData,
LogManager $logManager
) {
$this->logger = $logManager->getLogger(__CLASS__);
$this->logger = $logManager->getLogger(self::class);
$this->import = new Import();
}
@ -143,7 +143,7 @@ class Importer
}
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;
}

View file

@ -70,7 +70,7 @@ class FetchData
$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)) {
$this->cache->set($cacheIdentifier, $jsonLD);
return $jsonLD;

View file

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

View file

@ -25,35 +25,20 @@ 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;
/**
* @var mixed[]
* @param mixed[] $data
*/
private array $data;
public function __construct(
int $typo3StoragePid,
string $typo3DatabaseTableName,
int $typo3SystemLanguageUid,
string $remoteId,
array $data
private readonly int $typo3StoragePid,
private readonly string $typo3DatabaseTableName,
private readonly int $typo3SystemLanguageUid,
private readonly string $remoteId,
private readonly array $data
) {
$this->typo3StoragePid = $typo3StoragePid;
$this->typo3DatabaseTableName = $typo3DatabaseTableName;
$this->typo3SystemLanguageUid = $typo3SystemLanguageUid;
$this->remoteId = $remoteId;
$this->data = $data;
}
public function getTypo3StoragePid(): int

View file

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

View file

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

View file

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

View file

@ -53,7 +53,7 @@ use WerkraumMedia\ThueCat\Domain\Repository\Backend\TownRepository;
class GeneralConverter implements Converter
{
private Logger $logger;
private readonly Logger $logger;
private ImportConfiguration $importConfiguration;
@ -79,7 +79,7 @@ class GeneralConverter implements Converter
private readonly NameExtractor $nameExtractor,
LogManager $logManager
) {
$this->logger = $logManager->getLogger(__CLASS__);
$this->logger = $logManager->getLogger(self::class);
}
public function convert(
@ -95,7 +95,7 @@ class GeneralConverter implements Converter
$converted = new GenericEntity(
$importConfiguration->getStoragePid(),
$this->getTableNameByEntityClass(get_class($entity)),
$this->getTableNameByEntityClass($entity::class),
$this->languageHandling->getLanguageUidForString(
$importConfiguration->getStoragePid(),
$language
@ -120,12 +120,12 @@ class GeneralConverter implements Converter
ImportConfiguration $importConfiguration,
string $language
): bool {
$tableName = $this->getTableNameByEntityClass(get_class($entity));
$tableName = $this->getTableNameByEntityClass($entity::class);
if (!$entity instanceof Minimum) {
$this->logger->info('Skipped conversion of entity, got unexpected type', [
'expectedType' => Minimum::class,
'actualType' => get_class($entity),
'actualType' => $entity::class,
]);
return false;
}
@ -313,6 +313,7 @@ class GeneralConverter implements Converter
if ($result === false || $result === '[]') {
return '{}';
}
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(
@ -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
@ -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
@ -426,11 +427,11 @@ class GeneralConverter implements Converter
'types' => $offer->getOfferTypes(),
'title' => $offer->getName(),
'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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,7 +37,7 @@ class MappingError extends ImportLogEntry
MappingException $exception
) {
$this->remoteId = $exception->getUrl();
$this->errors = json_encode([$exception->getMessage()]) ?: '';
$this->errors = json_encode([$exception->getMessage()], JSON_THROW_ON_ERROR) ?: '';
}
public function getRemoteId(): string
@ -47,7 +47,7 @@ class MappingError extends ImportLogEntry
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) {
throw new Exception('Could not parse errors.', 1671097690);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -75,7 +75,7 @@ class ImportLogRepository extends Repository
'import_log' => 'NEW0',
'type' => $entry->getType(),
'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
{
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
{

View file

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

View file

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

View file

@ -44,7 +44,7 @@ return (static function (string $extensionKey, string $tableName) {
[
'label' => '',
'value' => 0,
]
],
],
'foreign_table' => $tableName,
'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' => '',
'value' => 0,
]
],
],
'foreign_table' => $tableName,
'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
{
/**
* @var MockHandler
*/
private static $mockHandler;
private static ?MockHandler $mockHandler = null;
public static function registerClient(): void
{