Skip to content
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

Fix deprecation ignore by link #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/Deprecations/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static function ignorePackage(string $packageName): void
public static function ignoreDeprecations(string ...$links): void
{
foreach ($links as $link) {
self::$ignoredLinks[$link] = 0;
self::$ignoredLinks[$link] = 1;
}
}

Expand Down
17 changes: 17 additions & 0 deletions tests/Doctrine/Deprecations/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ public function testDeprecationWithIgnoredPackage(): void
$this->assertEquals(['https://github.com/doctrine/orm/issue/1234' => 1], Deprecation::getTriggeredDeprecations());
}

public function testDeprecationWithIgnoredLink(): void
{
Deprecation::enableWithTriggerError();
Deprecation::ignoreDeprecations('https://github.com/doctrine/orm/issue/1234');

Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issue/1234',
'this is deprecated %s %d',
'foo',
1234
);

$this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 if the deprecation is ignored, why is it taken into account in the count?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same test as the ane above for ignore by package. I don't know the reason behind this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not make sense to me, and in fact, the existing code makes no sense to me either.

/** @var array<string,bool> */
private static $ignoredPackages = [];
/** @var array<string,int> */
private static $ignoredLinks = [];

Why is ignoredLinks a hash of counters instead of a hash of booleans?

$this->assertEquals(['https://github.com/doctrine/orm/issue/1234' => 1], Deprecation::getTriggeredDeprecations());
}

public function testDeprecationIfCalledFromOutside(): void
{
Deprecation::enableWithTriggerError();
Expand Down