no_alias_functions.rst 3.3 KB

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