protected_to_private.rst 770 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. =============================
  2. Rule ``protected_to_private``
  3. =============================
  4. Converts ``protected`` variables and methods to ``private`` where possible.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. @@ -1,9 +1,9 @@
  13. <?php
  14. final class Sample
  15. {
  16. - protected $a;
  17. + private $a;
  18. - protected function test()
  19. + private function test()
  20. {
  21. }
  22. }
  23. Rule sets
  24. ---------
  25. The rule is part of the following rule sets:
  26. @PhpCsFixer
  27. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``protected_to_private`` rule.
  28. @Symfony
  29. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``protected_to_private`` rule.