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

Skip to content

Commit e612b92

Browse files
committed
Merge branch '3.0'
2 parents 45e26ca + 06dd574 commit e612b92

File tree

21 files changed

+173
-61
lines changed

21 files changed

+173
-61
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,29 @@
1919
class DeprecationErrorHandler
2020
{
2121
const MODE_WEAK = 'weak';
22-
const MODE_WEAK_VERBOSE = 'weak-verbose';
2322

2423
private static $isRegistered = false;
2524

26-
public static function register($mode = false)
25+
/**
26+
* Registers and configures the deprecation handler.
27+
*
28+
* The following reporting modes are supported:
29+
* - use "weak" to hide the deprecation report but keep a global count;
30+
* - use "/some-regexp/" to stop the test suite whenever a deprecation
31+
* message matches the given regular expression;
32+
* - use a number to define the upper bound of allowed deprecations,
33+
* making the test suite fail whenever more notices are trigerred.
34+
*
35+
* @param int|string|false $mode The reporting mode. Defaults to not allowing any deprecations.
36+
*/
37+
public static function register($mode = 0)
2738
{
2839
if (self::$isRegistered) {
2940
return;
3041
}
42+
if (self::MODE_WEAK !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) {
43+
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
44+
}
3145
$deprecations = array(
3246
'unsilencedCount' => 0,
3347
'remainingCount' => 0,
@@ -147,7 +161,8 @@ public static function register($mode = false)
147161
if (!empty($notices)) {
148162
echo "\n";
149163
}
150-
if (self::MODE_WEAK !== $mode && self::MODE_WEAK_VERBOSE !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
164+
165+
if (DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
151166
exit(1);
152167
}
153168
});

src/Symfony/Bridge/PhpUnit/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ It comes with the following features:
1212
* display the stack trace of a deprecation on-demand.
1313

1414
By default any non-legacy-tagged or any non-@-silenced deprecation notices will
15-
make tests fail.
16-
This can be changed by setting the `SYMFONY_DEPRECATIONS_HELPER` environment
17-
variable to `weak` or `weak-verbose`. This will make the bridge ignore
18-
deprecation notices and is useful to projects that must use deprecated interfaces
19-
for backward compatibility reasons.
15+
make tests fail. This can be changed by setting the `SYMFONY_DEPRECATIONS_HELPER`
16+
environment variable to the maximum number of deprecations that are allowed to be
17+
triggered before making the test suite fail. Alternatively, setting it to `weak`
18+
will make the bridge ignore any deprecation notices and is useful to projects
19+
that must use deprecated interfaces for backward compatibility reasons.
2020

2121
A summary of deprecation notices is displayed at the end of the test suite:
2222

src/Symfony/Bundle/FrameworkBundle/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected function getScript($request)
185185
$code = <<<EOF
186186
<?php
187187
188-
error_reporting($errorReporting & ~E_USER_DEPRECATED);
188+
error_reporting($errorReporting);
189189
190190
if ('$autoloader') {
191191
require_once '$autoloader';

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
118118
$helper = new DescriptorHelper();
119119
$options['format'] = $input->getOption('format');
120120
$options['raw_text'] = $input->getOption('raw');
121-
$options['output'] = $output;
121+
$options['output'] = $io;
122122
$helper->describe($output, $object, $options);
123123

124124
if (!$input->getArgument('name') && $input->isInteractive()) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<tag name="data_collector" template="@WebProfiler/Collector/request.html.twig" id="request" priority="335" />
1616
</service>
1717

18+
<service id="data_collector.ajax" class="Symfony\Component\HttpKernel\DataCollector\AjaxDataCollector" public="false">
19+
<tag name="data_collector" template="@WebProfiler/Collector/ajax.html.twig" id="ajax" priority="315" />
20+
</service>
21+
1822
<service id="data_collector.exception" class="Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector" public="false">
1923
<tag name="data_collector" template="@WebProfiler/Collector/exception.html.twig" id="exception" priority="305" />
2024
</service>

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<argument type="service" id="event_dispatcher" />
1414
<argument type="service" id="controller_resolver" />
1515
<argument type="service" id="request_stack" />
16-
<argument>false</argument>
1716
</service>
1817

1918
<service id="request_stack" class="Symfony\Component\HttpFoundation\RequestStack" />

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
</div>
5454
{% else %}
5555
{# sort collected logs in groups #}
56-
{% set deprecation_logs, debug_logs, info_and_error_logs = [], [], [] %}
56+
{% set deprecation_logs, debug_logs, info_and_error_logs, silenced_logs = [], [], [], [] %}
5757
{% for log in collector.logs %}
5858
{% if log.context.level is defined and log.context.type is defined and log.context.type in [constant('E_DEPRECATED'), constant('E_USER_DEPRECATED')] %}
5959
{% set deprecation_logs = deprecation_logs|merge([log]) %}
60+
{% elseif log.context.scream is defined and log.context.scream == true %}
61+
{% set silenced_logs = silenced_logs|merge([log]) %}
6062
{% elseif log.priorityName == 'DEBUG' %}
6163
{% set debug_logs = debug_logs|merge([log]) %}
6264
{% else %}
@@ -108,6 +110,21 @@
108110
{% endif %}
109111
</div>
110112
</div>
113+
114+
<div class="tab">
115+
<h3 class="tab-title">Silenced Errors <span class="badge">{{ collector.countscreams|default(0) }}</span></h3>
116+
117+
<div class="tab-content">
118+
{% if silenced_logs is empty %}
119+
<div class="empty">
120+
<p>There are no log messages of this level.</p>
121+
</div>
122+
{% else %}
123+
{{ helper.render_table(silenced_logs) }}
124+
{% endif %}
125+
</div>
126+
</div>
127+
111128
</div>
112129
{% endif %}
113130
{% endblock %}

src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu
3333
{
3434
$validator = $question->getValidator();
3535
$question->setValidator(function ($value) use ($validator) {
36-
if (null !== $validator && is_callable($validator)) {
36+
if (null !== $validator) {
3737
$value = $validator($value);
3838
}
3939

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private function calculateNumberOfColumns()
384384
$columns[] = $this->getNumberOfColumns($row);
385385
}
386386

387-
return $this->numberOfColumns = max($columns);
387+
$this->numberOfColumns = max($columns);
388388
}
389389

390390
private function buildTableRows($rows)
@@ -539,7 +539,7 @@ private function getNumberOfColumns(array $row)
539539
*
540540
* @param array $row
541541
*
542-
* @return array()
542+
* @return array
543543
*/
544544
private function getRowColumns($row)
545545
{
@@ -555,11 +555,9 @@ private function getRowColumns($row)
555555
}
556556

557557
/**
558-
* Gets column width.
559-
*
560-
* @param int $column
558+
* Calculates columns widths.
561559
*
562-
* @return int
560+
* @param array $rows
563561
*/
564562
private function calculateColumnsWidth($rows)
565563
{
@@ -580,8 +578,6 @@ private function calculateColumnsWidth($rows)
580578
/**
581579
* Gets column width.
582580
*
583-
* @param int $column
584-
*
585581
* @return int
586582
*/
587583
private function getColumnSeparatorWidth()

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function getScript($request)
105105
$code = <<<EOF
106106
<?php
107107
108-
error_reporting($errorReporting & ~E_USER_DEPRECATED);
108+
error_reporting($errorReporting);
109109
110110
require_once '$requirePath';
111111

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
2222
*/
2323
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
2424
{
25+
private $errorNames = array(
26+
E_DEPRECATED => 'E_DEPRECATED',
27+
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
28+
E_NOTICE => 'E_NOTICE',
29+
E_USER_NOTICE => 'E_USER_NOTICE',
30+
E_STRICT => 'E_STRICT',
31+
E_WARNING => 'E_WARNING',
32+
E_USER_WARNING => 'E_USER_WARNING',
33+
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
34+
E_CORE_WARNING => 'E_CORE_WARNING',
35+
E_USER_ERROR => 'E_USER_ERROR',
36+
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
37+
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
38+
E_PARSE => 'E_PARSE',
39+
E_ERROR => 'E_ERROR',
40+
E_CORE_ERROR => 'E_CORE_ERROR',
41+
);
42+
2543
private $logger;
2644

2745
public function __construct($logger = null)
@@ -106,6 +124,9 @@ private function sanitizeLogs($logs)
106124
if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
107125
$errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true);
108126
$silenced = !($context['type'] & $context['level']);
127+
if (isset($this->errorNames[$context['type']])) {
128+
$context = array_merge(array('name' => $this->errorNames[$context['type']]), $context);
129+
}
109130

110131
if (isset($errorContextById[$errorId])) {
111132
if (isset($errorContextById[$errorId]['errorCount'])) {

src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,10 @@ public function getKernel()
153153
/**
154154
* Gets the Surrogate instance.
155155
*
156-
* @throws \LogicException
157-
*
158156
* @return SurrogateInterface A Surrogate instance
159157
*/
160158
public function getSurrogate()
161159
{
162-
if (!$this->surrogate instanceof Esi) {
163-
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
164-
}
165-
166160
return $this->surrogate;
167161
}
168162

src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function getCollectTestData()
7575
),
7676
array(
7777
1,
78-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
79-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
78+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
79+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
8080
0,
8181
1,
8282
),
@@ -86,7 +86,7 @@ public function getCollectTestData()
8686
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
8787
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
8888
),
89-
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
89+
array(array('message' => 'foo3', 'context' => array('name' => 'E_USER_WARNING', 'type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
9090
0,
9191
1,
9292
),

0 commit comments

Comments
 (0)