lowercase_static_reference.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  51. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  52. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  53. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  54. - `@Symfony <./../../ruleSets/Symfony.rst>`_