strict_param.rst 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. =====================
  2. Rule ``strict_param``
  3. =====================
  4. Functions should be used with ``$strict`` param set to ``true``.
  5. Description
  6. -----------
  7. The functions "array_keys", "array_search", "base64_decode", "in_array" and
  8. "mb_detect_encoding" should be used with $strict param.
  9. .. warning:: Using this rule is risky.
  10. Risky when the fixed function is overridden or if the code relies on
  11. non-strict usage.
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. .. code-block:: diff
  17. --- Original
  18. +++ New
  19. @@ -1,6 +1,6 @@
  20. <?php
  21. $a = array_keys($b);
  22. -$a = array_search($b, $c);
  23. -$a = base64_decode($b);
  24. -$a = in_array($b, $c);
  25. -$a = mb_detect_encoding($b, $c);
  26. +$a = array_search($b, $c, true);
  27. +$a = base64_decode($b, true);
  28. +$a = in_array($b, $c, true);
  29. +$a = mb_detect_encoding($b, $c, true);
  30. Rule sets
  31. ---------
  32. The rule is part of the following rule set:
  33. @PhpCsFixer:risky
  34. Using the ``@PhpCsFixer:risky`` rule set will enable the ``strict_param`` rule.