Skip to content

Constructor of class xxx has an unused parameter $xxx also efects at new PHP 8 Attribute #7165

@ghost

Description

Bug report

Hi if you declare a new Attribute in PHP 8 this error is thrown:

Constructor of class XX\XXX\Structs\Attribute\ArrayList has an unused parameter $structName.

In this case it is part of the standart and the paramter will be used in reflection.

Code snippet that reproduces the problem

<?php
declare(strict_types=1);

namespace XX\XXX\Structs\Attribute;

use Attribute;

#[Attribute(Attribute::TARGET_PROPERTY)]
final class ArrayList
{
    public function __construct(string $structName)
    {}
}

https://phpstan.org/r/4f6303f0-6e98-46e8-9efc-9baf39b03a8b

Expected output

The issue is reported incorrectly.

Did PHPStan help you today? Did it make you happy in any way?

Yes, every day!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions