mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix @no-named-arguments more
This commit is contained in:
parent
1839b3e701
commit
6a91c2f70e
@ -533,7 +533,7 @@ class ArgumentsAnalyzer
|
||||
foreach ($args as $argument_offset => $arg) {
|
||||
$function_param = null;
|
||||
|
||||
if ($arg->name) {
|
||||
if ($arg->name && $function_storage->allow_named_arg_calls) {
|
||||
foreach ($function_params as $candidate_param) {
|
||||
if ($candidate_param->name === $arg->name->name) {
|
||||
$function_param = $candidate_param;
|
||||
@ -622,7 +622,7 @@ class ArgumentsAnalyzer
|
||||
foreach ($args as $argument_offset => $arg) {
|
||||
$function_param = null;
|
||||
|
||||
if ($arg->name) {
|
||||
if ($arg->name && $function_storage && $function_storage->allow_named_arg_calls) {
|
||||
foreach ($function_params as $candidate_param) {
|
||||
if ($candidate_param->name === $arg->name->name) {
|
||||
$function_param = $candidate_param;
|
||||
|
@ -247,6 +247,38 @@ class ArgTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'InvalidNamedArgument'
|
||||
],
|
||||
'noNamedArgsMethod' => [
|
||||
'<?php
|
||||
class CustomerData
|
||||
{
|
||||
/** @no-named-arguments */
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $email,
|
||||
public int $age,
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{age: int, name: string, email: string} $input
|
||||
*/
|
||||
function foo(array $input) : CustomerData {
|
||||
return new CustomerData(
|
||||
age: $input["age"],
|
||||
name: $input["name"],
|
||||
email: $input["email"],
|
||||
);
|
||||
}',
|
||||
'error_message' => 'InvalidScalarArgument'
|
||||
],
|
||||
'noNamedArgsFunction' => [
|
||||
'<?php
|
||||
/** @no-named-arguments */
|
||||
function takesArguments(string $name, int $age) : void {}
|
||||
|
||||
takesArguments(age: 5, name: "hello");',
|
||||
'error_message' => 'InvalidScalarArgument'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user