Skip to content

Commit 2a5bc2f

Browse files
committed
Add missing return types
1 parent e96cb01 commit 2a5bc2f

11 files changed

+40
-7
lines changed

Argument/ReferenceSetArgumentTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function getValues(): array
4444

4545
/**
4646
* @param Reference[] $values The service references to put in the set
47+
*
48+
* @return void
4749
*/
4850
public function setValues(array $values)
4951
{

Container.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALI
217217
*
218218
* As a separate method to allow "get()" to use the really fast `??` operator.
219219
*/
220-
private static function make(self $container, string $id, int $invalidBehavior)
220+
private static function make(self $container, string $id, int $invalidBehavior): ?object
221221
{
222222
if (isset($container->loading[$id])) {
223223
throw new ServiceCircularReferenceException($id, array_merge(array_keys($container->loading), [$id]));
@@ -338,6 +338,8 @@ public static function underscore(string $id): string
338338

339339
/**
340340
* Creates a service by requiring its factory file.
341+
*
342+
* @return mixed
341343
*/
342344
protected function load(string $file)
343345
{

Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ public function isCompiled(): bool
13251325
if ($this->asFiles && !$this->inlineFactories) {
13261326
$code .= <<<'EOF'
13271327
1328-
protected function load($file, $lazyLoad = true)
1328+
protected function load($file, $lazyLoad = true): mixed
13291329
{
13301330
if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) {
13311331
return $class::do($this, $lazyLoad);

Extension/Extension.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
2828
{
2929
private array $processedConfigs = [];
3030

31+
/**
32+
* @return string|false
33+
*/
3134
public function getXsdValidationBasePath()
3235
{
3336
return false;
3437
}
3538

39+
/**
40+
* @return string
41+
*/
3642
public function getNamespace()
3743
{
3844
return 'http://example.org/schema/dic/'.$this->getAlias();
@@ -67,6 +73,9 @@ public function getAlias(): string
6773
return Container::underscore($classBaseName);
6874
}
6975

76+
/**
77+
* @return ConfigurationInterface|null
78+
*/
7079
public function getConfiguration(array $config, ContainerBuilder $container)
7180
{
7281
$class = static::class;

Loader/YamlFileLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private function isUsingShortSyntax(array $service): bool
332332
/**
333333
* @throws InvalidArgumentException When tags are invalid
334334
*/
335-
private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = false, bool $trackBindings = true)
335+
private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = false, bool $trackBindings = true): Definition|Alias|null
336336
{
337337
if (preg_match('/^_[a-zA-Z0-9_]*$/', $id)) {
338338
throw new InvalidArgumentException(sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id));
@@ -706,6 +706,8 @@ private function parseDefinition(string $id, array|string|null $service, string
706706
} else {
707707
$this->setDefinition($id, $definition);
708708
}
709+
710+
return null;
709711
}
710712

711713
/**

ParameterBag/FrozenParameterBag.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,41 @@ public function __construct(
3434
$this->resolved = true;
3535
}
3636

37+
/**
38+
* @return never
39+
*/
3740
public function clear()
3841
{
3942
throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
4043
}
4144

45+
/**
46+
* @return never
47+
*/
4248
public function add(array $parameters)
4349
{
4450
throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
4551
}
4652

53+
/**
54+
* @return never
55+
*/
4756
public function set(string $name, array|bool|string|int|float|\UnitEnum|null $value)
4857
{
4958
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
5059
}
5160

61+
/**
62+
* @return never
63+
*/
5264
public function deprecate(string $name, string $package, string $version, string $message = 'The parameter "%s" is deprecated.')
5365
{
5466
throw new LogicException('Impossible to call deprecate() on a frozen ParameterBag.');
5567
}
5668

69+
/**
70+
* @return never
71+
*/
5772
public function remove(string $name)
5873
{
5974
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');

ParameterBag/ParameterBag.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ public function resolveString(string $value, array $resolving = []): mixed
255255
}, $value);
256256
}
257257

258+
/**
259+
* @return bool
260+
*/
258261
public function isResolved()
259262
{
260263
return $this->resolved;

Tests/Fixtures/php/services10_as_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ProjectServiceContainer extends Container
9393
return require $this->containerDir.\DIRECTORY_SEPARATOR.'removed-ids.php';
9494
}
9595

96-
protected function load($file, $lazyLoad = true)
96+
protected function load($file, $lazyLoad = true): mixed
9797
{
9898
if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) {
9999
return $class::do($this, $lazyLoad);

Tests/Fixtures/php/services9_as_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class ProjectServiceContainer extends Container
627627
return require $this->containerDir.\DIRECTORY_SEPARATOR.'removed-ids.php';
628628
}
629629

630-
protected function load($file, $lazyLoad = true)
630+
protected function load($file, $lazyLoad = true): mixed
631631
{
632632
if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) {
633633
return $class::do($this, $lazyLoad);

Tests/Fixtures/php/services_deprecated_parameters_as_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ProjectServiceContainer extends Container
7373
return true;
7474
}
7575

76-
protected function load($file, $lazyLoad = true)
76+
protected function load($file, $lazyLoad = true): mixed
7777
{
7878
if (class_exists($class = __NAMESPACE__.'\\'.$file, false)) {
7979
return $class::do($this, $lazyLoad);

0 commit comments

Comments
 (0)