lowercase_static_reference.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. @@ -3,16 +3,16 @@
  14. {
  15. public function baz1()
  16. {
  17. - return STATIC::baz2();
  18. + return static::baz2();
  19. }
  20. public function baz2($x)
  21. {
  22. - return $x instanceof Self;
  23. + return $x instanceof self;
  24. }
  25. - public function baz3(PaRent $x)
  26. + public function baz3(parent $x)
  27. {
  28. return true;
  29. }
  30. }
  31. Example #2
  32. ~~~~~~~~~~
  33. .. code-block:: diff
  34. --- Original
  35. +++ New
  36. @@ -1,8 +1,8 @@
  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. @Symfony
  50. Using the ``@Symfony`` rule set will enable the ``lowercase_static_reference`` rule.
  51. @PhpCsFixer
  52. Using the ``@PhpCsFixer`` rule set will enable the ``lowercase_static_reference`` rule.