Skip to content

Commit

Permalink
Merge branch '4.0' into 4.1
Browse files Browse the repository at this point in the history
* 4.0:
  Fix Clidumper tests
  Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
  Apply fixers
  Disable the native_constant_invocation fixer until it can be scoped
  Update the list of excluded files for the CS fixer
  • Loading branch information
nicolas-grekas committed Jul 26, 2018
2 parents fe8b415 + 2b1fa4d commit a221eb5
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Command/UserPasswordEncoderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$encodedPassword = $encoder->encodePassword($password, $salt);

$rows = array(
array('Encoder used', get_class($encoder)),
array('Encoder used', \get_class($encoder)),
array('Encoded password', $encodedPassword),
);
if (!$emptySalt) {
Expand All @@ -156,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->table(array('Key', 'Value'), $rows);

if (!$emptySalt) {
$errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt)));
$errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', \strlen($salt)));
} elseif ($saltlessWithoutEmptySalt) {
$errorIo->note('Self-salting encoder used: the encoder generated its own built-in salt.');
}
Expand Down Expand Up @@ -195,7 +195,7 @@ private function getUserClass(InputInterface $input, SymfonyStyle $io)
throw new RuntimeException('There are no configured encoders for the "security" extension.');
}

if (!$input->isInteractive() || 1 === count($this->userClasses)) {
if (!$input->isInteractive() || 1 === \count($this->userClasses)) {
return reset($this->userClasses);
}

Expand Down
6 changes: 3 additions & 3 deletions DataCollector/SecurityDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function collect(Request $request, Response $response, \Exception $except
if (null !== $this->roleHierarchy) {
$allRoles = $this->roleHierarchy->getReachableRoles($assignedRoles);
foreach ($allRoles as $role) {
if (!in_array($role, $assignedRoles, true)) {
if (!\in_array($role, $assignedRoles, true)) {
$inheritedRoles[] = $role;
}
}
Expand All @@ -125,7 +125,7 @@ public function collect(Request $request, Response $response, \Exception $except
'impersonator_user' => $impersonatorUser,
'impersonation_exit_path' => null,
'token' => $token,
'token_class' => $this->hasVarDumper ? new ClassStub(get_class($token)) : get_class($token),
'token_class' => $this->hasVarDumper ? new ClassStub(\get_class($token)) : \get_class($token),
'logout_url' => $logoutUrl,
'user' => $token->getUsername(),
'roles' => array_map(function (Role $role) { return $role->getRole(); }, $assignedRoles),
Expand All @@ -140,7 +140,7 @@ public function collect(Request $request, Response $response, \Exception $except
$this->data['voter_strategy'] = $this->accessDecisionManager->getStrategy();

foreach ($this->accessDecisionManager->getVoters() as $voter) {
$this->data['voters'][] = $this->hasVarDumper ? new ClassStub(get_class($voter)) : get_class($voter);
$this->data['voters'][] = $this->hasVarDumper ? new ClassStub(\get_class($voter)) : \get_class($voter);
}
} else {
$this->data['access_decision_log'] = array();
Expand Down
4 changes: 2 additions & 2 deletions Debug/WrappedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(GetResponseEvent $event)
*/
public function __call($method, $arguments)
{
return call_user_func_array(array($this->listener, $method), $arguments);
return \call_user_func_array(array($this->listener, $method), $arguments);
}

public function getWrappedListener(): ListenerInterface
Expand All @@ -64,7 +64,7 @@ public function getWrappedListener(): ListenerInterface
public function getInfo(): array
{
if (null === $this->stub) {
$this->stub = self::$hasVarDumper ? new ClassStub(get_class($this->listener)) : get_class($this->listener);
$this->stub = self::$hasVarDumper ? new ClassStub(\get_class($this->listener)) : \get_class($this->listener);
}

return array(
Expand Down
8 changes: 4 additions & 4 deletions DependencyInjection/MainConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function addRoleHierarchySection(ArrayNodeDefinition $rootNode)
->performNoDeepMerging()
->beforeNormalization()->ifString()->then(function ($v) { return array('value' => $v); })->end()
->beforeNormalization()
->ifTrue(function ($v) { return is_array($v) && isset($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()
Expand Down Expand Up @@ -218,7 +218,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
->children()
->arrayNode('delete_cookies')
->beforeNormalization()
->ifTrue(function ($v) { return is_array($v) && is_int(key($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')
Expand Down Expand Up @@ -346,11 +346,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 0 === count($v); })
->ifTrue(function ($v) { return 0 === \count($v); })
->thenInvalid('You must set a provider definition for the provider.')
->end()
;
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Security/Factory/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function addConfiguration(NodeDefinition $node)
;

foreach (array_merge($this->options, $this->defaultSuccessHandlerOptions, $this->defaultFailureHandlerOptions) as $name => $default) {
if (is_bool($default)) {
if (\is_bool($default)) {
$builder->booleanNode($name)->defaultValue($default);
} else {
$builder->scalarNode($name)->defaultValue($default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function determineEntryPoint($defaultEntryPointId, array $config)
}

$authenticatorIds = $config['authenticators'];
if (1 == count($authenticatorIds)) {
if (1 == \count($authenticatorIds)) {
// if there is only one authenticator, use that as the entry point
return array_shift($authenticatorIds);
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Security/Factory/RememberMeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
$userProviders[] = new Reference('security.user.provider.concrete.'.$providerName);
}
}
if (0 === count($userProviders)) {
if (0 === \count($userProviders)) {
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
}

Expand Down Expand Up @@ -139,7 +139,7 @@ public function addConfiguration(NodeDefinition $node)
;

foreach ($this->options as $name => $value) {
if (is_bool($value)) {
if (\is_bool($value)) {
$builder->booleanNode($name)->defaultValue($value);
} else {
$builder->scalarNode($name)->defaultValue($value);
Expand Down
12 changes: 6 additions & 6 deletions DependencyInjection/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function load(array $configs, ContainerBuilder $container)

private function createRoleHierarchy(array $config, ContainerBuilder $container)
{
if (!isset($config['role_hierarchy']) || 0 === count($config['role_hierarchy'])) {
if (!isset($config['role_hierarchy']) || 0 === \count($config['role_hierarchy'])) {
$container->removeDefinition('security.access.role_hierarchy_voter');

return;
Expand Down Expand Up @@ -158,7 +158,7 @@ private function createAuthorization($config, ContainerBuilder $container)
}

// allow cache warm-up for expressions
if (count($this->expressions)) {
if (\count($this->expressions)) {
$container->getDefinition('security.cache_warmer.expression')
->replaceArgument(0, new IteratorArgument(array_values($this->expressions)));
} else {
Expand Down Expand Up @@ -267,7 +267,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall['provider']));
}
$defaultProvider = $providerIds[$normalizedName];
} elseif (1 === count($providerIds)) {
} elseif (1 === \count($providerIds)) {
$defaultProvider = reset($providerIds);
}

Expand Down Expand Up @@ -330,7 +330,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
}

// add cookie logout handler
if (count($firewall['logout']['delete_cookies']) > 0) {
if (\count($firewall['logout']['delete_cookies']) > 0) {
$cookieHandlerId = 'security.logout.handler.cookie_clearing.'.$id;
$cookieHandler = $container->setDefinition($cookieHandlerId, new ChildDefinition('security.logout.handler.cookie_clearing'));
$cookieHandler->addArgument($firewall['logout']['delete_cookies']);
Expand Down Expand Up @@ -409,7 +409,7 @@ private function createContextListener($container, $contextKey)
return $this->contextListeners[$contextKey];
}

$listenerId = 'security.context_listener.'.count($this->contextListeners);
$listenerId = 'security.context_listener.'.\count($this->contextListeners);
$listener = $container->setDefinition($listenerId, new ChildDefinition('security.context_listener'));
$listener->replaceArgument(2, $contextKey);

Expand Down Expand Up @@ -682,7 +682,7 @@ private function createRequestMatcher($container, $path = null, $host = null, $m

// only add arguments that are necessary
$arguments = array($path, $host, $methods, $ip, $attributes);
while (count($arguments) > 0 && !end($arguments)) {
while (\count($arguments) > 0 && !end($arguments)) {
array_pop($arguments);
}

Expand Down
2 changes: 1 addition & 1 deletion Security/FirewallConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function isSecurityEnabled(): bool

public function allowsAnonymous(): bool
{
return in_array('anonymous', $this->listeners, true);
return \in_array('anonymous', $this->listeners, true);
}

public function isStateless(): bool
Expand Down
2 changes: 1 addition & 1 deletion Security/FirewallContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(iterable $listeners, ExceptionListener $exceptionLis
$this->logoutListener = $logoutListener;
$this->config = $config;
} else {
throw new \InvalidArgumentException(sprintf('Argument 3 passed to %s() must be instance of %s or null, %s given.', __METHOD__, LogoutListener::class, is_object($logoutListener) ? get_class($logoutListener) : gettype($logoutListener)));
throw new \InvalidArgumentException(sprintf('Argument 3 passed to %s() must be instance of %s or null, %s given.', __METHOD__, LogoutListener::class, \is_object($logoutListener) ? \get_class($logoutListener) : \gettype($logoutListener)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Debug/TraceableFirewallListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public function testOnKernelRequestRecordsListeners()
$this->assertCount(1, $listeners);
$this->assertSame($response, $listeners[0]['response']);
$this->assertInstanceOf(ClassStub::class, $listeners[0]['stub']);
$this->assertSame(get_class($listener), (string) $listeners[0]['stub']);
$this->assertSame(\get_class($listener), (string) $listeners[0]['stub']);
}
}
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/CompleteConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function testAccess()
$this->assertArrayNotHasKey($matcherId, $matcherIds);
$matcherIds[$matcherId] = true;

$i = count($matcherIds);
$i = \count($matcherIds);
if (1 === $i) {
$this->assertEquals(array('ROLE_USER'), $attributes);
$this->assertEquals('https', $channel);
Expand Down
2 changes: 0 additions & 2 deletions Tests/Functional/MissingUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Bundle\SecurityBundle\Tests\Functional;

use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

class MissingUserProviderTest extends WebTestCase
{
/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/UserPasswordEncoderCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function testThrowsExceptionOnNoConfiguredEncoders()

protected function setUp()
{
putenv('COLUMNS='.(119 + strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
$kernel = $this->createKernel(array('test_case' => 'PasswordEncode'));
$kernel->boot();

Expand All @@ -249,7 +249,7 @@ protected function tearDown()

private function setupArgon2i()
{
putenv('COLUMNS='.(119 + strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
$kernel = $this->createKernel(array('test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml'));
$kernel->boot();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ protected static function createKernel(array $options = array())

protected static function getVarDir()
{
return 'SB'.substr(strrchr(get_called_class(), '\\'), 1);
return 'SB'.substr(strrchr(\get_called_class(), '\\'), 1);
}
}
2 changes: 1 addition & 1 deletion Tests/SecurityUserValueResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testResolveNoUser()
$tokenStorage->setToken($token);

$resolver = new SecurityUserValueResolver($tokenStorage);
$metadata = new ArgumentMetadata('foo', get_class($mock), false, false, null);
$metadata = new ArgumentMetadata('foo', \get_class($mock), false, false, null);

$this->assertFalse($resolver->supports(Request::create('/'), $metadata));
}
Expand Down

0 comments on commit a221eb5

Please sign in to comment.