Skip to content

Support constructor promotion with readonly properties (UnusedVariable) #290

Closed
@defunctl

Description

@defunctl

The following throws this error:

phpcs: VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable: Unused function parameter $message.

<?php declare(strict_types=1);

namespace MyProject;

final class Manager {

	public function __construct(
		private readonly string $message
	) {}

	public function getMessage(): string {
		return $this->message;
	}

}

PHP Version: 8.1
Variable Analysis Version: v2.11.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions