Merge branch '2.7' into 2.8
* 2.7:
[Twig+FrameworkBundle] Fix forward compat with Form 2.8
[2.6] Static Code Analysis for Components
[Security/Http] Fix test relying on a private property
[Serializer] Fix bugs reported in b5990be491 (commitcomment-12301266)
Conflicts:
src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php
src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php
This commit is contained in:
commit
415e6f658f
@ -101,7 +101,7 @@ class Client extends BaseClient
|
|||||||
|
|
||||||
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
|
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
|
||||||
$requirePath = str_replace("'", "\\'", $r->getFileName());
|
$requirePath = str_replace("'", "\\'", $r->getFileName());
|
||||||
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
|
$symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__))));
|
||||||
$errorReporting = error_reporting();
|
$errorReporting = error_reporting();
|
||||||
|
|
||||||
$code = <<<EOF
|
$code = <<<EOF
|
||||||
|
@ -178,8 +178,7 @@ echo "Preparing resource bundle compilation (version $icuVersionInDownload)...\n
|
|||||||
$compiler = new GenrbCompiler($genrb, $genrbEnv);
|
$compiler = new GenrbCompiler($genrb, $genrbEnv);
|
||||||
$config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
|
$config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
|
||||||
|
|
||||||
// Don't wrap "/data" in realpath(), in case the directory does not exist
|
$baseDir = dirname(__DIR__).'/data';
|
||||||
$baseDir = realpath(__DIR__.'/..').'/data';
|
|
||||||
|
|
||||||
//$txtDir = $baseDir.'/txt';
|
//$txtDir = $baseDir.'/txt';
|
||||||
$jsonDir = $baseDir;
|
$jsonDir = $baseDir;
|
||||||
|
@ -54,10 +54,9 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authenticationManager
|
$authenticationManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->with(self::logicalAnd(
|
->with($this->callback(function ($token) {
|
||||||
$this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'),
|
return 'TheSecret' === $token->getSecret();
|
||||||
$this->attributeEqualTo('secret', 'TheSecret')
|
}))
|
||||||
))
|
|
||||||
->will($this->returnValue($anonymousToken))
|
->will($this->returnValue($anonymousToken))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
protected function instantiateObject(array $data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
|
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
isset($context['object_to_populate']) &&
|
isset($context['object_to_populate']) &&
|
||||||
|
@ -102,6 +102,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer
|
|||||||
$reflectionClass = new \ReflectionClass($class);
|
$reflectionClass = new \ReflectionClass($class);
|
||||||
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes);
|
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes);
|
||||||
|
|
||||||
|
$classMethods = get_class_methods($object);
|
||||||
foreach ($normalizedData as $attribute => $value) {
|
foreach ($normalizedData as $attribute => $value) {
|
||||||
if ($this->nameConverter) {
|
if ($this->nameConverter) {
|
||||||
$attribute = $this->nameConverter->denormalize($attribute);
|
$attribute = $this->nameConverter->denormalize($attribute);
|
||||||
@ -113,7 +114,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer
|
|||||||
if ($allowed && !$ignored) {
|
if ($allowed && !$ignored) {
|
||||||
$setter = 'set'.ucfirst($attribute);
|
$setter = 'set'.ucfirst($attribute);
|
||||||
|
|
||||||
if (method_exists($object, $setter)) {
|
if (in_array($setter, $classMethods)) {
|
||||||
$object->$setter($value);
|
$object->$setter($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,12 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('bar', $obj->getBar());
|
$this->assertEquals('bar', $obj->getBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstructorWArgWithPrivateMutator()
|
||||||
|
{
|
||||||
|
$obj = $this->normalizer->denormalize(array('foo' => 'bar'), __NAMESPACE__.'\ObjectConstructorArgsWithPrivateMutatorDummy', 'any');
|
||||||
|
$this->assertEquals('bar', $obj->getFoo());
|
||||||
|
}
|
||||||
|
|
||||||
public function testGroupsNormalize()
|
public function testGroupsNormalize()
|
||||||
{
|
{
|
||||||
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
||||||
@ -511,8 +517,8 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDenormalizeNonExistingAttribute()
|
public function testDenormalizeNonExistingAttribute()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
new PropertyDummy(),
|
new GetSetDummy(),
|
||||||
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\PropertyDummy')
|
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\GetSetDummy')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +526,12 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertFalse($this->normalizer->supportsNormalization(new \ArrayObject()));
|
$this->assertFalse($this->normalizer->supportsNormalization(new \ArrayObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPrivateSetter()
|
||||||
|
{
|
||||||
|
$obj = $this->normalizer->denormalize(array('foo' => 'foobar'), __NAMESPACE__.'\ObjectWithPrivateSetterDummy');
|
||||||
|
$this->assertEquals('bar', $obj->getFoo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetSetDummy
|
class GetSetDummy
|
||||||
@ -726,3 +738,37 @@ class GetCamelizedDummy
|
|||||||
return $this->bar_foo;
|
return $this->bar_foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ObjectConstructorArgsWithPrivateMutatorDummy
|
||||||
|
{
|
||||||
|
private $foo;
|
||||||
|
|
||||||
|
public function __construct($foo)
|
||||||
|
{
|
||||||
|
$this->setFoo($foo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFoo()
|
||||||
|
{
|
||||||
|
return $this->foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setFoo($foo)
|
||||||
|
{
|
||||||
|
$this->foo = $foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ObjectWithPrivateSetterDummy
|
||||||
|
{
|
||||||
|
private $foo = 'bar';
|
||||||
|
|
||||||
|
public function getFoo()
|
||||||
|
{
|
||||||
|
return $this->foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setFoo($foo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user