Skip to content

Commit e47a3e6

Browse files
Add return types - batch 6/n
1 parent d94a275 commit e47a3e6

File tree

58 files changed

+182
-314
lines changed

Some content is hidden

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

58 files changed

+182
-314
lines changed

Bundle/Bundle.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function build(ContainerBuilder $container)
6262
*
6363
* @throws \LogicException
6464
*/
65-
public function getContainerExtension()
65+
public function getContainerExtension(): ?ExtensionInterface
6666
{
6767
if (null === $this->extension) {
6868
$extension = $this->createContainerExtension();
@@ -92,7 +92,7 @@ public function getContainerExtension()
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function getNamespace()
95+
public function getNamespace(): string
9696
{
9797
if (null === $this->namespace) {
9898
$this->parseClassName();
@@ -104,7 +104,7 @@ public function getNamespace()
104104
/**
105105
* {@inheritdoc}
106106
*/
107-
public function getPath()
107+
public function getPath(): string
108108
{
109109
if (null === $this->path) {
110110
$reflected = new \ReflectionObject($this);
@@ -132,10 +132,8 @@ public function registerCommands(Application $application)
132132

133133
/**
134134
* Returns the bundle's container extension class.
135-
*
136-
* @return string
137135
*/
138-
protected function getContainerExtensionClass()
136+
protected function getContainerExtensionClass(): string
139137
{
140138
$basename = preg_replace('/Bundle$/', '', $this->getName());
141139

@@ -144,10 +142,8 @@ protected function getContainerExtensionClass()
144142

145143
/**
146144
* Creates the bundle's container extension.
147-
*
148-
* @return ExtensionInterface|null
149145
*/
150-
protected function createContainerExtension()
146+
protected function createContainerExtension(): ?ExtensionInterface
151147
{
152148
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
153149
}

Bundle/BundleInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ public function build(ContainerBuilder $container);
4444
*
4545
* @return ExtensionInterface|null The default extension or null if there is none
4646
*/
47-
public function getContainerExtension();
47+
public function getContainerExtension(): ?ExtensionInterface;
4848

4949
/**
5050
* Returns the bundle name (the class short name).
5151
*
5252
* @return string The Bundle name
5353
*/
54-
public function getName();
54+
public function getName(): string;
5555

5656
/**
5757
* Gets the Bundle namespace.
5858
*
5959
* @return string The Bundle namespace
6060
*/
61-
public function getNamespace();
61+
public function getNamespace(): string;
6262

6363
/**
6464
* Gets the Bundle directory path.
@@ -67,5 +67,5 @@ public function getNamespace();
6767
*
6868
* @return string The Bundle absolute path
6969
*/
70-
public function getPath();
70+
public function getPath(): string;
7171
}

Config/FileLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(KernelInterface $kernel)
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function locate(string $file, string $currentPath = null, bool $first = true)
36+
public function locate(string $file, string $currentPath = null, bool $first = true): string|array
3737
{
3838
if (isset($file[0]) && '@' === $file[0]) {
3939
$resource = $this->kernel->locateResource($file);

Controller/ArgumentResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ interface ArgumentResolverInterface
2828
*
2929
* @throws \RuntimeException When no value could be provided for a required argument
3030
*/
31-
public function getArguments(Request $request, callable $controller);
31+
public function getArguments(Request $request, callable $controller): array;
3232
}

Controller/ArgumentValueResolverInterface.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ interface ArgumentValueResolverInterface
2323
{
2424
/**
2525
* Whether this resolver can resolve the value for the given ArgumentMetadata.
26-
*
27-
* @return bool
2826
*/
29-
public function supports(Request $request, ArgumentMetadata $argument);
27+
public function supports(Request $request, ArgumentMetadata $argument): bool;
3028

3129
/**
3230
* Returns the possible value(s).
33-
*
34-
* @return iterable
3531
*/
36-
public function resolve(Request $request, ArgumentMetadata $argument);
32+
public function resolve(Request $request, ArgumentMetadata $argument): iterable;
3733
}

Controller/ContainerControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(ContainerInterface $container, LoggerInterface $logg
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
protected function instantiateController(string $class)
38+
protected function instantiateController(string $class): object
3939
{
4040
$class = ltrim($class, '\\');
4141

Controller/ControllerResolver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(LoggerInterface $logger = null)
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function getController(Request $request)
36+
public function getController(Request $request): callable|false
3737
{
3838
if (!$controller = $request->attributes->get('_controller')) {
3939
if (null !== $this->logger) {
@@ -95,7 +95,7 @@ public function getController(Request $request)
9595
*
9696
* @throws \InvalidArgumentException When the controller cannot be created
9797
*/
98-
protected function createController(string $controller)
98+
protected function createController(string $controller): callable
9999
{
100100
if (!str_contains($controller, '::')) {
101101
$controller = $this->instantiateController($controller);
@@ -132,10 +132,8 @@ protected function createController(string $controller)
132132

133133
/**
134134
* Returns an instantiated controller.
135-
*
136-
* @return object
137135
*/
138-
protected function instantiateController(string $class)
136+
protected function instantiateController(string $class): object
139137
{
140138
return new $class();
141139
}

Controller/ControllerResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ interface ControllerResolverInterface
3737
*
3838
* @throws \LogicException If a controller was found based on the request but it is not callable
3939
*/
40-
public function getController(Request $request);
40+
public function getController(Request $request): callable|false;
4141
}

Controller/TraceableArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(ArgumentResolverInterface $resolver, Stopwatch $stop
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getArguments(Request $request, callable $controller)
34+
public function getArguments(Request $request, callable $controller): array
3535
{
3636
$e = $this->stopwatch->start('controller.get_arguments');
3737

Controller/TraceableControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(ControllerResolverInterface $resolver, Stopwatch $st
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getController(Request $request)
34+
public function getController(Request $request): callable|false
3535
{
3636
$e = $this->stopwatch->start('controller.get_callable');
3737

0 commit comments

Comments
 (0)