unary_operator_spaces.rst 766 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. ==============================
  2. Rule ``unary_operator_spaces``
  3. ==============================
  4. Unary operators should be placed adjacent to their operands.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -$sample ++;
  14. --- $sample;
  15. -$sample = ! ! $a;
  16. -$sample = ~ $c;
  17. -function & foo(){}
  18. +$sample++;
  19. +--$sample;
  20. +$sample = !!$a;
  21. +$sample = ~$c;
  22. +function &foo(){}
  23. Rule sets
  24. ---------
  25. The rule is part of the following rule sets:
  26. @PhpCsFixer
  27. Using the `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ rule set will enable the ``unary_operator_spaces`` rule.
  28. @Symfony
  29. Using the `@Symfony <./../../ruleSets/Symfony.rst>`_ rule set will enable the ``unary_operator_spaces`` rule.