Cannot perform bitwise not on %s¶
Description¶
Bitwise operations are only available on integers. Other types are forbidden. Among the operations ~
is a bitwise operation. For the other operators, a different error is emitted.
Example¶
<?php
$array = [1,2];
~$array;
?>
Literal Examples¶
Cannot perform bitwise not on object
Cannot perform bitwise not on boolean
Cannot perform bitwise not on resource
Cannot perform bitwise not on array
Solutions¶
Use another operator than the bitwise not, such as
!
.Cast the forbidden type to int before using the bitwise.