Merge branch '4.2'
* 4.2: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
This commit is contained in:
commit
508602d995
@ -59,6 +59,14 @@ class SwiftMailerHandler extends BaseSwiftMailerHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function reset()
|
||||||
|
{
|
||||||
|
$this->flushMemorySpool();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes the mail queue if a memory spool is used.
|
* Flushes the mail queue if a memory spool is used.
|
||||||
*/
|
*/
|
||||||
|
@ -72,7 +72,7 @@ class TransChoiceTokenParser extends TransTokenParser
|
|||||||
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
|
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
|
||||||
|
|
||||||
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
||||||
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
|
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream->expect(Token::BLOCK_END_TYPE);
|
$stream->expect(Token::BLOCK_END_TYPE);
|
||||||
|
@ -67,7 +67,7 @@ class TransTokenParser extends AbstractTokenParser
|
|||||||
$stream->next();
|
$stream->next();
|
||||||
$locale = $this->parser->getExpressionParser()->parseExpression();
|
$locale = $this->parser->getExpressionParser()->parseExpression();
|
||||||
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
|
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
|
||||||
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
|
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class TransTokenParser extends AbstractTokenParser
|
|||||||
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
|
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
|
||||||
|
|
||||||
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
||||||
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
|
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream->expect(Token::BLOCK_END_TYPE);
|
$stream->expect(Token::BLOCK_END_TYPE);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"symfony/contracts": "^1.0.2",
|
"symfony/contracts": "^1.0.2",
|
||||||
"twig/twig": "^1.36.1|^2.6.1"
|
"twig/twig": "^1.37.1|^2.6.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~3.4|~4.0",
|
"symfony/asset": "~3.4|~4.0",
|
||||||
|
@ -585,9 +585,7 @@ class FrameworkExtension extends Extension
|
|||||||
$metadataStoreDefinition->replaceArgument(2, $transitionsMetadataDefinition);
|
$metadataStoreDefinition->replaceArgument(2, $transitionsMetadataDefinition);
|
||||||
|
|
||||||
// Create places
|
// Create places
|
||||||
$places = array_map(function (array $place) {
|
$places = array_column($workflow['places'], 'name');
|
||||||
return $place['name'];
|
|
||||||
}, $workflow['places']);
|
|
||||||
|
|
||||||
// Create a Definition
|
// Create a Definition
|
||||||
$definitionDefinition = new Definition(Workflow\Definition::class);
|
$definitionDefinition = new Definition(Workflow\Definition::class);
|
||||||
|
@ -28,11 +28,14 @@
|
|||||||
"symfony/process": "~3.4|~4.0",
|
"symfony/process": "~3.4|~4.0",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
},
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/log-implementation": "1.0"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/event-dispatcher": "",
|
"symfony/event-dispatcher": "",
|
||||||
"symfony/lock": "",
|
"symfony/lock": "",
|
||||||
"symfony/process": "",
|
"symfony/process": "",
|
||||||
"psr/log-implementation": "For using the console logger"
|
"psr/log": "For using the console logger"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/dependency-injection": "<3.4",
|
"symfony/dependency-injection": "<3.4",
|
||||||
|
@ -12,8 +12,12 @@
|
|||||||
namespace Symfony\Component\CssSelector\Tests\XPath;
|
namespace Symfony\Component\CssSelector\Tests\XPath;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||||
|
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||||
|
use Symfony\Component\CssSelector\Parser\Parser;
|
||||||
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
|
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
|
||||||
use Symfony\Component\CssSelector\XPath\Translator;
|
use Symfony\Component\CssSelector\XPath\Translator;
|
||||||
|
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||||
|
|
||||||
class TranslatorTest extends TestCase
|
class TranslatorTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -31,6 +35,73 @@ class TranslatorTest extends TestCase
|
|||||||
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
|
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testCssToXPathPseudoElement()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$translator->cssToXPath('e::first-line');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testGetExtensionNotExistsExtension()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$translator->getExtension('fake');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testAddCombinationNotExistsExtension()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$parser = new Parser();
|
||||||
|
$xpath = $parser->parse('*')[0];
|
||||||
|
$combinedXpath = $parser->parse('*')[0];
|
||||||
|
$translator->addCombination('fake', $xpath, $combinedXpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testAddFunctionNotExistsFunction()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$function = new FunctionNode(new ElementNode(), 'fake');
|
||||||
|
$translator->addFunction($xpath, $function);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testAddPseudoClassNotExistsClass()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$translator->addPseudoClass($xpath, 'fake');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
|
||||||
|
*/
|
||||||
|
public function testAddAttributeMatchingClassNotExistsClass()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$translator->addAttributeMatching($xpath, '', '', '');
|
||||||
|
}
|
||||||
|
|
||||||
/** @dataProvider getXmlLangTestData */
|
/** @dataProvider getXmlLangTestData */
|
||||||
public function testXmlLang($css, array $elementsId)
|
public function testXmlLang($css, array $elementsId)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,14 @@ class DebugClassLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function findFile($class)
|
||||||
|
{
|
||||||
|
return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the given class or interface.
|
* Loads the given class or interface.
|
||||||
*
|
*
|
||||||
|
@ -34,8 +34,6 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
|||||||
*/
|
*/
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$this->usedBindings = $container->getRemovedBindingIds();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
parent::process($container);
|
parent::process($container);
|
||||||
|
|
||||||
|
@ -124,8 +124,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
private $removedIds = array();
|
private $removedIds = array();
|
||||||
|
|
||||||
private $removedBindingIds = array();
|
|
||||||
|
|
||||||
private static $internalTypes = array(
|
private static $internalTypes = array(
|
||||||
'int' => true,
|
'int' => true,
|
||||||
'float' => true,
|
'float' => true,
|
||||||
@ -502,8 +500,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
|
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeId($id);
|
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
|
||||||
unset($this->removedIds[$id]);
|
|
||||||
|
|
||||||
parent::set($id, $service);
|
parent::set($id, $service);
|
||||||
}
|
}
|
||||||
@ -516,7 +513,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
public function removeDefinition($id)
|
public function removeDefinition($id)
|
||||||
{
|
{
|
||||||
if (isset($this->definitions[$id = (string) $id])) {
|
if (isset($this->definitions[$id = (string) $id])) {
|
||||||
$this->removeId($id);
|
unset($this->definitions[$id]);
|
||||||
|
$this->removedIds[$id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,8 +836,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeId($alias);
|
unset($this->definitions[$alias], $this->removedIds[$alias]);
|
||||||
unset($this->removedIds[$alias]);
|
|
||||||
|
|
||||||
return $this->aliasDefinitions[$alias] = $id;
|
return $this->aliasDefinitions[$alias] = $id;
|
||||||
}
|
}
|
||||||
@ -852,7 +849,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
public function removeAlias($alias)
|
public function removeAlias($alias)
|
||||||
{
|
{
|
||||||
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
|
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
|
||||||
$this->removeId($alias);
|
unset($this->aliasDefinitions[$alias]);
|
||||||
|
$this->removedIds[$alias] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,8 +979,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
$id = (string) $id;
|
$id = (string) $id;
|
||||||
|
|
||||||
$this->removeId($id);
|
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
|
||||||
unset($this->removedIds[$id]);
|
|
||||||
|
|
||||||
return $this->definitions[$id] = $definition;
|
return $this->definitions[$id] = $definition;
|
||||||
}
|
}
|
||||||
@ -1511,18 +1508,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
return $services;
|
return $services;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets removed binding ids.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
public function getRemovedBindingIds()
|
|
||||||
{
|
|
||||||
return $this->removedBindingIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a reasonably unique hash of a value.
|
* Computes a reasonably unique hash of a value.
|
||||||
*
|
*
|
||||||
@ -1631,21 +1616,4 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeId($id)
|
|
||||||
{
|
|
||||||
$this->removedIds[$id] = true;
|
|
||||||
unset($this->aliasDefinitions[$id]);
|
|
||||||
|
|
||||||
if (!isset($this->definitions[$id])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->definitions[$id]->getBindings() as $binding) {
|
|
||||||
list(, $identifier) = $binding->getValues();
|
|
||||||
$this->removedBindingIds[$identifier] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($this->definitions[$id]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -112,24 +112,6 @@ class ResolveBindingsPassTest extends TestCase
|
|||||||
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
|
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOverriddenBindings()
|
|
||||||
{
|
|
||||||
$container = new ContainerBuilder();
|
|
||||||
|
|
||||||
$binding = new BoundArgument('bar');
|
|
||||||
|
|
||||||
$container->register('foo', 'stdClass')
|
|
||||||
->setBindings(array('$foo' => clone $binding));
|
|
||||||
$container->register('bar', 'stdClass')
|
|
||||||
->setBindings(array('$foo' => clone $binding));
|
|
||||||
|
|
||||||
$container->register('foo', 'stdClass');
|
|
||||||
|
|
||||||
(new ResolveBindingsPass())->process($container);
|
|
||||||
|
|
||||||
$this->assertInstanceOf('stdClass', $container->get('foo'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTupleBinding()
|
public function testTupleBinding()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -399,7 +399,7 @@ class ResolveChildDefinitionsPassTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
||||||
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
|
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
|
||||||
*/
|
*/
|
||||||
public function testProcessDetectsChildDefinitionIndirectCircularReference()
|
public function testProcessDetectsChildDefinitionIndirectCircularReference()
|
||||||
{
|
{
|
||||||
|
@ -559,7 +559,7 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$config->setDefinition('baz', new Definition('BazClass'));
|
$config->setDefinition('baz', new Definition('BazClass'));
|
||||||
$config->setAlias('alias_for_foo', 'foo');
|
$config->setAlias('alias_for_foo', 'foo');
|
||||||
$container->merge($config);
|
$container->merge($config);
|
||||||
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
|
||||||
|
|
||||||
$aliases = $container->getAliases();
|
$aliases = $container->getAliases();
|
||||||
$this->assertArrayHasKey('alias_for_foo', $aliases);
|
$this->assertArrayHasKey('alias_for_foo', $aliases);
|
||||||
|
@ -4,9 +4,6 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
public: true
|
public: true
|
||||||
synthetic: true
|
synthetic: true
|
||||||
foo:
|
|
||||||
class: App\FooService
|
|
||||||
public: true
|
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||||
public: true
|
public: true
|
||||||
@ -19,3 +16,6 @@ services:
|
|||||||
|
|
||||||
shared: false
|
shared: false
|
||||||
configurator: c
|
configurator: c
|
||||||
|
foo:
|
||||||
|
class: App\FooService
|
||||||
|
public: true
|
||||||
|
@ -4,6 +4,15 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
public: true
|
public: true
|
||||||
synthetic: true
|
synthetic: true
|
||||||
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
||||||
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
||||||
|
public: true
|
||||||
|
tags:
|
||||||
|
- { name: foo }
|
||||||
|
- { name: baz }
|
||||||
|
deprecated: '%service_id%'
|
||||||
|
arguments: [1]
|
||||||
|
factory: f
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
|
||||||
public: true
|
public: true
|
||||||
@ -14,12 +23,3 @@ services:
|
|||||||
lazy: true
|
lazy: true
|
||||||
arguments: [1]
|
arguments: [1]
|
||||||
factory: f
|
factory: f
|
||||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
|
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
|
|
||||||
public: true
|
|
||||||
tags:
|
|
||||||
- { name: foo }
|
|
||||||
- { name: baz }
|
|
||||||
deprecated: '%service_id%'
|
|
||||||
arguments: [1]
|
|
||||||
factory: f
|
|
||||||
|
@ -18,8 +18,14 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|||||||
|
|
||||||
trait ValidatorExtensionTrait
|
trait ValidatorExtensionTrait
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var ValidatorInterface|null
|
||||||
|
*/
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ValidatorExtension
|
||||||
|
*/
|
||||||
protected function getValidatorExtension()
|
protected function getValidatorExtension()
|
||||||
{
|
{
|
||||||
if (!interface_exists(ValidatorInterface::class)) {
|
if (!interface_exists(ValidatorInterface::class)) {
|
||||||
@ -31,9 +37,9 @@ trait ValidatorExtensionTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
|
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
|
||||||
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(array('addPropertyConstraint'))->getMock();
|
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(['addPropertyConstraint'])->getMock();
|
||||||
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
|
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
|
||||||
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(array()));
|
$this->validator->expects($this->any())->method('validate')->will($this->returnValue([]));
|
||||||
|
|
||||||
return new ValidatorExtension($this->validator);
|
return new ValidatorExtension($this->validator);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ class XmlFileLoader extends FileLoader
|
|||||||
if (isset($xml->{'discriminator-map'})) {
|
if (isset($xml->{'discriminator-map'})) {
|
||||||
$mapping = array();
|
$mapping = array();
|
||||||
foreach ($xml->{'discriminator-map'}->mapping as $element) {
|
foreach ($xml->{'discriminator-map'}->mapping as $element) {
|
||||||
$mapping[(string) $element->attributes()->type] = (string) $element->attributes()->class;
|
$elementAttributes = $element->attributes();
|
||||||
|
$mapping[(string) $elementAttributes->type] = (string) $elementAttributes->class;
|
||||||
}
|
}
|
||||||
|
|
||||||
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
|
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
|
||||||
|
@ -28,7 +28,7 @@ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryI
|
|||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->validators = array();
|
$this->validators = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +46,7 @@ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryI
|
|||||||
$this->validators[$name] = $this->container->get($name);
|
$this->validators[$name] = $this->container->get($name);
|
||||||
} else {
|
} else {
|
||||||
if (!class_exists($name)) {
|
if (!class_exists($name)) {
|
||||||
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
|
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators[$name] = new $name();
|
$this->validators[$name] = new $name();
|
||||||
|
Reference in New Issue
Block a user