Browse Source

Merge pull request #15028 from cakephp/expression-params

Update Expression parameter names
Mark Story 5 years ago
parent
commit
cd8e0c7a80

+ 10 - 10
src/Database/Expression/QueryExpression.php

@@ -369,23 +369,23 @@ class QueryExpression implements ExpressionInterface, Countable
     /**
      * Adds a new condition to the expression object in the form "EXISTS (...)".
      *
-     * @param \Cake\Database\ExpressionInterface $query the inner query
+     * @param \Cake\Database\ExpressionInterface $expression the inner query
      * @return $this
      */
-    public function exists(ExpressionInterface $query)
+    public function exists(ExpressionInterface $expression)
     {
-        return $this->add(new UnaryExpression('EXISTS', $query, UnaryExpression::PREFIX));
+        return $this->add(new UnaryExpression('EXISTS', $expression, UnaryExpression::PREFIX));
     }
 
     /**
      * Adds a new condition to the expression object in the form "NOT EXISTS (...)".
      *
-     * @param \Cake\Database\ExpressionInterface $query the inner query
+     * @param \Cake\Database\ExpressionInterface $expression the inner query
      * @return $this
      */
-    public function notExists(ExpressionInterface $query)
+    public function notExists(ExpressionInterface $expression)
     {
-        return $this->add(new UnaryExpression('NOT EXISTS', $query, UnaryExpression::PREFIX));
+        return $this->add(new UnaryExpression('NOT EXISTS', $expression, UnaryExpression::PREFIX));
     }
 
     /**
@@ -508,11 +508,11 @@ class QueryExpression implements ExpressionInterface, Countable
     /**
      * Builds equal condition or assignment with identifier wrapping.
      *
-     * @param string $left Left join condition field name.
-     * @param string $right Right join condition field name.
+     * @param string $leftField Left join condition field name.
+     * @param string $rightField Right join condition field name.
      * @return $this
      */
-    public function equalFields(string $left, string $right)
+    public function equalFields(string $leftField, string $rightField)
     {
         $wrapIdentifier = function ($field) {
             if ($field instanceof ExpressionInterface) {
@@ -522,7 +522,7 @@ class QueryExpression implements ExpressionInterface, Countable
             return new IdentifierExpression($field);
         };
 
-        return $this->eq($wrapIdentifier($left), $wrapIdentifier($right));
+        return $this->eq($wrapIdentifier($leftField), $wrapIdentifier($rightField));
     }
 
     /**

+ 5 - 5
src/Database/Expression/UnaryExpression.php

@@ -58,20 +58,20 @@ class UnaryExpression implements ExpressionInterface
      *
      * @var int
      */
-    protected $_mode;
+    protected $position;
 
     /**
      * Constructor
      *
      * @param string $operator The operator to used for the expression
      * @param mixed $value the value to use as the operand for the expression
-     * @param int $mode either UnaryExpression::PREFIX or UnaryExpression::POSTFIX
+     * @param int $position either UnaryExpression::PREFIX or UnaryExpression::POSTFIX
      */
-    public function __construct(string $operator, $value, $mode = self::PREFIX)
+    public function __construct(string $operator, $value, $position = self::PREFIX)
     {
         $this->_operator = $operator;
         $this->_value = $value;
-        $this->_mode = $mode;
+        $this->position = $position;
     }
 
     /**
@@ -84,7 +84,7 @@ class UnaryExpression implements ExpressionInterface
             $operand = $operand->sql($binder);
         }
 
-        if ($this->_mode === self::POSTFIX) {
+        if ($this->position === self::POSTFIX) {
             return '(' . $operand . ') ' . $this->_operator;
         }
 

+ 11 - 11
src/Database/Expression/ValuesExpression.php

@@ -80,45 +80,45 @@ class ValuesExpression implements ExpressionInterface
     /**
      * Add a row of data to be inserted.
      *
-     * @param array|\Cake\Database\Query $data Array of data to append into the insert, or
+     * @param array|\Cake\Database\Query $values Array of data to append into the insert, or
      *   a query for doing INSERT INTO .. SELECT style commands
      * @return void
      * @throws \Cake\Database\Exception When mixing array + Query data types.
      */
-    public function add($data): void
+    public function add($values): void
     {
         if (
             (
                 count($this->_values) &&
-                $data instanceof Query
+                $values instanceof Query
             ) ||
             (
                 $this->_query &&
-                is_array($data)
+                is_array($values)
             )
         ) {
             throw new Exception(
-                'You cannot mix subqueries and array data in inserts.'
+                'You cannot mix subqueries and array values in inserts.'
             );
         }
-        if ($data instanceof Query) {
-            $this->setQuery($data);
+        if ($values instanceof Query) {
+            $this->setQuery($values);
 
             return;
         }
-        $this->_values[] = $data;
+        $this->_values[] = $values;
         $this->_castedExpressions = false;
     }
 
     /**
      * Sets the columns to be inserted.
      *
-     * @param array $cols Array with columns to be inserted.
+     * @param array $columns Array with columns to be inserted.
      * @return $this
      */
-    public function setColumns(array $cols)
+    public function setColumns(array $columns)
     {
-        $this->_columns = $cols;
+        $this->_columns = $columns;
         $this->_castedExpressions = false;
 
         return $this;