mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +01:00
Flag stdClass::__construct()
calls that have arguments
Fixes vimeo/psalm#10018
This commit is contained in:
parent
f40e23faef
commit
62b525993d
@ -244,6 +244,17 @@ final class NewAnalyzer extends CallAnalyzer
|
|||||||
new Union([$result_atomic_type]),
|
new Union([$result_atomic_type]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (strtolower($fq_class_name) === 'stdclass' && $stmt->getArgs() !== []) {
|
||||||
|
IssueBuffer::maybeAdd(
|
||||||
|
new TooManyArguments(
|
||||||
|
'stdClass::__construct() has no parameters',
|
||||||
|
new CodeLocation($statements_analyzer->getSource(), $stmt),
|
||||||
|
'stdClass::__construct',
|
||||||
|
),
|
||||||
|
$statements_analyzer->getSuppressedIssues(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (strtolower($fq_class_name) !== 'stdclass' &&
|
if (strtolower($fq_class_name) !== 'stdclass' &&
|
||||||
$codebase->classlikes->classExists($fq_class_name)
|
$codebase->classlikes->classExists($fq_class_name)
|
||||||
) {
|
) {
|
||||||
|
@ -1238,7 +1238,7 @@ class MethodCallTest extends TestCase
|
|||||||
}
|
}
|
||||||
class Child1 extends Old {}
|
class Child1 extends Old {}
|
||||||
class Child2 extends Old {}
|
class Child2 extends Old {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template IsClient of bool
|
* @template IsClient of bool
|
||||||
*/
|
*/
|
||||||
@ -1798,6 +1798,13 @@ class MethodCallTest extends TestCase
|
|||||||
',
|
',
|
||||||
'error_message' => 'InvalidParamDefault',
|
'error_message' => 'InvalidParamDefault',
|
||||||
],
|
],
|
||||||
|
'stdClassConstructorHasNoParameters' => [
|
||||||
|
'code' => <<<'PHP'
|
||||||
|
<?php
|
||||||
|
$a = new stdClass(5);
|
||||||
|
PHP,
|
||||||
|
'error_message' => 'TooManyArguments',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user