Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd8f0b3

Browse files
committed
Introduce weak vendors mode
Deprecations coming from the vendors are segregated from otherdeprecations. A new mode is introduced, in which deprecations comingfrom the vendors are not taken into account when deciding to exit withan error code.
1 parenta736458 commitbd8f0b3

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class DeprecationErrorHandler
2020
{
2121
constMODE_WEAK ='weak';
22+
constMODE_WEAK_VENDORS ='weak_vendors';
2223
constMODE_DISABLED ='disabled';
2324

2425
privatestatic$isRegistered =false;
@@ -28,6 +29,7 @@ class DeprecationErrorHandler
2829
*
2930
* The following reporting modes are supported:
3031
* - use "weak" to hide the deprecation report but keep a global count;
32+
* - use "weak_vendors" to act as "weak" but only for vendors;
3133
* - use "/some-regexp/" to stop the test suite whenever a deprecation
3234
* message matches the given regular expression;
3335
* - use a number to define the upper bound of allowed deprecations,
@@ -50,7 +52,10 @@ public static function register($mode = 0)
5052
if (false ===$mode) {
5153
$mode =getenv('SYMFONY_DEPRECATIONS_HELPER');
5254
}
53-
if (DeprecationErrorHandler::MODE_WEAK !==$mode && (!isset($mode[0]) ||'/' !==$mode[0])) {
55+
if (!in_array($mode,array(
56+
DeprecationErrorHandler::MODE_WEAK,
57+
DeprecationErrorHandler::MODE_WEAK_VENDORS
58+
)) && (!isset($mode[0]) ||'/' !==$mode[0])) {
5459
$mode =preg_match('/^[1-9][0-9]*$/',$mode) ? (int)$mode :0;
5560
}
5661

@@ -67,6 +72,12 @@ public static function register($mode = 0)
6772
'legacy' =>array(),
6873
'other' =>array(),
6974
);
75+
if (DeprecationErrorHandler::MODE_WEAK_VENDORS ===$mode) {
76+
$deprecations +=array(
77+
'remaining vendorCount' =>0,
78+
'remaining vendor' =>array(),
79+
);
80+
}
7081
$deprecationHandler =function ($type,$msg,$file,$line,$context)use (&$deprecations,$getMode) {
7182
$mode =$getMode();
7283
if ((E_USER_DEPRECATED !==$type &&E_DEPRECATED !==$type) || DeprecationErrorHandler::MODE_DISABLED ===$mode) {
@@ -76,6 +87,10 @@ public static function register($mode = 0)
7687
$trace =debug_backtrace(true);
7788
$group ='other';
7889

90+
$isVendor = (strpos($file,'/vendor/') !==false);
91+
$isWeak = DeprecationErrorHandler::MODE_WEAK ===$mode ||
92+
DeprecationErrorHandler::MODE_WEAK_VENDORS ===$mode &&$isVendor;
93+
7994
$i =count($trace);
8095
while (1 <$i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' ===$trace[$i]['class'] ||0 ===strpos($trace[$i]['class'],'PHPUnit_')))) {
8196
// No-op
@@ -94,6 +109,8 @@ public static function register($mode = 0)
94109
||in_array('legacy', \PHPUnit_Util_Test::getGroups($class,$method),true)
95110
) {
96111
$group ='legacy';
112+
}elseif (DeprecationErrorHandler::MODE_WEAK_VENDORS ===$mode &&$isVendor) {
113+
$group ='remaining vendor';
97114
}else {
98115
$group ='remaining';
99116
}
@@ -112,13 +129,13 @@ public static function register($mode = 0)
112129

113130
exit(1);
114131
}
115-
if ('legacy' !==$group &&DeprecationErrorHandler::MODE_WEAK !==$mode) {
132+
if ('legacy' !==$group &&!$isWeak) {
116133
$ref = &$deprecations[$group][$msg]['count'];
117134
++$ref;
118135
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
119136
++$ref;
120137
}
121-
}elseif (DeprecationErrorHandler::MODE_WEAK !==$mode) {
138+
}elseif (!$isWeak) {
122139
$ref = &$deprecations[$group][$msg]['count'];
123140
++$ref;
124141
}
@@ -162,9 +179,15 @@ public static function register($mode = 0)
162179
return$b['count'] -$a['count'];
163180
};
164181

165-
foreach (array('unsilenced','remaining','legacy','other')as$group) {
182+
$groups =array('unsilenced','remaining');
183+
if (DeprecationErrorHandler::MODE_WEAK_VENDORS ===$mode) {
184+
$groups[] ='remaining vendor';
185+
}
186+
array_push($groups,'legacy','other');
187+
188+
foreach ($groupsas$group) {
166189
if ($deprecations[$group.'Count']) {
167-
echo"\n",$colorize(sprintf('%s deprecation notices (%d)',ucfirst($group),$deprecations[$group.'Count']),'legacy' !==$group),"\n";
190+
echo"\n",$colorize(sprintf('%s deprecation notices (%d)',ucfirst($group),$deprecations[$group.'Count']),!in_array($group,array('legacy','remaining vendor'),true)),"\n";
168191

169192
uasort($deprecations[$group],$cmp);
170193

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp