Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e81aa76

Browse files
Merge branch '4.0'
* 4.0: [YAML] Issue #26065: leading spaces in YAML multi-line string literals [Bridge\PhpUnit] Exit as late as possible [Bridge\PhpUnit] Cleanup BC layer [PhpBridge] add PHPUnit 7 support to SymfonyTestsListener [Lock] Log already-locked errors as "notice" instead of "warning" add context to serialize and deserialize Update Repository Symlink Helper isCsrfTokenValid() replace string by ?string Document explicitly that dotfiles and vcs files are ignored by default [HttpKernel] don't try to wire Request argument with controller.service_arguments Make kernel build time optionally deterministic Use 0 for unlimited expiry [Routing] fix typo Bump default PHPUnit version from 6.3 to 6.5 do not mock the container builder in tests [Cache][WebProfiler] fix collecting cache stats with sub-requests + allow clearing calls
2 parents 3ef76bf + 6e34963 commit e81aa76

File tree

30 files changed

+456
-316
lines changed

30 files changed

+456
-316
lines changed

link

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ if (!is_dir("$argv[1]/vendor/symfony")) {
3737
$sfPackages = array('symfony/symfony' => __DIR__);
3838

3939
$filesystem = new Filesystem();
40-
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
40+
$braces = array('Bundle', 'Bridge', 'Component', 'Component/Security');
41+
$directories = call_user_func_array('array_merge', array_values(array_map(function ($part) {
42+
return glob(__DIR__.'/src/Symfony/'.$part.'/*', GLOB_ONLYDIR | GLOB_NOSORT);
43+
}, $braces)));
44+
45+
foreach ($directories as $dir) {
4146
if ($filesystem->exists($composer = "$dir/composer.json")) {
4247
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir;
4348
}

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,41 +214,62 @@ public static function register($mode = 0)
214214
return $b['count'] - $a['count'];
215215
};
216216

217-
$groups = array('unsilenced', 'remaining');
218-
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
219-
$groups[] = 'remaining vendor';
220-
}
221-
array_push($groups, 'legacy', 'other');
217+
$displayDeprecations = function ($deprecations) use ($colorize, $cmp) {
218+
$groups = array('unsilenced', 'remaining');
219+
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
220+
$groups[] = 'remaining vendor';
221+
}
222+
array_push($groups, 'legacy', 'other');
222223

223-
foreach ($groups as $group) {
224-
if ($deprecations[$group.'Count']) {
225-
echo "\n", $colorize(
226-
sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']),
227-
'legacy' !== $group && 'remaining vendor' !== $group
228-
), "\n";
224+
foreach ($groups as $group) {
225+
if ($deprecations[$group.'Count']) {
226+
echo "\n", $colorize(
227+
sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']),
228+
'legacy' !== $group && 'remaining vendor' !== $group
229+
), "\n";
229230

230-
uasort($deprecations[$group], $cmp);
231+
uasort($deprecations[$group], $cmp);
231232

232-
foreach ($deprecations[$group] as $msg => $notices) {
233-
echo "\n ", $notices['count'], 'x: ', $msg, "\n";
233+
foreach ($deprecations[$group] as $msg => $notices) {
234+
echo "\n ", $notices['count'], 'x: ', $msg, "\n";
234235

235-
arsort($notices);
236+
arsort($notices);
236237

237-
foreach ($notices as $method => $count) {
238-
if ('count' !== $method) {
239-
echo ' ', $count, 'x in ', preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method), "\n";
238+
foreach ($notices as $method => $count) {
239+
if ('count' !== $method) {
240+
echo ' ', $count, 'x in ', preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method), "\n";
241+
}
240242
}
241243
}
242244
}
243245
}
244-
}
245-
if (!empty($notices)) {
246-
echo "\n";
247-
}
246+
if (!empty($notices)) {
247+
echo "\n";
248+
}
249+
};
248250

249-
if (DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
250-
exit(1);
251+
$displayDeprecations($deprecations);
252+
253+
// store failing status
254+
$isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
255+
256+
// reset deprecations array
257+
foreach ($deprecations as $group => $arrayOrInt) {
258+
$deprecations[$group] = is_int($arrayOrInt) ? 0 : array();
251259
}
260+
261+
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
262+
foreach ($deprecations as $group => $arrayOrInt) {
263+
if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) {
264+
echo "Shutdown-time deprecations:\n";
265+
break;
266+
}
267+
}
268+
$displayDeprecations($deprecations);
269+
if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
270+
exit(1);
271+
}
272+
});
252273
});
253274
}
254275
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListener.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @internal
2020
*/
21-
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
21+
class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
2222
{
2323
private $trait;
2424

@@ -34,26 +34,26 @@ public function globalListenerDisabled()
3434

3535
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
3636
{
37-
return $this->trait->startTestSuite($suite);
37+
$this->trait->startTestSuite($suite);
3838
}
3939

4040
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
4141
{
42-
return $this->trait->addSkippedTest($test, $e, $time);
42+
$this->trait->addSkippedTest($test, $e, $time);
4343
}
4444

4545
public function startTest(\PHPUnit_Framework_Test $test)
4646
{
47-
return $this->trait->startTest($test);
47+
$this->trait->startTest($test);
4848
}
4949

5050
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
5151
{
52-
return $this->trait->addWarning($test, $e, $time);
52+
$this->trait->addWarning($test, $e, $time);
5353
}
5454

5555
public function endTest(\PHPUnit_Framework_Test $test, $time)
5656
{
57-
return $this->trait->endTest($test, $time);
57+
$this->trait->endTest($test, $time);
5858
}
5959
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\Framework\BaseTestListener;
15+
use PHPUnit\Framework\Test;
16+
use PHPUnit\Framework\TestSuite;
17+
use PHPUnit\Framework\Warning;
18+
19+
/**
20+
* Collects and replays skipped tests.
21+
*
22+
* @author Nicolas Grekas <[email protected]>
23+
*
24+
* @internal
25+
*/
26+
class SymfonyTestsListenerForV6 extends BaseTestListener
27+
{
28+
private $trait;
29+
30+
public function __construct(array $mockedNamespaces = array())
31+
{
32+
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
33+
}
34+
35+
public function globalListenerDisabled()
36+
{
37+
$this->trait->globalListenerDisabled();
38+
}
39+
40+
public function startTestSuite(TestSuite $suite)
41+
{
42+
$this->trait->startTestSuite($suite);
43+
}
44+
45+
public function addSkippedTest(Test $test, \Exception $e, $time)
46+
{
47+
$this->trait->addSkippedTest($test, $e, $time);
48+
}
49+
50+
public function startTest(Test $test)
51+
{
52+
$this->trait->startTest($test);
53+
}
54+
55+
public function addWarning(Test $test, Warning $e, $time)
56+
{
57+
$this->trait->addWarning($test, $e, $time);
58+
}
59+
60+
public function endTest(Test $test, $time)
61+
{
62+
$this->trait->endTest($test, $time);
63+
}
64+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit;
13+
14+
use PHPUnit\Framework\Test;
15+
use PHPUnit\Framework\TestListener;
16+
use PHPUnit\Framework\TestListenerDefaultImplementation;
17+
use PHPUnit\Framework\TestSuite;
18+
use PHPUnit\Framework\Warning;
19+
20+
/**
21+
* Collects and replays skipped tests.
22+
*
23+
* @author Nicolas Grekas <[email protected]>
24+
*
25+
* @internal
26+
*/
27+
class SymfonyTestsListenerForV7 implements TestListener
28+
{
29+
use TestListenerDefaultImplementation;
30+
31+
private $trait;
32+
33+
public function __construct(array $mockedNamespaces = array())
34+
{
35+
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
36+
}
37+
38+
public function globalListenerDisabled()
39+
{
40+
$this->trait->globalListenerDisabled();
41+
}
42+
43+
public function startTestSuite(TestSuite $suite): void
44+
{
45+
$this->trait->startTestSuite($suite);
46+
}
47+
48+
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
49+
{
50+
$this->trait->addSkippedTest($test, $t, $time);
51+
}
52+
53+
public function startTest(Test $test): void
54+
{
55+
$this->trait->startTest($test);
56+
}
57+
58+
public function addWarning(Test $test, Warning $e, float $time): void
59+
{
60+
$this->trait->addWarning($test, $e, $time);
61+
}
62+
63+
public function endTest(Test $test, float $time): void
64+
{
65+
$this->trait->endTest($test, $time);
66+
}
67+
}

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,10 @@
1111

1212
namespace Symfony\Bridge\PhpUnit;
1313

14-
use PHPUnit\Framework\BaseTestListener;
15-
use PHPUnit\Framework\Test;
16-
use PHPUnit\Framework\TestSuite;
17-
use PHPUnit\Framework\Warning;
18-
1914
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
20-
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
21-
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
22-
// gets defined without executing the code before it and so the definition is not properly conditional)
15+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
16+
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
17+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
2318
} else {
24-
/**
25-
* Collects and replays skipped tests.
26-
*
27-
* @author Nicolas Grekas <[email protected]>
28-
*
29-
* @final
30-
*/
31-
class SymfonyTestsListener extends BaseTestListener
32-
{
33-
private $trait;
34-
35-
public function __construct(array $mockedNamespaces = array())
36-
{
37-
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
38-
}
39-
40-
public function globalListenerDisabled()
41-
{
42-
$this->trait->globalListenerDisabled();
43-
}
44-
45-
public function startTestSuite(TestSuite $suite)
46-
{
47-
return $this->trait->startTestSuite($suite);
48-
}
49-
50-
public function addSkippedTest(Test $test, \Exception $e, $time)
51-
{
52-
return $this->trait->addSkippedTest($test, $e, $time);
53-
}
54-
55-
public function startTest(Test $test)
56-
{
57-
return $this->trait->startTest($test);
58-
}
59-
60-
public function addWarning(Test $test, Warning $e, $time)
61-
{
62-
return $this->trait->addWarning($test, $e, $time);
63-
}
64-
65-
public function endTest(Test $test, $time)
66-
{
67-
return $this->trait->endTest($test, $time);
68-
}
69-
}
19+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
7020
}

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ $foo = new FooTestCase();
5959
$foo->testLegacyFoo();
6060
$foo->testNonLegacyBar();
6161

62+
register_shutdown_function(function () {
63+
exit('I get precedence over any exit statements inside the deprecation error handler.');
64+
});
65+
6266
?>
6367
--EXPECTF--
6468
Unsilenced deprecation notices (3)
@@ -80,3 +84,4 @@ Other deprecation notices (1)
8084

8185
1x: root deprecation
8286

87+
I get precedence over any exit statements inside the deprecation error handler.

0 commit comments

Comments
 (0)