no_alias_functions.rst 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ===========================
  2. Rule ``no_alias_functions``
  3. ===========================
  4. Master functions shall be used instead of aliases.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky when any of the alias functions are overridden.
  10. Configuration
  11. -------------
  12. ``sets``
  13. ~~~~~~~~
  14. List of sets to fix. Defined sets are:
  15. * ``@all`` (all listed sets);
  16. * ``@internal`` (native functions);
  17. * ``@exif`` (EXIF functions);
  18. * ``@ftp`` (FTP functions);
  19. * ``@IMAP`` (IMAP functions);
  20. * ``@ldap`` (LDAP functions);
  21. * ``@mbreg`` (from ``ext-mbstring``);
  22. * ``@mysqli`` (mysqli functions);
  23. * ``@oci`` (oci functions);
  24. * ``@odbc`` (odbc functions);
  25. * ``@openssl`` (openssl functions);
  26. * ``@pcntl`` (PCNTL functions);
  27. * ``@pg`` (pg functions);
  28. * ``@posix`` (POSIX functions);
  29. * ``@snmp`` (SNMP functions);
  30. * ``@sodium`` (libsodium functions);
  31. * ``@time`` (time functions).
  32. Allowed values: a subset of ``['@all', '@exif', '@ftp', '@IMAP', '@internal', '@ldap', '@mbreg', '@mysqli', '@oci', '@odbc', '@openssl', '@pcntl', '@pg', '@posix', '@snmp', '@sodium', '@time']``
  33. Default value: ``['@internal', '@IMAP', '@pg']``
  34. Examples
  35. --------
  36. Example #1
  37. ~~~~~~~~~~
  38. *Default* configuration.
  39. .. code-block:: diff
  40. --- Original
  41. +++ New
  42. <?php
  43. -$a = chop($b);
  44. -close($b);
  45. -$a = doubleval($b);
  46. -$a = fputs($b, $c);
  47. -$a = get_required_files();
  48. -ini_alter($b, $c);
  49. -$a = is_double($b);
  50. -$a = is_integer($b);
  51. -$a = is_long($b);
  52. -$a = is_real($b);
  53. -$a = is_writeable($b);
  54. -$a = join($glue, $pieces);
  55. -$a = key_exists($key, $array);
  56. -magic_quotes_runtime($new_setting);
  57. -$a = pos($array);
  58. -$a = show_source($filename, true);
  59. -$a = sizeof($b);
  60. -$a = strchr($haystack, $needle);
  61. -$a = imap_header($imap_stream, 1);
  62. -user_error($message);
  63. +$a = rtrim($b);
  64. +closedir($b);
  65. +$a = floatval($b);
  66. +$a = fwrite($b, $c);
  67. +$a = get_included_files();
  68. +ini_set($b, $c);
  69. +$a = is_float($b);
  70. +$a = is_int($b);
  71. +$a = is_int($b);
  72. +$a = is_float($b);
  73. +$a = is_writable($b);
  74. +$a = implode($glue, $pieces);
  75. +$a = array_key_exists($key, $array);
  76. +set_magic_quotes_runtime($new_setting);
  77. +$a = current($array);
  78. +$a = highlight_file($filename, true);
  79. +$a = count($b);
  80. +$a = strstr($haystack, $needle);
  81. +$a = imap_headerinfo($imap_stream, 1);
  82. +trigger_error($message);
  83. mbereg_search_getregs();
  84. Example #2
  85. ~~~~~~~~~~
  86. With configuration: ``['sets' => ['@mbreg']]``.
  87. .. code-block:: diff
  88. --- Original
  89. +++ New
  90. <?php
  91. $a = is_double($b);
  92. -mbereg_search_getregs();
  93. +mb_ereg_search_getregs();
  94. Rule sets
  95. ---------
  96. The rule is part of the following rule sets:
  97. - `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
  98. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_ with config:
  99. ``['sets' => ['@all']]``
  100. - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_ with config:
  101. ``['sets' => ['@all']]``
  102. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ with config:
  103. ``['sets' => ['@all']]``
  104. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  105. References
  106. ----------
  107. - Fixer class: `PhpCsFixer\\Fixer\\Alias\\NoAliasFunctionsFixer <./../../../src/Fixer/Alias/NoAliasFunctionsFixer.php>`_
  108. - Test class: `PhpCsFixer\\Tests\\Fixer\\Alias\\NoAliasFunctionsFixerTest <./../../../tests/Fixer/Alias/NoAliasFunctionsFixerTest.php>`_
  109. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.