Skip to content

Question regarding NoConstructorParameterWithDefaultValueRule  #461

@daniplaninc

Description

@daniplaninc

Hi,

Sorry if this is very basic question. I only recently started using phpstan and I came across this rule. I don't understand what is the proper way to do this? Why is a constructor parameter with default value bad?

I tried to research this, but I could not find anything..

Excerpt from my code that triggers this rule:

final class Client
{

public function __construct(
    protected string $endpoint,
    protected string $access_key,
    protected string $secret_key,
    protected int $timeout = 10,
    protected null|int $retryTimes = null,
    protected null|int $retryMilliseconds = null,
) {
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions