short_scalar_cast.rst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ==========================
  2. Rule ``short_scalar_cast``
  3. ==========================
  4. Cast ``(boolean)`` and ``(integer)`` should be written as ``(bool)`` and
  5. ``(int)``, ``(double)`` and ``(real)`` as ``(float)``, ``(binary)`` as
  6. ``(string)``.
  7. Examples
  8. --------
  9. Example #1
  10. ~~~~~~~~~~
  11. .. code-block:: diff
  12. --- Original
  13. +++ New
  14. <?php
  15. -$a = (boolean) $b;
  16. -$a = (integer) $b;
  17. -$a = (double) $b;
  18. +$a = (bool) $b;
  19. +$a = (int) $b;
  20. +$a = (float) $b;
  21. -$a = (binary) $b;
  22. +$a = (string) $b;
  23. Rule sets
  24. ---------
  25. The rule is part of the following rule sets:
  26. - `@PER <./../../ruleSets/PER.rst>`_
  27. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  28. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  29. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  30. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  31. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  32. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
  33. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  34. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  35. - `@Symfony <./../../ruleSets/Symfony.rst>`_