Merge branch '3.1'
* 3.1: [TwigBundle] added missing dependencies for tests fixed CS adding missing dep [TwigBundle] Adjust CacheWarmingTest for TemplateCacheWarmer introduced in 2.8 [TwigBundle] Fix CacheWarmingTest are order dependent Revert "bug #20080 [Form] compound forms without children should be considered rendered implicitly (backbone87)" [2.7][VarDumper] Fix PHP 7.1 compat [2.8][VarDumper] Fix PHP 7.1 compat silent file operation to avoid open basedir issues Fix #19943 Make sure to process each interface metadata only once #17580 compound forms without children should be considered rendered implicitly
This commit is contained in:
commit
6399ffa32b
@ -31,7 +31,7 @@ class NewCacheWamingTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
|
||||
}
|
||||
|
||||
public function testCacheIsNotWarmedWhenTemplatingIsDisabled()
|
||||
public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled()
|
||||
{
|
||||
$kernel = new CacheWarmingKernel(false);
|
||||
$kernel->boot();
|
||||
@ -40,7 +40,7 @@ class NewCacheWamingTest extends \PHPUnit_Framework_TestCase
|
||||
$warmer->enableOptionalWarmers();
|
||||
$warmer->warmUp($kernel->getCacheDir());
|
||||
|
||||
$this->assertFalse(file_exists($kernel->getCacheDir().'/twig'));
|
||||
$this->assertTrue(file_exists($kernel->getCacheDir().'/twig'));
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
@ -72,7 +72,7 @@ class CacheWarmingKernel extends Kernel
|
||||
{
|
||||
$this->withTemplating = $withTemplating;
|
||||
|
||||
parent::__construct('dev', true);
|
||||
parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -106,7 +106,7 @@ class CacheWarmingKernel extends Kernel
|
||||
|
||||
public function getCacheDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache';
|
||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
|
@ -32,7 +32,8 @@
|
||||
"symfony/routing": "~2.8|~3.0",
|
||||
"symfony/templating": "~2.8|~3.0",
|
||||
"symfony/yaml": "~2.8|~3.0",
|
||||
"symfony/framework-bundle": "~3.2"
|
||||
"symfony/framework-bundle": "~3.2",
|
||||
"doctrine/annotations": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" },
|
||||
|
@ -79,7 +79,7 @@ class ExecutableFinder
|
||||
}
|
||||
foreach ($suffixes as $suffix) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === DIRECTORY_SEPARATOR || is_executable($file))) {
|
||||
if (@is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === DIRECTORY_SEPARATOR || is_executable($file))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
@ -114,9 +114,27 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
|
||||
$metadata->mergeConstraints($this->getMetadataFor($parent->name));
|
||||
}
|
||||
|
||||
// Include constraints from all implemented interfaces that have not been processed via parent class yet
|
||||
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
|
||||
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name || ($parent && $parent->implementsInterface($interface->name))) {
|
||||
$interfaces = $metadata->getReflectionClass()->getInterfaces();
|
||||
|
||||
$interfaces = array_filter($interfaces, function ($interface) use ($parent, $interfaces) {
|
||||
$interfaceName = $interface->getName();
|
||||
|
||||
if ($parent && $parent->implementsInterface($interfaceName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($interfaces as $i) {
|
||||
if ($i !== $interface && $i->implementsInterface($interfaceName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// Include constraints from all directly implemented interfaces
|
||||
foreach ($interfaces as $interface) {
|
||||
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
|
||||
continue;
|
||||
}
|
||||
$metadata->mergeConstraints($this->getMetadataFor($interface->name));
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
* @Assert\GroupSequence({"Foo", "Entity"})
|
||||
* @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"})
|
||||
*/
|
||||
class Entity extends EntityParent
|
||||
class Entity extends EntityParent implements EntityInterfaceB
|
||||
{
|
||||
/**
|
||||
* @Assert\NotNull
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||
|
||||
interface EntityInterface
|
||||
interface EntityInterfaceA
|
||||
{
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?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\Validator\Tests\Fixtures;
|
||||
|
||||
interface EntityInterfaceB extends EntityParentInterface
|
||||
{
|
||||
}
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
|
||||
class EntityParent implements EntityInterface
|
||||
class EntityParent implements EntityInterfaceA
|
||||
{
|
||||
protected $firstName;
|
||||
private $internal;
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?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\Validator\Tests\Fixtures;
|
||||
|
||||
interface EntityParentInterface
|
||||
{
|
||||
}
|
@ -18,17 +18,19 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||
|
||||
class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
||||
const INTERFACECLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterface';
|
||||
const CLASS_NAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||
const PARENT_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
||||
const INTERFACE_A_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterfaceA';
|
||||
const INTERFACE_B_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterfaceB';
|
||||
const PARENT_INTERFACE_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParentInterface';
|
||||
|
||||
public function testLoadClassMetadataWithInterface()
|
||||
{
|
||||
$factory = new LazyLoadingMetadataFactory(new TestLoader());
|
||||
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
|
||||
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
|
||||
|
||||
$constraints = array(
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityInterface', 'EntityParent'))),
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))),
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
|
||||
);
|
||||
|
||||
@ -38,12 +40,12 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
public function testMergeParentConstraints()
|
||||
{
|
||||
$factory = new LazyLoadingMetadataFactory(new TestLoader());
|
||||
$metadata = $factory->getMetadataFor(self::CLASSNAME);
|
||||
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
|
||||
|
||||
$constraints = array(
|
||||
new ConstraintA(array('groups' => array(
|
||||
'Default',
|
||||
'EntityInterface',
|
||||
'EntityInterfaceA',
|
||||
'EntityParent',
|
||||
'Entity',
|
||||
))),
|
||||
@ -52,6 +54,17 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
'EntityParent',
|
||||
'Entity',
|
||||
))),
|
||||
new ConstraintA(array('groups' => array(
|
||||
'Default',
|
||||
'EntityParentInterface',
|
||||
'EntityInterfaceB',
|
||||
'Entity',
|
||||
))),
|
||||
new ConstraintA(array('groups' => array(
|
||||
'Default',
|
||||
'EntityInterfaceB',
|
||||
'Entity',
|
||||
))),
|
||||
new ConstraintA(array('groups' => array(
|
||||
'Default',
|
||||
'Entity',
|
||||
@ -67,34 +80,36 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
|
||||
|
||||
$parentClassConstraints = array(
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityInterface', 'EntityParent'))),
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA', 'EntityParent'))),
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
|
||||
);
|
||||
$interfaceConstraints = array(new ConstraintA(array('groups' => array('Default', 'EntityInterface'))));
|
||||
$interfaceAConstraints = array(
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityInterfaceA'))),
|
||||
);
|
||||
|
||||
$cache->expects($this->never())
|
||||
->method('has');
|
||||
$cache->expects($this->exactly(2))
|
||||
->method('read')
|
||||
->withConsecutive(
|
||||
array($this->equalTo(self::PARENTCLASS)),
|
||||
array($this->equalTo(self::INTERFACECLASS))
|
||||
array($this->equalTo(self::PARENT_CLASS)),
|
||||
array($this->equalTo(self::INTERFACE_A_CLASS))
|
||||
)
|
||||
->will($this->returnValue(false));
|
||||
$cache->expects($this->exactly(2))
|
||||
->method('write')
|
||||
->withConsecutive(
|
||||
$this->callback(function ($metadata) use ($interfaceConstraints) {
|
||||
return $interfaceConstraints == $metadata->getConstraints();
|
||||
$this->callback(function ($metadata) use ($interfaceAConstraints) {
|
||||
return $interfaceAConstraints == $metadata->getConstraints();
|
||||
}),
|
||||
$this->callback(function ($metadata) use ($parentClassConstraints) {
|
||||
return $parentClassConstraints == $metadata->getConstraints();
|
||||
})
|
||||
);
|
||||
|
||||
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
|
||||
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
|
||||
|
||||
$this->assertEquals(self::PARENTCLASS, $metadata->getClassName());
|
||||
$this->assertEquals(self::PARENT_CLASS, $metadata->getClassName());
|
||||
$this->assertEquals($parentClassConstraints, $metadata->getConstraints());
|
||||
}
|
||||
|
||||
@ -104,7 +119,7 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
|
||||
$factory = new LazyLoadingMetadataFactory($loader, $cache);
|
||||
|
||||
$metadata = new ClassMetadata(self::PARENTCLASS);
|
||||
$metadata = new ClassMetadata(self::PARENT_CLASS);
|
||||
$metadata->addConstraint(new ConstraintA());
|
||||
|
||||
$loader->expects($this->never())
|
||||
@ -116,7 +131,7 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
->method('read')
|
||||
->will($this->returnValue($metadata));
|
||||
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(self::PARENTCLASS));
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(self::PARENT_CLASS));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class ReflectionCaster
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
$a += array(
|
||||
$prefix.'type' => $c->__toString(),
|
||||
$prefix.'name' => method_exists('ReflectionType', 'getName') ? $c->getName() : $c->__toString(),
|
||||
$prefix.'allowsNull' => $c->allowsNull(),
|
||||
$prefix.'isBuiltin' => $c->isBuiltin(),
|
||||
);
|
||||
@ -217,12 +217,13 @@ class ReflectionCaster
|
||||
'position' => 'getPosition',
|
||||
'isVariadic' => 'isVariadic',
|
||||
'byReference' => 'isPassedByReference',
|
||||
'allowsNull' => 'allowsNull',
|
||||
));
|
||||
|
||||
try {
|
||||
if (method_exists($c, 'hasType')) {
|
||||
if ($c->hasType()) {
|
||||
$a[$prefix.'typeHint'] = $c->getType()->__toString();
|
||||
$a[$prefix.'typeHint'] = method_exists('ReflectionType', 'getName') ? $c->getType()->getName() : $c->getType()->__toString();
|
||||
}
|
||||
} else {
|
||||
$v = explode(' ', $c->__toString(), 6);
|
||||
@ -235,9 +236,14 @@ class ReflectionCaster
|
||||
$a[$prefix.'typeHint'] = $m[1];
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if (isset($a[$prefix.'typeHint'])) {
|
||||
$v = $a[$prefix.'typeHint'];
|
||||
$a[$prefix.'typeHint'] = new ClassStub($v, array(class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', ''));
|
||||
=======
|
||||
if (!isset($a[$prefix.'typeHint'])) {
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
>>>>>>> 3.1
|
||||
}
|
||||
|
||||
try {
|
||||
@ -245,9 +251,13 @@ class ReflectionCaster
|
||||
if (method_exists($c, 'isDefaultValueConstant') && $c->isDefaultValueConstant()) {
|
||||
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
|
||||
}
|
||||
if (null === $v) {
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
if (isset($a[$prefix.'typeHint']) && $c->allowsNull()) {
|
||||
if (isset($a[$prefix.'typeHint']) && $c->allowsNull() && !method_exists('ReflectionType', 'getName')) {
|
||||
$a[$prefix.'default'] = null;
|
||||
unset($a[$prefix.'allowsNull']);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user