Skip to content

Commit ee2c6a4

Browse files
committed
Aligned implementation after applying return type Rector
1 parent 63dac90 commit ee2c6a4

File tree

16 files changed

+82
-98
lines changed

16 files changed

+82
-98
lines changed

src/lib/FieldType/BinaryBase/BinaryBaseStorage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public function hasFieldData()
205205
return true;
206206
}
207207

208-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
208+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
209209
{
210+
return [];
210211
}
211212
}

src/lib/FieldType/Image/ImageStorage.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@ public function hasFieldData(): bool
192192
return true;
193193
}
194194

195-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
195+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
196196
{
197-
// @todo: Correct?
198-
return null;
197+
return [];
199198
}
200199

201200
/**

src/lib/FieldType/Keyword/KeywordStorage.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,8 @@ public function hasFieldData(): bool
7171
return true;
7272
}
7373

74-
/**
75-
* @param \Ibexa\Contracts\Core\Persistence\Content\VersionInfo $versionInfo
76-
* @param \Ibexa\Contracts\Core\Persistence\Content\Field $field
77-
* @param array $context
78-
*
79-
* @return \Ibexa\Contracts\Core\Search\Field[]|null
80-
*/
81-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
74+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
8275
{
83-
return null;
76+
return [];
8477
}
8578
}

src/lib/FieldType/MapLocation/MapLocationStorage.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,9 @@ public function hasFieldData(): bool
6060
return true;
6161
}
6262

63-
/**
64-
* @param \Ibexa\Contracts\Core\Persistence\Content\VersionInfo $versionInfo
65-
* @param \Ibexa\Contracts\Core\Persistence\Content\Field $field
66-
* @param array $context
67-
*
68-
* @return \Ibexa\Contracts\Core\Search\Field[]|null
69-
*/
70-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
63+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
7164
{
72-
return is_array($field->value->externalData) ? $field->value->externalData['address'] : null;
65+
// Handled by @see \Ibexa\Core\FieldType\MapLocation\SearchField::getIndexData()
66+
return [];
7367
}
7468
}

src/lib/FieldType/NullStorage.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ public function hasFieldData(): bool
5050
return false;
5151
}
5252

53-
/**
54-
* @see \Ibexa\Contracts\Core\FieldType\FieldStorage::getIndexData()
55-
*/
56-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): bool
53+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
5754
{
58-
return false;
55+
return [];
5956
}
6057

6158
/**

src/lib/FieldType/Url/UrlStorage.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co
4646

4747
$map = $this->gateway->getUrlIdMap([$url]);
4848

49-
if (isset($map[$url])) {
50-
$urlId = $map[$url];
51-
} else {
52-
$urlId = $this->gateway->insertUrl($url);
53-
}
49+
$urlId = $map[$url] ?? $this->gateway->insertUrl($url);
5450

5551
$this->gateway->linkUrl($urlId, $field->id, $versionInfo->versionNo);
5652

@@ -112,14 +108,8 @@ public function hasFieldData(): bool
112108
return true;
113109
}
114110

115-
/**
116-
* @param \Ibexa\Contracts\Core\Persistence\Content\VersionInfo $versionInfo
117-
* @param \Ibexa\Contracts\Core\Persistence\Content\Field $field
118-
* @param array $context
119-
*
120-
* @return \Ibexa\Contracts\Core\Search\Field[]
121-
*/
122-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
111+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
123112
{
113+
return [];
124114
}
125115
}

src/lib/FieldType/User/UserStorage.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,9 @@ public function hasFieldData(): bool
6969
return true;
7070
}
7171

72-
/**
73-
* @param \Ibexa\Contracts\Core\Persistence\Content\VersionInfo $versionInfo
74-
* @param \Ibexa\Contracts\Core\Persistence\Content\Field $field
75-
* @param array $context
76-
*
77-
* @return \Ibexa\Contracts\Core\Search\Field[]
78-
*/
79-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
72+
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): array
8073
{
74+
return [];
8175
}
8276

8377
/**

src/lib/MVC/Symfony/Translation/CatalogueMapperFileWriter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public function write(MessageCatalogue $catalogue, $domain, $filePath, $format)
7474
$this->innerFileWriter->write($newCatalogue, $domain, $filePath, $format);
7575
}
7676

77-
/**
78-
* @param $filePath
79-
*
80-
* @return mixed
81-
*/
82-
private function getEnglishFilePath($filePath): string|array|null
77+
private function getEnglishFilePath(string $filePath): string
8378
{
84-
return preg_replace('/\.[-_a-z]+\.xlf$/i', '.en.xlf', $filePath);
79+
$enFilePath = preg_replace('/\.[-_a-z]+\.xlf$/i', '.en.xlf', $filePath);
80+
if (null === $enFilePath) {
81+
throw new InvalidArgumentException("failed to get English XLF file path for '$filePath'");
82+
}
83+
84+
return $enFilePath;
8585
}
8686

8787
/**

src/lib/Persistence/Legacy/Content/FieldValue/Converter/AuthorConverter.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Ibexa\Core\Persistence\Legacy\Content\FieldValue\Converter;
99

1010
use DOMDocument;
11+
use Ibexa\Contracts\Core\Exception\InvalidArgumentException;
1112
use Ibexa\Contracts\Core\Persistence\Content\FieldValue;
1213
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;
1314
use Ibexa\Core\FieldType\Author\Type as AuthorType;
@@ -106,8 +107,11 @@ public function getIndexColumn(): string
106107
* @param array $authorValue
107108
*
108109
* @return string The generated XML string
110+
*
111+
* @throws \DOMException
112+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
109113
*/
110-
private function generateXmlString(array $authorValue): string|false
114+
private function generateXmlString(array $authorValue): string
111115
{
112116
$doc = new DOMDocument('1.0', 'utf-8');
113117

@@ -119,14 +123,22 @@ private function generateXmlString(array $authorValue): string|false
119123

120124
foreach ($authorValue as $author) {
121125
$authorNode = $doc->createElement('author');
122-
$authorNode->setAttribute('id', $author['id']);
126+
$authorNode->setAttribute('id', (string)$author['id']);
123127
$authorNode->setAttribute('name', $author['name']);
124128
$authorNode->setAttribute('email', $author['email']);
125129
$authors->appendChild($authorNode);
126130
unset($authorNode);
127131
}
128132

129-
return $doc->saveXML();
133+
$xml = $doc->saveXML();
134+
if (false === $xml) {
135+
throw new InvalidArgumentException(
136+
'$authorValue',
137+
'AuthorConverter: an error occurred when trying to save author field data'
138+
);
139+
}
140+
141+
return $xml;
130142
}
131143

132144
/**

src/lib/Persistence/Legacy/Content/FieldValue/Converter/DateAndTimeConverter.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use DateInterval;
1111
use DateTime;
1212
use DOMDocument;
13+
use Ibexa\Contracts\Core\Exception\InvalidArgumentException;
1314
use Ibexa\Contracts\Core\Persistence\Content\FieldValue;
1415
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;
1516
use Ibexa\Core\FieldType\DateAndTime\Type as DateAndTimeType;
@@ -155,11 +156,10 @@ public function getIndexColumn(): string
155156
/**
156157
* Generates the internal XML structure for $dateInterval, used for date adjustment.
157158
*
158-
* @param \DateInterval $dateInterval
159-
*
160-
* @return string The generated XML string
159+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
160+
* @throws \DOMException
161161
*/
162-
protected function generateDateIntervalXML(DateInterval $dateInterval): string|false
162+
protected function generateDateIntervalXML(DateInterval $dateInterval): string
163163
{
164164
// Constructing XML structure
165165
$doc = new DOMDocument('1.0', 'utf-8');
@@ -197,7 +197,15 @@ protected function generateDateIntervalXML(DateInterval $dateInterval): string|f
197197

198198
$doc->appendChild($root);
199199

200-
return $doc->saveXML();
200+
$xml = $doc->saveXML();
201+
if (false === $xml) {
202+
throw new InvalidArgumentException(
203+
'$authorValue',
204+
'DateAndTimeConverter: an error occurred when trying to save date and time field data'
205+
);
206+
}
207+
208+
return $xml;
201209
}
202210

203211
/**

0 commit comments

Comments
 (0)