constant_case.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ======================
  2. Rule ``constant_case``
  3. ======================
  4. The PHP constants ``true``, ``false``, and ``null`` MUST be written using the
  5. correct casing.
  6. Configuration
  7. -------------
  8. ``case``
  9. ~~~~~~~~
  10. Whether to use the ``upper`` or ``lower`` case syntax.
  11. Allowed values: ``'lower'`` and ``'upper'``
  12. Default value: ``'lower'``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. -$a = FALSE;
  23. -$b = True;
  24. -$c = nuLL;
  25. +$a = false;
  26. +$b = true;
  27. +$c = null;
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['case' => 'upper']``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php
  35. $a = FALSE;
  36. -$b = True;
  37. -$c = nuLL;
  38. +$b = TRUE;
  39. +$c = NULL;
  40. Rule sets
  41. ---------
  42. The rule is part of the following rule sets:
  43. - `@PER <./../../ruleSets/PER.rst>`_
  44. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  45. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  46. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  47. - `@PSR2 <./../../ruleSets/PSR2.rst>`_
  48. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  49. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  50. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  51. References
  52. ----------
  53. - Fixer class: `PhpCsFixer\\Fixer\\Casing\\ConstantCaseFixer <./../../../src/Fixer/Casing/ConstantCaseFixer.php>`_
  54. - Test class: `PhpCsFixer\\Tests\\Fixer\\Casing\\ConstantCaseFixerTest <./../../../tests/Fixer/Casing/ConstantCaseFixerTest.php>`_
  55. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.