Skip to content

Commit

Permalink
Manually fix issues arisen from auto fixing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSiepmann committed Dec 5, 2023
1 parent 65898e9 commit 1ec50a5
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Classes/Domain/Import/Entity/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Base extends Minimum
{
use ManagedBy;

protected ForeignReference $photo;
protected ?ForeignReference $photo = null;

/**
* Images of this Thing.
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Import/Entity/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -80,7 +80,7 @@ class Place extends Base

protected string $distanceToPublicTransport = '';

protected ForeignReference $accessibilitySpecification;
protected ?ForeignReference $accessibilitySpecification = null;

public function getAddress(): ?Address
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Import/Entity/Shared/ManagedBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Import/EntityMapper/JsonDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private function mapKey(mixed $key)
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;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Import/Typo3Converter/NameExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function extract(
}

if ($name === '' && method_exists($remote, 'getName')) {
$name = trim((string) $remote->getName());
$name = trim((string)$remote->getName());
}

return $name;
Expand Down
9 changes: 7 additions & 2 deletions Classes/Domain/Model/Backend/ImportLogEntry/MappingError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,7 +52,7 @@ public function getRemoteId(): string

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);
}
Expand Down
8 changes: 7 additions & 1 deletion Classes/Domain/Model/Backend/ImportLogEntry/SavingEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Frontend/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Frontend/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 : []);
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Frontend/Offers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Frontend/OpeningHours.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function createArray(string $serialized): array
{
$array = array_map(
[OpeningHour::class, 'createFromArray'],
json_decode($serialized, true, 512, JSON_THROW_ON_ERROR) ?? []
json_decode($serialized, true) ?? []
);

$array = GeneralUtility::makeInstance(DateBasedFilter::class)
Expand Down
15 changes: 15 additions & 0 deletions Classes/Domain/Model/Frontend/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Classes/Domain/Model/Frontend/TouristAttraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
13 changes: 11 additions & 2 deletions Configuration/Extbase/Persistence/Classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
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 => [
Expand Down Expand Up @@ -47,7 +49,14 @@
'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',
],
];
2 changes: 1 addition & 1 deletion Documentation/Maintenance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
15 changes: 15 additions & 0 deletions Documentation/Maintenance/Extbase.rst
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ <h2>{f:translate(id: 'content.parkingFacilitiesNearBy', extensionName: 'Thuecat'
</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>
Expand Down Expand Up @@ -109,6 +109,7 @@ <h3>{f:translate(id: 'content.languages', extensionName: 'Thuecat')}</h3>
</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}">
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Domain/Import/Importer/FetchDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function returnsEmptyArrayInCaseOfError(): void
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function canBeCreated(): void
$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,
Expand Down

0 comments on commit 1ec50a5

Please sign in to comment.