1.2.864. Not Not¶
Double not makes a boolean, not a true
.
This is a wrong casting to boolean. PHP supports (boolean)
to do the same, faster and cleaner.
<?php
// Explicit code
$b = (boolean) $x;
$b = (bool) $x;
// Wrong type casting
$b = !!$x;
?>
See also Logical Operators and Type Juggling.
1.2.864.1. Connex PHP features¶
1.2.864.1.1. Suggestions¶
Use
(bool)
casting operator for thatDon’t typecast, and let PHP handle it. This works in situations where the boolean is immediately used.
1.2.864.1.2. Specs¶
Short name |
Structures/NotNot |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
ClearPHP |
|
Examples |
|
Available in |