Skip to content

Commit

Permalink
Improve callable phpdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 8, 2023
1 parent 2bfe076 commit 98fcad5
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 129 deletions.
64 changes: 32 additions & 32 deletions Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,15 @@ public function set($set, $val = null, $bind = true)
* Can be used in two different ways, as where( field, value ) or as an array of
* conditions to use: where( array('fieldName', ...), array('value', ...) );
*
* @param string|string[]|callable $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
* @param string|string[]|\Closure($this): void $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
*
* @return $this
*
Expand Down Expand Up @@ -661,15 +661,15 @@ public function where($key, $value = null, $op = '=', $bind = true)
* Can be used in two different ways, as where( field, value ) or as an array of
* conditions to use: where( array('fieldName', ...), array('value', ...) );
*
* @param string|string[]|callable $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
* @param string|string[]|\Closure($this): void $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
*
* @return $this
*/
Expand All @@ -684,15 +684,15 @@ public function and_where($key, $value = null, $op = '=', $bind = true)
* Can be used in two different ways, as where( field, value ) or as an array of
* conditions to use: where( array('fieldName', ...), array('value', ...) );
*
* @param string|string[]|callable $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
* @param string|string[]|\Closure($this): void $key Single field name, or an array of field names.
* If given as a function (i.e. a closure), the function is called, passing the
* query itself in as the only parameter, so the function can add extra conditions
* with parentheses around the additional parameters.
* @param string|string[] $value Single field value, or an array of
* values. Can be null to search for `IS NULL` or `IS NOT NULL` (depending
* on the value of `$op` which should be `=` or `!=`.
* @param string $op Condition operator: <, >, = etc
* @param bool $bind Escape the value (true, default) or not (false).
*
* @return $this
*/
Expand Down Expand Up @@ -727,11 +727,11 @@ public function or_where($key, $value = null, $op = '=', $bind = true)
* define if a grouping bracket should be opened or closed in the query.
* This method is not prefer.
*
* @param bool|callable $inOut If callable it will create the group
* automatically and pass the query into the called function. For
* legacy operations use `true` to open brackets, `false` to close.
* @param string $op Conditional operator to use to join to the
* preceding condition. Default `AND`.
* @param bool|\Closure($this): void $inOut If callable it will create the group
* automatically and pass the query into the called function. For
* legacy operations use `true` to open brackets, `false` to close.
* @param string $op Conditional operator to use to join to the
* preceding condition. Default `AND`.
*
* @return $this
*
Expand Down
23 changes: 12 additions & 11 deletions Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace DataTables;

use DataTables;
use DataTables\Database\Query;
use DataTables\Editor\Field;
use DataTables\Editor\Join;

Expand Down Expand Up @@ -561,9 +562,9 @@ public function leftJoinRemove($_ = null)
* Add an event listener. The `Editor` class will trigger an number of
* events that some action can be taken on.
*
* @param string $name Event name
* @param callable $callback Callback function to execute when the event
* occurs
* @param string $name Event name
* @param callable($this, mixed, mixed, mixed, mixed, mixed): ?false $callback Callback function to execute when the event
* occurs
*
* @return $this
*/
Expand Down Expand Up @@ -859,9 +860,9 @@ public function validate(&$errors, $data)
* and remove actions performed from the client-side. Multiple validators
* can be added.
*
* @param callable $_ Function to execute when validating the input data.
* It is passed three parameters: 1. The editor instance, 2. The action
* and 3. The values.
* @param callable($this, self::ACTION_*, array): ?string $_ Function to execute when validating the input data.
* It is passed three parameters: 1. The editor instance, 2. The action
* and 3. The values.
*
* @return ($_ is null ? callable : $this) The validator function.
*/
Expand Down Expand Up @@ -890,9 +891,9 @@ public function validator($_ = null)
* undefined (since Editor expects the row to still be available, but the
* condition removes it from the result set).
*
* @param string|callable $key Single field name or a closure function
* @param string $value Single field value.
* @param string $op Condition operator: <, >, = etc
* @param string|\Closure(Query): void $key Single field name or a closure function
* @param string $value Single field value.
* @param string $op Condition operator: <, >, = etc
*
* @return ($key is null ? string[] : $this) Where condition array.
*/
Expand Down Expand Up @@ -2047,7 +2048,7 @@ private function _ssp_limit($query, $http)
private function _get_where($query)
{
for ($i = 0; $i < count($this->_where); ++$i) {
if (is_callable($this->_where[$i])) {
if ($this->_where[$i] instanceof \Closure) {
$this->_where[$i]($query);
} else {
$query->where(
Expand Down Expand Up @@ -2220,7 +2221,7 @@ private function _insert_or_update_table($table, $values, $where = null)
for ($j = 0, $jen = count($this->_where); $j < $jen; ++$j) {
$cond = $this->_where[$j];

if (!is_callable($cond)) {
if (!$cond instanceof \Closure) {
// Make sure the value wasn't in the submitted data set,
// otherwise we would be overwriting it
if (!isset($set[$cond['key']])) {
Expand Down
Loading

0 comments on commit 98fcad5

Please sign in to comment.