Skip to content

Commit 415e6f6

Browse files
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 b5990be#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
2 parents 8eb8681 + 38b9a88 commit 415e6f6

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function getScript($request)
101101

102102
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
103103
$requirePath = str_replace("'", "\\'", $r->getFileName());
104-
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
104+
$symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__))));
105105
$errorReporting = error_reporting();
106106

107107
$code = <<<EOF

src/Symfony/Component/Intl/Resources/bin/update-data.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@
178178
$compiler = new GenrbCompiler($genrb, $genrbEnv);
179179
$config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
180180

181-
// Don't wrap "/data" in realpath(), in case the directory does not exist
182-
$baseDir = realpath(__DIR__.'/..').'/data';
181+
$baseDir = dirname(__DIR__).'/data';
183182

184183
//$txtDir = $baseDir.'/txt';
185184
$jsonDir = $baseDir;

src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ public function testHandleWithTokenStorageHavingNoToken()
5454
$authenticationManager
5555
->expects($this->once())
5656
->method('authenticate')
57-
->with(self::logicalAnd(
58-
$this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'),
59-
$this->attributeEqualTo('secret', 'TheSecret')
60-
))
57+
->with($this->callback(function ($token) {
58+
return 'TheSecret' === $token->getSecret();
59+
}))
6160
->will($this->returnValue($anonymousToken))
6261
;
6362

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ protected function prepareForDenormalization($data)
291291
*
292292
* @throws RuntimeException
293293
*/
294-
protected function instantiateObject(array $data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
294+
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
295295
{
296296
if (
297297
isset($context['object_to_populate']) &&

src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
102102
$reflectionClass = new \ReflectionClass($class);
103103
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes);
104104

105+
$classMethods = get_class_methods($object);
105106
foreach ($normalizedData as $attribute => $value) {
106107
if ($this->nameConverter) {
107108
$attribute = $this->nameConverter->denormalize($attribute);
@@ -113,7 +114,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
113114
if ($allowed && !$ignored) {
114115
$setter = 'set'.ucfirst($attribute);
115116

116-
if (method_exists($object, $setter)) {
117+
if (in_array($setter, $classMethods)) {
117118
$object->$setter($value);
118119
}
119120
}

src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ public function testConstructorWithObjectDenormalize()
228228
$this->assertEquals('bar', $obj->getBar());
229229
}
230230

231+
public function testConstructorWArgWithPrivateMutator()
232+
{
233+
$obj = $this->normalizer->denormalize(array('foo' => 'bar'), __NAMESPACE__.'\ObjectConstructorArgsWithPrivateMutatorDummy', 'any');
234+
$this->assertEquals('bar', $obj->getFoo());
235+
}
236+
231237
public function testGroupsNormalize()
232238
{
233239
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
@@ -511,15 +517,21 @@ public function testObjectToPopulate()
511517
public function testDenormalizeNonExistingAttribute()
512518
{
513519
$this->assertEquals(
514-
new PropertyDummy(),
515-
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\PropertyDummy')
520+
new GetSetDummy(),
521+
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\GetSetDummy')
516522
);
517523
}
518524

519525
public function testNoTraversableSupport()
520526
{
521527
$this->assertFalse($this->normalizer->supportsNormalization(new \ArrayObject()));
522528
}
529+
530+
public function testPrivateSetter()
531+
{
532+
$obj = $this->normalizer->denormalize(array('foo' => 'foobar'), __NAMESPACE__.'\ObjectWithPrivateSetterDummy');
533+
$this->assertEquals('bar', $obj->getFoo());
534+
}
523535
}
524536

525537
class GetSetDummy
@@ -726,3 +738,37 @@ public function getBar_foo()
726738
return $this->bar_foo;
727739
}
728740
}
741+
742+
class ObjectConstructorArgsWithPrivateMutatorDummy
743+
{
744+
private $foo;
745+
746+
public function __construct($foo)
747+
{
748+
$this->setFoo($foo);
749+
}
750+
751+
public function getFoo()
752+
{
753+
return $this->foo;
754+
}
755+
756+
private function setFoo($foo)
757+
{
758+
$this->foo = $foo;
759+
}
760+
}
761+
762+
class ObjectWithPrivateSetterDummy
763+
{
764+
private $foo = 'bar';
765+
766+
public function getFoo()
767+
{
768+
return $this->foo;
769+
}
770+
771+
private function setFoo($foo)
772+
{
773+
}
774+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy