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

Variable Arguments with PHPDoc: Variable gets extra array dimension #56

Open
DABugh opened this issue Feb 27, 2023 · 0 comments
Open

Variable Arguments with PHPDoc: Variable gets extra array dimension #56

DABugh opened this issue Feb 27, 2023 · 0 comments

Comments

@DABugh
Copy link

DABugh commented Feb 27, 2023

Short version: for function(string ...$vars) with PHPDoc, $vars is interpreted as string[][].


Consider the function:

function FunctionWithoutPHPDoc(string ...$stringArray)
{
    var_dump($stringArray);
}

$stringArray is declared as an array of strings. The hover text correctly identifies it as such:

@param string[] ...$stringArray

However, adding a PHPDoc changes how Intelephense recognizes the variable type.

Press Ctrl+. and select "Add PHPDoc" to produce this code block:

/**
 * @param string[] $stringArray 
 * 
 * @return void 
 */
function FunctionWithPHPDoc(string ...$stringArray)
{
    var_dump($stringArray);
}

(the function has been renamed in this example, obviously, but that is irrelevant to the issue)

The hover text now displays:

@param string[][] $stringArray

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

1 participant