Skip to content

Commit

Permalink
Only cast in echo when tracking taints
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 29, 2020
1 parent cff9760 commit ab29ac0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function analyze(

$expr_type = $statements_analyzer->node_data->getType($expr);

if ($expr_type) {
if ($codebase->taint && $expr_type) {
$expr_type = CastAnalyzer::castStringAttempt(
$statements_analyzer,
$context,
Expand Down
2 changes: 1 addition & 1 deletion tests/ToStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function providerInvalidCodeParse()
'<?php
class A {}
echo (new A);',
'error_message' => 'InvalidCast',
'error_message' => 'InvalidArgument',
],
'echoCastClass' => [
'<?php
Expand Down

0 comments on commit ab29ac0

Please sign in to comment.