sirbrillig / phpcs-variable-analysis

Find undefined and unused variables with the PHP Codesniffer static analysis tool.
Other
135 stars 14 forks source link

Handle constructor promotion with Nullable types #320

Closed yokozawa0701 closed 5 months ago

yokozawa0701 commented 5 months ago

I want to use Nullable types in a constructor promotion like following.

public function __construct(
    public ?string $name,
) {}

But it showed Unused function parameter $name. (VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable) . Is it possible to use like this?

sirbrillig commented 5 months ago

In theory that was handled by https://github.com/sirbrillig/phpcs-variable-analysis/pull/266 and https://github.com/sirbrillig/phpcs-variable-analysis/issues/290 but I wouldn't be surprised if there's a bug with nullable types. I'll try to fix it.

yokozawa0701 commented 5 months ago

Thank you so much!