no_php4_constructor.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ============================
  2. Rule ``no_php4_constructor``
  3. ============================
  4. Convert PHP4-style constructors to ``__construct``.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky when old style constructor being fixed is overridden or overrides parent
  10. one.
  11. Examples
  12. --------
  13. Example #1
  14. ~~~~~~~~~~
  15. .. code-block:: diff
  16. --- Original
  17. +++ New
  18. <?php
  19. class Foo
  20. {
  21. - public function Foo($bar)
  22. + public function __construct($bar)
  23. {
  24. }
  25. }
  26. Rule sets
  27. ---------
  28. The rule is part of the following rule sets:
  29. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
  30. - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
  31. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  32. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  33. References
  34. ----------
  35. - Fixer class: `PhpCsFixer\\Fixer\\ClassNotation\\NoPhp4ConstructorFixer <./../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php>`_
  36. - Test class: `PhpCsFixer\\Tests\\Fixer\\ClassNotation\\NoPhp4ConstructorFixerTest <./../../../tests/Fixer/ClassNotation/NoPhp4ConstructorFixerTest.php>`_
  37. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.