Skip to content

Commit 1663cd6

Browse files
Add return types - batch 4/n
1 parent 6c4158f commit 1663cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+176
-239
lines changed

ConfigCache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(string $file, bool $debug)
5151
*
5252
* @return bool true if the cache is fresh, false otherwise
5353
*/
54-
public function isFresh()
54+
public function isFresh(): bool
5555
{
5656
if (!$this->debug && is_file($this->getPath())) {
5757
return true;

ConfigCacheFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(bool $debug)
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function cache(string $file, callable $callback)
38+
public function cache(string $file, callable $callback): ConfigCacheInterface
3939
{
4040
$cache = new ConfigCache($file, $this->debug);
4141
if (!$cache->isFresh()) {

ConfigCacheFactoryInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ interface ConfigCacheFactoryInterface
2525
*
2626
* @param string $file The absolute cache file path
2727
* @param callable $callable The callable to be executed when the cache needs to be filled (i. e. is not fresh). The cache will be passed as the only parameter to this callback
28-
*
29-
* @return ConfigCacheInterface
3028
*/
31-
public function cache(string $file, callable $callable);
29+
public function cache(string $file, callable $callable): ConfigCacheInterface;
3230
}

ConfigCacheInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface ConfigCacheInterface
2525
*
2626
* @return string The cache file path
2727
*/
28-
public function getPath();
28+
public function getPath(): string;
2929

3030
/**
3131
* Checks if the cache is still fresh.
@@ -34,7 +34,7 @@ public function getPath();
3434
*
3535
* @return bool Whether the cache is still fresh
3636
*/
37-
public function isFresh();
37+
public function isFresh(): bool;
3838

3939
/**
4040
* Writes the given content into the cache file. Metadata will be stored

Definition/ArrayNode.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function setNormalizeKeys(bool $normalizeKeys)
4646
* If you have a mixed key like foo-bar_moo, it will not be altered.
4747
* The key will also not be altered if the target key already exists.
4848
*/
49-
protected function preNormalize(mixed $value)
49+
protected function preNormalize(mixed $value): mixed
5050
{
5151
if (!$this->normalizeKeys || !\is_array($value)) {
5252
return $value;
@@ -70,7 +70,7 @@ protected function preNormalize(mixed $value)
7070
*
7171
* @return array<string, NodeInterface>
7272
*/
73-
public function getChildren()
73+
public function getChildren(): array
7474
{
7575
return $this->children;
7676
}
@@ -90,7 +90,7 @@ public function setXmlRemappings(array $remappings)
9090
*
9191
* @return array an array of the form [[string, string]]
9292
*/
93-
public function getXmlRemappings()
93+
public function getXmlRemappings(): array
9494
{
9595
return $this->xmlRemappings;
9696
}
@@ -151,15 +151,15 @@ public function setName(string $name)
151151
/**
152152
* {@inheritdoc}
153153
*/
154-
public function hasDefaultValue()
154+
public function hasDefaultValue(): bool
155155
{
156156
return $this->addIfNotSet;
157157
}
158158

159159
/**
160160
* {@inheritdoc}
161161
*/
162-
public function getDefaultValue()
162+
public function getDefaultValue(): mixed
163163
{
164164
if (!$this->hasDefaultValue()) {
165165
throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath()));
@@ -200,7 +200,7 @@ public function addChild(NodeInterface $node)
200200
* @throws UnsetKeyException
201201
* @throws InvalidConfigurationException if the node doesn't have enough children
202202
*/
203-
protected function finalizeValue(mixed $value)
203+
protected function finalizeValue(mixed $value): mixed
204204
{
205205
if (false === $value) {
206206
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
@@ -264,7 +264,7 @@ protected function validateType(mixed $value)
264264
*
265265
* @throws InvalidConfigurationException
266266
*/
267-
protected function normalizeValue(mixed $value)
267+
protected function normalizeValue(mixed $value): mixed
268268
{
269269
if (false === $value) {
270270
return $value;
@@ -325,7 +325,7 @@ protected function normalizeValue(mixed $value)
325325
*
326326
* @return array The remapped values
327327
*/
328-
protected function remapXml(array $value)
328+
protected function remapXml(array $value): array
329329
{
330330
foreach ($this->xmlRemappings as [$singular, $plural]) {
331331
if (!isset($value[$singular])) {
@@ -345,7 +345,7 @@ protected function remapXml(array $value)
345345
* @throws InvalidConfigurationException
346346
* @throws \RuntimeException
347347
*/
348-
protected function mergeValues(mixed $leftSide, mixed $rightSide)
348+
protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed
349349
{
350350
if (false === $rightSide) {
351351
// if this is still false after the last config has been merged the

Definition/BaseNode.php

+14-27
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,17 @@ public function setAttribute(string $key, mixed $value)
102102
$this->attributes[$key] = $value;
103103
}
104104

105-
/**
106-
* @return mixed
107-
*/
108-
public function getAttribute(string $key, mixed $default = null)
105+
public function getAttribute(string $key, mixed $default = null): mixed
109106
{
110107
return $this->attributes[$key] ?? $default;
111108
}
112109

113-
/**
114-
* @return bool
115-
*/
116-
public function hasAttribute(string $key)
110+
public function hasAttribute(string $key): bool
117111
{
118112
return isset($this->attributes[$key]);
119113
}
120114

121-
/**
122-
* @return array
123-
*/
124-
public function getAttributes()
115+
public function getAttributes(): array
125116
{
126117
return $this->attributes;
127118
}
@@ -149,7 +140,7 @@ public function setInfo(string $info)
149140
*
150141
* @return string|null The info text
151142
*/
152-
public function getInfo()
143+
public function getInfo(): ?string
153144
{
154145
return $this->getAttribute('info');
155146
}
@@ -167,7 +158,7 @@ public function setExample(string|array $example)
167158
*
168159
* @return string|array|null The example
169160
*/
170-
public function getExample()
161+
public function getExample(): string|array|null
171162
{
172163
return $this->getAttribute('example');
173164
}
@@ -238,17 +229,15 @@ public function setFinalValidationClosures(array $closures)
238229
/**
239230
* {@inheritdoc}
240231
*/
241-
public function isRequired()
232+
public function isRequired(): bool
242233
{
243234
return $this->required;
244235
}
245236

246237
/**
247238
* Checks if this node is deprecated.
248-
*
249-
* @return bool
250239
*/
251-
public function isDeprecated()
240+
public function isDeprecated(): bool
252241
{
253242
return (bool) $this->deprecation;
254243
}
@@ -269,15 +258,15 @@ public function getDeprecation(string $node, string $path): array
269258
/**
270259
* {@inheritdoc}
271260
*/
272-
public function getName()
261+
public function getName(): string
273262
{
274263
return $this->name;
275264
}
276265

277266
/**
278267
* {@inheritdoc}
279268
*/
280-
public function getPath()
269+
public function getPath(): string
281270
{
282271
if (null !== $this->parent) {
283272
return $this->parent->getPath().$this->pathSeparator.$this->name;
@@ -372,17 +361,15 @@ final public function normalize(mixed $value): mixed
372361
*
373362
* @return mixed The normalized array value
374363
*/
375-
protected function preNormalize(mixed $value)
364+
protected function preNormalize(mixed $value): mixed
376365
{
377366
return $value;
378367
}
379368

380369
/**
381370
* Returns parent node for this node.
382-
*
383-
* @return NodeInterface|null
384371
*/
385-
public function getParent()
372+
public function getParent(): ?NodeInterface
386373
{
387374
return $this->parent;
388375
}
@@ -440,21 +427,21 @@ abstract protected function validateType(mixed $value);
440427
*
441428
* @return mixed The normalized value
442429
*/
443-
abstract protected function normalizeValue(mixed $value);
430+
abstract protected function normalizeValue(mixed $value): mixed;
444431

445432
/**
446433
* Merges two values together.
447434
*
448435
* @return mixed The merged value
449436
*/
450-
abstract protected function mergeValues(mixed $leftSide, mixed $rightSide);
437+
abstract protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed;
451438

452439
/**
453440
* Finalizes a value.
454441
*
455442
* @return mixed The finalized value
456443
*/
457-
abstract protected function finalizeValue(mixed $value);
444+
abstract protected function finalizeValue(mixed $value): mixed;
458445

459446
/**
460447
* Tests if placeholder values are allowed for this node.

Definition/BooleanNode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function validateType(mixed $value)
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
protected function isValueEmpty(mixed $value)
42+
protected function isValueEmpty(mixed $value): bool
4343
{
4444
// a boolean value cannot be empty
4545
return false;

0 commit comments

Comments
 (0)