strict_param.rst 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  10. -------
  11. Using this rule is risky
  12. ~~~~~~~~~~~~~~~~~~~~~~~~
  13. Risky when the fixed function is overridden or if the code relies on non-strict
  14. usage.
  15. Examples
  16. --------
  17. Example #1
  18. ~~~~~~~~~~
  19. .. code-block:: diff
  20. --- Original
  21. +++ New
  22. <?php
  23. $a = array_keys($b);
  24. -$a = array_search($b, $c);
  25. -$a = base64_decode($b);
  26. -$a = in_array($b, $c);
  27. -$a = mb_detect_encoding($b, $c);
  28. +$a = array_search($b, $c, true);
  29. +$a = base64_decode($b, true);
  30. +$a = in_array($b, $c, true);
  31. +$a = mb_detect_encoding($b, $c, true);
  32. Rule sets
  33. ---------
  34. The rule is part of the following rule set:
  35. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_