[PhpUnitBridge] fixes

This commit is contained in:
Nicolas Grekas 2019-04-12 15:46:34 +02:00
parent a36fbe3d38
commit b11585e31f
2 changed files with 9 additions and 7 deletions

View File

@ -227,8 +227,10 @@ class DeprecationErrorHandler
return $this->configuration = Configuration::inWeakMode();
}
if (self::MODE_WEAK_VENDORS === $mode) {
echo sprintf('Setting SYMFONY_DEPRECATIONS_HELPER to "%s" is deprecated in favor of "max[self]=0"', $mode).PHP_EOL;
exit(1);
++$this->deprecations['remaining selfCount'];
$msg = sprintf('Setting SYMFONY_DEPRECATIONS_HELPER to "%s" is deprecated in favor of "max[self]=0"', $mode);
$ref = &$this->deprecations['remaining self'][$msg]['count'];
++$ref;
}
if (isset($mode[0]) && '/' === $mode[0]) {
return $this->configuration = Configuration::fromRegex($mode);

View File

@ -16,8 +16,6 @@ namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
*/
class Configuration
{
const GROUPS = ['total', 'indirect', 'direct', 'self'];
/**
* @var int[]
*/
@ -46,9 +44,11 @@ class Configuration
*/
private function __construct(array $thresholds = [], $regex = '', $verboseOutput = true)
{
$groups = ['total', 'indirect', 'direct', 'self'];
foreach ($thresholds as $group => $threshold) {
if (!\in_array($group, self::GROUPS, true)) {
throw new \InvalidArgumentException(sprintf('Unrecognized threshold "%s", expected one of "%s"', $group, implode('", "', self::GROUPS)));
if (!\in_array($group, $groups, true)) {
throw new \InvalidArgumentException(sprintf('Unrecognized threshold "%s", expected one of "%s"', $group, implode('", "', $groups)));
}
if (!is_numeric($threshold)) {
throw new \InvalidArgumentException(sprintf('Threshold for group "%s" has invalid value "%s"', $group, $threshold));
@ -66,7 +66,7 @@ class Configuration
'self' => $this->thresholds['indirect'],
];
}
foreach (self::GROUPS as $group) {
foreach ($groups as $group) {
if (!isset($this->thresholds[$group])) {
$this->thresholds[$group] = 999999;
}