Skip to content

Commit

Permalink
Disable mixed calls diagnosis for trackMixedCalls: false (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Nov 5, 2024
1 parent a3ddfe2 commit bcfa0a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ services:
- phpstan.diagnoseExtension
arguments:
reportTransitivelyDeadMethodAsSeparateError: %shipmonkDeadCode.reportTransitivelyDeadMethodAsSeparateError%
trackCallsOnMixed: %shipmonkDeadCode.trackCallsOnMixed%


parameters:
Expand Down
8 changes: 6 additions & 2 deletions src/Rule/DeadMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class DeadMethodRule implements Rule, DiagnoseExtension

private bool $reportTransitivelyDeadMethodAsSeparateError;

private bool $trackCallsOnMixed;

/**
* @var array<string, array{string, int}> methodKey => [file, line]
*/
Expand All @@ -96,11 +98,13 @@ class DeadMethodRule implements Rule, DiagnoseExtension

public function __construct(
ClassHierarchy $classHierarchy,
bool $reportTransitivelyDeadMethodAsSeparateError
bool $reportTransitivelyDeadMethodAsSeparateError,
bool $trackCallsOnMixed
)
{
$this->classHierarchy = $classHierarchy;
$this->reportTransitivelyDeadMethodAsSeparateError = $reportTransitivelyDeadMethodAsSeparateError;
$this->trackCallsOnMixed = $trackCallsOnMixed;
}

public function getNodeType(): string
Expand Down Expand Up @@ -558,7 +562,7 @@ private function isNeverReportedAsDead(string $methodKey): bool

public function print(Output $output): void
{
if ($this->mixedCalls === [] || !$output->isDebug()) {
if ($this->mixedCalls === [] || !$output->isDebug() || !$this->trackCallsOnMixed) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Rule/DeadMethodRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected function getRule(): DeadMethodRule
$this->rule = new DeadMethodRule(
new ClassHierarchy(),
!$this->emitErrorsInGroups,
true,
);
}

Expand Down

0 comments on commit bcfa0a0

Please sign in to comment.