Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Rules/Classes/UnusedConstructorParametersRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function processNode(Node $node, Scope $scope): array
if (count($originalNode->params) === 0) {
return [];
}
if ($node->getClassReflection()->isAttributeClass()) {
return [];
}

$message = sprintf(
'Constructor of class %s has an unused parameter $%%s.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public function testBug1917(): void
$this->analyse([__DIR__ . '/data/bug-1917.php'], []);
}

public function testBug7165(): void
{
$this->analyse([__DIR__ . '/data/bug-7165.php'], []);
}

public function testBug10865(): void
{
$this->analyse([__DIR__ . '/data/bug-10865.php'], []);
Expand Down
12 changes: 12 additions & 0 deletions tests/PHPStan/Rules/Classes/data/bug-7165.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1); // lint >= 8.0

namespace Bug7165;

#[\Attribute]
class MyAttribute
{
public function __construct(string $name)
{
}
}

Loading