Skip to content

Commit ba09ebf

Browse files
minor #33770 Add types to constructors and private/final/internal methods (Batch III) (derrabus)
This PR was squashed before being merged into the 4.4 branch (closes #33770). Discussion ---------- Add types to constructors and private/final/internal methods (Batch III) | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #32179, #33228 | License | MIT | Doc PR | N/A Followup to #33709, this time with: * Validator * VarDumper * Workflow * Yaml * all bridges * all bundles That should be the final batch. 😃 Commits ------- 6493902287 Add types to constructors and private/final/internal methods (Batch III)
2 parents 57aa8b4 + 4426ee3 commit ba09ebf

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

Command/AssetsInstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private function hardCopy(string $originDir, string $targetDir): string
262262
return self::METHOD_COPY;
263263
}
264264

265-
private function getPublicDirectory(ContainerInterface $container)
265+
private function getPublicDirectory(ContainerInterface $container): string
266266
{
267267
$defaultPublicDir = 'public';
268268

Command/ContainerDebugCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ protected function getContainerBuilder(): ContainerBuilder
238238
return $this->containerBuilder = $container;
239239
}
240240

241-
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden)
241+
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden): string
242242
{
243243
$name = ltrim($name, '\\');
244244

@@ -258,7 +258,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io,
258258
return $io->choice('Select one of the following services to display its information', $matchingServices);
259259
}
260260

261-
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden)
261+
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden): array
262262
{
263263
$serviceIds = $builder->getServiceIds();
264264
$foundServiceIds = $foundServiceIdsIgnoringBackslashes = [];
@@ -280,7 +280,7 @@ private function findServiceIdsContaining(ContainerBuilder $builder, string $nam
280280
/**
281281
* @internal
282282
*/
283-
public function filterToServiceTypes($serviceId)
283+
public function filterToServiceTypes(string $serviceId): bool
284284
{
285285
// filter out things that could not be valid class names
286286
if (!preg_match('/(?(DEFINE)(?<V>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))^(?&V)(?:\\\\(?&V))*+(?: \$(?&V))?$/', $serviceId)) {

Controller/AbstractController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
4747
* @internal
4848
* @required
4949
*/
50-
public function setContainer(ContainerInterface $container)
50+
public function setContainer(ContainerInterface $container): ?ContainerInterface
5151
{
5252
$previous = $this->container;
5353
$this->container = $container;

Templating/Helper/RequestHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
1515

16+
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\RequestStack;
1718
use Symfony\Component\Templating\Helper\Helper;
1819

@@ -57,7 +58,7 @@ public function getLocale()
5758
return $this->getRequest()->getLocale();
5859
}
5960

60-
private function getRequest()
61+
private function getRequest(): Request
6162
{
6263
if (!$this->requestStack->getCurrentRequest()) {
6364
throw new \LogicException('A Request must be available.');

Templating/Helper/SessionHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
1515

1616
use Symfony\Component\HttpFoundation\RequestStack;
17+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1718
use Symfony\Component\Templating\Helper\Helper;
1819

1920
/**
@@ -61,7 +62,7 @@ public function hasFlash($name)
6162
return $this->getSession()->getFlashBag()->has($name);
6263
}
6364

64-
private function getSession()
65+
private function getSession(): SessionInterface
6566
{
6667
if (null === $this->session) {
6768
if (!$this->requestStack->getMasterRequest()) {

Tests/Controller/AbstractControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function __call(string $method, array $arguments)
9393
return $this->$method(...$arguments);
9494
}
9595

96-
public function setContainer(ContainerInterface $container)
96+
public function setContainer(ContainerInterface $container): ?ContainerInterface
9797
{
9898
if (!$this->throwOnUnexpectedService) {
9999
return parent::setContainer($container);

0 commit comments

Comments
 (0)