noverify icon indicating copy to clipboard operation
noverify copied to clipboard

Add a new kind of type filter for dynamic rules?

Open quasilyte opened this issue 4 years ago • 0 comments

There is ambiguity in X type constraint when matched against X|Y.

It should either fail because X|Y means that it's not always X, but sometimes we want it to succeed as X|Y also means that it could be X.

At the very least we should choose which strategy we get with the default @type constraint.

Here are two examples that require different types of @type filter:

/**
 * We don't want to match int|float type.
 * This is a simplified case, but the real constrain should look like !(int|float).
 *
 * @warning used bitwise operator on a non-numeric type
 * @type !int $x
 * @type !int $y
 */
bitwise_ops: {
  $x & $y;
  $x | $y;
}

/**
 * We don't want to match object|bool here as it may give a false positive.
 *
 * @warning maybe wanted to compare an object with null instead of false?
 * @type object $obj
 */
obj_cmp: {
  $obj === false;
  $obj == false;
}

quasilyte avatar Sep 02 '20 17:09 quasilyte