ereg_to_preg.rst 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. =====================
  2. Rule ``ereg_to_preg``
  3. =====================
  4. Replace deprecated ``ereg`` regular expression functions with ``preg``.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky if the ``ereg`` function is overridden.
  10. Examples
  11. --------
  12. Example #1
  13. ~~~~~~~~~~
  14. .. code-block:: diff
  15. --- Original
  16. +++ New
  17. -<?php $x = ereg('[A-Z]');
  18. +<?php $x = preg_match('/[A-Z]/D');
  19. Rule sets
  20. ---------
  21. The rule is part of the following rule sets:
  22. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  23. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  24. References
  25. ----------
  26. - Fixer class: `PhpCsFixer\\Fixer\\Alias\\EregToPregFixer <./../../../src/Fixer/Alias/EregToPregFixer.php>`_
  27. - Test class: `PhpCsFixer\\Tests\\Fixer\\Alias\\EregToPregFixerTest <./../../../tests/Fixer/Alias/EregToPregFixerTest.php>`_
  28. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.