Skip to content

Commit 87adf25

Browse files
Merge branch '4.0'
* 4.0: Have weak_vendors ignore deprecations from outside [HttpFoundation] fixed return type of method HeaderBag::get [HttpFoundation] Added "resource" type on Request::create docblock [Console] Fix using finally where the catch can also fail [Process] Skip environment variables with false value in Process Revert "bug symfony#25789 Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)" Formatting fix in upgrade 3.0 document don't split lines on carriage returns when dumping trim spaces from unquoted scalar values Revert "bug symfony#25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)" [DI] compilation perf tweak [Validator] Conflict with egulias/email-validator 2.0 [Validator] add missing parent isset and add test
2 parents f456b0f + ee04e5b commit 87adf25

File tree

23 files changed

+156
-66
lines changed

23 files changed

+156
-66
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ public static function register($mode = 0)
7575
}
7676
}
7777
}
78-
$path = realpath($path) ?: $path;
78+
$realPath = realpath($path);
79+
if (false === $realPath && '-' !== $path && 'Standard input code' !== $path) {
80+
return true;
81+
}
7982
foreach ($vendors as $vendor) {
80-
if (0 === strpos($path, $vendor) && false !== strpbrk(substr($path, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
83+
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
8184
return true;
8285
}
8386
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
@trigger_error('I come from… afar! :D', E_USER_DEPRECATED);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$phar = new Phar(__DIR__.DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar');
4+
$phar->buildFromDirectory(__DIR__.DIRECTORY_SEPARATOR.'deprecation');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
3+
--FILE--
4+
<?php
5+
6+
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
7+
putenv('ANSICON');
8+
putenv('ConEmuANSI');
9+
putenv('TERM');
10+
11+
$vendor = __DIR__;
12+
while (!file_exists($vendor.'/vendor')) {
13+
$vendor = dirname($vendor);
14+
}
15+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
16+
require PHPUNIT_COMPOSER_INSTALL;
17+
require_once __DIR__.'/../../bootstrap.php';
18+
eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
19+
20+
?>
21+
--EXPECTF--
22+
23+
Other deprecation notices (1)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
3+
The phar can be regenerated by running php src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php
4+
--FILE--
5+
<?php
6+
7+
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
8+
putenv('ANSICON');
9+
putenv('ConEmuANSI');
10+
putenv('TERM');
11+
12+
$vendor = __DIR__;
13+
while (!file_exists($vendor.'/vendor')) {
14+
$vendor = dirname($vendor);
15+
}
16+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
17+
require PHPUNIT_COMPOSER_INSTALL;
18+
require_once __DIR__.'/../../bootstrap.php';
19+
\Phar::loadPhar(__DIR__.'/deprecation.phar', 'deprecation.phar');
20+
include 'phar://deprecation.phar/deprecation.php';
21+
22+
?>
23+
--EXPECTF--
24+
25+
Other deprecation notices (1)

src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ public function canBeEnabled()
283283
->beforeNormalization()
284284
->ifArray()
285285
->then(function ($v) {
286-
if (!isset($v['enabled'])) {
287-
$v['enabled'] = !empty($v);
288-
}
286+
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
289287

290288
return $v;
291289
})

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,6 @@ public function testCanBeDisabled()
208208
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
209209
}
210210

211-
public function testEnableableNodeIsDisabledForEmptyConfigurationWhenNormalized()
212-
{
213-
$config = array();
214-
215-
$node = new ArrayNodeDefinition('root');
216-
$node->canBeEnabled();
217-
218-
$this->assertEquals(
219-
array('enabled' => false),
220-
$node->getNode()->normalize($config),
221-
'An enableable node is disabled by default'
222-
);
223-
}
224-
225211
public function testIgnoreExtraKeys()
226212
{
227213
$node = new ArrayNodeDefinition('root');
@@ -297,7 +283,6 @@ public function getEnableableNodeFixtures()
297283
array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'),
298284
array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'),
299285
array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'),
300-
array(array('enabled' => false, 'foo' => 'bar'), array(), 'enableable node is disabled by default'),
301286
);
302287
}
303288

src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Config\Tests\Definition\Builder;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Config\Definition\Processor;
1615
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
1716
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1817

@@ -133,24 +132,6 @@ public function testDefinitionExampleGetsTransferredToNode()
133132
$this->assertEquals('example', $children['child']->getExample());
134133
}
135134

136-
public function testRootNodeThatCanBeEnabledIsDisabledByDefault()
137-
{
138-
$builder = new TreeBuilder();
139-
140-
$builder->root('test')
141-
->canBeEnabled();
142-
143-
$tree = $builder->buildTree();
144-
$children = $tree->getChildren();
145-
146-
$this->assertFalse($children['enabled']->getDefaultValue());
147-
148-
$processor = new Processor();
149-
$result = $processor->process($tree, array());
150-
151-
$this->assertEquals(array('enabled' => false), $result);
152-
}
153-
154135
public function testDefaultPathSeparatorIsDot()
155136
{
156137
$builder = new TreeBuilder();

src/Symfony/Component/Console/Application.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
874874
}
875875

876876
$event = new ConsoleCommandEvent($command, $input, $output);
877+
$e = null;
877878

878879
try {
879880
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
@@ -886,13 +887,18 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
886887
} catch (\Throwable $e) {
887888
$event = new ConsoleErrorEvent($input, $output, $e, $command);
888889
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
890+
$e = $event->getError();
889891

890-
if (0 !== $exitCode = $event->getExitCode()) {
891-
throw $event->getError();
892+
if (0 === $exitCode = $event->getExitCode()) {
893+
$e = null;
892894
}
893-
} finally {
894-
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
895-
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
895+
}
896+
897+
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
898+
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
899+
900+
if (null !== $e) {
901+
throw $e;
896902
}
897903

898904
return $event->getExitCode();

0 commit comments

Comments
 (0)