ACR Rules

  1. Home
  2. Docs
  3. ACR Rules
  4. Reliability (41)
  5. Short-circuit logic should be used correctly to prevent null pointer dereferences in conditionals

Short-circuit logic should be used correctly to prevent null pointer dereferences in conditionals

Introduced in version: 1.3 (29 Jan 2020)

If short circuit logic is used it should be applied correctly. Mixing up equal with not-equal or and with or will open the possibility for dereferencing of empty variables.

Non-compliant examples:
$Var = empty and isMatch($Var,'qwe')
$Var != empty or isMatch($Var,'qwe')
isMatch($Var,'qwe') and $Var = empty
isMatch($Var,'qwe') or $Var != empty

Compliant examples:
$Var != empty and isMatch($Var,'qwe')
$Var = empty or isMatch($Var,'qwe')