diff --git a/core/coreexception.class.inc.php b/core/coreexception.class.inc.php index 7188446c7..cf6469807 100644 --- a/core/coreexception.class.inc.php +++ b/core/coreexception.class.inc.php @@ -28,31 +28,39 @@ class CoreException extends Exception { + /** + * CoreException constructor. + * + * @param string $sIssue error message + * @param array|null $aContextData key/value array, value MUST implements _toString + * @param string $sImpact + * @param Exception|null $oPrevious + */ public function __construct($sIssue, $aContextData = null, $sImpact = '', $oPrevious = null) { $this->m_sIssue = $sIssue; $this->m_sImpact = $sImpact; - $this->m_aContextData = $aContextData ? $aContextData : array(); - + + if (is_array($aContextData)) { + $this->m_aContextData = $aContextData; + } else { + $this->m_aContextData = []; + } + $sMessage = $sIssue; - if (!empty($sImpact)) $sMessage .= "($sImpact)"; - if (count($this->m_aContextData) > 0) - { + if (!empty($sImpact)) { + $sMessage .= "($sImpact)"; + } + if (count($this->m_aContextData) > 0) { $sMessage .= ": "; $aContextItems = array(); - foreach($this->m_aContextData as $sKey => $value) - { - if (is_array($value)) - { + foreach ($this->m_aContextData as $sKey => $value) { + if (is_array($value)) { $aPairs = array(); - foreach($value as $key => $val) - { - if (is_array($val)) - { + foreach ($value as $key => $val) { + if (is_array($val)) { $aPairs[] = $key.'=>('.implode(', ', $val).')'; - } - else - { + } else { $aPairs[] = $key.'=>'.$val; } } diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index 1f65b5c5b..141bf4198 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -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); }