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

Prevent duplicate (Possibly)UnusedMethod/(Possibly)UnusedProperty #8883

Merged
merged 1 commit into from Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Psalm/Internal/Codebase/ClassLikes.php
Expand Up @@ -2144,7 +2144,8 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v
'Cannot find ' . ($has_variable_calls ? 'explicit' : 'any')
. ' references to property ' . $property_id
. ($has_variable_calls ? ' (but did find some potential references)' : ''),
$property_storage->location
$property_storage->location,
$property_id
);

if ($codebase->alter_code) {
Expand Down Expand Up @@ -2173,7 +2174,8 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v
'Cannot find ' . ($has_variable_calls ? 'explicit' : 'any')
. ' references to private property ' . $property_id
. ($has_variable_calls ? ' (but did find some potential references)' : ''),
$property_storage->location
$property_storage->location,
$property_id
);

if ($codebase->alter_code) {
Expand Down
13 changes: 13 additions & 0 deletions src/Psalm/Issue/PossiblyUnusedMethod.php
Expand Up @@ -2,8 +2,21 @@

namespace Psalm\Issue;

use Psalm\CodeLocation;

use function strtolower;

final class PossiblyUnusedMethod extends MethodIssue
{
public const ERROR_LEVEL = -2;
public const SHORTCODE = 87;

public function __construct(
string $message,
CodeLocation $code_location,
string $method_id
) {
parent::__construct($message, $code_location, $method_id);
$this->dupe_key = strtolower($method_id);
}
}
13 changes: 12 additions & 1 deletion src/Psalm/Issue/PossiblyUnusedProperty.php
Expand Up @@ -2,8 +2,19 @@

namespace Psalm\Issue;

final class PossiblyUnusedProperty extends CodeIssue
use Psalm\CodeLocation;

final class PossiblyUnusedProperty extends PropertyIssue
{
public const ERROR_LEVEL = -2;
public const SHORTCODE = 149;

public function __construct(
string $message,
CodeLocation $code_location,
string $property_id
) {
parent::__construct($message, $code_location, $property_id);
$this->dupe_key = $property_id;
}
}
13 changes: 13 additions & 0 deletions src/Psalm/Issue/UnusedMethod.php
Expand Up @@ -2,8 +2,21 @@

namespace Psalm\Issue;

use Psalm\CodeLocation;

use function strtolower;

final class UnusedMethod extends MethodIssue
{
public const ERROR_LEVEL = -2;
public const SHORTCODE = 76;

public function __construct(
string $message,
CodeLocation $code_location,
string $method_id
) {
parent::__construct($message, $code_location, $method_id);
$this->dupe_key = strtolower($method_id);
}
}
13 changes: 12 additions & 1 deletion src/Psalm/Issue/UnusedProperty.php
Expand Up @@ -2,8 +2,19 @@

namespace Psalm\Issue;

final class UnusedProperty extends CodeIssue
use Psalm\CodeLocation;

final class UnusedProperty extends PropertyIssue
{
public const ERROR_LEVEL = -2;
public const SHORTCODE = 150;

public function __construct(
string $message,
CodeLocation $code_location,
string $property_id
) {
parent::__construct($message, $code_location, $property_id);
$this->dupe_key = $property_id;
}
}