Skip to content

best-practices/no-unused-parameter wrongly thrown on used parameter #148

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

Closed
giorgiopogliani opened this issue Mar 10, 2025 · 0 comments
Closed
Assignees
Labels
Priority: High After critical issues are fixed, handle these before any further issues. Status: Closed This issue is closed and no more work is planned. Subject: Linter An issue or PR related to the linter. Type: Bug An issue causing unintended or problematic behavior.

Comments

@giorgiopogliani
Copy link

giorgiopogliani commented Mar 10, 2025

🐞 Describe the Bug

The notice is best-practices/no-unused-parameter wrongly thrown on a used parameter parameter. The parameter is used inside the array access square brackets.

🔄 Steps to Reproduce

  1. mago lint the code example
  2. the $key variable is actually used but reported as unused

⚙️ Configuration (mago.toml)

empty

📜 Command Output

note[best-practices/no-unused-parameter]: Parameter `$key` is never used.
   ┌─ test.php:9:25
   │
 9 │ ╭     public function set(string $key, string $value, ?string $default = null): void
   │                           ^^^^^^^^^^^ Parameter `$key` is declared here.
10 │ │     {
11 │ │         $this->data[$key] = $value ?? $default;
12 │ │     }
   │ ╰─────'

   = This parameter is declared but not used within the method.
   = Help: Consider prefixing the parameter with an underscore (`_`) to indicate that it is intentionally unused, or remove it if it is not needed.

note: found 1 issues: 1 note(s)
 = 1 issues contain auto-fix suggestions

📂 PHP Code Sample (If Applicable)

<?php

declare(strict_types=1);

class Test
{
    private array $data = [];

    public function set(string $key, string $value, ?string $default = null): void
    {
        $this->data[$key] = $value ?? $default;
    }
}

🖥️ Operating System

macOS

📦 How did you install Mago?

Cargo (cargo install mago)

📝 Additional Context

No response

@giorgiopogliani giorgiopogliani added the Type: Bug An issue causing unintended or problematic behavior. label Mar 10, 2025
@azjezz azjezz added Priority: High After critical issues are fixed, handle these before any further issues. Subject: Linter An issue or PR related to the linter. labels Mar 10, 2025
@azjezz azjezz closed this as completed in 2b2ab7e Mar 13, 2025
@azjezz azjezz added the Status: Closed This issue is closed and no more work is planned. label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High After critical issues are fixed, handle these before any further issues. Status: Closed This issue is closed and no more work is planned. Subject: Linter An issue or PR related to the linter. Type: Bug An issue causing unintended or problematic behavior.
Projects
None yet
Development

No branches or pull requests

2 participants