Skip to content

Commit

Permalink
fixed CS for lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 28, 2013
1 parent 93edf44 commit 35b407f
Show file tree
Hide file tree
Showing 44 changed files with 104 additions and 105 deletions.
Expand Up @@ -55,7 +55,7 @@ public function process(ContainerBuilder $container)

$this->container = $container;
$this->connections = $container->getParameter($this->connections);
$sortFunc = function($a, $b) {
$sortFunc = function ($a, $b) {
$a = isset($a['priority']) ? $a['priority'] : 0;
$b = isset($b['priority']) ? $b['priority'] : 0;

Expand Down
Expand Up @@ -295,7 +295,7 @@ public function testValidateUniquenessWithUnrewoundArray()
$repository->expects($this->once())
->method('findByCustom')
->will(
$this->returnCallback(function() use ($entity) {
$this->returnCallback(function () use ($entity) {
$returnValue = array(
$entity,
);
Expand Down
Expand Up @@ -207,12 +207,12 @@ protected function outputServices(OutputInterface $output, $serviceIds, $showPri
}
}
$format = '%-'.$maxName.'s ';
$format .= implode("", array_map(function($length) { return "%-{$length}s "; }, $maxTags));
$format .= implode("", array_map(function ($length) { return "%-{$length}s "; }, $maxTags));
$format .= '%-'.$maxScope.'s %s';

// the title field needs extra space to make up for comment tags
$format1 = '%-'.($maxName + 19).'s ';
$format1 .= implode("", array_map(function($length) { return '%-'.($length + 19).'s '; }, $maxTags));
$format1 .= implode("", array_map(function ($length) { return '%-'.($length + 19).'s '; }, $maxTags));
$format1 .= '%-'.($maxScope + 19).'s %s';

$tags = array();
Expand Down Expand Up @@ -288,7 +288,7 @@ protected function outputService(OutputInterface $output, $serviceId)
$output->writeln('<comment>Tags</comment>');
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $singleTagData) {
$output->writeln(sprintf(' - %-30s (%s)', $tagName, implode(', ', array_map(function($key, $value) {
$output->writeln(sprintf(' - %-30s (%s)', $tagName, implode(', ', array_map(function ($key, $value) {
return sprintf('<info>%s</info>: %s', $key, $value);
}, array_keys($singleTagData), array_values($singleTagData)))));
}
Expand Down
Expand Up @@ -41,12 +41,12 @@ public function getConfigTreeBuilder()
->end()
->arrayNode('trusted_proxies')
->beforeNormalization()
->ifTrue(function($v) { return !is_array($v) && !is_null($v); })
->then(function($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
->ifTrue(function ($v) { return !is_array($v) && !is_null($v); })
->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
->end()
->prototype('scalar')
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
if (empty($v)) {
return false;
}
Expand All @@ -70,8 +70,8 @@ public function getConfigTreeBuilder()
->scalarNode('default_locale')->defaultValue('en')->end()
->arrayNode('trusted_hosts')
->beforeNormalization()
->ifTrue(function($v) { return is_string($v); })
->then(function($v) { return array($v); })
->ifTrue(function ($v) { return is_string($v); })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
Expand Down Expand Up @@ -226,7 +226,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)

private function addTemplatingSection(ArrayNodeDefinition $rootNode)
{
$organizeUrls = function($urls) {
$organizeUrls = function ($urls) {
$urls += array(
'http' => array(),
'ssl' => array(),
Expand Down Expand Up @@ -263,8 +263,8 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
->validate()
->ifTrue(function($v) {return !in_array('FrameworkBundle:Form', $v); })
->then(function($v){
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
->then(function ($v) {
return array_merge(array('FrameworkBundle:Form'), $v);
})
->end()
Expand All @@ -278,8 +278,8 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->performNoDeepMerging()
->addDefaultsIfNotSet()
->beforeNormalization()
->ifTrue(function($v) { return !is_array($v); })
->then(function($v) { return array($v); })
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->beforeNormalization()
->always()
Expand All @@ -303,8 +303,8 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->isRequired()
->requiresAtLeastOneElement()
->beforeNormalization()
->ifTrue(function($v){ return !is_array($v); })
->then(function($v){ return array($v); })
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
Expand All @@ -313,8 +313,8 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('loaders')
->beforeNormalization()
->ifTrue(function($v){ return !is_array($v); })
->then(function($v){ return array($v); })
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
Expand All @@ -332,8 +332,8 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->performNoDeepMerging()
->addDefaultsIfNotSet()
->beforeNormalization()
->ifTrue(function($v) { return !is_array($v); })
->then(function($v) { return array($v); })
->ifTrue(function ($v) { return !is_array($v); })
->then(function ($v) { return array($v); })
->end()
->beforeNormalization()
->always()
Expand Down
Expand Up @@ -389,7 +389,7 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
// Apply request scope to assets helper if one or more packages are request-scoped
$requireRequestScope = array_reduce(
$namedPackages,
function($v, Reference $ref) use ($container) {
function ($v, Reference $ref) use ($container) {
return $v || 'request' === $container->getDefinition($ref)->getScope();
},
'request' === $defaultPackage->getScope()
Expand All @@ -400,7 +400,7 @@ function($v, Reference $ref) use ($container) {
}

if (!empty($config['loaders'])) {
$loaders = array_map(function($loader) { return new Reference($loader); }, $config['loaders']);
$loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);

// Use a delegation unless only a single loader was registered
if (1 === count($loaders)) {
Expand Down Expand Up @@ -437,7 +437,7 @@ function($v, Reference $ref) use ($container) {
}

$container->setParameter('templating.engines', $config['engines']);
$engines = array_map(function($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);

// Use a delegation unless only a single engine was registered
if (1 === count($engines)) {
Expand Down
Expand Up @@ -181,7 +181,7 @@ public function testTranslator()
}
}

$files = array_map(function($resource) { return realpath($resource[1]); }, $resources);
$files = array_map(function ($resource) { return realpath($resource[1]); }, $resources);
$ref = new \ReflectionClass('Symfony\Component\Validator\Validator');
$this->assertContains(
strtr(dirname($ref->getFileName()) . '/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
Expand Down
Expand Up @@ -57,7 +57,7 @@ public function collect(Request $request, Response $response, \Exception $except
'authenticated' => $token->isAuthenticated(),
'token_class' => get_class($token),
'user' => $token->getUsername(),
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
'roles' => array_map(function ($role) { return $role->getRole();}, $token->getRoles()),
);
}
}
Expand Down
Expand Up @@ -132,10 +132,10 @@ private function addRoleHierarchySection(ArrayNodeDefinition $rootNode)
->useAttributeAsKey('id')
->prototype('array')
->performNoDeepMerging()
->beforeNormalization()->ifString()->then(function($v) { return array('value' => $v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return array('value' => $v); })->end()
->beforeNormalization()
->ifTrue(function($v) { return is_array($v) && isset($v['value']); })
->then(function($v) { return preg_split('/\s*,\s*/', $v['value']); })
->ifTrue(function ($v) { return is_array($v) && isset($v['value']); })
->then(function ($v) { return preg_split('/\s*,\s*/', $v['value']); })
->end()
->prototype('scalar')->end()
->end()
Expand All @@ -162,18 +162,18 @@ private function addAccessControlSection(ArrayNodeDefinition $rootNode)
->end()
->scalarNode('host')->defaultNull()->end()
->arrayNode('ips')
->beforeNormalization()->ifString()->then(function($v) { return array($v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
->prototype('scalar')->end()
->end()
->arrayNode('methods')
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
->prototype('scalar')->end()
->end()
->end()
->fixXmlConfig('role')
->children()
->arrayNode('roles')
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
->prototype('scalar')->end()
->end()
->end()
Expand Down Expand Up @@ -223,8 +223,8 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
->children()
->arrayNode('delete_cookies')
->beforeNormalization()
->ifTrue(function($v) { return is_array($v) && is_int(key($v)); })
->then(function($v) { return array_map(function($v) { return array('name' => $v); }, $v); })
->ifTrue(function ($v) { return is_array($v) && is_int(key($v)); })
->then(function ($v) { return array_map(function ($v) { return array('name' => $v); }, $v); })
->end()
->useAttributeAsKey('name')
->prototype('array')
Expand Down Expand Up @@ -278,10 +278,10 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
$firewallNodeBuilder
->end()
->validate()
->ifTrue(function($v) {
->ifTrue(function ($v) {
return true === $v['security'] && isset($v['pattern']) && !isset($v['request_matcher']);
})
->then(function($firewall) use ($abstractFactoryKeys) {
->then(function ($firewall) use ($abstractFactoryKeys) {
foreach ($abstractFactoryKeys as $k) {
if (!isset($firewall[$k]['check_path'])) {
continue;
Expand Down Expand Up @@ -331,7 +331,7 @@ private function addProvidersSection(ArrayNodeDefinition $rootNode)
->arrayNode('providers')
->beforeNormalization()
->ifString()
->then(function($v) { return preg_split('/\s*,\s*/', $v); })
->then(function ($v) { return preg_split('/\s*,\s*/', $v); })
->end()
->prototype('scalar')->end()
->end()
Expand All @@ -349,11 +349,11 @@ private function addProvidersSection(ArrayNodeDefinition $rootNode)

$providerNodeBuilder
->validate()
->ifTrue(function($v){return count($v) > 1;})
->ifTrue(function ($v) {return count($v) > 1;})
->thenInvalid('You cannot set multiple provider types for the same provider')
->end()
->validate()
->ifTrue(function($v){return count($v) === 0;})
->ifTrue(function ($v) {return count($v) === 0;})
->thenInvalid('You must set a provider definition for the provider.')
->end()
;
Expand All @@ -378,7 +378,7 @@ private function addEncodersSection(ArrayNodeDefinition $rootNode)
->prototype('array')
->canBeUnset()
->performNoDeepMerging()
->beforeNormalization()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end()
->children()
->scalarNode('algorithm')->cannotBeEmpty()->end()
->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end()
Expand Down
Expand Up @@ -126,7 +126,7 @@ public function addConfiguration(NodeDefinition $node)
->scalarNode('token_provider')->end()
->arrayNode('user_providers')
->beforeNormalization()
->ifString()->then(function($v) { return array($v); })
->ifString()->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()
->end()
Expand Down
Expand Up @@ -57,7 +57,7 @@ public function addConfiguration(NodeDefinition $node)
->children()
->scalarNode('password')->defaultValue(uniqid())->end()
->arrayNode('roles')
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
->prototype('scalar')->end()
->end()
->end()
Expand Down
Expand Up @@ -229,7 +229,7 @@ private function createFirewalls($config, ContainerBuilder $container)
$mapDef->replaceArgument(1, $map);

// add authentication providers to authentication manager
$authenticationProviders = array_map(function($id) {
$authenticationProviders = array_map(function ($id) {
return new Reference($id);
}, array_values(array_unique($authenticationProviders)));
$container
Expand Down

0 comments on commit 35b407f

Please sign in to comment.