Skip to content

Commit 1fc66ff

Browse files
Merge branch '4.1'
* 4.1: Fix CS Allow reuse of Session between requests [MonologBridge] Re-add option option to ignore empty context and extra data [Lock] remove useless code [PhpUnitBridge] fix disabling DeprecationErrorHandler using phpunit.xml file Provide debug_backtrace with proper args [DI] fix infinite loop involving self-references in decorated services forward false label option to nested types [DI] fix dumping lazy services forward the invalid_message option in date types
2 parents 0d9154e + 76cf0ca commit 1fc66ff

File tree

22 files changed

+218
-173
lines changed

22 files changed

+218
-173
lines changed

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function __construct(array $options = array())
6161
'colors' => true,
6262
'multiline' => false,
6363
'level_name_format' => '%-9s',
64+
'ignore_empty_context_and_extra' => true,
6465
), $options);
6566

6667
if (class_exists(VarCloner::class)) {
@@ -101,20 +102,16 @@ public function format(array $record)
101102

102103
$levelColor = self::$levelColorMap[$record['level']];
103104

104-
if ($this->options['multiline']) {
105-
$separator = "\n";
105+
if (!$this->options['ignore_empty_context_and_extra'] || !empty($record['context'])) {
106+
$context = ($this->options['multiline'] ? "\n" : ' ').$this->dumpData($record['context']);
106107
} else {
107-
$separator = ' ';
108-
}
109-
110-
$context = $this->dumpData($record['context']);
111-
if ($context) {
112-
$context = $separator.$context;
108+
$context = '';
113109
}
114110

115-
$extra = $this->dumpData($record['extra']);
116-
if ($extra) {
117-
$extra = $separator.$extra;
111+
if (!$this->options['ignore_empty_context_and_extra'] || !empty($record['extra'])) {
112+
$extra = ($this->options['multiline'] ? "\n" : ' ').$this->dumpData($record['extra']);
113+
} else {
114+
$extra = '';
118115
}
119116

120117
$formatted = strtr($this->options['format'], array(

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
6464
$realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock();
6565
$realOutput->setVerbosity($verbosity);
6666
if ($realOutput->isDebug()) {
67-
$log = "16:21:54 $levelName [app] My info message\n[]\n[]\n";
67+
$log = "16:21:54 $levelName [app] My info message\n";
6868
} else {
69-
$log = "16:21:54 $levelName [app] My info message [] []\n";
69+
$log = "16:21:54 $levelName [app] My info message\n";
7070
}
7171
$realOutput
7272
->expects($isHandling ? $this->once() : $this->never())
@@ -149,7 +149,7 @@ public function testWritingAndFormatting()
149149
$output
150150
->expects($this->once())
151151
->method('write')
152-
->with("16:21:54 <fg=green>INFO </> <comment>[app]</> My info message\n[]\n[]\n")
152+
->with("16:21:54 <fg=green>INFO </> <comment>[app]</> My info message\n")
153153
;
154154

155155
$handler = new ConsoleHandler(null, false);

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public static function register($mode = 0)
5454
if (false === $mode) {
5555
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
5656
}
57-
if (DeprecationErrorHandler::MODE_WEAK !== $mode && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) {
57+
if (DeprecationErrorHandler::MODE_DISABLED !== $mode
58+
&& DeprecationErrorHandler::MODE_WEAK !== $mode
59+
&& DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode
60+
&& (!isset($mode[0]) || '/' !== $mode[0])
61+
) {
5862
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
5963
}
6064

@@ -108,7 +112,7 @@ public static function register($mode = 0)
108112
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
109113
}
110114

111-
$trace = debug_backtrace(true);
115+
$trace = debug_backtrace();
112116
$group = 'other';
113117
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
114118

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public function testFirewalls()
159159
null,
160160
null,
161161
array(
162-
'simple_form',
163-
'anonymous',
162+
'simple_form',
163+
'anonymous',
164164
),
165165
null,
166166
),

src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public function provideUndefinedMethodData()
6464
),
6565
array(
6666
array(
67-
'type' => 1,
68-
'message' => 'Call to undefined method class@anonymous::test()',
69-
'file' => '/home/possum/work/symfony/test.php',
70-
'line' => 11,
67+
'type' => 1,
68+
'message' => 'Call to undefined method class@anonymous::test()',
69+
'file' => '/home/possum/work/symfony/test.php',
70+
'line' => 11,
7171
),
7272
'Attempted to call an undefined method named "test" of class "class@anonymous".',
7373
),

src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ protected function processValue($value, $isRoot = false)
127127
return $value;
128128
}
129129
$this->currentDefinition = $value;
130+
} elseif ($this->currentDefinition === $value) {
131+
return $value;
130132
}
131133
$this->lazy = false;
132134

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function dump(array $options = array())
167167
}
168168
}
169169

170-
(new AnalyzeServiceReferencesPass(false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container);
170+
(new AnalyzeServiceReferencesPass(false))->process($this->container);
171171
$this->circularReferences = array();
172172
$this->singleUsePrivateIds = array();
173173
$checkedNodes = array();

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,22 @@ public function testServiceLocatorArgument()
15141514
$container->set('foo5', $foo5 = new \stdClass());
15151515
$this->assertSame($foo5, $locator->get('foo5'));
15161516
}
1517+
1518+
public function testDecoratedSelfReferenceInvolvingPrivateServices()
1519+
{
1520+
$container = new ContainerBuilder();
1521+
$container->register('foo', 'stdClass')
1522+
->setPublic(false)
1523+
->setProperty('bar', new Reference('foo'));
1524+
$container->register('baz', 'stdClass')
1525+
->setPublic(false)
1526+
->setProperty('inner', new Reference('baz.inner'))
1527+
->setDecoratedService('foo');
1528+
1529+
$container->compile();
1530+
1531+
$this->assertSame(array('service_container'), array_keys($container->getDefinitions()));
1532+
}
15171533
}
15181534

15191535
class FooClass

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ public function testResolvedBase64EnvParameters()
399399
$container->compile(true);
400400

401401
$expected = array(
402-
'env(foo)' => 'd29ybGQ=',
403-
'hello' => 'world',
402+
'env(foo)' => 'd29ybGQ=',
403+
'hello' => 'world',
404404
);
405405
$this->assertSame($expected, $container->getParameterBag()->all());
406406
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,11 @@ protected function getBar5Service()
127127
*/
128128
protected function getConnectionService()
129129
{
130-
$a = ($this->services['dispatcher'] ?? $this->getDispatcherService());
131-
132-
if (isset($this->services['connection'])) {
133-
return $this->services['connection'];
134-
}
135-
136-
$b = new \stdClass();
130+
$a = new \stdClass();
137131

138-
$this->services['connection'] = $instance = new \stdClass($a, $b);
132+
$this->services['connection'] = $instance = new \stdClass(($this->services['dispatcher'] ?? $this->getDispatcherService()), $a);
139133

140-
$b->logger = ($this->services['logger'] ?? $this->getLoggerService());
134+
$a->logger = ($this->services['logger'] ?? $this->getLoggerService());
141135

142136
return $instance;
143137
}
@@ -149,21 +143,15 @@ protected function getConnectionService()
149143
*/
150144
protected function getConnection2Service()
151145
{
152-
$a = ($this->services['dispatcher2'] ?? $this->getDispatcher2Service());
153-
154-
if (isset($this->services['connection2'])) {
155-
return $this->services['connection2'];
156-
}
157-
158-
$b = new \stdClass();
146+
$a = new \stdClass();
159147

160-
$this->services['connection2'] = $instance = new \stdClass($a, $b);
148+
$this->services['connection2'] = $instance = new \stdClass(($this->services['dispatcher2'] ?? $this->getDispatcher2Service()), $a);
161149

162-
$c = new \stdClass($instance);
150+
$b = new \stdClass($instance);
163151

164-
$c->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service()));
152+
$b->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service()));
165153

166-
$b->logger2 = $c;
154+
$a->logger2 = $b;
167155

168156
return $instance;
169157
}
@@ -373,12 +361,6 @@ protected function getManager2Service()
373361
*/
374362
protected function getSubscriberService()
375363
{
376-
$a = ($this->services['manager'] ?? $this->getManagerService());
377-
378-
if (isset($this->services['subscriber'])) {
379-
return $this->services['subscriber'];
380-
}
381-
382-
return $this->services['subscriber'] = new \stdClass($a);
364+
return $this->services['subscriber'] = new \stdClass(($this->services['manager'] ?? $this->getManagerService()));
383365
}
384366
}

0 commit comments

Comments
 (0)