8000 Merge branch '3.2' · symfony/symfony@9b99fff · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b99fff

Browse files
committed
Merge branch '3.2'
* 3.2: [TwigBundle] fixed usage when Templating is not installed [Validator] Check cascasdedGroups for being countable [Cache] Add changelog for 3.2 [Cache] Add changelog [Filesystem] Check that the directory is writable after created it in dumpFile() [HttpFoundation] Improved set cookie header tests [Serializer] int is valid when float is expected when deserializing JSON [Console] increased code coverage of Output classes Added missing headers in fixture files [Profiler][VarDumper] Fix minor color issue & duplicated selector
2 parents efe2a93 + 831d0a0 commit 9b99fff

File tree

16 files changed

+162
-27
lines changed

16 files changed

+162
-27
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function process(ContainerBuilder $container)
4949
if ($container->has('form.extension')) {
5050
$container->getDefinition('twig.extension.form')->addTag('twig.extension');
5151
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
52-
$container->getDefinition('twig.loader.filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
52+
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
5353
}
5454

5555
if ($container->has('translator')) {
@@ -85,15 +85,15 @@ public function process(ContainerBuilder $container)
8585
}
8686

8787
$composerRootDir = $this->getComposerRootDir($container->getParameter('kernel.root_dir'));
88-
$loader = $container->getDefinition('twig.loader.filesystem');
89-
$loader->replaceArgument(2, $composerRootDir);
90-
91-
if (!$container->has('templating')) {
92-
$loader = $container->getDefinition('twig.loader.native_filesystem');
93-
$loader->replaceArgument(1, $composerRootDir);
94-
$loader->addTag('twig.loader');
95-
$loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
96-
88+
$twigLoader = $container->getDefinition('twig.loader.native_filesystem');
89+
if ($container->has('templating')) {
90+
$loader = $container->getDefinition('twig.loader.filesystem');
91+
$loader->setMethodCalls($twigLoader->getMethodCalls());
92+
$loader->replaceArgument(2, $composerRootDir);
93+
94+
$twigLoader->clearTag('twig.loader');
95+
} else {
96+
$twigLoader->replaceArgument(1, $composerRootDir);
9797
$container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false));
9898
}
9999

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function load(array $configs, ContainerBuilder $container)
7878
$envConfiguratorDefinition->replaceArgument(4, $config['number_format']['decimal_point']);
7979
$envConfiguratorDefinition->replaceArgument(5, $config['number_format']['thousands_separator']);
8080

81-
$twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.filesystem');
81+
$twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.native_filesystem');
8282

8383
// register user-configured paths
8484
foreach ($config['paths'] as $path => $namespace) {

src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<tag name="twig.loader"/>
1212
</service>
1313

14-
<service id="twig.loader" alias="twig.loader.filesystem" />
15-
1614
<service id="templating.engine.twig" class="Symfony\Bundle\TwigBundle\TwigEngine" public="false">
1715
<argument type="service" id="twig" />
1816
<argument type="service" id="templating.name_parser" />

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testTwigLoaderPaths($format)
153153
$this->loadFromFile($container, 'extra', $format);
154154
$this->compileContainer($container);
155155

156-
$def = $container->getDefinition('twig.loader.filesystem');
156+
$def = $container->getDefinition('twig.loader.native_filesystem');
157157
$paths = array();
158158
foreach ($def->getMethodCalls() as $call) {
159159
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@
172172
font-size: 11px;
173173
padding: 4px 8px 4px 0;
174174
}
175-
.sf-toolbar-block .sf-toolbar-info-piece span {
176-
175+
.sf-toolbar-block:not(.sf-toolbar-block-dump) .sf-toolbar-info-piece span {
176+
color: #F5F5F5;
177177
}
178178
.sf-toolbar-block .sf-toolbar-info-piece span {
179-
color: #F5F5F5;
180179
font-size: 12px;
181180
}
182181

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CHANGELOG
2+
=========
3+
4+
3.2.0
5+
-----
6+
7+
* added TagAwareAdapter for tags-based invalidation
8+
* added PdoAdapter with PDO and Doctrine DBAL support
9+
* added PhpArrayAdapter and PhpFilesAdapter for OPcache-backed shared memory storage (PHP 7+ only)
10+
* added NullAdapter
11+
12+
3.1.0
13+
-----
14+
15+
* added the component with strict PSR-6 implementations
16+
* added ApcuAdapter, ArrayAdapter, FilesystemAdapter and RedisAdapter
17+
* added AbstractAdapter, ChainAdapter and ProxyAdapter
18+
* added DoctrineAdapter and DoctrineProvider for bidirectional interoperability with Doctrine Cache

src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Output;
1313

14+
use Symfony\Component\Console\Formatter\OutputFormatter;
1415
use Symfony\Component\Console\Output\ConsoleOutput;
1516
use Symfony\Component\Console\Output\Output;
1617

@@ -22,4 +23,19 @@ public function testConstructor()
2223
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
2324
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
2425
}
26+
27+
public function testSetFormatter()
28+
{
29+
$output = new ConsoleOutput();
30+
$outputFormatter = new OutputFormatter();
31+
$output->setFormatter($outputFormatter);
32+
$this->assertSame($outputFormatter, $output->getFormatter());
33+
}
34+
35+
public function testSetVerbosity()
36+
{
37+
$output = new ConsoleOutput();
38+
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
39+
$this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity());
40+
}
2541
}

src/Symfony/Component/Console/Tests/Output/NullOutputTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Component\Console\Tests\Output;
1313

14+
use Symfony\Component\Console\Formatter\OutputFormatter;
1415
use Symfony\Component\Console\Output\NullOutput;
16+
use Symfony\Component\Console\Output\Output;
1517
use Symfony\Component\Console\Output\OutputInterface;
1618

1719
class NullOutputTest extends \PHPUnit_Framework_TestCase
@@ -36,4 +38,50 @@ public function testVerbosity()
3638
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
3739
$this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput');
3840
}
41+
42+
public function testSetFormatter()
43+
{
44+
$output = new NullOutput();
45+
$outputFormatter = new OutputFormatter();
46+
$output->setFormatter($outputFormatter);
47+
$this->assertNotSame($outputFormatter, $output->getFormatter());
48+
}
49+
50+
public function testSetVerbosity()
51+
{
52+
$output = new NullOutput();
53+
$output->setVerbosity(Output::VERBOSITY_NORMAL);
54+
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity());
55+
}
56+
57+
public function testSetDecorated()
58+
{
59+
$output = new NullOutput();
60+
$output->setDecorated(true);
61+
$this->assertFalse($output->isDecorated());
62+
}
63+
64+
public function testIsQuiet()
65+
{
66+
$output = new NullOutput();
67+
$this->assertTrue($output->isQuiet());
68+
}
69+
70+
public function testIsVerbose()
71+
{
72+
$output = new NullOutput();
73+
$this->assertFalse($output->isVerbose());
74+
}
75+
76+
public function testIsVeryVerbose()
77+
{
78+
$output = new NullOutput();
79+
$this->assertFalse($output->isVeryVerbose());
80+
}
81+
82+
public function testIsDebug()
83+
{
84+
$output = new NullOutput();
85+
$this->assertFalse($output->isDebug());
86+
}
3987
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,9 @@ public function dumpFile($filename, $content)
632632

633633
if (!is_dir($dir)) {
634634
$this->mkdir($dir);
635-
} elseif (!is_writable($dir)) {
635+
}
636+
637+
if (!is_writable($dir)) {
636638
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
637639
}
638640

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function provideMakeDispositionFail()
331331
);
332332
}
333333

334-
protected function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
334+
private function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
335335
{
336336
$this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual));
337337
}

src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/BasicTypesController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
413

514
class BasicTypesController

src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/ExtendingRequest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
413

514
use Symfony\Component\HttpFoundation\Request;

src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
413

514
class VariadicController

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Serializer\Normalizer;
1313

1414
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
15+
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1516
use Symfony\Component\Serializer\Exception\CircularReferenceException;
1617
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
1718
use Symfony\Component\Serializer\Exception\LogicException;
@@ -271,6 +272,16 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma
271272
}
272273
}
273274

275+
// JSON only has a Number type corresponding to both int and float PHP types.
276+
// PHP's json_encode, JavaScript's JSON.stringify, Go's json.Marshal as well as most other JSON encoders convert
277+
// floating-point numbers like 12.0 to 12 (the decimal part is dropped when possible).
278+
// PHP's json_decode automatically converts Numbers without a decimal part to integers.
279+
// To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when
280+
// a float is expected.
281+
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && is_int($data) && false !== strpos($format, JsonEncoder::FORMAT)) {
282+
return (float) $data;
283+
}
284+
274285
if (call_user_func('is_'.$builtinType, $data)) {
275286
return $data;
276287
}

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,21 @@ public function testDenomalizeRecursive()
580580
'inners' => array(array('foo' => 1), array('foo' => 2)),
581581
), ObjectOuter::class);
582582

583-
$this->assertEquals('foo', $obj->getInner()->foo);
584-
$this->assertEquals('bar', $obj->getInner()->bar);
585-
$this->assertEquals('1988-01-21', $obj->getDate()->format('Y-m-d'));
586-
$this->assertEquals(1, $obj->getInners()[0]->foo);
587-
$this->assertEquals(2, $obj->getInners()[1]->foo);
583+
$this->assertSame('foo', $obj->getInner()->foo);
584+
$this->assertSame('bar', $obj->getInner()->bar);
585+
$this->assertSame('1988-01-21', $obj->getDate()->format('Y-m-d'));
586+
$this->assertSame(1, $obj->getInners()[0]->foo);
587+
$this->assertSame(2, $obj->getInners()[1]->foo);
588+
}
589+
590+
public function testAcceptJsonNumber()
591+
{
592+
$extractor = new PropertyInfoExtractor(array(), array(new PhpDocExtractor(), new ReflectionExtractor()));
593+
$normalizer = new ObjectNormalizer(null, null, null, $extractor);
594+
$serializer = new Serializer(array(new ArrayDenormalizer(), new DateTimeNormalizer(), $normalizer));
595+
596+
$this->assertSame(10.0, $serializer->denormalize(array('number' => 10), JsonNumber::class, 'json')->number);
597+
$this->assertSame(10.0, $serializer->denormalize(array('number' => 10), JsonNumber::class, 'jsonld')->number);
588598
}
589599

590600
/**
@@ -892,3 +902,11 @@ public function __construct($id, Unknown $unknown)
892902
{
893903
}
894904
}
905+
906+
class JsonNumber
907+
{
908+
/**
909+
* @var float
910+
*/
911+
public $number;
912+
}

src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,7 @@ private function validateGenericNode($value, $object, $cacheKey, MetadataInterfa
720720
// The $cascadedGroups property is set, if the "Default" group is
721721
// overridden by a group sequence
722722
// See validateClassNode()
723-
$cascadedGroups = count($cascadedGroups) > 0
724-
? $cascadedGroups
725-
: $groups;
723+
$cascadedGroups = null !== $cascadedGroups && count($cascadedGroups) > 0 ? $cascadedGroups : $groups;
726724

727725
if (is_array($value)) {
728726
// Arrays are always traversed, independent of the specified

0 commit comments

Comments
 (0)
0