rspec/rules/S2761/php/rule.adoc

22 lines
542 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
Calling the ``++!++`` or ``++~++`` prefix operator twice does nothing: the second invocation undoes the first. Such mistakes are typically caused by accidentally double-tapping the key in question without noticing. Either this is a bug, if the operator was actually meant to be called once, or misleading if done on purpose.
2020-06-30 12:48:07 +02:00
== Noncompliant Code Example
----
$a = 0;
$b = false;
$c = !!$a; // Noncompliant
$d = ~~$b; // Noncompliant
----
== Compliant Solution
----
$a = 0;
$b = false;
$c = !$a; // Compliant
$d = ~$b; // Compliant
----