Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
12.4
-
Product Version: Apache NetBeans IDE 12.4
Java: 15.0.2; OpenJDK 64-Bit Server VM 15.0.2+7-27
Runtime: OpenJDK Runtime Environment 15.0.2+7-27
Description
If a class property is used only to create an instance of an anonymous class, it is marked with an 'Unused' hint.
The example code is below. There is also an image attached with a screenshot, note how $anyParameter in Factory1 constructor is underlined. This goes for both constructor argument promotion and the PHP7-style property declaration.
<?php declare(strict_types = 1); namespace Cz\Test\UsedProperty; class Factory1 { public function __construct(private bool $anyParameter) { } public function create(): Interface1 { return new class ($this->anyParameter) implements Interface1 { public function __construct(private bool $parameter1) { } public function getSomeParameter(): bool { return $this->parameter1; } }; } } interface Interface1 { function getSomeParameter(): bool; }
Attachments
Attachments
Issue Links
- links to