Manually fix issues arisen from auto fixing stuff

This commit is contained in:
Daniel Siepmann 2023-12-05 08:55:20 +01:00
parent 65898e97e0
commit 1ec50a526f
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
20 changed files with 85 additions and 23 deletions

View file

@ -30,7 +30,7 @@ class Base extends Minimum
{
use ManagedBy;
protected ForeignReference $photo;
protected ?ForeignReference $photo = null;
/**
* Images of this Thing.

View file

@ -39,9 +39,9 @@ class Place extends Base
use Organization;
use ContainedInPlace;
protected Address $address;
protected ?Address $address = null;
protected Geo $geo;
protected ?Geo $geo = null;
/**
* @var OpeningHour[]
@ -80,7 +80,7 @@ class Place extends Base
protected string $distanceToPublicTransport = '';
protected ForeignReference $accessibilitySpecification;
protected ?ForeignReference $accessibilitySpecification = null;
public function getAddress(): ?Address
{

View file

@ -30,7 +30,7 @@ trait ManagedBy
/**
* The Thing responsible for the data within this Thing.
*/
protected ?ForeignReference $managedBy;
protected ?ForeignReference $managedBy = null;
public function getManagedBy(): ?ForeignReference
{

View file

@ -235,7 +235,7 @@ class JsonDecode extends SymfonyJsonDecode
private function doesRuleMatch(array $rule, string $type): bool
{
if ($rule['type'] === 'beginsWith') {
return str_starts_with($type, (string) $rule['comparisonValue']);
return str_starts_with($type, (string)$rule['comparisonValue']);
}
return false;

View file

@ -59,7 +59,7 @@ class NameExtractor
}
if ($name === '' && method_exists($remote, 'getName')) {
$name = trim((string) $remote->getName());
$name = trim((string)$remote->getName());
}
return $name;

View file

@ -31,7 +31,12 @@ class MappingError extends ImportLogEntry
{
protected string $remoteId = '';
protected string $errors = '';
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $errors = '[]';
public function __construct(
MappingException $exception
@ -47,7 +52,7 @@ class MappingError extends ImportLogEntry
public function getErrors(): array
{
$errors = json_decode($this->errors, true, 512, JSON_THROW_ON_ERROR);
$errors = json_decode($this->errors, true);
if (is_array($errors) === false) {
throw new Exception('Could not parse errors.', 1671097690);
}

View file

@ -41,18 +41,24 @@ class SavingEntity extends ImportLogEntry
protected string $errors = '';
/**
* @var string[]
*/
protected array $errorsAsArray = [];
/**
* @param string[] $errorsAsArray
*/
public function __construct(
Entity $entity,
protected array $errorsAsArray
array $errorsAsArray
) {
$this->remoteId = $entity->getRemoteId();
$this->insertion = $entity->wasCreated();
$this->recordUid = $entity->getTypo3Uid();
$this->recordPid = $entity->getTypo3StoragePid();
$this->tableName = $entity->getTypo3DatabaseTableName();
$this->errorsAsArray = $errorsAsArray;
}
public function getRemoteId(): string

View file

@ -35,7 +35,7 @@ class AccessiblitySpecification implements TypeInterface
public function __construct(
private readonly string $serialized
) {
$this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
$this->data = json_decode($serialized, true);
}
public function getCertificationStatus(): string

View file

@ -35,7 +35,7 @@ class Address implements TypeInterface
public function __construct(
private readonly string $serialized
) {
$this->data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
$this->data = json_decode($serialized, true) ?? [];
}
public function getStreet(): string

View file

@ -41,7 +41,7 @@ class Media implements TypeInterface
public function __construct(
private readonly string $serialized
) {
$data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
$data = json_decode($serialized, true);
$this->data = $this->prepareData(is_array($data) ? $data : []);
}

View file

@ -42,7 +42,7 @@ class Offers implements TypeInterface, Iterator, Countable
public function __construct(
private readonly string $serialized
) {
$array = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR);
$array = json_decode($serialized, true);
if (is_array($array)) {
$array = array_map([Offer::class, 'createFromArray'], $array);
usort($array, function (Offer $offerA, Offer $offerB) {

View file

@ -52,7 +52,7 @@ class OpeningHours implements TypeInterface, Iterator, Countable
{
$array = array_map(
[OpeningHour::class, 'createFromArray'],
json_decode($serialized, true, 512, JSON_THROW_ON_ERROR) ?? []
json_decode($serialized, true) ?? []
);
$array = GeneralUtility::makeInstance(DateBasedFilter::class)

View file

@ -41,14 +41,29 @@ abstract class Place extends Base
*/
protected ObjectStorage $parkingFacilityNearBy;
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $sanitation = '';
protected string $otherService = '';
protected string $trafficInfrastructure = '';
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $paymentAccepted = '';
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $distanceToPublicTransport = '';
protected ?AccessiblitySpecification $accessibilitySpecification = null;

View file

@ -39,8 +39,18 @@ class TouristAttraction extends Place
protected string $architecturalStyle = '';
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $digitalOffer = '';
/**
* Necessary for Extbase/Symfony.
*
* @var string
*/
protected string $photography = '';
protected string $petsAllowed = '';

View file

@ -11,7 +11,9 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\Organisation;
use WerkraumMedia\ThueCat\Domain\Model\Backend\ParkingFacility;
use WerkraumMedia\ThueCat\Domain\Model\Backend\TouristInformation;
use WerkraumMedia\ThueCat\Domain\Model\Backend\Town;
use WerkraumMedia\ThueCat\Domain\Model\Frontend\TouristAttraction;
use WerkraumMedia\ThueCat\Domain\Model\Frontend\ParkingFacility as FrontendParkingFacility;
use WerkraumMedia\ThueCat\Domain\Model\Frontend\TouristAttraction as FrontendTouristAttraction;
use WerkraumMedia\ThueCat\Domain\Model\Frontend\Town as FrontendTown;
return [
Organisation::class => [
@ -47,7 +49,14 @@ return [
'tableName' => 'tx_thuecat_import_log_entry',
'recordType' => 'mappingError',
],
TouristAttraction::class => [
FrontendTouristAttraction::class => [
'tableName' => 'tx_thuecat_tourist_attraction',
],
FrontendTown::class => [
'tableName' => 'tx_thuecat_town',
],
FrontendParkingFacility::class => [
'tableName' => 'tx_thuecat_parking_facility',
],
];

View file

@ -14,4 +14,4 @@ Those changes are documented so we know what to do once we drop an older version
:glob:
:reversed:
Maintenance/PHP/*
Maintenance/*

View file

@ -0,0 +1,15 @@
.. _maintenanceExtbase:
Extbase
=======
PHPDoc Blocks with type hints mentioning `Necessary for Extbase/Symfony.`
-------------------------------------------------------------------------
Those are necessary (at least with TYPO3 v12) because of Extbase and the underlying
Symfony component.
Extbase uses the PHPDocExtractor first, before using the `ReflectionExtractor`, both part of Symfony property-info package.
The `ReflectionExtractor` will check the mutator followed by accessors prior checking the property itself.
Some of our properties have different return values by accessors than the stored value that is set to the property.
We therefore need to keep the PHPDoc block as this is checked first.

View file

@ -71,10 +71,10 @@
</f:if>
</div>
<div class="row thuecat__services">
<f:if condition="{entity.generalInformation || entity.otherServices || entity.petsAllowed || entity.isAccessibleForFree
|| entity.publicAccess || entity.accessibilitySpecification.certificationStatus || entity.museumServices
|| entity.digitalOffer || entity.trafficInfrastructures || entity.paymentAccepted || entity.availableLanguages
|| entity.sanitation || entity.photography || entity.startOfConstruction || entity.architecturalStyles}"
<f:if condition="{entity.generalInformation} || {entity.otherServices} || {entity.petsAllowed} || {entity.isAccessibleForFree}
|| {entity.publicAccess} || {entity.accessibilitySpecification.certificationStatus} || {entity.museumServices}
|| {entity.digitalOffer} || {entity.trafficInfrastructures} || {entity.paymentAccepted} || {entity.availableLanguages}
|| {entity.sanitation} || {entity.photography} || {entity.startOfConstruction} || {entity.architecturalStyles}"
>
<div class="col-md-6">
<h2>{f:translate(id: 'content.generalInformation', extensionName: 'Thuecat')}</h2>
@ -109,6 +109,7 @@
</f:if>
<f:if condition="{entity.sanitation}">
<h3>{f:translate(id: 'content.sanitation', extensionName: 'Thuecat')}</h3>
sanitation
{f:render(partial: 'Sanitation', arguments: {sanitation: entity.sanitation})}
</f:if>
<f:if condition="{entity.photography}">

View file

@ -103,7 +103,7 @@ class FetchDataTest extends TestCase
$httpClient->method('sendRequest')->willReturn($response);
$body = $this->createStub(StreamInterface::class);
$body->method('__toString')->willReturn('');
$body->method('__toString')->willReturn('[]');
$response->method('getStatusCode')->willReturn(200);
$response->method('getBody')->willReturn($body);

View file

@ -53,6 +53,7 @@ class GeneralConverterTest extends TestCase
$parkingFacilityRepository = $this->createStub(ParkingFacilityRepository::class);
$nameExtractor = $this->createStub(NameExtractor::class);
$logManager = $this->createStub(LogManager::class);
$logManager->method('getLogger')->willReturn($this->createStub(Logger::class));
$subject = new GeneralConverter(
$resolveForeignReference,