diff --git a/lib/Doctrine/Deprecations/Deprecation.php b/lib/Doctrine/Deprecations/Deprecation.php index 00cd15d..4626493 100644 --- a/lib/Doctrine/Deprecations/Deprecation.php +++ b/lib/Doctrine/Deprecations/Deprecation.php @@ -132,6 +132,10 @@ public static function disable() : void { self::$type = self::TYPE_NONE; self::$logger = null; + + foreach (self::$ignoredLinks as $link => $count) { + self::$ignoredLinks[$link] = 0; + } } public static function ignorePackage(string $packageName, string $version = "0.0.1") : void @@ -148,7 +152,9 @@ public static function ignoreDeprecations(...$links) : void public static function getUniqueTriggeredDeprecationsCount() : int { - return count(self::$ignoredLinks); + return array_reduce(self::$ignoredLinks, function (int $carry, int $count) { + return $carry + $count; + }, 0); } /** diff --git a/tests/Doctrine/Deprecations/DeprecationTest.php b/tests/Doctrine/Deprecations/DeprecationTest.php index eb64f68..11c6c17 100644 --- a/tests/Doctrine/Deprecations/DeprecationTest.php +++ b/tests/Doctrine/Deprecations/DeprecationTest.php @@ -42,6 +42,25 @@ public function testDeprecation() } } + public function testDeprecationResetsCounts() + { + try { + Deprecation::trigger( + "doctrine/orm", + "2.7", + "https://github.com/doctrine/deprecations/1234", + "this is deprecated %s %d", + "foo", + 1234 + ); + } catch(\Exception $e) { + Deprecation::disable(); + + $this->assertEquals(0, Deprecation::getUniqueTriggeredDeprecationsCount()); + $this->assertEquals(["https://github.com/doctrine/deprecations/1234" => 0], Deprecation::getTriggeredDeprecations()); + } + } + public function testDeprecationWithNumericLinkPointingToGithubIssue() { Deprecation::enableWithTriggerError();