phpinspectionsea
phpinspectionsea copied to clipboard
Sensless proxy sniff triggered when overriding __construct with constructor parameter promotion
Subject | Details |
---|---|
Plugin | Php Inspections (EA Extended) 4.0.7 |
Language level | 8.0 |
Current behaviour
I have a class which extends the php PDO class to allow it to be re-connectable during a long running task if the connection is closed.
class ReConnectablePDO extends PDO
{
public function __construct(private string $dsn, private ?string $username = null, private ?string $password = null, private ?array $options = null)
{
parent::__construct($dsn, $username, $password, $options);
}
public function reConnect(): self
{
return new static($this->dsn, $this->username, $this->password, $this->options);
}
}
The __construct()
method is flagged as [EA] '__construct' method can be dropped, as it only calls parent's one.
, linked to the senseless proxy function sniff.
However, the constructor parameters here use constructor parameter promotion to create new properties which do not exists on the parent class.
Expected behaviour No warning
Environment details
PhpStorm 2021.3.1 Build #PS-213.6461.83, built on December 29, 2021
Runtime version: 11.0.13+7-b1751.21 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
OS X 12.2