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

Skip to content

Commit 40280f2

Browse files
committed
Merge branch '3.2'
* 3.2: [WebProfilerBundle] Fix AJAX panel with fetch requests Don’t compile when Opcache is not enabled on CLI DateIntervalType: 'invert' should not inherit the 'required' option [Form] DateIntervalType: Do not try to translate choices [TwigBridge] fix constructor args check Allow simple-phpunit to be used with an HTTP proxy Minor fixes for 3.2 Fix a web profiler form issue with fields added to the form after the form was built do not trigger deprecations for valid YAML Write an exception message in a one heading line [Workflow] Added missing docblock [Finder] Refine phpdoc about argument for NumberComparator Fixed max width from ajax request url element (td) Fix unresolved parameters from default bundle configs in debug:config [github] Tweak PR template [Serializer] Optimize max depth checking
2 parents 5126639 + 1943c26 commit 40280f2

File tree

26 files changed

+121
-64
lines changed

26 files changed

+121
-64
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | "master" for new features / 2.7, 2.8 or 3.1 for fixes
3+
| Branch? | master / 2.7, 2.8, 3.1 or 3.2 <!--see comment below-->
44
| Bug fix? | yes/no
55
| New feature? | yes/no
66
| BC breaks? | yes/no
77
| Deprecations? | yes/no
88
| Tests pass? | yes/no
9-
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any
9+
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
1010
| License | MIT
11-
| Doc PR | reference to the documentation PR, if any
11+
| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->
12+
13+
<!--
14+
- Bug fixes must be submitted against the lowest branch where they apply
15+
(lowest branches are regularly merged to upper ones so they get the fixes too).
16+
- Features and deprecations must be submitted against the master branch.
17+
- Please fill in this template according to the PR you're about to submit.
18+
- Replace this comment by a description of what your PR is solving.
19+
-->

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
3737
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
3838
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
3939
}
40-
if (extension_loaded('openssl') && ini_get('allow_url_fopen')) {
40+
if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
4141
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
4242
} else {
4343
@unlink("$PHPUNIT_VERSION.zip");

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FormExtension extends \Twig_Extension implements \Twig_Extension_InitRunti
3131

3232
public function __construct($renderer = null)
3333
{
34-
if ($this->renderer instanceof TwigRendererInterface) {
34+
if ($renderer instanceof TwigRendererInterface) {
3535
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0. Pass the Twig_Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED);
3636
} elseif (null !== $renderer && !(is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) {
3737
throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__));

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
105105

106106
$io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
107107

108-
$io->writeln(Yaml::dump($config, 10));
108+
$io->writeln(Yaml::dump($container->getParameterBag()->resolveValue($config), 10));
109109
}
110110

111111
private function compileContainer()

src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
1818
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
1919
use Symfony\Component\Workflow\Marking;
20-
use Symfony\Component\Workflow\Workflow;
2120

2221
/**
57AE 2322
* @author Grégoire Pineau <lyrixx@lyrixx.info>

src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function json($data, $status = 200, $headers = array(), $context = arr
137137
protected function file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT)
138138
{
139139
$response = new BinaryFileResponse($file);
140-
$response->setContentDisposition($disposition, $fileName === null ? $response->getFile()->getFileName() : $fileName);
140+
$response->setContentDisposition($disposition, $fileName === null ? $response->getFile()->getFilename() : $fileName);
141141

142142
return $response;
143143
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Cache\Adapter\ProxyAdapter;
2121
use Symfony\Component\Cache\Adapter\RedisAdapter;
2222
use Symfony\Component\DependencyInjection\ContainerBuilder;
23-
use Symfony\Component\DependencyInjection\Definition;
2423
use Symfony\Component\DependencyInjection\DefinitionDecorator;
2524
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
2625
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
<div class="text-exception">
1010
<div class="open-quote">“</div>
1111

12-
<h1>
13-
{{ exception.message|nl2br|format_file_from_text }}
14-
</h1>
12+
<h1>{{ exception.message|nl2br|format_file_from_text }}</h1>
1513

1614
<div>
1715
<strong>{{ status_code }}</strong> {{ status_text }} - {{ exception.class|abbr_class }}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
{% import _self as tree %}
458458
<div class="tree-details{% if not show|default(false) %} hidden{% endif %}" {% if data.id is defined %}id="{{ data.id }}-details"{% endif %}>
459459
<h2 class="dump-inline">
460-
{{ name|default('(no name)') }} ({{ profiler_dump(data.type_class) }})
460+
{{ name|default('(no name)') }} {% if data.type_class is defined %}({{ profiler_dump(data.type_class) }}){% endif %}
461461
</h2>
462462

463463
{% if data.errors is defined and data.errors|length > 0 %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,28 @@
234234
var oldFetch = window.fetch;
235235
window.fetch = function () {
236236
var promise = oldFetch.apply(this, arguments);
237-
if (!arguments[0].match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
237+
var url = arguments[0];
238+
var params = arguments[1];
239+
var paramType = Object.prototype.toString.call(arguments[0]);
240+
if (paramType === '[object Request]') {
241+
url = arguments[0].url;
242+
params = {
243+
method: arguments[0].method,
244+
credentials: arguments[0].credentials,
245+
headers: arguments[0].headers,
246+
mode: arguments[0].mode,
247+
redirect: arguments[0].redirect
248+
};
249+
}
250+
if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
238251
var method = 'GET';
239-
if (arguments[1] && arguments[1].method !== undefined) {
240-
method = arguments[1].method;
252+
if (params && params.method !== undefined) {
253+
method = params.method;
241254
}
242255
243256
var stackElement = {
244257
error: false,
245-
url: arguments[0],
258+
url: url,
246259
method: method,
247260
type: 'fetch',
248261
start: new Date()

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function doSave(array $values, $lifetime)
9393
$ok = true;
9494
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
9595

96-
foreach ($values as $id => $value) {
96+
foreach ($values as $key => $value) {
9797
if (null === $value || is_object($value)) {
9898
$value = serialize($value);
9999
} elseif (is_array($value)) {
@@ -109,13 +109,16 @@ protected function doSave(array $values, $lifetime)
109109
$value = serialize($value);
110110
}
111111
} elseif (!is_scalar($value)) {
112-
throw new InvalidArgumentException(sprintf('Value of type "%s" is not serializable', $key, gettype($value)));
112+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, gettype($value)));
113113
}
114114

115115
$data[1] = $value;
116-
$file = $this->getFile($id, true);
116+
$file = $this->getFile($key, true);
117117
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
118-
@opcache_compile_file($file);
118+
119+
if ('cli' !== PHP_SAPI || ini_get('opcache.enable_cli')) {
120+
@opcache_compile_file($file);
121+
}
119122
}
120123

121124
return $ok;

src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function tearDownAfterClass()
3030
}
3131

3232
/**
33-
* @expectedException Psr\Cache\InvalidArgumentException
33+
* @expectedException \Psr\Cache\InvalidArgumentException
3434
*/
3535
public function testInvalidTag()
3636
{

src/Symfony/Component/Cache/Tests/CacheItemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testTag()
6565

6666
/**
6767
* @dataProvider provideInvalidKey
68-
* @expectedException Symfony\Component\Cache\Exception\InvalidArgumentException
68+
* @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException
6969
* @expectedExceptionMessage Cache tag
7070
*/
7171
public function testInvalidTag($tag)

src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit_Framework_TestCase;
1515
use Symfony\Component\Console\Command\Command;
16-
use Symfony\Component\Console\Style\SymfonyStyle;
1716
use Symfony\Component\Console\Tester\CommandTester;
1817

1918
class SymfonyStyleTest extends PHPUnit_Framework_TestCase

src/Symfony/Component/Finder/Comparator/NumberComparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class NumberComparator extends Comparator
3737
/**
3838
* Constructor.
3939
*
40-
* @param string $test A comparison string
40+
* @param string|int $test A comparison string or an integer
4141
*
4242
* @throws \InvalidArgumentException If the test is not understood
4343
*/

src/Symfony/Component/Finder/Finder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function files()
111111
* $finder->depth('> 1') // the Finder will start matching at level 1.
112112
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
113113
*
114-
* @param int $level The depth level expression
114+
* @param string|int $level The depth level expression
115115
*
116116
* @return Finder|SplFileInfo[] The current Finder instance
117117
*
@@ -283,7 +283,7 @@ public function notPath($pattern)
283283
* $finder->size('<= 1Ki');
284284
* $finder->size(4);
285285
*
286-
* @param string $size A size range string
286+
* @param string|int $size A size range string or an integer
287287
*
288288
* @return Finder|SplFileInfo[] The current Finder instance
289289
*

src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
102102
$childOptions[$part] = array();
103103
$childOptions[$part]['error_bubbling'] = true;
104104
if ('choice' === $options['widget']) {
105+
$childOptions[$part]['choice_translation_domain'] = false;
105106
$childOptions[$part]['choices'] = $options[$part];
106107
$childOptions[$part]['placeholder'] = $options['placeholder'][$part];
107108
}
108109
}
109110
}
110-
$invertOptions = array(
111-
'error_bubbling' => true,
112-
);
113111
// Append generic carry-along options
114112
foreach (array('required', 'translation_domain') as $passOpt) {
115113
foreach ($this->timeParts as $part) {
116114
if ($options['with_'.$part]) {
117115
$childOptions[$part][$passOpt] = $options[$passOpt];
118116
}
119117
}
120-
if ($options['with_invert']) {
121-
$invertOptions[$passOpt] = $options[$passOpt];
122-
}
123118
}
124119
foreach ($this->timeParts as $part) {
125120
if ($options['with_'.$part]) {
@@ -135,7 +130,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
135130
}
136131
}
137132
if ($options['with_invert']) {
138-
$builder->add('invert', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', $invertOptions);
133+
$builder->add('invert', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(
134+
'error_bubbling' => true,
135+
'required' => false,
136+
'translation_domain' => $options['translation_domain'],
137+
));
139138
}
140139
$builder->addViewTransformer(new DateIntervalToArrayTransformer($parts, 'text' === $options['widget']));
141140
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php

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

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Component\Form\Extension\Core\Type\DateIntervalType;
1415
use Symfony\Component\Form\FormError;
1516
use Symfony\Component\Form\Test\TypeTestCase as TestCase;
1617

@@ -364,4 +365,38 @@ public function testDateTypeChoiceErrorsBubbleUp()
364365
$this->assertSame(array(), iterator_to_array($form['years']->getErrors()));
365366
$this->assertSame(array($error), iterator_to_array($form->getErrors()));
366367
}
368+
369+
public function testTranslationsAreDisabledForChoiceWidget()
370+
{
371+
$form = $this->factory->create(
372+
DateIntervalType::class,
373+
null,
374+
array(
375+
'widget' => 'choice',
376+
'with_hours' => true,
377+
'with_minutes' => true,
378+
'with_seconds' => true,
379+
)
380+
);
381+
$this->assertFalse($form->get('years')->getConfig()->getOption('choice_translation_domain'));
382+
$this->assertFalse($form->get('months')->getConfig()->getOption('choice_translation_domain'));
383+
$this->assertFalse($form->get('days')->getConfig()->getOption('choice_translation_domain'));
384+
$this->assertFalse($form->get('hours')->getConfig()->getOption('choice_translation_domain'));
385+
$this->assertFalse($form->get('minutes')->getConfig()->getOption('choice_translation_domain'));
386+
$this->assertFalse($form->get('seconds')->getConfig()->getOption('choice_translation_domain'));
387+
}
388+
389+
public function testInvertDoesNotInheritRequiredOption()
390+
{
391+
$form = $this->factory->create(
392+
'Symfony\Component\Form\Extension\Core\Type\DateIntervalType',
393+
null,
394+
array(
395+
'input' => 'dateinterval',
396+
'with_invert' => true,
397+
'required' => true,
398+
)
399+
);
400+
$this->assertFalse($form->get('invert')->getConfig()->getOption('required'));
401+
}
367402
}

src/Symfony/Component/Serializer/Encoder/YamlEncoder.php

Lines changed: 0 additions & 1 deletion
F438
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Yaml\Dumper;
1515
use Symfony\Component\Yaml\Parser;
16-
use Symfony\Component\Yaml\Yaml;
1716

1817
/**
1918
* Encodes YAML data.

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
1919
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
2020
use Symfony\Component\PropertyInfo\Type;
21+
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
2122
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
2223
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
2324

@@ -68,9 +69,10 @@ public function normalize($object, $format = null, array $context = array())
6869
$stack = array();
6970
$attributes = $this->getAttributes($object, $format, $context);
7071
$class = get_class($object);
72+
$attributesMetadata = $this->classMetadataFactory ? $this->classMetadataFactory->getMetadataFor($class)->getAttributesMetadata() : null;
7173

7274
foreach ($attributes as $attribute) {
73-
if ($this->isMaxDepthReached($class, $attribute, $context)) {
75+
if (null !== $attributesMetadata && $this->isMaxDepthReached($attributesMetadata, $class, $attribute, $context)) {
7476
continue;
7577
}
7678

@@ -300,42 +302,35 @@ private function updateData(array $data, $attribute, $attributeValue)
300302
/**
301303
* Is the max depth reached for the given attribute?
302304
*
303-
* @param string $class
304-
* @param string $attribute
305-
* @param array $context
305+
* @param AttributeMetadataInterface[] $attributesMetadata
306+
* @param string $class
307+
* @param string $attribute
308+
* @param array $context
306309
*
307310
* @return bool
308311
*/
309-
private function isMaxDepthReached($class, $attribute, array &$context)
312+
private function isMaxDepthReached(array $attributesMetadata, $class, $attribute, array &$context)
310313
{
311-
if (!$this->classMetadataFactory || !isset($context[static::ENABLE_MAX_DEPTH])) {
314+
if (
315+
!isset($context[static::ENABLE_MAX_DEPTH]) ||
316+
!isset($attributesMetadata[$attribute]) ||
317+
null === $maxDepth = $attributesMetadata[$attribute]->getMaxDepth()
318+
) {
312319
return false;
313320
}
314321

315-
$classMetadata = $this->classMetadataFactory->getMetadataFor($class);
316-
$attributesMetadata = $classMetadata->getAttributesMetadata();
317-
318-
if (!isset($attributesMetadata[$attribute])) {
319-
return false;
320-
}
322+
$key = sprintf(static::DEPTH_KEY_PATTERN, $class, $attribute);
323+
if (!isset($context[$key])) {
324+
$context[$key] = 1;
321325

322-
$maxDepth = $attributesMetadata[$attribute]->getMaxDepth();
323-
if (null === $maxDepth) {
324326
return false;
325327
}
326328

327-
$key = sprintf(static::DEPTH_KEY_PATTERN, $class, $attribute);
328-
$keyExist = isset($context[$key]);
329-
330-
if ($keyExist && $context[$key] === $maxDepth) {
329+
if ($context[$key] === $maxDepth) {
331330
return true;
332331
}
333332

334-
if ($keyExist) {
335-
++$context[$key];
336-
} else {
337-
$context[$key] = 1;
338-
}
333+
++$context[$key];
339334

340335
return false;
341336
}

src/Symfony/Component/VarDumper/Caster/StubCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public static function castStub(Stub $c, array $a, Stub $stub, $isNested)
3131
$stub->attr = $c->attr;
3232

3333
if (Stub::TYPE_REF === $c->type && !$c->class && is_string($c->value) && !preg_match('//u', $c->value)) {
34-
$stub->type = self::TYPE_STRING;
35-
$stub->class = self::STRING_BINARY;
34+
$stub->type = Stub::TYPE_STRING;
35+
$stub->class = Stub::STRING_BINARY;
3636
}
3737

3838
return array();

0 commit comments

Comments
 (0)
0