lowercase_static_reference.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ===================================
  2. Rule ``lowercase_static_reference``
  3. ===================================
  4. Class static references ``self``, ``static`` and ``parent`` MUST be in lower
  5. case.
  6. Examples
  7. --------
  8. Example #1
  9. ~~~~~~~~~~
  10. .. code-block:: diff
  11. --- Original
  12. +++ New
  13. <?php
  14. class Foo extends Bar
  15. {
  16. public function baz1()
  17. {
  18. - return STATIC::baz2();
  19. + return static::baz2();
  20. }
  21. public function baz2($x)
  22. {
  23. - return $x instanceof Self;
  24. + return $x instanceof self;
  25. }
  26. - public function baz3(PaRent $x)
  27. + public function baz3(parent $x)
  28. {
  29. return true;
  30. }
  31. }
  32. Example #2
  33. ~~~~~~~~~~
  34. .. code-block:: diff
  35. --- Original
  36. +++ New
  37. <?php
  38. class Foo extends Bar
  39. {
  40. - public function baz(?self $x) : SELF
  41. + public function baz(?self $x) : self
  42. {
  43. return false;
  44. }
  45. }
  46. Rule sets
  47. ---------
  48. The rule is part of the following rule sets:
  49. - `@PER <./../../ruleSets/PER.rst>`_
  50. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  51. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  52. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  53. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  54. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  55. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  56. References
  57. ----------
  58. - Fixer class: `PhpCsFixer\\Fixer\\Casing\\LowercaseStaticReferenceFixer <./../../../src/Fixer/Casing/LowercaseStaticReferenceFixer.php>`_
  59. - Test class: `PhpCsFixer\\Tests\\Fixer\\Casing\\LowercaseStaticReferenceFixerTest <./../../../tests/Fixer/Casing/LowercaseStaticReferenceFixerTest.php>`_
  60. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.