"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Database/Query.php" between
cakephp-4.0.1.tar.gz and cakephp-4.0.2.tar.gz

About: CakePHP is a rapid development framework for PHP applications. Source code.

Query.php  (cakephp-4.0.1):Query.php  (cakephp-4.0.2)
skipping to change at line 332 skipping to change at line 332
* var_dump($value); * var_dump($value);
* } * }
* }); * });
* ``` * ```
* *
* @param callable $visitor A function or callable to be executed for each p art * @param callable $visitor A function or callable to be executed for each p art
* @return $this * @return $this
*/ */
public function traverse($visitor) public function traverse($visitor)
{ {
$parts = array_keys($this->_parts); foreach ($this->_parts as $name => $part) {
foreach ($parts as $name) { $visitor($part, $name);
$visitor($this->_parts[$name], $name);
} }
return $this; return $this;
} }
/** /**
* Will iterate over the provided parts. * Will iterate over the provided parts.
* *
* Traversing functions can aggregate results using variables in the closure * Traversing functions can aggregate results using variables in the closure
* or instance variables. This method can be used to traverse a subset of * or instance variables. This method can be used to traverse a subset of
skipping to change at line 1906 skipping to change at line 1905
* stored inside this query at any nesting depth in any part of the query. * stored inside this query at any nesting depth in any part of the query.
* *
* Callback will receive as first parameter the currently visited expression . * Callback will receive as first parameter the currently visited expression .
* *
* @param callable $callback the function to be executed for each Expression Interface * @param callable $callback the function to be executed for each Expression Interface
* found inside this query. * found inside this query.
* @return $this * @return $this
*/ */
public function traverseExpressions(callable $callback) public function traverseExpressions(callable $callback)
{ {
$visitor = function ($expression) use (&$visitor, $callback) { if (!$callback instanceof Closure) {
if (is_array($expression)) { $callback = Closure::fromCallable($callback);
foreach ($expression as $e) { }
$visitor($e);
}
return null; foreach ($this->_parts as $part) {
} $this->_expressionsVisitor($part, $callback);
}
if ($expression instanceof ExpressionInterface) { return $this;
$expression->traverse($visitor); }
if (!($expression instanceof self)) { /**
$callback($expression); * Query parts traversal method used by traverseExpressions()
} *
* @param \Cake\Database\ExpressionInterface|\Cake\Database\ExpressionInterf
ace[] $expression Query expression or
* array of expressions.
* @param \Closure $callback The callback to be executed for each Expression
Interface
* found inside this query.
* @return void
*/
protected function _expressionsVisitor($expression, Closure $callback): void
{
if (is_array($expression)) {
foreach ($expression as $e) {
$this->_expressionsVisitor($e, $callback);
} }
};
return $this->traverse($visitor); return;
}
if ($expression instanceof ExpressionInterface) {
$expression->traverse(function ($exp) use ($callback) {
$this->_expressionsVisitor($exp, $callback);
});
if (!$expression instanceof self) {
$callback($expression);
}
}
} }
/** /**
* Associates a query placeholder to a value and a type. * Associates a query placeholder to a value and a type.
* *
* ``` * ```
* $query->bind(':id', 1, 'integer'); * $query->bind(':id', 1, 'integer');
* ``` * ```
* *
* @param string|int $param placeholder to be replaced with quoted version * @param string|int $param placeholder to be replaced with quoted version
 End of changes. 7 change blocks. 
17 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)