8000 Merge branch '4.2' · symfony/symfony@d8af8b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8af8b6

Browse files
Merge branch '4.2'
* 4.2: Bump phpunit bridge cache id [appveyor] fix create-project phpunit Fix HttpKernel Debug requirement Fix heredoc use final annotation to allow mocking the class synchronise the form builder docblock Grammar fix in exception message fix tests forward the parse error to the calling code Avoid dots in generated class names. [Debug][DebugClassLoader] Match more cases for final, deprecated and internal classes / methods extends ensure compatibility with older PHPUnit mocks [Security] Do not mix usage of password_*() functions and sodium_*() ones
2 parents 14d458d + 61bf16c commit d8af8b6

File tree

24 files changed

+150
-78
lines changed

24 files changed

+150
-78
lines changed

phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/2155067dfc73e0e77dbc26f236af17e4df552de5
4+
// Cache-Id: https://github.com/symfony/symfony/commit/aad0c58
55

66
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
77
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";

src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ protected function tearDown()
4545
$this->form = null;
4646
}
4747

48-
protected function getBuilder($name = 'name')
48+
protected function getBuilder()
4949
{
50-
return new FormBuilder($name, null, $this->dispatcher, $this->factory);
50+
return new FormBuilder('name', null, $this->dispatcher, $this->factory);
5151
}
5252

53-
protected function getForm($name = 'name')
53+
protected function getForm()
5454
{
55-
return $this->getBuilder($name)
55+
return $this->getBuilder()
5656
->setData($this->collection)
5757
->addEventSubscriber(new MergeDoctrineCollectionListener())
5858
->getForm();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
9292
@mkdir($PHPUNIT_DIR, 0777, true);
9393
chdir($PHPUNIT_DIR);
9494
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
95-
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
95+
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old"));
96+
rename("phpunit-$PHPUNIT_VERSION", "phpunit-$PHPUNIT_VERSION.old");
97+
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old"));
9698
}
9799
passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
98100
chdir("phpunit-$PHPUNIT_VERSION");

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
1616
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1717
use Symfony\Component\DependencyInjection\Container;
18+
use Symfony\Component\Form\Form;
1819
use Symfony\Component\HttpFoundation\BinaryFileResponse;
1920
use Symfony\Component\HttpFoundation\File\File;
2021
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -487,7 +488,8 @@ public function testCreateNotFoundException()
487488

488489
public function testCreateForm()
489490
{
490-
$form = $this->getMockBuilder('Symfony\Component\Form\FormInterface')->getMock();
491+
$config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
492+
$form = new Form($config);
491493

492494
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
493495
$formFactory->expects($this->once())->method('create')->willReturn($form);

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
233233
// Detect annotations on the class
234234
if (false !== $doc = $refl->getDocComment()) {
235235
foreach (['final', 'deprecated', 'internal'] as $annotation) {
236-
if (false !== \strpos($doc, $annotation) && preg_match('#\n \* @'.$annotation.'(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $doc, $notice)) {
237-
self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
236+
if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
237+
self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
238238
}
239239
}
240240

@@ -366,7 +366,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class)
366366

367367
foreach (['final', 'internal'] as $annotation) {
368368
if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) {
369-
$message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : '';
369+
$message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : '';
370370
self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message];
371371
$finalOrInternal = true;
372372
}

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,31 @@ class_exis 57AE ts('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true
198198

199199
public function testExtendedFinalClass()
200200
{
201-
set_error_handler(function () { return false; });
202-
$e = error_reporting(0);
203-
trigger_error('', E_USER_NOTICE);
201+
$deprecations = [];
202+
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
203+
$e = error_reporting(E_USER_DEPRECATED);
204+
205+
require __DIR__.'/Fixtures/FinalClasses.php';
204206

205-
class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true);
207+
$i = 1;
208+
while(class_exists($finalClass = __NAMESPACE__.'\\Fixtures\\FinalClass'.$i++, false)) {
209+
spl_autoload_call($finalClass);
210+
class_exists('Test\\'.__NAMESPACE__.'\\Extends'.substr($finalClass, strrpos($finalClass, '\\') + 1), true);
211+
}
206212

207213
error_reporting($e);
208214
restore_error_handler();
209215

210-
$lastError = error_get_last();
211-
unset($lastError['file'], $lastError['line']);
212-
213-
$xError = [
214-
'type' => E_USER_DEPRECATED,
215-
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".',
216-
];
217-
218-
$this->assertSame($xError, $lastError);
216+
$this->assertSame([
217+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass1" class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass1".',
218+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass2" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass2".',
219+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass3" class is considered final comment with @@@ and ***. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass3".',
220+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass4" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass4".',
221+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass5" class is considered final multiline comment. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass5".',
222+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass6" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass6".',
223+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass7" class is considered final another multiline comment... It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass7".',
224+
'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass8" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass8".',
225+
], $deprecations);
219226
}
220227

221228
public function testExtendedFinalMethod()
@@ -383,8 +390,9 @@ public function findFile($class)
383390
eval('namespace Test\\'.__NAMESPACE__.'; class NonDeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\NonDeprecatedInterface {}');
384391
} elseif ('Test\\'.__NAMESPACE__.'\Float' === $class) {
385392
eval('namespace Test\\'.__NAMESPACE__.'; class Float {}');
386-
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsFinalClass' === $class) {
387-
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsFinalClass extends \\'.__NAMESPACE__.'\Fixtures\FinalClass {}');
393+
} elseif (0 === strpos($class, 'Test\\'.__NAMESPACE__.'\ExtendsFinalClass')) {
394+
$classShortName = substr($class, strrpos($class, '\\') + 1);
395+
eval('namespace Test\\'.__NAMESPACE__.'; class '.$classShortName.' extends \\'.__NAMESPACE__.'\Fixtures\\'.substr($classShortName, 7).' {}');
388396
} elseif ('Test\\'.__NAMESPACE__.'\ExtendsAnnotatedClass' === $class) {
389397
eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsAnnotatedClass extends \\'.__NAMESPACE__.'\Fixtures\AnnotatedClass {
390398
public function deprecatedMethod() { }

src/Symfony/Component/Debug/Tests/Fixtures/FinalClass.php

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace Symfony\Component\Debug\Tests\Fixtures;
4+
5+
/**
6+
* @final since version 3.3.
7+
*/
8+
class FinalClass1
9+
{
10+
// simple comment
11+
}
12+
13+
/**
14+
* @final
15+
*/
16+
class FinalClass2
17+
{
18+
// no comment
19+
}
20+
21+
/**
22+
* @final comment with @@@ and ***
23+
*
24+
* @author John Doe
25+
*/
26+
class FinalClass3
27+
{
28+
// with comment and a tag after
29+
}
30+
31+
/**
32+
* @final
33+
* @author John Doe
34+
*/
35+
class FinalClass4
36+
{
37+
// without comment and a tag after
38+
}
39+
40+
/**
41+
* @author John Doe
42+
*
43+
*
44+
* @final multiline
45+
* comment
46+
*/
47+
class FinalClass5
48+
{
49+
// with comment and a tag before
50+
}
51+
52+
/**
53+
* @author John Doe
54+
*
55+
* @final
56+
*/
57+
class FinalClass6
58+
{
59+
// without comment and a tag before
60+
}
61+
62+
/**
63+
* @author John Doe
64+
*
65+
* @final another
66+
*
67+
* multiline comment...
68+
*
69+
* @return string
70+
*/
71+
class FinalClass7
72+
{
73+
// with comment and a tag before and after
74+
}
75+
76+
/**
77+
* @author John Doe
78+
* @final
79+
* @return string
80+
*/
81+
class FinalClass8
82+
{
83+
// without comment and a tag before and after
84+
}

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private function parseFileToDOM($file)
395395
try {
396396
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
397397
} catch (\InvalidArgumentException $e) {
398-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
398+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s', $file, $e->getMessage()), $e->getCode(), $e);
399399
}
400400

401401
$this->validateExtensions($dom, $file);

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ protected function loadFile($file)
630630
try {
631631
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
632632
} catch (ParseException $e) {
633-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
633+
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
634634
}
635635

636636
return $this->validate($configuration, $file);

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testParseFile()
6868
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
6969
} catch (\Exception $e) {
7070
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
71-
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
71+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
7272

7373
$e = $e->getPrevious();
7474
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
@@ -82,7 +82,7 @@ public function testParseFile()
8282
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
8383
} catch (\Exception $e) {
8484
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
85-
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
85+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
8686

8787
$e = $e->getPrevious();
8888
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
@@ -428,7 +428,7 @@ public function testExtensions()
428428
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
429429
} catch (\Exception $e) {
430430
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
431-
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
431+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
432432

433433
$e = $e->getPrevious();
434434
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
@@ -465,7 +465,7 @@ public function testExtensionInPhar()
465465
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
466466
} catch (\Exception $e) {
467467
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
468-
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
468+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
469469

470470
$e = $e->getPrevious();
471471
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
@@ -516,7 +516,7 @@ public function testDocTypeIsNotAllowed()
516516
$this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type');
517517
} catch (\Exception $e) {
518518
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
519-
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
519+
$this->assertRegExp(sprintf('#^Unable to parse file ".+%s": .+.$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
520520

521521
$e = $e->getPrevious();
522522
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private function lexVarname()
212212
}
213213

214214
if (' ' === $this->data[$this->cursor] || "\t" === $this->data[$this->cursor]) {
215-
throw $this->createFormatException('Whitespace are not supported after the variable name');
215+
throw $this->createFormatException('Whitespace characters are not supported after the variable name');
216216
}
217217

218218
if ('=' !== $this->data[$this->cursor]) {

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getEnvDataWithFormatErrors()
3636
{
3737
$tests = [
3838
['FOO=BAR BAZ', "A value containing spaces must be surrounded by quotes in \".env\" at line 1.\n...FOO=BAR BAZ...\n ^ line 1 offset 11"],
39-
['FOO BAR=BAR', "Whitespace are not supported after the variable name in \".env\" at line 1.\n...FOO BAR=BAR...\n ^ line 1 offset 3"],
39+
['FOO BAR=BAR', "Whitespace characters are not supported after the variable name in \".env\" at line 1.\n...FOO BAR=BAR...\n ^ line 1 offset 3"],
4040
['FOO', "Missing = in the environment variable declaration in \".env\" at line 1.\n...FOO...\n ^ line 1 offset 3"],
4141
['FOO="foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO=\"foo...\n ^ line 1 offset 8"],
4242
['FOO=\'foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO='foo...\n ^ line 1 offset 8"],

src/Symfony/Component/Form/ResolvedFormType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function getOptionsResolver()
205205
* Override this method if you want to customize the builder class.
206206
*
207207
* @param string $name The name of the builder
208-
* @param string $dataClass The data class
208+
* @param string|null $dataClass The data class
209209
* @param FormFactoryInterface $factory The current form factory
210210
* @param array $options The builder options
211211
*

src/Symfony/Component/Form/Test/TypeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function setUp()
3232
parent::setUp();
3333

3434
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
35-
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
35+
$this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory);
3636
}
3737

3838
protected function tearDown()

src/Symfony/Component/Form/Tests/AbstractFormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ abstract protected function createForm();
5555
/**
5656
* @param string $name
5757
* @param EventDispatcherInterface $dispatcher
58-
* @param string $dataClass
58+
* @param string|null $dataClass
5959
* @param array $options
6060
*
6161
* @return FormBuilder

0 commit comments

Comments
 (0)
0