Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add return types to bundles #42500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('debug');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ public function load(array $configs, ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): string|false
{
return __DIR__.'/../Resources/config/schema';
}

/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
return 'http://symfony.com/schema/dic/debug';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $phpArrayFile)
/**
* {@inheritdoc}
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}
Expand All @@ -42,7 +42,7 @@ public function isOptional()
*
* @return string[] A list of classes to preload on PHP 7.4+
*/
public function warmUp(string $cacheDir)
public function warmUp(string $cacheDir): array
{
$arrayAdapter = new ArrayAdapter();

Expand All @@ -66,7 +66,7 @@ public function warmUp(string $cacheDir)
/**
* @return string[] A list of classes to preload on PHP 7.4+
*/
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
{
return (array) $phpArrayAdapter->warmUp($values);
}
Expand All @@ -85,5 +85,5 @@ final protected function ignoreAutoloadException(string $class, \Exception $exce
/**
* @return bool false if there is nothing to warm-up
*/
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter);
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(Reader $annotationReader, string $phpArrayFile, stri
/**
* {@inheritdoc}
*/
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
{
$annotatedClassPatterns = $cacheDir.'/annotations.map';

Expand Down Expand Up @@ -76,7 +76,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
/**
* @return string[] A list of classes to preload on PHP 7.4+
*/
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
{
// make sure we don't cache null values
$values = array_filter($values, function ($val) { return null !== $val; });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
*
* @return string[]
*/
public function warmUp(string $cacheDir)
public function warmUp(string $cacheDir): array
{
$generator = new ConfigBuilderGenerator($cacheDir);

Expand Down Expand Up @@ -84,7 +84,7 @@ private function dumpExtension(ExtensionInterface $extension, ConfigBuilderGener
/**
* {@inheritdoc}
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(array $loaders, string $phpArrayFile)
/**
* {@inheritdoc}
*/
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
{
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(ContainerInterface $container)
*
* @return string[]
*/
public function warmUp(string $cacheDir)
public function warmUp(string $cacheDir): array
{
if (null === $this->translator) {
$this->translator = $this->container->get('translator');
Expand All @@ -54,7 +54,7 @@ public function warmUp(string $cacheDir)
/**
* {@inheritdoc}
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(ValidatorBuilder $validatorBuilder, string $phpArray
/**
* {@inheritdoc}
*/
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
{
if (!method_exists($this->validatorBuilder, 'getLoaders')) {
return false;
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
/**
* @return string[] A list of classes to preload on PHP 7.4+
*/
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
{
// make sure we don't cache null values
$values = array_filter($values, function ($val) { return null !== $val; });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ protected function listBundles(OutputInterface|StyleInterface $output)
}
}

/**
* @return ExtensionInterface
*/
protected function findExtension(string $name)
protected function findExtension(string $name): ExtensionInterface
{
$bundles = $this->initializeBundles();
$minScore = \INF;
Expand Down
18 changes: 8 additions & 10 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ public function __construct(KernelInterface $kernel)

/**
* Gets the Kernel associated with this Console.
*
* @return KernelInterface
*/
public function getKernel()
public function getKernel(): KernelInterface
{
return $this->kernel;
}
Expand All @@ -69,7 +67,7 @@ public function reset()
*
* @return int 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->registerCommands();

Expand All @@ -85,7 +83,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
/**
* {@inheritdoc}
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
{
if (!$command instanceof ListCommand) {
if ($this->registrationErrors) {
Expand All @@ -109,7 +107,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
/**
* {@inheritdoc}
*/
public function find(string $name)
public function find(string $name): Command
{
$this->registerCommands();

Expand All @@ -119,7 +117,7 @@ public function find(string $name)
/**
* {@inheritdoc}
*/
public function get(string $name)
public function get(string $name): Command
{
$this->registerCommands();

Expand All @@ -135,7 +133,7 @@ public function get(string $name)
/**
* {@inheritdoc}
*/
public function all(string $namespace = null)
public function all(string $namespace = null): array
{
$this->registerCommands();

Expand All @@ -145,12 +143,12 @@ public function all(string $namespace = null)
/**
* {@inheritdoc}
*/
public function getLongVersion()
public function getLongVersion(): string
{
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
}

public function add(Command $command)
public function add(Command $command): ?Command
{
$this->registerCommands();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ protected function formatParameter(mixed $value): string
return (string) $value;
}

/**
* @return mixed
*/
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId)
protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId): mixed
{
if ($builder->hasDefinition($serviceId)) {
return $builder->getDefinition($serviceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
*
* @return array|bool|float|int|string|null
*/
protected function getParameter(string $name)
protected function getParameter(string $name): array|bool|float|int|string|null
{
if (!$this->container->has('parameter_bag')) {
throw new ServiceNotFoundException('parameter_bag.', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
Expand Down Expand Up @@ -399,7 +399,7 @@ protected function getDoctrine(): ManagerRegistry
*
* @see TokenInterface::getUser()
*/
protected function getUser()
protected function getUser(): ?object
{
if (!$this->container->has('security.token_storage')) {
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(bool $debug)
*
* @return TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('framework');
$rootNode = $treeBuilder->getRootNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
use Symfony\Component\Cache\ResettableInterface;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\DirectoryResource;
Expand Down Expand Up @@ -585,7 +586,7 @@ public function load(array $configs, ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
{
return new Configuration($container->getParameter('kernel.debug'));
}
Expand Down Expand Up @@ -2583,12 +2584,12 @@ private function resolveTrustedHeaders(array $headers): int
/**
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): string|false
{
return \dirname(__DIR__).'/Resources/config/schema';
}

public function getNamespace()
public function getNamespace(): string
{
return 'http://symfony.com/schema/dic/symfony';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(KernelInterface $kernel, string|StoreInterface $cach
/**
* {@inheritdoc}
*/
protected function forward(Request $request, bool $catch = false, Response $entry = null)
protected function forward(Request $request, bool $catch = false, Response $entry = null): Response
{
$this->getKernel()->boot();
$this->getKernel()->getContainer()->set('cache', $this);
Expand All @@ -78,7 +78,7 @@ protected function forward(Request $request, bool $catch = false, Response $entr
*
* @return array An array of options
*/
protected function getOptions()
protected function getOptions(): array
{
return [];
}
Expand Down
22 changes: 6 additions & 16 deletions src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ public function __construct(KernelInterface $kernel, array $server = [], History

/**
* Returns the container.
*
* @return ContainerInterface
*/
public function getContainer()
public function getContainer(): ContainerInterface
{
$container = $this->kernel->getContainer();

Expand All @@ -56,10 +54,8 @@ public function getContainer()

/**
* Returns the kernel.
*
* @return KernelInterface
*/
public function getKernel()
public function getKernel(): KernelInterface
{
return $this->kernel;
}
Expand All @@ -69,7 +65,7 @@ public function getKernel()
*
* @return HttpProfile|false|null
*/
public function getProfile()
public function getProfile(): HttpProfile|false|null
{
if (null === $this->response || !$this->getContainer()->has('profiler')) {
return false;
Expand Down Expand Up @@ -146,10 +142,8 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
* {@inheritdoc}
*
* @param Request $request
*
* @return Response
*/
protected function doRequest(object $request)
protected function doRequest(object $request): Response
{
// avoid shutting down the Kernel if no request has been performed yet
// WebTestCase::createClient() boots the Kernel but do not handle a request
Expand All @@ -173,10 +167,8 @@ protected function doRequest(object $request)
* {@inheritdoc}
*
* @param Request $request
*
* @return Response
*/
protected function doRequestInProcess(object $request)
protected function doRequestInProcess(object $request): Response
{
$response = parent::doRequestInProcess($request);

Expand All @@ -194,10 +186,8 @@ protected function doRequestInProcess(object $request)
* client and override this method.
*
* @param Request $request
*
* @return string
*/
protected function getScript(object $request)
protected function getScript(object $request): string
{
$kernel = var_export(serialize($this->kernel), true);
$request = var_export(serialize($request), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec

/**
* Makes the default route name more sane by removing common keywords.
*
* @return string
*/
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
{
$name = preg_replace('/(bundle|controller)_/', '_', parent::getDefaultRouteName($class, $method));

Expand Down
Loading