Merge branch '3.4' into 4.0

* 3.4:
  PHP CS Fixer: clean up repo and adjust config
  use interface_exists instead of class_exists
  [DX] [DI] Improve exception for invalid setter injection arguments
  Dumper shouldn't use html format for phpdbg
  [Validator] Fix access to root object when using composite constraint
This commit is contained in:
Nicolas Grekas 2018-01-03 18:15:19 +01:00
commit dde7381c03
21 changed files with 61 additions and 25 deletions

View File

@ -36,5 +36,9 @@ return PhpCsFixer\Config::create()
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
// explicit heredoc test
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
// explicit trigger_error tests
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt')
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt')
->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
)
;

View File

@ -88,18 +88,35 @@ class TranslationExtensionTest extends TestCase
array('{% trans into "fr"%}Hello{% endtrans %}', 'Hello'),
// transchoice
array('{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is no apples', array('count' => 0)),
array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is 5 apples', array('count' => 5)),
array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony')),
array('{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony)', array('count' => 5)),
array('{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is no apples', array('count' => 0)),
array('{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is 5 apples'),
array(
'{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is no apples',
array('count' => 0),
),
array(
'{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is 5 apples',
array('count' => 5),
),
array(
'{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony)',
array('count' => 5, 'name' => 'Symfony'),
),
array(
'{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
'There is 5 apples (Symfony)',
array('count' => 5),
),
array(
'{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is no apples',
array('count' => 0),
),
array(
'{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
'There is 5 apples',
),
// trans filter
array('{{ "Hello"|trans }}', 'Hello'),

View File

@ -47,6 +47,8 @@ class Translator extends BaseTranslator implements WarmableInterface
private $resources = array();
/**
* Constructor.
*
* Available options:
*
* * cache_dir: The cache directory (or null to disable caching)

View File

@ -39,7 +39,7 @@ class ServerLogCommand extends Command
}
// based on a symfony/symfony package, it crashes due a missing FormatterInterface from monolog/monolog
if (!class_exists(FormatterInterface::class)) {
if (!interface_exists(FormatterInterface::class)) {
return false;
}

View File

@ -1,4 +1,4 @@
Copyright (c) 2016-present Fabien Potencier
Copyright (c) 2016-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -26,7 +26,6 @@ ErrorHandler::register()->setDefaultLogger(new TestLogger());
ini_set('display_errors', 1);
throw new \Exception('foo');
?>
--EXPECTF--
Uncaught Exception: foo

View File

@ -24,7 +24,9 @@ var_dump(array(
$eHandler[0]->setExceptionHandler('print_r');
if (true) {
class Broken implements \Serializable {};
class Broken implements \Serializable
{
}
}
?>

View File

@ -454,6 +454,9 @@ class YamlFileLoader extends FileLoader
$args = isset($call[1]) ? $this->resolveServices($call[1], $file) : array();
}
if (!is_array($args)) {
throw new InvalidArgumentException(sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in %s. Check your YAML syntax.', $method, $id, $file));
}
$definition->addMethodCall($method, $args);
}
}

View File

@ -1,4 +1,4 @@
Copyright (c) 2016-present Fabien Potencier
Copyright (c) 2016-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -34,6 +34,8 @@ class MemcachedSessionHandler extends AbstractSessionHandler
private $prefix;
/**
* Constructor.
*
* List of available options:
* * prefix: The prefix to use for the memcached keys in order to avoid collision
* * expiretime: The time to live in seconds.

View File

@ -34,6 +34,8 @@ class MongoDbSessionHandler extends AbstractSessionHandler
private $options;
/**
* Constructor.
*
* List of available options:
* * database: The name of the database [required]
* * collection: The name of the collection [required]

View File

@ -25,7 +25,7 @@ use Symfony\Component\HttpFoundation\Response;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @method Request|null getRequest() A Request instance
* @method Request|null getRequest() A Request instance
* @method Response|null getResponse() A Response instance
*/
class Client extends BaseClient

View File

@ -1,4 +1,4 @@
Copyright (c) 2012-present Fabien Potencier
Copyright (c) 2012-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
Copyright (c) 2016-present Fabien Potencier
Copyright (c) 2016-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-present Fabien Potencier
Copyright (c) 2015-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -34,6 +34,8 @@ class Route implements \Serializable
private $compiled;
/**
* Constructor.
*
* Available options:
*
* * compiler_class: A class name able to compile this route instance (RouteCompiler by default)

View File

@ -1,4 +1,4 @@
Copyright (c) 2004-present Fabien Potencier
Copyright (c) 2004-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Tests\Validator;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Expression;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
@ -581,6 +582,7 @@ abstract class AbstractTest extends AbstractValidatorTest
$called = false;
$entity = new Entity();
$entity->firstName = 'Bernhard';
$entity->data = array('firstName' => 'Bernhard');
$callback = function ($value, ExecutionContextInterface $context) use ($entity, &$called) {
$called = true;
@ -589,6 +591,7 @@ abstract class AbstractTest extends AbstractValidatorTest
$this->metadata->addConstraint(new Callback($callback));
$this->metadata->addPropertyConstraint('firstName', new Callback($callback));
$this->metadata->addPropertyConstraint('data', new Collection(array('firstName' => new Expression('value == this.firstName'))));
$this->validator->validate($entity);

View File

@ -108,7 +108,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
$this->validateGenericNode(
$value,
null,
$previousObject,
is_object($value) ? spl_object_hash($value) : null,
$metadata,
$this->defaultPropertyPath,

View File

@ -29,7 +29,7 @@ class VarDumper
{
if (null === self::$handler) {
$cloner = new VarCloner();
$dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
$dumper = in_array(PHP_SAPI, array('cli', 'phpdbg')) ? new CliDumper() : new HtmlDumper();
self::$handler = function ($var) use ($cloner, $dumper) {
$dumper->dump($cloner->cloneVar($var));
};

View File

@ -1,4 +1,4 @@
Copyright (c) 2014-present Fabien Potencier
Copyright (c) 2014-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal