declare type for arguments of anonymous functions for v2.7

This commit is contained in:
DQNEO 2018-04-06 02:53:39 +09:00 committed by Fabien Potencier
parent 3d40bfa1c4
commit 74ab256bec
9 changed files with 13 additions and 9 deletions

View File

@ -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);

View File

@ -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());
}

View File

@ -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());

View File

@ -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,

View File

@ -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,

View File

@ -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()));

View File

@ -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);
}

View File

@ -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,
);

View File

@ -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)) {