Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Rules/UseSafeFunctionsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public function processNode(Node $node, Scope $scope): array
}
}
}
if ($functionName === "json_decode" || $functionName === "json_encode") {
foreach ($node->args as $arg) {
// Named argument might be not place on exact "documented" position
if ($arg->name instanceof Node\Identifier && $arg->name->toLowerString() === "flags") {
if ($this->argValueIncludeJSONTHROWONERROR($arg)) {
return [];
}
}
}
}
}

return ["Function $functionName is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\\$functionName;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library."];
Expand Down