Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NarrowPublicClassMethodParamTypeRule: wrong error when method is called recusively #36

Open
scollovati opened this issue Jul 9, 2024 · 1 comment

Comments

@scollovati
Copy link

Example:

public function myMethod(string $Id, int $recursive_round = 1): ?array
{
    [...]

    return self::myMethod($Id, 2);
}

Error wrongly reported: Parameters should have "string" types as the only types passed to this method

Actually, the error message is misleading (reported here: #35 (comment)) but also wrong. The parameter should not be removed from the method signature.

@TheoD02
Copy link

TheoD02 commented Jul 10, 2024

Hi,

I'm encountering a similar issue, but in a different context. Here's the situation 😄

Method Definition

public function authenticate(string|false $code = false): ?string

Reported Error

Parameters should have "string|false" types as the only types passed to this method

In my project, I have only two calls to this method:

$accessToken = $this->service->oauth()->authenticate($code);
// and
$accessToken = $this->service->oauth()->authenticate();

Expected Behavior

I expect no error because false is the default value.

Temporary Solution

To resolve this issue for now, I am explicitly setting the default value to false:

$accessToken = $this->deezerClient->oauth()->authenticate(false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants