Merge pull request #14256 from greenpeace-cee/innodb-log-tables
[civicrm-core.git] / CRM / Utils / SQL / BaseParamQuery.php
index 82fb91cfc36150d06644fffabc20b795bfa77a59..159f56a5fad60f2832034fc54a100a36023f2d06 100644 (file)
@@ -36,11 +36,20 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess {
    */
   const INTERPOLATE_AUTO = 'auto';
 
+  /**
+   * @var mixed
+   */
   protected $mode = NULL;
 
-  protected $params = array();
+  /**
+   * @var array
+   */
+  protected $params = [];
 
-  // Public to work-around PHP 5.3 limit.
+  /**
+   * Public to work-around PHP 5.3 limit.
+   * @var bool
+   */
   public $strict = NULL;
 
   /**
@@ -86,10 +95,10 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess {
 
       $select = $this;
       return preg_replace_callback('/([#!@])([a-zA-Z0-9_]+)/', function($m) use ($select, $args) {
-        if (isset($args[$m[2]])) {
+        if (array_key_exists($m[2], $args)) {
           $values = $args[$m[2]];
         }
-        elseif (isset($args[$m[1] . $m[2]])) {
+        elseif (array_key_exists($m[1] . $m[2], $args)) {
           // Backward compat. Keys in $args look like "#myNumber" or "@myString".
           $values = $args[$m[1] . $m[2]];
         }
@@ -100,10 +109,10 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess {
           // Unrecognized variables are ignored. Mitigate risk of accidents.
           return $m[0];
         }
-        $values = is_array($values) ? $values : array($values);
+        $values = is_array($values) ? $values : [$values];
         switch ($m[1]) {
           case '@':
-            $parts = array_map(array($select, 'escapeString'), $values);
+            $parts = array_map([$select, 'escapeString'], $values);
             return implode(', ', $parts);
 
           // TODO: ensure all uses of this un-escaped literal are safe