From b11585e31f8d461b2fb5407ed10a0de4abc420d2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 12 Apr 2019 15:46:34 +0200 Subject: [PATCH] [PhpUnitBridge] fixes --- src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php | 6 ++++-- .../PhpUnit/DeprecationErrorHandler/Configuration.php | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 9289b5e942..542588c55a 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -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); diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 069f815963..20e8127a83 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -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; }