[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(); return $this->configuration = Configuration::inWeakMode();
} }
if (self::MODE_WEAK_VENDORS === $mode) { 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; ++$this->deprecations['remaining selfCount'];
exit(1); $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]) { if (isset($mode[0]) && '/' === $mode[0]) {
return $this->configuration = Configuration::fromRegex($mode); return $this->configuration = Configuration::fromRegex($mode);

View File

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