1.2.1414. Uses Default Values¶
Default values are provided to methods so as to make it convenient to use. However, with new versions, those values may change. For example, in PHP 5.4, htmlentities() switched from Latin1
to UTF-8
default encoding.
As much as possible, it is recommended to use explicit values in those methods, so as to prevent from being surprise at a future PHP evolution.
This analyzer tend to report a lot of false positives, including usage of count(). Count() indeed has a second argument for recursive counts, and a default value. This may be ignored safely.
<?php
$string = Eu não sou o pão;
echo htmlentities($string);
// PHP 5.3 : Eu não sou o pão
// PHP 5.4 : Eu não sou o pão
// Stable across versions
echo htmlentities($string, 'UTF8');
?>
1.2.1414.1. Suggestions¶
Mention all arguments, as much as possible
1.2.1414.2. Specs¶
Short name |
Functions/UsesDefaultArguments |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |