Merge branch '3.4' into 4.2

* 3.4:
  fixed CS
  [HttpKernel] Remove TestEventDispatcher.
This commit is contained in:
Fabien Potencier 2019-06-13 12:50:42 +02:00
commit 0f958aabfa
25 changed files with 33 additions and 69 deletions

View File

@ -15,7 +15,7 @@ return PhpCsFixer\Config::create()
'ordered_imports' => true,
'protected_to_private' => false,
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
])

View File

@ -58,7 +58,7 @@ class DoctrineTestHelper
$config = new Configuration();
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
$config->setAutoGenerateProxyClasses(true);
$config->setProxyDir(\sys_get_temp_dir());
$config->setProxyDir(sys_get_temp_dir());
$config->setProxyNamespace('SymfonyTests\Doctrine');
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader()));
$config->setQueryCacheImpl(new ArrayCache());

View File

@ -186,7 +186,7 @@ class UniqueEntityValidator extends ConstraintValidator
return $this->formatValue($value, self::PRETTY_DATE);
}
if (\method_exists($value, '__toString')) {
if (method_exists($value, '__toString')) {
return (string) $value;
}

View File

@ -85,7 +85,7 @@ class UndefinedCallableHandler
private static function onUndefined($name, $type, $component)
{
if (\class_exists(FullStack::class) && isset(self::$fullStackEnable[$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));
}

View File

@ -681,7 +681,7 @@ class PdoSessionHandler extends AbstractSessionHandler
switch ($this->driver) {
case 'mysql':
// MySQL 5.7.5 and later enforces a maximum length on lock names of 64 characters. Previously, no limit was enforced.
$lockId = \substr($sessionId, 0, 64);
$lockId = substr($sessionId, 0, 64);
// should we handle the return value? 0 on timeout, null on error
// we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout
$stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)');

View File

@ -47,7 +47,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
'token' => $response->headers->get('X-Debug-Token'),
'start_time' => $startTime * 1000,
'events' => [],
'stopwatch_installed' => \class_exists(Stopwatch::class, false),
'stopwatch_installed' => class_exists(Stopwatch::class, false),
];
}

View File

@ -132,12 +132,12 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
$maxAge = null;
$sMaxage = null;
if (\is_numeric($this->ageDirectives['max-age'])) {
if (is_numeric($this->ageDirectives['max-age'])) {
$maxAge = $this->ageDirectives['max-age'] + $this->age;
$response->headers->addCacheControlDirective('max-age', $maxAge);
}
if (\is_numeric($this->ageDirectives['s-maxage'])) {
if (is_numeric($this->ageDirectives['s-maxage'])) {
$sMaxage = $this->ageDirectives['s-maxage'] + $this->age;
if ($maxAge !== $sMaxage) {
@ -145,7 +145,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
}
}
if (\is_numeric($this->ageDirectives['expires'])) {
if (is_numeric($this->ageDirectives['expires'])) {
$date = clone $response->getDate();
$date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds');
$response->setExpires($date);

View File

@ -52,6 +52,6 @@ class TimeDataCollectorTest extends TestCase
$c->collect($request, new Response());
$this->assertEquals(123456000, $c->getStartTime());
$this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled());
$this->assertSame(class_exists(Stopwatch::class, false), $c->isStopwatchInstalled());
}
}

View File

@ -1,36 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\Fixtures;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
class TestEventDispatcher extends TraceableEventDispatcher
{
public function getCalledListeners()
{
return ['foo'];
}
public function getNotCalledListeners()
{
return ['bar'];
}
public function reset()
{
}
public function getOrphanedEvents()
{
return [];
}
}

View File

@ -138,7 +138,7 @@ abstract class AbstractToken implements TokenInterface
{
$serialized = [$this->user, $this->authenticated, $this->roles, $this->attributes];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -61,7 +61,7 @@ class AnonymousToken extends AbstractToken
{
$serialized = [$this->secret, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -81,7 +81,7 @@ class PreAuthenticatedToken extends AbstractToken
{
$serialized = [$this->credentials, $this->providerKey, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -96,7 +96,7 @@ class RememberMeToken extends AbstractToken
{
$serialized = [$this->secret, $this->providerKey, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -93,7 +93,7 @@ class UsernamePasswordToken extends AbstractToken
{
$serialized = [$this->credentials, $this->providerKey, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -47,7 +47,7 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE
return true;
}
if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) {
if (class_exists('ParagonIE_Sodium_Compat') && method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) {
return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available();
}
@ -87,8 +87,8 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE
return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded);
}
if (\function_exists('sodium_crypto_pwhash_str_verify')) {
$valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw);
\sodium_memzero($raw);
$valid = !$this->isPasswordTooLong($raw) && sodium_crypto_pwhash_str_verify($encoded, $raw);
sodium_memzero($raw);
return $valid;
}
@ -109,12 +109,12 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE
private function encodePasswordSodiumFunction($raw)
{
$hash = \sodium_crypto_pwhash_str(
$hash = sodium_crypto_pwhash_str(
$raw,
\SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
\SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
\sodium_memzero($raw);
sodium_memzero($raw);
return $hash;
}

View File

@ -46,7 +46,7 @@ abstract class AccountStatusException extends AuthenticationException
{
$serialized = [$this->user, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -51,7 +51,7 @@ class AuthenticationException extends RuntimeException implements \Serializable
$this->line,
];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -62,7 +62,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException
{
$serialized = [parent::serialize(true), $this->messageKey, $this->messageData];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -56,7 +56,7 @@ class UsernameNotFoundException extends AuthenticationException
{
$serialized = [$this->username, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -50,7 +50,7 @@ class ConcreteToken extends AbstractToken
{
$serialized = [$this->credentials, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
public function unserialize($serialized)

View File

@ -78,7 +78,7 @@ class PostAuthenticationGuardToken extends AbstractToken implements GuardTokenIn
{
$serialized = [$this->providerKey, parent::serialize(true)];
return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null);
return $this->doSerialize($serialized, \func_num_args() ? func_get_arg(0) : null);
}
/**

View File

@ -97,7 +97,7 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) {
if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username)));
}

View File

@ -85,7 +85,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) {
if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username)));
}

View File

@ -507,7 +507,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
{
if (\func_num_args() >= 3) {
$format = \func_get_arg(2);
$format = func_get_arg(2);
} else {
// will be deprecated in version 4
$format = null;

View File

@ -73,7 +73,7 @@ foreach ($config['original_files'] as $originalFilePath) {
$translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths);
$totalMissingTranslations += array_sum(array_map(function ($translation) {
return \count($translation['missingKeys']);
return count($translation['missingKeys']);
}, array_values($translationStatus)));
printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output']);
@ -113,8 +113,8 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths)
$missingKeys = array_diff_key($allTranslationKeys, $translatedKeys);
$translationStatus[$locale] = [
'total' => \count($allTranslationKeys),
'translated' => \count($translatedKeys),
'total' => count($allTranslationKeys),
'translated' => count($translatedKeys),
'missingKeys' => $missingKeys,
];
}
@ -176,7 +176,7 @@ function printTable($translations, $verboseOutput)
textColorNormal();
if (true === $verboseOutput && \count($translation['missingKeys']) > 0) {
if (true === $verboseOutput && count($translation['missingKeys']) > 0) {
echo str_repeat('-', 80).PHP_EOL;
echo '| Missing Translations:'.PHP_EOL;