🐛 Fix CoreException constructor generating a warning on PHP >= 7.2

In the CoreException constructor, we're using the $aContextData parameter to do a count(), a foreach(), and uses values as string.
Only a null check was done.
Now we are also checking that the value is_array().
As others checks (Countable, Iterable, __toString() impl) are quite difficult depending on the PHP version we're running, we didn't add any other checks.

The call in \MatchExpression::__construct (added in 05a0d612) was passing directly an Expression object. We could embed it in an array, but the object hierarchy isn't implementing __toString so we would have another bug.
In consequence we removed this parameter.
This commit is contained in:
Pierre Goiffon
2020-10-19 11:57:53 +02:00
parent 18d5231900
commit 1cfb52d220
2 changed files with 25 additions and 17 deletions

View File

@@ -872,7 +872,7 @@ class MatchExpression extends BinaryExpression
public function __construct(FieldExpression $oLeftExpr, Expression $oRightExpr)
{
if (!$oRightExpr instanceof ScalarExpression && !$oRightExpr instanceof VariableExpression) {
throw new CoreException('Only instance of ScalarExpression or VariableExpression are allowed in MATCHES '.get_class( $oRightExpr).' found', $oRightExpr);
throw new CoreException('Only instance of ScalarExpression or VariableExpression are allowed in MATCHES '.get_class($oRightExpr).' found');
}
parent::__construct($oLeftExpr, 'MATCHES', $oRightExpr);
}