Yes, using a single equals in a php if condition is sometimes desired, but how can I set a custom error in PhpStorm on the below code to prevent me from doing so?
mark as error when:
if (a = b) {
//crap I just reassigned a when I wanted to check if a == b
}
There is an inspection for that already -- just use it.
Settings/Preferences | Editor | Inspections | PHP | Probable bugs -> Assignment in condition
It works just fine:
Severity can be changed from "Warning" to "Error" if needed.
NOTE:
Obviously, it will now highlight ALL such assignments .. not just this particular place. But you can create custom scope and turn it on or off for files in those scopes.
For particular place it can also be suppressed via special comment:
/** @noinspection PhpAssignmentInConditionInspection */
if ($a = $b) {
echo 'hello!';
}