Skip to content

Commit 6e34963

Browse files
Merge branch '3.4' into 4.0
* 3.4: [YAML] Issue symfony#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 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 963b675 + 8ed107d commit 6e34963

File tree

29 files changed

+453
-313
lines changed

29 files changed

+453
-313
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
@@ -215,41 +215,62 @@ public static function register($mode = 0)
215215
return $b['count'] - $a['count'];
216216
};
217217

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

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";
225+
foreach ($groups as $group) {
226+
if ($deprecations[$group.'Count']) {
227+
echo "\n", $colorize(
228+
sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']),
229+
'legacy' !== $group && 'remaining vendor' !== $group
230+
), "\n";
230231

231-
uasort($deprecations[$group], $cmp);
232+
uasort($deprecations[$group], $cmp);
232233

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

236-
arsort($notices);
237+
arsort($notices);
237238

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

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

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)