Skip to content
Permalink
Browse files

Analyse encapsulated string when method not known

Ref #2052
  • Loading branch information...
muglug committed Aug 23, 2019
1 parent e0cd04d commit f00ee740c0d34fda538716728b277ccdfa8928b2
Showing with 13 additions and 3 deletions.
  1. +4 −3 src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
  2. +9 −0 tests/UnusedCodeTest.php
@@ -341,10 +341,10 @@ protected static function checkMethodArgs(
protected static function checkFunctionArguments(
StatementsAnalyzer $statements_analyzer,
array $args,
$function_params,
$method_id,
?array $function_params,
?string $method_id,
Context $context,
$generic_params = null
?array $generic_params = null
) {
$last_param = $function_params
? $function_params[count($function_params) - 1]
@@ -592,6 +592,7 @@ private static function evaluateAribitraryParam(
|| $arg->value instanceof PhpParser\Node\Expr\PropertyFetch
|| $arg->value instanceof PhpParser\Node\Expr\Array_
|| $arg->value instanceof PhpParser\Node\Expr\BinaryOp
|| $arg->value instanceof PhpParser\Node\Scalar\Encapsed
) {
$was_inside_call = $context->inside_call;
$context->inside_call = true;
@@ -528,6 +528,15 @@ function fooBar(): void {}
($foo . ucfirst($bar))();',
],
'usedParamInUnknownMethodConcat' => [
'<?php
/**
* @psalm-suppress MixedMethodCall
*/
function foo(string $s, object $o) : void {
$o->foo("COUNT{$s}");
}'
],
];
}

0 comments on commit f00ee74

Please sign in to comment.
You can’t perform that action at this time.