-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge] Replace "weak-verbose" by "deprecations upper bound" mode #16937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,15 +19,29 @@ | |
class DeprecationErrorHandler | ||
{ | ||
const MODE_WEAK = 'weak'; | ||
const MODE_WEAK_VERBOSE = 'weak-verbose'; | ||
|
||
private static $isRegistered = false; | ||
|
||
public static function register($mode = false) | ||
/** | ||
* Registers and configures the deprecation handler. | ||
* | ||
* The following reporting modes are supported: | ||
* - use "weak" to hide the deprecation report but keep a global count; | ||
* - use "/some-regexp/" to stop the test suite whenever a deprecation | ||
* message matches the given regular expression; | ||
* - use a number to define the upper bound of allowed deprecations, | ||
* making the test suite fail whenever more notices are trigerred. | ||
* | ||
* @param int|string|false $mode The reporting mode. Defaults to not allowing any deprecations. | ||
*/ | ||
public static function register($mode = 0) | ||
{ | ||
if (self::$isRegistered) { | ||
return; | ||
} | ||
if (self::MODE_WEAK !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) { | ||
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will break the regex filtering feature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed... fixed! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this regex good for? |
||
} | ||
$deprecations = array( | ||
'unsilencedCount' => 0, | ||
'remainingCount' => 0, | ||
|
@@ -147,7 +161,7 @@ public static function register($mode = false) | |
if (!empty($notices)) { | ||
echo "\n"; | ||
} | ||
if (DeprecationErrorHandler::MODE_WEAK !== $mode && DeprecationErrorHandler::MODE_WEAK_VERBOSE !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) { | ||
if (DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { | ||
exit(1); | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What
false
does doesn't seem to be defined at all.