no_useless_nullsafe_operator.rst 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. =====================================
  2. Rule ``no_useless_nullsafe_operator``
  3. =====================================
  4. There should not be useless Null-safe operator ``?->`` used.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. class Foo extends Bar
  14. {
  15. public function test() {
  16. - echo $this?->parentMethod();
  17. + echo $this->parentMethod();
  18. }
  19. }
  20. Rule sets
  21. ---------
  22. The rule is part of the following rule sets:
  23. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  24. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  25. References
  26. ----------
  27. - Fixer class: `PhpCsFixer\\Fixer\\Operator\\NoUselessNullsafeOperatorFixer <./../../../src/Fixer/Operator/NoUselessNullsafeOperatorFixer.php>`_
  28. - Test class: `PhpCsFixer\\Tests\\Fixer\\Operator\\NoUselessNullsafeOperatorFixerTest <./../../../tests/Fixer/Operator/NoUselessNullsafeOperatorFixerTest.php>`_
  29. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.