fopen_flags.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ====================
  2. Rule ``fopen_flags``
  3. ====================
  4. The flags in ``fopen`` calls must omit ``t``, and ``b`` must be omitted or
  5. included consistently.
  6. Warning
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Risky when the function ``fopen`` is overridden.
  11. Configuration
  12. -------------
  13. ``b_mode``
  14. ~~~~~~~~~~
  15. The ``b`` flag must be used (``true``) or omitted (``false``).
  16. Allowed types: ``bool``
  17. Default value: ``true``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. <?php
  27. -$a = fopen($foo, 'rwt');
  28. +$a = fopen($foo, 'rwb');
  29. Example #2
  30. ~~~~~~~~~~
  31. With configuration: ``['b_mode' => false]``.
  32. .. code-block:: diff
  33. --- Original
  34. +++ New
  35. <?php
  36. -$a = fopen($foo, 'rwt');
  37. +$a = fopen($foo, 'rw');
  38. Rule sets
  39. ---------
  40. The rule is part of the following rule sets:
  41. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ with config:
  42. ``['b_mode' => false]``
  43. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_ with config:
  44. ``['b_mode' => false]``
  45. References
  46. ----------
  47. - Fixer class: `PhpCsFixer\\Fixer\\FunctionNotation\\FopenFlagsFixer <./../../../src/Fixer/FunctionNotation/FopenFlagsFixer.php>`_
  48. - Test class: `PhpCsFixer\\Tests\\Fixer\\FunctionNotation\\FopenFlagsFixerTest <./../../../tests/Fixer/FunctionNotation/FopenFlagsFixerTest.php>`_
  49. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.