protected_to_private.rst 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. <?php
  13. final class Sample
  14. {
  15. - protected $a;
  16. + private $a;
  17. - protected function test()
  18. + private function test()
  19. {
  20. }
  21. }
  22. Rule sets
  23. ---------
  24. The rule is part of the following rule set:
  25. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  26. References
  27. ----------
  28. - Fixer class: `PhpCsFixer\\Fixer\\ClassNotation\\ProtectedToPrivateFixer <./../../../src/Fixer/ClassNotation/ProtectedToPrivateFixer.php>`_
  29. - Test class: `PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ProtectedToPrivateFixerTest <./../../../tests/Fixer/ClassNotation/ProtectedToPrivateFixerTest.php>`_
  30. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.