8000 Merge branch '2.7' into 2.8 · symfony/symfony@f5fefef · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit f5fefef

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Added 'default' color [HttpFoundation] Reload the session after regenerating its id [HttpFoundation] Add a test case to confirm a bug in session migration [Serializer] Fix ClassMetadata::sleep() [2.6] Static Code Analysis for Components and Bundles [Finder] Command::addAtIndex() fails with Command instance argument [DependencyInjection] Freeze also FrozenParameterBag::remove [Twig][Bridge] replaced `extends` with `use` in bootstrap_3_horizontal_layout.html.twig fix CS fixed CS Add a way to reset the singleton [Security] allow to use `method` in XML configs [Serializer] Fix Groups tests. Remove duplicate example Remove var not used due to returning early (introduced in 8982c32) [Serializer] Fix Groups PHPDoc Enhance hhvm test skip message fix for legacy asset() with EmptyVersionStrategy [Form] Added upgrade notes for #15061
2 parents 86e77eb + 175af7f commit f5fefef

File tree

53 files changed

+386
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+386
-72
lines changed

UPGRADE-2.7.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,57 @@ Security
665665
* `SwitchUserListener`
666666
* `AccessListener`
667667
* `RememberMeListener`
668+
669+
UPGRADE FROM 2.7.1 to 2.7.2
670+
===========================
671+
672+
Form
673+
----
674+
675+
* In order to fix a few regressions in the new `ChoiceList` implementation,
676+
a few details had to be changed compared to 2.7.
677+
678+
The legacy `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface`
679+
now does not extend the new `Symfony\Component\Form\ChoiceList\ChoiceListInterface`
680+
anymore. If you pass an implementation of the old interface in a context
681+
where the new interface is required, wrap the list into a
682+
`LegacyChoiceListAdapter`:
683+
684+
Before:
685+
686+
```php
687+
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
688+
689+
function doSomething(ChoiceListInterface $choiceList)
690+
{
691+
// ...
692+
}
693+
694+
doSomething($legacyList);
695+
```
696+
697+
After:
698+
699+
```php
700+
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
701+
use Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter;
702+
703+
function doSomething(ChoiceListInterface $choiceList)
704+
{
705+
// ...
706+
}
707+
708+
doSomething(new LegacyChoiceListAdapter($legacyList));
709+
```
710+
711+
The new `ChoiceListInterface` now has two additional methods
712+
`getStructuredValues()` and `getOriginalKeys()`. You should add these methods
713+
if you implement this interface. See their doc blocks and the implementation
714+
of the core choice lists for inspiration.
715+
716+
The method `ArrayKeyChoiceList::toArrayKey()` was marked as internal. This
717+
method was never supposed to be used outside the class.
718+
719+
The method `ChoiceListFactoryInterface::createView()` does not accept arrays
720+
and `Traversable` instances anymore for the `$groupBy` parameter. Pass a
721+
callable instead.

UPGRADE-3.0.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,6 @@ UPGRADE FROM 2.x to 3.0
300300
echo $form->getErrors(true, false);
301301
```
302302

303-
```php
304-
echo $form->getErrors(true, false);
305-
```
306-
307303
### FrameworkBundle
308304

309305
* The `config:debug`, `container:debug`, `router:debug`, `translation:debug`

src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testLogNonUtf8Array()
9191
'utf8' => 'foo',
9292
array(
9393
'nonutf8' => DbalLogger::BINARY_DATA_VALUE,
94-
)
94+
),
9595
)
9696
)
9797
;
@@ -100,7 +100,7 @@ public function testLogNonUtf8Array()
100100
'utf8' => 'foo',
101101
array(
102102
'nonutf8' => "\x7F\xFF",
103-
)
103+
),
104104
));
105105
}
106106

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,15 @@ private function getLegacyAssetUrl($path, $packageName = null, $absolute = false
108108
$v->setAccessible(true);
109109
$currentVersionStrategy = $v->getValue($package);
110110

111-
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
112-
$f->setAccessible(true);
113-
$format = $f->getValue($currentVersionStrategy);
114-
115-
$v->setValue($package, new StaticVersionStrategy($version, $format));
111+
if (property_exists($currentVersionStrategy, 'format')) {
112+
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
113+
$f->setAccessible(true);
114+
$format = $f->getValue($currentVersionStrategy);
115+
116+
$v->setValue($package, new StaticVersionStrategy($version, $format));
117+
} else {
118+
$v->setValue($package, new StaticVersionStrategy($version));
119+
}
116120
}
117121

118122
try {

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "bootstrap_3_layout.html.twig" %}
1+
{% use "bootstrap_3_layout.html.twig" %}
22

33
{% block form_start -%}
44
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %}

src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Asset\Package;
1616
use Symfony\Component\Asset\Packages;
1717
use Symfony\Component\Asset\PathPackage;
18+
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
1819
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
1920

2021
class AssetExtensionTest extends \PHPUnit_Framework_TestCase
@@ -41,6 +42,16 @@ public function testGetAssetUrlWithPackageSubClass()
4142
$this->assertEquals('/foo/me.png?version=42', $extension->getAssetUrl('me.png', null, false, 42));
4243
}
4344

45+
/**
46+
* @group legacy
47+
*/
48+
public function testGetAssetUrlWithEmptyVersionStrategy()
49+
{
50+
$extension = $this->createExtension(new PathPackage('foo', new EmptyVersionStrategy()));
51+
52+
$this->assertEquals('/foo/me.png?42', $extension->getAssetUrl('me.png', null, false, 42));
53+
}
54+
4455
private function createExtension(Package $package)
4556
{
4657
$foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
121121
$extractor = $this->getContainer()->get('translation.extractor');
122122
$extractor->setPrefix($input->getOption('prefix'));
123123
foreach ($transPaths as $path) {
124-
$path = $path.'views';
124+
$path .= 'views';
125125
if (is_dir($path)) {
126126
$extractor->extract($path, $extractedCatalogue);
127127
}
@@ -132,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
132132
$output->text('Loading translation files');
133133
$loader = $this->getContainer()->get('translation.loader');
134134
foreach ($transPaths as $path) {
135-
$path = $path.'translations';
135+
$path .= 'translations';
136136
if (is_dir($path)) {
137137
$loader->loadMessages($path, $currentCatalogue);
138138
}
@@ -183,7 +183,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
183183

184184
$bundleTransPath = false;
185185
foreach ($transPaths as $path) {
186-
$path = $path.'translations';
186+
$path .= 'translations';
187187
if (is_dir($path)) {
188188
$bundleTransPath = $path;
189189
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
274274
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
275275

276276
if ($definition->getFile()) {
277-
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
277+
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ?: '-');
278278
}
279279

280280
if ($definition->getFactoryClass(false)) {

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,22 +670,22 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
670670
if (class_exists('Symfony\Component\Validator\Validation')) {
671671
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
672672

673-
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
673+
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
674674
}
675675
if (class_exists('Symfony\Component\Form\Form')) {
676676
$r = new \ReflectionClass('Symfony\Component\Form\Form');
677677

678-
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
678+
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
679679
}
680680
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
681681
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
682682

683-
$dirs[] = dirname($r->getFilename()).'/../Resources/translations';
683+
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
684684
}
685685
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
686686
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
687687
$reflection = new \ReflectionClass($class);
688-
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) {
688+
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
689689
$dirs[] = $dir;
690690
}
691691
if (is_dir($dir = sprintf($overridePath, $bundle))) {
@@ -807,7 +807,7 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
807807
$bundles = $container->getParameter('kernel.bundles');
808808
foreach ($bundles as $bundle) {
809809
$reflection = new \ReflectionClass($bundle);
810-
$dirname = dirname($reflection->getFilename());
810+
$dirname = dirname($reflection->getFileName());
811811

812812
if (is_file($file = $dirname.'/Resources/config/validation.xml')) {
813813
$files[0][] = realpath($file);
@@ -827,7 +827,15 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
827827
$files[1][] = $file->getRealpath();
828828
}
829829

830+
<<<<<<< HEAD
830831
$container->addResource(new DirectoryResource($dir));
832+
=======
833+
foreach ($container->getParameter('kernel.bundles') as $bundle) {
834+
$reflection = new \ReflectionClass($bundle);
835+
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.yml')) {
836+
$files[] = realpath($file);
837+
$container->addResource(new FileResource($file));
838+
>>>>>>> 2.6
831839
}
832840
}
833841

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
{
2525
$this->fs = new Filesystem();
2626
$this->kernel = new TestAppKernel('test', true);
27-
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_');
27+
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true);
2828
$this->kernel->setRootDir($this->rootDir);
2929
$this->fs->mkdir($this->rootDir);
3030
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testDebugInvalidDirectory()
9595
protected function setUp()
9696
{
9797
$this->fs = new Filesystem();
98-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation');
98+
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true);
9999
$this->fs->mkdir($this->translationDir.'/Resources/translations');
100100
$this->fs->mkdir($this->translationDir.'/Resources/views');
101101
}

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getDescribeContainerParameterTestData()
112112
{
113113
$data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter());
114114

115-
array_push($data[0], array('parameter' => 'database_name'));
115+
$data[0][] = array('parameter' => 'database_name');
116116

117117
return $data;
118118
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Expand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private function addAccessControlSection(ArrayNodeDefinition $rootNode)
162162
->cannotBeOverwritten()
163163
->prototype('array')
164164
->fixXmlConfig('ip')
165+
->fixXmlConfig('method')
165166
->children()
166167
->scalarNode('requires_channel')->defaultNull()->end()
167168
->scalarNode('path')
@@ -300,7 +301,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
300301
})
301302
->end()
302303
->children()
303-
->scalarNode('secret')->defaultValue(uniqid())->end()
304+
->scalarNode('secret')->defaultValue(uniqid('', true))->end()
304305
->end()
305306
->end()
306307
->arrayNode('switch_user')

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function addConfiguration(NodeDefinition $node)
5454
->useAttributeAsKey('name')
5555
->prototype('array')
5656
->children()
57-
->scalarNode('password')->defaultValue(uniqid())->end()
57+
->scalarNode('password')->defaultValue(uniqid('', true))->end()
5858
->arrayNode('roles')
5959
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
6060
->prototype('scalar')->end()

src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1919

2020
/**
21-
* Lists twig functions, filters, globals and tests present in the current project
21+
* Lists twig functions, filters, globals and tests present in the current project.
2222
*
2323
* @author Jordi Boggiano <j.boggiano@seld.be>
2424
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function load(array $configs, ContainerBuilder $container)
8888
$container->addResource(new FileExistenceResource($dir));
8989

9090
$reflection = new \ReflectionClass($class);
91-
$dir = dirname($reflection->getFilename()).'/Resources/views';
91+
$dir = dirname($reflection->getFileName()).'/Resources/views';
9292
if (is_dir($dir)) {
9393
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
9494
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,8 @@ public function testTwigLoaderPaths($format)
190190
$def = $container->getDefinition('twig.loader.filesystem');
191191
$paths = array();
192192
foreach ($def->getMethodCalls() as $call) {
193-
if ('addPath' === $call[0]) {
194-
if (false === strpos($call[1][0], 'Form')) {
195-
$paths[] = $call[1];
196-
}
193+
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {
194+
$paths[] = $call[1];
197195
}
198196
}
199197

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public function __construct($name, $value, $expires = null, $path = null, $domai
8282

8383
$this->expires = $timestampAsDateTime->getTimestamp();
8484
}
85-
8685
}
8786

8887
/**

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static function phpize($value)
196196
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
197197
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
198198
$raw = $value;
199-
$cast = intval($value);
199+
$cast = (int) $value;
200200

201201
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
202202
case 'true' === $lowercaseValue:

src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2929
'magenta' => array('set' => 35, 'unset' => 39),
3030
'cyan' => array('set' => 36, 'unset' => 39),
3131
'white' => array('set' => 37, 'unset' => 39),
32+
'default' => array('set' => 39, 'unset' => 39),
3233
);
3334
private static $availableBackgroundColors = array(
3435
'black' => array('set' => 40, 'unset' => 49),
@@ -39,6 +40,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
3940
'magenta' => array('set' => 45, 'unset' => 49),
4041
'cyan' => array('set' => 46, 'unset' => 49),
4142
'white' => array('set' => 47, 'unset' => 49),
43+
'default' => array('set' => 49, 'unset' => 49),
4244
);
4345
private static $availableOptions = array(
4446
'bold' => array('set' => 1, 'unset' => 22),

src/Symfony/Component/Console/Helper/DebugFormatterHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class DebugFormatterHelper extends Helper
2222
{
23-
private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white');
23+
private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
2424
private $started = array();
2525
private $count = -1;
2626

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public function setCurrent($step)
374374
}
375375

376376
/**
377-
* Sets whether to overwrite the progressbar, false for new line
377+
* Sets whether to overwrite the progressbar, false for new line.
378378
*
379379
* @param bool $overwrite
380380
*/
@@ -401,8 +401,8 @@ public function setProgress($step)
401401
$this->max = $step;
402402
}
403403

404-
$prevPeriod = intval($this->step / $this->redrawFreq);
405-
$currPeriod = intval($step / $this->redrawFreq);
404+
$prevPeriod = (int) ($this->step / $this->redrawFreq);
405+
$currPeriod = (int) ($step / $this->redrawFreq);
406406
$this->step = $step;
407407
$this->percent = $this->max ? (float) $this->step / $this->max : 0;
408408
if ($prevPeriod !== $currPeriod || $this->max === $step) {

src/Symfony/Component/Console/Question/ChoiceQuestion.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ private function getDefaultValidator()
161161
if (false === $result) {
162162
throw new \InvalidArgumentException(sprintf($errorMessage, $value));
163163
}
164-
array_push($multiselectChoices, (string) $result);
164+
165+
$multiselectChoices[] = $choices[(string) $result];
165166
}
166167

167168
if ($multiselect) {

0 commit comments

Comments
 (0)
0