diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 42d68de902dd..27bbd984cb38 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -71,7 +71,7 @@ protected function log($message, array $params) $this->logger->debug($message, $params); } - private function normalizeParams(array $params) + private function normalizeParams(array $params): array { foreach ($params as $index => $param) { // normalize recursively diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 9a3ff10b823a..0f396a395832 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -12,6 +12,9 @@ namespace Symfony\Bridge\Doctrine\Security\User; use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Common\Persistence\ObjectRepository; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; @@ -124,17 +127,17 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword) } } - private function getObjectManager() + private function getObjectManager(): ObjectManager { return $this->registry->getManager($this->managerName); } - private function getRepository() + private function getRepository(): ObjectRepository { return $this->getObjectManager()->getRepository($this->classOrAlias); } - private function getClass() + private function getClass(): string { if (null === $this->class) { $class = $this->classOrAlias; @@ -149,7 +152,7 @@ private function getClass() return $this->class; } - private function getClassMetadata() + private function getClassMetadata(): ClassMetadata { return $this->getObjectManager()->getClassMetadata($this->classOrAlias); } diff --git a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php index 5f161358cf9c..0a44dcbf85da 100644 --- a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php +++ b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php @@ -40,7 +40,7 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName); } - public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository) + public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository) { $repositoryHash = $this->getRepositoryHash($entityManager, $entityName); @@ -56,7 +56,7 @@ private function createRepository(EntityManagerInterface $entityManager, string return new $repositoryClassName($entityManager, $metadata); } - private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName) + private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName): string { return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index c0b4a56e5070..5988aafefc74 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -11,9 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Security\User; +use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\ORM\Tools\SchemaTool; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; +use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\User; use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; @@ -59,9 +61,7 @@ public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty { $user = new User(1, 1, 'user1'); - $repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface') - ->disableOriginalConstructor() - ->getMock(); + $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); $repository ->expects($this->once()) ->method('loadUserByUsername') @@ -147,7 +147,7 @@ public function testSupportProxy() public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() { - $repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock(); + $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); $repository->expects($this->once()) ->method('loadUserByUsername') ->with('name') @@ -166,7 +166,7 @@ public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided( public function testLoadUserByUserNameShouldDeclineInvalidInterface() { $this->expectException('InvalidArgumentException'); - $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $repository = $this->createMock(ObjectRepository::class); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), @@ -180,7 +180,7 @@ public function testPasswordUpgrades() { $user = new User(1, 1, 'user1'); - $repository = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock(); + $repository = $this->createMock([ObjectRepository::class, PasswordUpgraderInterface::class]); $repository->expects($this->once()) ->method('upgradePassword') ->with($user, 'foobar'); diff --git a/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php b/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php index 101c61f07882..8285254e1299 100644 --- a/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php +++ b/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php @@ -133,7 +133,7 @@ public function format(array $record) /** * @internal */ - public function echoLine($line, $depth, $indentPad) + public function echoLine(string $line, int $depth, string $indentPad) { if (-1 !== $depth) { fwrite($this->outputBuffer, $line); @@ -143,7 +143,7 @@ public function echoLine($line, $depth, $indentPad) /** * @internal */ - public function castObject($v, array $a, Stub $s, $isNested) + public function castObject($v, array $a, Stub $s, bool $isNested): array { if ($this->options['multiline']) { return $a; @@ -157,7 +157,7 @@ public function castObject($v, array $a, Stub $s, $isNested) return $a; } - private function replacePlaceHolder(array $record) + private function replacePlaceHolder(array $record): array { $message = $record['message']; diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index c11fe901ea9a..28582d31725a 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -103,7 +103,7 @@ private function createSocket() return $socket; } - private function formatRecord(array $record) + private function formatRecord(array $record): string { if ($this->processors) { foreach ($this->processors as $processor) { diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index b3a2c44df313..edefbd8bcb45 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -364,7 +364,7 @@ private function getMetadata(string $type, $entity) return null; } - private function getPrettyMetadata(string $type, $entity, bool $decorated) + private function getPrettyMetadata(string $type, $entity, bool $decorated): ?string { if ('tests' === $type) { return ''; diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index f25574c1e2dc..f3e718c0a4a9 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -119,7 +119,7 @@ private function getStdin(): string return $template; } - private function getFilesInfo(array $filenames) + private function getFilesInfo(array $filenames): array { $filesInfo = []; foreach ($filenames as $filename) { diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index b5dadfe06822..d91e1c167600 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -236,7 +236,7 @@ public function formatFileFromText($text) /** * @internal */ - public function formatLogMessage($message, array $context) + public function formatLogMessage(string $message, array $context): string { if ($context && false !== strpos($message, '{')) { $replacements = []; diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 842042aac7ac..174a5cc3fe4b 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -111,7 +111,7 @@ public function getName() * * @see ChoiceView::isSelected() */ -function twig_is_selected_choice(ChoiceView $choice, $selectedValue) +function twig_is_selected_choice(ChoiceView $choice, $selectedValue): bool { if (\is_array($selectedValue)) { return \in_array($choice->value, $selectedValue, true); @@ -123,7 +123,7 @@ function twig_is_selected_choice(ChoiceView $choice, $selectedValue) /** * @internal */ -function twig_is_root_form(FormView $formView) +function twig_is_root_form(FormView $formView): bool { return null === $formView->parent; } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index a75b7b2cc46c..72badea2d2bd 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -132,7 +132,7 @@ private function isNamedArguments(Node $arguments): bool return false; } - private function getVarName() + private function getVarName(): string { return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); } diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php index be5f97eeca5a..fa3049d3dd7c 100644 --- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php +++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php @@ -65,7 +65,7 @@ class UndefinedCallableHandler 'workflow' => 'enable "framework.workflows"', ]; - public static function onUndefinedFilter($name) + public static function onUndefinedFilter(string $name): bool { if (!isset(self::$filterComponents[$name])) { return false; @@ -76,7 +76,7 @@ public static function onUndefinedFilter($name) return true; } - public static function onUndefinedFunction($name) + public static function onUndefinedFunction(string $name): bool { if (!isset(self::$functionComponents[$name])) { return false; @@ -87,7 +87,7 @@ public static function onUndefinedFunction($name) return true; } - private static function onUndefined($name, $type, $component) + private static function onUndefined(string $name, string $type, string $component) { if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) { throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index d38e89f0e9bd..396dcbaf659c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -262,7 +262,7 @@ private function hardCopy(string $originDir, string $targetDir): string return self::METHOD_COPY; } - private function getPublicDirectory(ContainerInterface $container) + private function getPublicDirectory(ContainerInterface $container): string { $defaultPublicDir = 'public'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index ef3a70d33ef1..4b55579d689d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -238,7 +238,7 @@ protected function getContainerBuilder(): ContainerBuilder return $this->containerBuilder = $container; } - private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden) + private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden): string { $name = ltrim($name, '\\'); @@ -258,7 +258,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io, return $io->choice('Select one of the following services to display its information', $matchingServices); } - private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden) + private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden): array { $serviceIds = $builder->getServiceIds(); $foundServiceIds = $foundServiceIdsIgnoringBackslashes = []; @@ -280,7 +280,7 @@ private function findServiceIdsContaining(ContainerBuilder $builder, string $nam /** * @internal */ - public function filterToServiceTypes($serviceId) + public function filterToServiceTypes(string $serviceId): bool { // filter out things that could not be valid class names if (!preg_match('/(?(DEFINE)(?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))^(?&V)(?:\\\\(?&V))*+(?: \$(?&V))?$/', $serviceId)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php index ac7ab231e01a..bc4c75585d7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php @@ -47,7 +47,7 @@ abstract class AbstractController implements ServiceSubscriberInterface * @internal * @required */ - public function setContainer(ContainerInterface $container) + public function setContainer(ContainerInterface $container): ?ContainerInterface { $previous = $this->container; $this->container = $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php index 351ed712c4a5..fbc054909700 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php @@ -13,6 +13,7 @@ @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); +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Templating\Helper\Helper; @@ -57,7 +58,7 @@ public function getLocale() return $this->getRequest()->getLocale(); } - private function getRequest() + private function getRequest(): Request { if (!$this->requestStack->getCurrentRequest()) { throw new \LogicException('A Request must be available.'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php index 86c0fcda1b93..296387b5c46c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php @@ -14,6 +14,7 @@ @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); use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Templating\Helper\Helper; /** @@ -61,7 +62,7 @@ public function hasFlash($name) return $this->getSession()->getFlashBag()->has($name); } - private function getSession() + private function getSession(): SessionInterface { if (null === $this->session) { if (!$this->requestStack->getMasterRequest()) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 68db3bb99f48..27eed3fbface 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -93,7 +93,7 @@ public function __call(string $method, array $arguments) return $this->$method(...$arguments); } - public function setContainer(ContainerInterface $container) + public function setContainer(ContainerInterface $container): ?ContainerInterface { if (!$this->throwOnUnexpectedService) { return parent::setContainer($container); diff --git a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php index c80e3c4bb11d..fa651fd588b3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php @@ -182,12 +182,12 @@ private function createPasswordQuestion(): Question })->setHidden(true)->setMaxAttempts(20); } - private function generateSalt() + private function generateSalt(): string { return base64_encode(random_bytes(30)); } - private function getUserClass(InputInterface $input, SymfonyStyle $io) + private function getUserClass(InputInterface $input, SymfonyStyle $io): string { if (null !== $userClass = $input->getArgument('user-class')) { return $userClass; diff --git a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php index 81d7b8a68f2e..36b01fda12fb 100644 --- a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php +++ b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php @@ -60,7 +60,7 @@ public function __invoke(RequestEvent $event) /** * Proxies all method calls to the original listener. */ - public function __call($method, $arguments) + public function __call(string $method, array $arguments) { return $this->listener->{$method}(...$arguments); } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index 5e07c6303f5a..79ef873ec2ad 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -89,7 +89,7 @@ public function addConfiguration(NodeDefinition $node) } } - final public function addOption($name, $default = null) + final public function addOption(string $name, $default = null) { $this->options[$name] = $default; } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php index 9fe4ea847035..0946cfeaa49d 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php @@ -92,7 +92,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider, return [$providerId, $listenerId, $entryPointId]; } - private function determineEntryPoint(?string $defaultEntryPointId, array $config) + private function determineEntryPoint(?string $defaultEntryPointId, array $config): string { if ($defaultEntryPointId) { // explode if they've configured the entry_point, but there is already one diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 4eca9ecef4b1..a2aa67c95881 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -598,7 +598,7 @@ private function createEncoder(array $config) } // Parses user providers and returns an array of their ids - private function createUserProviders(array $config, ContainerBuilder $container) + private function createUserProviders(array $config, ContainerBuilder $container): array { $providerIds = []; foreach ($config['providers'] as $name => $provider) { @@ -610,7 +610,7 @@ private function createUserProviders(array $config, ContainerBuilder $container) } // Parses a tag and returns the id for the related user provider service - private function createUserDaoProvider(string $name, array $provider, ContainerBuilder $container) + private function createUserDaoProvider(string $name, array $provider, ContainerBuilder $container): string { $name = $this->getUserProviderId($name); @@ -649,12 +649,12 @@ private function createUserDaoProvider(string $name, array $provider, ContainerB throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name)); } - private function getUserProviderId(string $name) + private function getUserProviderId(string $name): string { return 'security.user.provider.concrete.'.strtolower($name); } - private function createExceptionListener(ContainerBuilder $container, array $config, string $id, ?string $defaultEntryPoint, bool $stateless) + private function createExceptionListener(ContainerBuilder $container, array $config, string $id, ?string $defaultEntryPoint, bool $stateless): string { $exceptionListenerId = 'security.exception_listener.'.$id; $listener = $container->setDefinition($exceptionListenerId, new ChildDefinition('security.exception_listener')); @@ -672,7 +672,7 @@ private function createExceptionListener(ContainerBuilder $container, array $con return $exceptionListenerId; } - private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless) + private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless): string { $userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider; @@ -692,7 +692,7 @@ private function createSwitchUserListener(ContainerBuilder $container, string $i return $switchUserListenerId; } - private function createExpression(ContainerBuilder $container, string $expression) + private function createExpression(ContainerBuilder $container, string $expression): Reference { if (isset($this->expressions[$id = '.security.expression.'.ContainerBuilder::hash($expression)])) { return $this->expressions[$id]; @@ -711,7 +711,7 @@ private function createExpression(ContainerBuilder $container, string $expressio return $this->expressions[$id] = new Reference($id); } - private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []) + private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference { if ($methods) { $methods = array_map('strtoupper', (array) $methods); diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index c0b175c3a2ed..386653eb22d9 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -42,7 +42,7 @@ protected function configure() ; } - protected function findFiles($filename) + protected function findFiles($filename): iterable { if (0 === strpos($filename, '@')) { $dir = $this->getApplication()->getKernel()->locateResource($filename); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 9aefb8dbb03f..9d2447aed42b 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -172,7 +172,7 @@ public function load(array $configs, ContainerBuilder $container) } } - private function getBundleTemplatePaths(ContainerBuilder $container, array $config) + private function getBundleTemplatePaths(ContainerBuilder $container, array $config): array { $bundleHierarchy = []; foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { @@ -199,7 +199,7 @@ private function getBundleTemplatePaths(ContainerBuilder $container, array $conf return $bundleHierarchy; } - private function normalizeBundleName(string $name) + private function normalizeBundleName(string $name): string { if ('Bundle' === substr($name, -6)) { $name = substr($name, 0, -6); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 6bda0e00acef..28b0e2aa57cf 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -397,7 +397,7 @@ private function denyAccessIfProfilerDisabled() $this->profiler->disable(); } - private function renderWithCspNonces(Request $request, string $template, array $variables, int $code = 200, array $headers = ['Content-Type' => 'text/html']) + private function renderWithCspNonces(Request $request, string $template, array $variables, int $code = 200, array $headers = ['Content-Type' => 'text/html']): Response { $response = new Response('', $code, $headers); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/NonceGenerator.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/NonceGenerator.php index 728043551f3e..19af8496908d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/NonceGenerator.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/NonceGenerator.php @@ -20,7 +20,7 @@ */ class NonceGenerator { - public function generate() + public function generate(): string { return bin2hex(random_bytes(16)); } diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php index ff9e32f589b8..40d257c335b2 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php @@ -127,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - private function getLogs($socket) + private function getLogs($socket): iterable { $sockets = [(int) $socket => $socket]; $write = []; @@ -150,7 +150,7 @@ private function getLogs($socket) } } - private function displayLog(InputInterface $input, OutputInterface $output, $clientId, array $record) + private function displayLog(InputInterface $input, OutputInterface $output, int $clientId, array $record) { if (isset($record['log_id'])) { $clientId = unpack('H*', $record['log_id'])[1]; diff --git a/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php b/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php index 596b32c5fb14..63a8197d5e4a 100644 --- a/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php +++ b/src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php @@ -44,7 +44,7 @@ public function load(array $configs, ContainerBuilder $container) } } - private function getPublicDirectory(ContainerBuilder $container) + private function getPublicDirectory(ContainerBuilder $container): string { $kernelProjectDir = $container->getParameter('kernel.project_dir'); $publicDir = 'public'; diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index d0161772404d..ec0bd0321973 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -174,7 +174,7 @@ private function createServerProcess(WebServerConfig $config): Process return $process; } - private function getDefaultPidFile() + private function getDefaultPidFile(): string { return ($this->pidFileDirectory ?? getcwd()).'/.web-server-pid'; } diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 6c538fddc930..dc268ebcb9e7 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -91,7 +91,7 @@ public function validate($value, Constraint $constraint) } } - private function getPropertyAccessor() + private function getPropertyAccessor(): PropertyAccessorInterface { if (null === $this->propertyAccessor) { $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index 3d061554d5a7..f9f954b1cbc7 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -65,7 +65,7 @@ public function validate($value, Constraint $constraint) } } - private function getExpressionLanguage() + private function getExpressionLanguage(): ExpressionLanguage { if (null === $this->expressionLanguage) { if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index eb06c732ec99..243cf316ab4b 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -208,7 +208,7 @@ private static function moreDecimalsThan(string $double, int $numberOfDecimals): * Convert the limit to the smallest possible number * (i.e. try "MB", then "kB", then "bytes"). */ - private function factorizeSizes(int $size, int $limit, bool $binaryFormat) + private function factorizeSizes(int $size, int $limit, bool $binaryFormat): array { if ($binaryFormat) { $coef = self::MIB_BYTES; diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index e927f013aa05..95fed46a7772 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -225,7 +225,7 @@ public function validate($value, Constraint $constraint) } } - private static function toBigInt($string) + private static function toBigInt(string $string): string { $chars = str_split($string); $bigInt = ''; @@ -245,7 +245,7 @@ private static function toBigInt($string) return $bigInt; } - private static function bigModulo97($bigInt) + private static function bigModulo97(string $bigInt): int { $parts = str_split($bigInt, 7); $rest = 0; diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 10eff4475b33..d9461fe53a6c 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -15,6 +15,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Mapping\ClassMetadataInterface; use Symfony\Component\Validator\Mapping\MemberMetadata; use Symfony\Component\Validator\Mapping\MetadataInterface; @@ -22,6 +23,7 @@ use Symfony\Component\Validator\Util\PropertyPath; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Violation\ConstraintViolationBuilder; +use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -200,7 +202,7 @@ public function addViolation($message, array $parameters = []) /** * {@inheritdoc} */ - public function buildViolation($message, array $parameters = []) + public function buildViolation($message, array $parameters = []): ConstraintViolationBuilderInterface { return new ConstraintViolationBuilder( $this->violations, @@ -218,7 +220,7 @@ public function buildViolation($message, array $parameters = []) /** * {@inheritdoc} */ - public function getViolations() + public function getViolations(): ConstraintViolationListInterface { return $this->violations; } @@ -226,7 +228,7 @@ public function getViolations() /** * {@inheritdoc} */ - public function getValidator() + public function getValidator(): ValidatorInterface { return $this->validator; } @@ -258,7 +260,7 @@ public function getObject() /** * {@inheritdoc} */ - public function getMetadata() + public function getMetadata(): ?MetadataInterface { return $this->metadata; } @@ -266,12 +268,12 @@ public function getMetadata() /** * {@inheritdoc} */ - public function getGroup() + public function getGroup(): ?string { return $this->group; } - public function getConstraint() + public function getConstraint(): ?Constraint { return $this->constraint; } @@ -279,7 +281,7 @@ public function getConstraint() /** * {@inheritdoc} */ - public function getClassName() + public function getClassName(): ?string { return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null; } @@ -287,7 +289,7 @@ public function getClassName() /** * {@inheritdoc} */ - public function getPropertyName() + public function getPropertyName(): ?string { return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : null; } @@ -295,7 +297,7 @@ public function getPropertyName() /** * {@inheritdoc} */ - public function getPropertyPath($subPath = '') + public function getPropertyPath($subPath = ''): string { return PropertyPath::append($this->propertyPath, $subPath); } @@ -315,7 +317,7 @@ public function markGroupAsValidated($cacheKey, $groupHash) /** * {@inheritdoc} */ - public function isGroupValidated($cacheKey, $groupHash) + public function isGroupValidated($cacheKey, $groupHash): bool { return isset($this->validatedObjects[$cacheKey][$groupHash]); } @@ -331,7 +333,7 @@ public function markConstraintAsValidated($cacheKey, $constraintHash) /** * {@inheritdoc} */ - public function isConstraintValidated($cacheKey, $constraintHash) + public function isConstraintValidated($cacheKey, $constraintHash): bool { return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]); } @@ -347,7 +349,7 @@ public function markObjectAsInitialized($cacheKey) /** * {@inheritdoc} */ - public function isObjectInitialized($cacheKey) + public function isObjectInitialized($cacheKey): bool { return isset($this->initializedObjects[$cacheKey]); } diff --git a/src/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php b/src/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php index bfce37c49d0d..f448b0a6803b 100644 --- a/src/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php +++ b/src/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php @@ -40,7 +40,7 @@ public function setCache(Cache $cache) /** * {@inheritdoc} */ - public function has($class) + public function has($class): bool { return $this->cache->contains($class); } diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index ac9ace919dc0..1863641c91e5 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -236,7 +236,7 @@ class ConstraintViolationAssertion private $constraint; private $cause; - public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = []) + public function __construct(ExecutionContextInterface $context, string $message, Constraint $constraint = null, array $assertions = []) { $this->context = $context; $this->message = $message; @@ -244,14 +244,14 @@ public function __construct(ExecutionContextInterface $context, $message, Constr $this->assertions = $assertions; } - public function atPath($path) + public function atPath(string $path) { $this->propertyPath = $path; return $this; } - public function setParameter($key, $value) + public function setParameter(string $key, $value) { $this->parameters[$key] = $value; @@ -279,14 +279,14 @@ public function setInvalidValue($invalidValue) return $this; } - public function setPlural($number) + public function setPlural(int $number) { $this->plural = $number; return $this; } - public function setCode($code) + public function setCode(string $code) { $this->code = $code; @@ -300,7 +300,7 @@ public function setCause($cause) return $this; } - public function buildNextViolation($message) + public function buildNextViolation(string $message): self { $assertions = $this->assertions; $assertions[] = $this; @@ -328,7 +328,7 @@ public function assertRaised() } } - private function getViolation() + private function getViolation(): ConstraintViolation { return new ConstraintViolation( $this->message, diff --git a/src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php b/src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php index d9deeaa5fd58..908b85400533 100644 --- a/src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php +++ b/src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php @@ -57,7 +57,7 @@ public function setLocale($locale) /** * {@inheritdoc} */ - public function getLocale() + public function getLocale(): string { return $this->translator->getLocale(); } @@ -65,7 +65,7 @@ public function getLocale() /** * {@inheritdoc} */ - public function trans($id, array $parameters = [], $domain = null, $locale = null) + public function trans($id, array $parameters = [], $domain = null, $locale = null): string { return $this->translator->trans($id, $parameters, $domain, $locale); } @@ -73,7 +73,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul /** * {@inheritdoc} */ - public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) + public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null): string { return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale); } diff --git a/src/Symfony/Component/Validator/Validation.php b/src/Symfony/Component/Validator/Validation.php index 71edfedb1839..dbf1dbc0ed7d 100644 --- a/src/Symfony/Component/Validator/Validation.php +++ b/src/Symfony/Component/Validator/Validation.php @@ -25,8 +25,6 @@ final class Validation * * If you want to configure the validator, use * {@link createValidatorBuilder()} instead. - * - * @return ValidatorInterface The new validator */ public static function createValidator(): ValidatorInterface { @@ -35,8 +33,6 @@ public static function createValidator(): ValidatorInterface /** * Creates a configurable builder for validator objects. - * - * @return ValidatorBuilderInterface The new builder */ public static function createValidatorBuilder(): ValidatorBuilder { diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 2dc71b66b2da..fd228045fcd3 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -41,12 +41,11 @@ class Caster * Casts objects to arrays and adds the dynamic property prefix. * * @param object $obj The object to cast - * @param string $class The class of the object * @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not * * @return array The array-cast of the object, with prefixed dynamic properties */ - public static function castObject($obj, $class, $hasDebugInfo = false): array + public static function castObject($obj, string $class, bool $hasDebugInfo = false): array { $a = $obj instanceof \Closure ? [] : (array) $obj; @@ -110,7 +109,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false): array * * @return array The filtered array */ - public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array + public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array { $count = 0; @@ -151,7 +150,7 @@ public static function filter(array $a, $filter, array $listedProperties = [], & return $a; } - public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested) + public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array { if (isset($a['__PHP_Incomplete_Class_Name'])) { $stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')'; diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index f2f518266250..26925170acdd 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -54,7 +54,7 @@ public static function castInterval(\DateInterval $interval, array $a, Stub $stu return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a; } - private static function formatInterval(\DateInterval $i) + private static function formatInterval(\DateInterval $i): string { $format = '%R '; diff --git a/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php b/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php index b0177fa4887d..942eecb11fb4 100644 --- a/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php @@ -35,7 +35,7 @@ public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNes return $a; } - private static function getNonDefaultOptions(\Memcached $c) + private static function getNonDefaultOptions(\Memcached $c): array { self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions(); self::$optionConstants = self::$optionConstants ?? self::getOptionConstants(); @@ -50,7 +50,7 @@ private static function getNonDefaultOptions(\Memcached $c) return $nonDefaultOptions; } - private static function discoverDefaultOptions() + private static function discoverDefaultOptions(): array { $defaultMemcached = new \Memcached(); $defaultMemcached->addServer('127.0.0.1', 11211); @@ -65,7 +65,7 @@ private static function discoverDefaultOptions() return $defaultOptions; } - private static function getOptionConstants() + private static function getOptionConstants(): array { $reflectedMemcached = new \ReflectionClass(\Memcached::class); diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index a3bbadd53827..7a6e89ad7782 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -363,7 +363,7 @@ public static function getSignature(array $a) return $signature; } - private static function addExtra(&$a, \Reflector $c) + private static function addExtra(array &$a, \Reflector $c) { $x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : []; @@ -379,7 +379,7 @@ private static function addExtra(&$a, \Reflector $c) } } - private static function addMap(&$a, \Reflector $c, $map, $prefix = Caster::PREFIX_VIRTUAL) + private static function addMap(array &$a, \Reflector $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL) { foreach ($map as $k => $m) { if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) { diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index 4901b3c110bc..b2d4e3c8a9a8 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -203,7 +203,7 @@ public static function castWeakReference(\WeakReference $c, array $a, Stub $stub return $a; } - private static function castSplArray($c, array $a, Stub $stub, $isNested) + private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array { $prefix = Caster::PREFIX_VIRTUAL; $class = $stub->class; diff --git a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php index afc65350eb2d..3d3d18eeb21e 100644 --- a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php +++ b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php @@ -76,7 +76,7 @@ protected function getDump($data, $key = null, $filter = 0) return rtrim($dumper->dump($data, true)); } - private function prepareExpectation($expected, int $filter) + private function prepareExpectation($expected, int $filter): string { if (!\is_string($expected)) { $expected = $this->getDump($expected, null, $filter); diff --git a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php index fbae74dd9182..e3f690b52338 100644 --- a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php @@ -61,7 +61,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt /** * @internal */ - protected function findPlaces(Definition $definition, Marking $marking = null) + protected function findPlaces(Definition $definition, Marking $marking = null): array { $workflowMetadata = $definition->getMetadataStore(); @@ -96,7 +96,7 @@ protected function findPlaces(Definition $definition, Marking $marking = null) /** * @internal */ - protected function findTransitions(Definition $definition) + protected function findTransitions(Definition $definition): array { $workflowMetadata = $definition->getMetadataStore(); @@ -124,7 +124,7 @@ protected function findTransitions(Definition $definition) /** * @internal */ - protected function addPlaces(array $places) + protected function addPlaces(array $places): string { $code = ''; @@ -145,7 +145,7 @@ protected function addPlaces(array $places) /** * @internal */ - protected function addTransitions(array $transitions) + protected function addTransitions(array $transitions): string { $code = ''; @@ -159,7 +159,7 @@ protected function addTransitions(array $transitions) /** * @internal */ - protected function findEdges(Definition $definition) + protected function findEdges(Definition $definition): array { $workflowMetadata = $definition->getMetadataStore(); @@ -192,7 +192,7 @@ protected function findEdges(Definition $definition) /** * @internal */ - protected function addEdges(array $edges) + protected function addEdges(array $edges): string { $code = ''; @@ -216,7 +216,7 @@ protected function addEdges(array $edges) /** * @internal */ - protected function startDot(array $options) + protected function startDot(array $options): string { return sprintf("digraph workflow {\n %s\n node [%s];\n edge [%s];\n\n", $this->addOptions($options['graph']), @@ -228,7 +228,7 @@ protected function startDot(array $options) /** * @internal */ - protected function endDot() + protected function endDot(): string { return "}\n"; } @@ -236,7 +236,7 @@ protected function endDot() /** * @internal */ - protected function dotize($id) + protected function dotize(string $id): string { return hash('sha1', $id); } diff --git a/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php index 56ec2697be99..4bd818d5363f 100644 --- a/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php @@ -44,7 +44,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt /** * @internal */ - protected function findEdges(Definition $definition) + protected function findEdges(Definition $definition): array { $workflowMetadata = $definition->getMetadataStore(); @@ -82,7 +82,7 @@ protected function findEdges(Definition $definition) /** * @internal */ - protected function addEdges(array $edges) + protected function addEdges(array $edges): string { $code = ''; diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 2d56bd9ee508..32cabdaae5b1 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -254,7 +254,7 @@ public function getMetadataStore(): MetadataStoreInterface return $this->definition->getMetadataStore(); } - private function buildTransitionBlockerListForTransition($subject, Marking $marking, Transition $transition) + private function buildTransitionBlockerListForTransition($subject, Marking $marking, Transition $transition): TransitionBlockerList { foreach ($transition->getFroms() as $place) { if (!$marking->has($place)) { diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 9fdef61af081..d15ffb38c8aa 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -137,7 +137,7 @@ private function validate(string $content, int $flags, string $file = null) return ['file' => $file, 'valid' => true]; } - private function display(SymfonyStyle $io, array $files) + private function display(SymfonyStyle $io, array $files): int { switch ($this->format) { case 'txt': @@ -149,7 +149,7 @@ private function display(SymfonyStyle $io, array $files) } } - private function displayTxt(SymfonyStyle $io, array $filesInfo) + private function displayTxt(SymfonyStyle $io, array $filesInfo): int { $countFiles = \count($filesInfo); $erroredFiles = 0; @@ -178,7 +178,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo) return min($erroredFiles, 1); } - private function displayJson(SymfonyStyle $io, array $filesInfo) + private function displayJson(SymfonyStyle $io, array $filesInfo): int { $errors = 0; @@ -198,7 +198,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo) return min($errors, 1); } - private function getFiles(string $fileOrDirectory) + private function getFiles(string $fileOrDirectory): iterable { if (is_file($fileOrDirectory)) { yield new \SplFileInfo($fileOrDirectory); @@ -225,7 +225,7 @@ private function getStdin(): string return $yaml; } - private function getParser() + private function getParser(): Parser { if (!$this->parser) { $this->parser = new Parser(); @@ -234,7 +234,7 @@ private function getParser() return $this->parser; } - private function getDirectoryIterator(string $directory) + private function getDirectoryIterator(string $directory): iterable { $default = function ($directory) { return new \RecursiveIteratorIterator( @@ -250,7 +250,7 @@ private function getDirectoryIterator(string $directory) return $default($directory); } - private function isReadable(string $fileOrDirectory) + private function isReadable(string $fileOrDirectory): bool { $default = function ($fileOrDirectory) { return is_readable($fileOrDirectory); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index c34e264b669a..b43ce64bdee5 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1134,7 +1134,7 @@ private function getLineTag(string $value, int $flags, bool $nextLineCheck = tru throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename); } - private function parseQuotedString($yaml) + private function parseQuotedString(string $yaml): ?string { if ('' === $yaml || ('"' !== $yaml[0] && "'" !== $yaml[0])) { throw new \InvalidArgumentException(sprintf('"%s" is not a quoted string.', $yaml)); @@ -1223,7 +1223,7 @@ private function lexInlineMapping(string $yaml): string return implode("\n", $lines); } - private function lexInlineSequence($yaml) + private function lexInlineSequence(string $yaml): string { if ('' === $yaml || '[' !== $yaml[0]) { throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));