From 74ab256bec07c954a74bac0007d49cb37292724e Mon Sep 17 00:00:00 2001 From: DQNEO Date: Fri, 6 Apr 2018 02:53:39 +0900 Subject: [PATCH] declare type for arguments of anonymous functions for v2.7 --- .../Tests/DependencyInjection/DoctrineExtensionTest.php | 2 +- src/Symfony/Bridge/Twig/Command/DebugCommand.php | 2 +- .../Bundle/FrameworkBundle/Controller/ControllerNameParser.php | 3 ++- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 3 ++- .../Component/DependencyInjection/Loader/YamlFileLoader.php | 3 ++- .../Component/HttpKernel/Profiler/FileProfilerStorage.php | 2 +- .../Intl/Tests/DateFormatter/IntlDateFormatterTest.php | 2 +- .../Security/Core/Authorization/Voter/ExpressionVoter.php | 3 ++- .../Validator/Mapping/Factory/LazyLoadingMetadataFactory.php | 2 +- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 5de9e50e7c..7325a4e211 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -204,7 +204,7 @@ class DoctrineExtensionTest extends TestCase $definition = $container->getDefinition('doctrine.orm.default_metadata_cache'); $defCalls = $definition->getMethodCalls(); $expectedCalls[] = 'setNamespace'; - $actualCalls = array_map(function ($call) { + $actualCalls = array_map(function (array $call) { return $call[0]; }, $defCalls); diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index d6d8f1cdc8..5720096c46 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -199,7 +199,7 @@ EOF } // format args - $args = array_map(function ($param) { + $args = array_map(function (\ReflectionParameter $param) { if ($param->isDefaultValueAvailable()) { return $param->getName().' = '.json_encode($param->getDefaultValue()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php index c65b860a1b..c2ede8175c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\KernelInterface; /** @@ -117,7 +118,7 @@ class ControllerNameParser */ private function findAlternative(string $nonExistentBundleName): ?string { - $bundleNames = array_map(function ($b) { + $bundleNames = array_map(function (BundleInterface $b) { return $b->getName(); }, $this->kernel->getBundles()); diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 7c89984cef..bbfb234a79 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\ExpressionLanguage\Expression; /** @@ -667,7 +668,7 @@ EOF // can it be handled by an extension? if (!$this->container->hasExtension($node->namespaceURI)) { - $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); + $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); throw new InvalidArgumentException(sprintf( 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $node->tagName, diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 81584f57ef..055e31bc65 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser as YamlParser; use Symfony\Component\Yaml\Tag\TaggedValue; @@ -652,7 +653,7 @@ class YamlFileLoader extends FileLoader } if (!$this->container->hasExtension($namespace)) { - $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions())); + $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); throw new InvalidArgumentException(sprintf( 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $namespace, diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index d78411d3f6..d7179e1264 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -144,7 +144,7 @@ class FileProfilerStorage implements ProfilerStorageInterface // when there are errors in sub-requests, the parent and/or children tokens // may equal the profile token, resulting in infinite loops $parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null; - $childrenToken = array_filter(array_map(function ($p) use ($profileToken) { + $childrenToken = array_filter(array_map(function (Profile $p) use ($profileToken) { return $profileToken !== $p->getToken() ? $p->getToken() : null; }, $profile->getChildren())); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 88af2e775b..15c4e9e2ff 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -219,7 +219,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest */ private function notImplemented(array $dataSets) { - return array_map(function ($row) { + return array_map(function (array $row) { return array($row[0], $row[1], 0); }, $dataSets); } diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php index cbee938667..a735a52673 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Security\Core\Authorization\Voter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; use Symfony\Component\Security\Core\Authorization\ExpressionLanguage; +use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; use Symfony\Component\ExpressionLanguage\Expression; @@ -85,7 +86,7 @@ class ExpressionVoter implements VoterInterface 'user' => $token->getUser(), 'object' => $subject, 'subject' => $subject, - 'roles' => array_map(function ($role) { return $role->getRole(); }, $roles), + 'roles' => array_map(function (Role $role) { return $role->getRole(); }, $roles), 'trust_resolver' => $this->trustResolver, ); diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index a18d94d216..770fa5c579 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -124,7 +124,7 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface $interfaces = $metadata->getReflectionClass()->getInterfaces(); - $interfaces = array_filter($interfaces, function ($interface) use ($parent, $interfaces) { + $interfaces = array_filter($interfaces, function (\ReflectionClass $interface) use ($parent, $interfaces) { $interfaceName = $interface->getName(); if ($parent && $parent->implementsInterface($interfaceName)) {