From 7228f4df8f4df129feb99419ec86a1aa22c19a46 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Fri, 29 Dec 2023 20:37:52 -0600 Subject: [PATCH 1/7] documentation corrections and test addition --- phalcon/DataMapper/Query/AbstractQuery.zep | 41 ++++++++++++ .../Validation/Validator/Uniqueness.zep | 12 ++-- phalcon/Mvc/Model/Criteria.zep | 35 +++++++++- phalcon/Mvc/Model/Query/Builder.zep | 26 +++++++- phalcon/Mvc/Model/Query/BuilderInterface.zep | 44 ++++++++++++- phalcon/Mvc/Model/Resultset/Complex.zep | 3 +- phalcon/Mvc/View/Engine/Volt/Compiler.zep | 56 +++++++++++++++- .../Engine/Volt/Compiler/CompileSetCest.php | 65 ++++++++++++++++++- 8 files changed, 266 insertions(+), 16 deletions(-) diff --git a/phalcon/DataMapper/Query/AbstractQuery.zep b/phalcon/DataMapper/Query/AbstractQuery.zep index d4a2056f3f8..5bb7af161bf 100644 --- a/phalcon/DataMapper/Query/AbstractQuery.zep +++ b/phalcon/DataMapper/Query/AbstractQuery.zep @@ -180,6 +180,47 @@ abstract class AbstractQuery this->store["WHERE"] = []; } + public function resetColumns() + { + let this->store["COLUMNS"] = []; + } + + public function resetFrom() + { + let this->store["FROM"] = []; + } + + public function resetWhere() + { + let this->store["WHERE"] = []; + } + + public function resetGroupBy() + { + let this->store["GROUP"] = []; + } + + public function resetHaving() + { + let this->store["HAVING"] = []; + } + + public function resetOrderBy() + { + let this->store["ORDER"] = []; + } + + public function resetLimit() + { + let this->store["LIMIT"] = 0, + this->store["OFFSET"] = 0; + } + + public function resetFlags() + { + let this->store["FLAGS"] = []; + } + /** * Builds the flags statement(s) * diff --git a/phalcon/Filter/Validation/Validator/Uniqueness.zep b/phalcon/Filter/Validation/Validator/Uniqueness.zep index 9b3e152a164..54e8a448e97 100644 --- a/phalcon/Filter/Validation/Validator/Uniqueness.zep +++ b/phalcon/Filter/Validation/Validator/Uniqueness.zep @@ -101,13 +101,13 @@ class Uniqueness extends AbstractCombinedFieldsValidator /** * Constructor * - * @param array options = [ - * 'message' => '', - * 'template' => '', + * @param array $options = [ + * 'message' => '', + * 'template' => '', * 'allowEmpty' => false, - * 'convert' => null, - * 'model' => null, - * 'except' => null + * 'convert' => null, + * 'model' => null, + * 'except' => null * ] */ public function __construct(array! options = []) diff --git a/phalcon/Mvc/Model/Criteria.zep b/phalcon/Mvc/Model/Criteria.zep index 751db8b1169..a62cc2abe95 100644 --- a/phalcon/Mvc/Model/Criteria.zep +++ b/phalcon/Mvc/Model/Criteria.zep @@ -158,18 +158,49 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface } /** - * Sets the columns to be queried + * Sets the columns to be queried. The columns can be either a `string` or + * an `array`. The string can specify one or more columns, separated by + * commas, the same way that one uses the SQL select statement. You can + * use aliases, aggregate functions etc. If you need to reference other + * models you will need to reference them with their namespaces. + * + * When using an array as a parameter, you will need to specify one field + * per element. If a key is defined in our array, it will be used as the + * alias in the query * *```php + * columns("id, name"); + * + * // Array, one column per element * $criteria->columns( * [ * "id", * "name", * ] * ); + * + * // Array, named keys. The name of the key acts as an alias (`AS` clause) + * $criteria->columns( + * [ + * "name", + * "number" => "COUNT(*)", + * ] + * ); + * + * // Different models + * $criteria->columns( + * [ + * "\Phalcon\Models\Invoices.*", + * "\Phalcon\Models\Customers.cst_name_first", + * "\Phalcon\Models\Customers.cst_name_last", + * ] + * ); *``` * - * @param string|array columns + * @param string|array $columns */ public function columns(var columns) -> { diff --git a/phalcon/Mvc/Model/Query/Builder.zep b/phalcon/Mvc/Model/Query/Builder.zep index d3cf01ccfa0..9c00c5e3b0e 100644 --- a/phalcon/Mvc/Model/Query/Builder.zep +++ b/phalcon/Mvc/Model/Query/Builder.zep @@ -447,11 +447,23 @@ class Builder implements BuilderInterface, InjectionAwareInterface } /** - * Sets the columns to be queried + * Sets the columns to be queried. The columns can be either a `string` or + * an `array`. The string can specify one or more columns, separated by + * commas, the same way that one uses the SQL select statement. You can + * use aliases, aggregate functions etc. If you need to reference other + * models you will need to reference them with their namespaces. + * + * When using an array as a parameter, you will need to specify one field + * per element. If a key is defined in our array, it will be used as the + * alias in the query * *```php + * columns("id, name"); * + * // Array, one column per element * $builder->columns( * [ * "id", @@ -459,13 +471,25 @@ class Builder implements BuilderInterface, InjectionAwareInterface * ] * ); * + * // Array, named keys. The name of the key acts as an alias (`AS` clause) * $builder->columns( * [ * "name", * "number" => "COUNT(*)", * ] * ); + * + * // Different models + * $builder->columns( + * [ + * "\Phalcon\Models\Invoices.*", + * "\Phalcon\Models\Customers.cst_name_first", + * "\Phalcon\Models\Customers.cst_name_last", + * ] + * ); *``` + * + * @param string|array $columns */ public function columns(var columns) -> { diff --git a/phalcon/Mvc/Model/Query/BuilderInterface.zep b/phalcon/Mvc/Model/Query/BuilderInterface.zep index 8b6327ebb30..d575b57098d 100644 --- a/phalcon/Mvc/Model/Query/BuilderInterface.zep +++ b/phalcon/Mvc/Model/Query/BuilderInterface.zep @@ -41,9 +41,49 @@ interface BuilderInterface public function betweenWhere(string! expr, minimum, maximum, string! operator = BuilderInterface::OPERATOR_AND) -> ; /** - * Sets the columns to be queried + * Sets the columns to be queried. The columns can be either a `string` or + * an `array`. The string can specify one or more columns, separated by + * commas, the same way that one uses the SQL select statement. You can + * use aliases, aggregate functions etc. If you need to reference other + * models you will need to reference them with their namespaces. * - * @param string|array columns + * When using an array as a parameter, you will need to specify one field + * per element. If a key is defined in our array, it will be used as the + * alias in the query + * + *```php + * columns("id, name"); + * + * // Array, one column per element + * $builder->columns( + * [ + * "id", + * "name", + * ] + * ); + * + * // Array, named keys. The name of the key acts as an alias (`AS` clause) + * $builder->columns( + * [ + * "name", + * "number" => "COUNT(*)", + * ] + * ); + * + * // Different models + * $builder->columns( + * [ + * "\Phalcon\Models\Invoices.*", + * "\Phalcon\Models\Customers.cst_name_first", + * "\Phalcon\Models\Customers.cst_name_last", + * ] + * ); + *``` + * + * @param string|array $columns */ public function columns(columns) -> ; diff --git a/phalcon/Mvc/Model/Resultset/Complex.zep b/phalcon/Mvc/Model/Resultset/Complex.zep index dfc4cda31d7..2fd385c062e 100644 --- a/phalcon/Mvc/Model/Resultset/Complex.zep +++ b/phalcon/Mvc/Model/Resultset/Complex.zep @@ -285,7 +285,8 @@ class Complex extends Resultset implements ResultsetInterface } /** - * Serializing a resultset will dump all related rows into a big array + * Serializing a resultset will dump all related rows into a big array, + * serialize it and return the resulting string */ public function serialize() -> string { diff --git a/phalcon/Mvc/View/Engine/Volt/Compiler.zep b/phalcon/Mvc/View/Engine/Volt/Compiler.zep index 0aa770fbc52..aefe7610498 100644 --- a/phalcon/Mvc/View/Engine/Volt/Compiler.zep +++ b/phalcon/Mvc/View/Engine/Volt/Compiler.zep @@ -1144,9 +1144,59 @@ class Compiler implements InjectionAwareInterface } /** - * Compiles a "set" statement returning PHP code - * - * @param array statement + * Compiles a "set" statement returning PHP code. The method accepts an + * array produced by the Volt parser and creates the `set` statement in PHP. + * This method is not particularly useful in development, since it requires + * advanced knowledge of the Volt parser. + * + * ```php + * 306, + * "assignments" => [ + * [ + * "variable" => [ + * "type" => 265, + * "value" => "a", + * "file" => "eval code", + * "line" => 1 + * ], + * "op" => 61, + * "expr" => [ + * "type" => 360, + * "left" => [ + * [ + * "expr" => [ + * "type" => 258, + * "value" => "1", + * "file" => "eval code", + * "line" => 1 + * ], + * "name" => "first", + * "file" => "eval code", + * "line" => 1 + * ] + * ], + * "file" => "eval code", + * "line" => 1 + * ], + * "file" => "eval code", + * "line" => 1 + * ] + * ] + * ]; + * + * echo $compiler->compileSet($source); + * // 1]; ?>"; + * + * @param array $statement * * @throws \Phalcon\Mvc\View\Engine\Volt\Exception * @return string diff --git a/tests/integration/Mvc/View/Engine/Volt/Compiler/CompileSetCest.php b/tests/integration/Mvc/View/Engine/Volt/Compiler/CompileSetCest.php index e805561d9cc..01bb7812d3a 100644 --- a/tests/integration/Mvc/View/Engine/Volt/Compiler/CompileSetCest.php +++ b/tests/integration/Mvc/View/Engine/Volt/Compiler/CompileSetCest.php @@ -14,6 +14,7 @@ namespace Phalcon\Tests\Integration\Mvc\View\Engine\Volt\Compiler; use IntegrationTester; +use Phalcon\Mvc\View\Engine\Volt\Compiler; /** * Class CompileSetCest @@ -29,6 +30,68 @@ class CompileSetCest public function mvcViewEngineVoltCompilerCompileSet(IntegrationTester $I) { $I->wantToTest('Mvc\View\Engine\Volt\Compiler - compileSet()'); - $I->skipTest('Need implementation'); + + $volt = new Compiler(); + + $source = [ + "type" => 306, + "assignments" => [ + [ + "variable" => [ + "type" => 265, + "value" => "a", + "file" => "eval code", + "line" => 1 + ], + "op" => 61, + "expr" => [ + "type" => 360, + "left" => [ + [ + "expr" => [ + "type" => 258, + "value" => "1", + "file" => "eval code", + "line" => 1 + ], + "name" => "first", + "file" => "eval code", + "line" => 1 + ], + [ + "expr" => [ + "type" => 258, + "value" => "2", + "file" => "eval code", + "line" => 1 + ], + "name" => "second", + "file" => "eval code", + "line" => 1 + ], + [ + "expr" => [ + "type" => 258, + "value" => "3", + "file" => "eval code", + "line" => 1 + ], + "name" => "third", + "file" => "eval code", + "line" => 1 + ] + ], + "file" => "eval code", + "line" => 1 + ], + "file" => "eval code", + "line" => 1 + ] + ] + ]; + + $expected = " 1, 'second' => 2, 'third' => 3]; ?>"; + $actual = $volt->compileSet($source); + $I->assertSame($expected, $actual); } } From 5da065704417c0e2798783b2bf59a84b972076d6 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sat, 6 Jan 2024 14:28:09 -0600 Subject: [PATCH 2/7] mostly docblock corrections; returning self from datamapper --- phalcon/DataMapper/Query/AbstractQuery.zep | 60 ++++++++++-- phalcon/Mvc/Model.zep | 25 +++-- phalcon/Mvc/Model/Criteria.zep | 99 +++++++++++--------- phalcon/Mvc/Model/Query/Builder.zep | 26 ++--- phalcon/Mvc/Model/Query/BuilderInterface.zep | 13 +-- phalcon/Mvc/View/Engine/Volt/Compiler.zep | 1 + 6 files changed, 145 insertions(+), 79 deletions(-) diff --git a/phalcon/DataMapper/Query/AbstractQuery.zep b/phalcon/DataMapper/Query/AbstractQuery.zep index 5bb7af161bf..d97c1a42287 100644 --- a/phalcon/DataMapper/Query/AbstractQuery.zep +++ b/phalcon/DataMapper/Query/AbstractQuery.zep @@ -167,7 +167,7 @@ abstract class AbstractQuery /** * Resets the internal array */ - public function reset() + public function reset() -> { let this->store["COLUMNS"] = [], this->store["FLAGS"] = [], @@ -178,47 +178,89 @@ abstract class AbstractQuery this->store["ORDER"] = [], this->store["OFFSET"] = 0, this->store["WHERE"] = []; + + return this; } - public function resetColumns() + /** + * Resets the columns + */ + public function resetColumns() -> { let this->store["COLUMNS"] = []; + + return this; } - public function resetFrom() + /** + * Resets the from + */ + public function resetFrom() -> { let this->store["FROM"] = []; + + return this; } - public function resetWhere() + /** + * Resets the where + */ + public function resetWhere() -> { let this->store["WHERE"] = []; + + return this; } - public function resetGroupBy() + /** + * Resets the group by + */ + public function resetGroupBy() -> { let this->store["GROUP"] = []; + + return this; } - public function resetHaving() + /** + * Resets the having + */ + public function resetHaving() -> { let this->store["HAVING"] = []; + + return this; } - public function resetOrderBy() + /** + * Resets the order by + */ + public function resetOrderBy() -> { let this->store["ORDER"] = []; + + return this; } - public function resetLimit() + /** + * Resets the limit and offset + */ + public function resetLimit() -> { let this->store["LIMIT"] = 0, this->store["OFFSET"] = 0; + + return this; } - public function resetFlags() + /** + * Resets the flags + */ + public function resetFlags() -> { let this->store["FLAGS"] = []; + + return this; } /** diff --git a/phalcon/Mvc/Model.zep b/phalcon/Mvc/Model.zep index dc000d98422..e3b4fdeea1d 100644 --- a/phalcon/Mvc/Model.zep +++ b/phalcon/Mvc/Model.zep @@ -3342,17 +3342,26 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface, /** * Updates a model instance. If the instance doesn't exist in the - * persistence it will throw an exception. Returning true on success or - * false otherwise. + * persistence it will throw an exception. Returning `true` on success or + * `false` otherwise. * - *```php - * // Updating a robot name - * $robot = Robots::findFirst("id = 100"); + * ```php + * name = "Biomass"; + * use MyApp\Models\Invoices; * - * $robot->update(); - *``` + * $invoice = Invoices::findFirst('inv_id = 4'); + * + * $invoice->inv_total = 120; + * + * $invoice->update(); + * ``` + * + * !!! warning "NOTE" + * + * When retrieving the record with `findFirst()`, you need to get the full + * object back (no `columns` definition) but also retrieve it using the + * primary key. If not, the ORM will issue an `INSERT` instead of `UPDATE`. */ public function update() -> bool { diff --git a/phalcon/Mvc/Model/Criteria.zep b/phalcon/Mvc/Model/Criteria.zep index a62cc2abe95..554a1875e29 100644 --- a/phalcon/Mvc/Model/Criteria.zep +++ b/phalcon/Mvc/Model/Criteria.zep @@ -17,19 +17,19 @@ use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; /** - * Phalcon\Mvc\Model\Criteria - * * This class is used to build the array parameter required by * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() using an * object-oriented interface. * * ```php - * $robots = Robots::query() - * ->where("type = :type:") - * ->andWhere("year < 2000") - * ->bind(["type" => "mechanical"]) + * where("inv_cst_id = :customerId:") + * ->andWhere("inv_created_date < '2000-01-01'") + * ->bind(["customerId" => 1]) * ->limit(5, 10) - * ->orderBy("name") + * ->orderBy("inv_title") * ->execute(); * ``` */ @@ -159,34 +159,36 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface /** * Sets the columns to be queried. The columns can be either a `string` or - * an `array`. The string can specify one or more columns, separated by - * commas, the same way that one uses the SQL select statement. You can - * use aliases, aggregate functions etc. If you need to reference other - * models you will need to reference them with their namespaces. + * an `array` of strings. If the argument is a (single, non-embedded) string, + * its content can specify one or more columns, separated by commas, the same + * way that one uses the SQL select statement. You can use aliases, aggregate + * functions, etc. If you need to reference other models you will need to + * reference them with their namespaces. * * When using an array as a parameter, you will need to specify one field - * per element. If a key is defined in our array, it will be used as the - * alias in the query + * per array element. If a non-numeric key is defined in the array, it will + * be used as the alias in the query * *```php * columns("id, name"); + * $criteria->columns("id, category"); * * // Array, one column per element * $criteria->columns( * [ - * "id", - * "name", + * "inv_id", + * "inv_total", * ] * ); * - * // Array, named keys. The name of the key acts as an alias (`AS` clause) + * // Array with named key. The name of the key acts as an + * // alias (`AS` clause) * $criteria->columns( * [ - * "name", - * "number" => "COUNT(*)", + * "inv_cst_id", + * "total_invoices" => "COUNT(*)", * ] * ); * @@ -222,10 +224,11 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface /** * Creates a query builder from criteria. * - * ```php - * $builder = Robots::query() - * ->where("type = :type:") - * ->bind(["type" => "mechanical"]) + * where("inv_cst_id = :customerId:") + * ->bind(["customerId" => 1]) * ->createBuilder(); * ``` */ @@ -524,19 +527,21 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface * Adds an INNER join to the query * *```php + * innerJoin( - * Robots::class + * Invoices::class * ); * * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id" + * Invoices::class, + * "inv_cst_id = Customers.cst_id" * ); * * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * Invoices::class, + * "i.inv_cst_id = Customers.cst_id", + * "i" * ); *``` */ @@ -601,25 +606,27 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface * Adds an INNER join to the query * *```php + * join( - * Robots::class + * Invoices::class * ); * * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id" + * Invoices::class, + * "inv_cst_id = Customers.cst_id" * ); * * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * Invoices::class, + * "i.inv_cst_id = Customers.cst_id", + * "i" * ); * * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r", + * Invoices::class, + * "i.inv_cst_id = Customers.cst_id", + * "i", * "LEFT" * ); *``` @@ -650,10 +657,12 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface * Adds a LEFT join to the query * *```php + * leftJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * Invoices::class, + * "i.inv_cst_id = Customers.cst_id", + * "i" * ); *``` */ @@ -808,10 +817,12 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface * Adds a RIGHT join to the query * *```php + * rightJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * Invoices::class, + * "i.inv_cst_id = Customers.cst_id", + * "i" * ); *``` */ diff --git a/phalcon/Mvc/Model/Query/Builder.zep b/phalcon/Mvc/Model/Query/Builder.zep index 9c00c5e3b0e..d5fc63093e2 100644 --- a/phalcon/Mvc/Model/Query/Builder.zep +++ b/phalcon/Mvc/Model/Query/Builder.zep @@ -448,34 +448,36 @@ class Builder implements BuilderInterface, InjectionAwareInterface /** * Sets the columns to be queried. The columns can be either a `string` or - * an `array`. The string can specify one or more columns, separated by - * commas, the same way that one uses the SQL select statement. You can - * use aliases, aggregate functions etc. If you need to reference other - * models you will need to reference them with their namespaces. + * an `array` of strings. If the argument is a (single, non-embedded) string, + * its content can specify one or more columns, separated by commas, the same + * way that one uses the SQL select statement. You can use aliases, aggregate + * functions, etc. If you need to reference other models you will need to + * reference them with their namespaces. * * When using an array as a parameter, you will need to specify one field - * per element. If a key is defined in our array, it will be used as the - * alias in the query + * per array element. If a non-numeric key is defined in the array, it will + * be used as the alias in the query * *```php * columns("id, name"); + * $builder->columns("id, category"); * * // Array, one column per element * $builder->columns( * [ - * "id", - * "name", + * "inv_id", + * "inv_total", * ] * ); * - * // Array, named keys. The name of the key acts as an alias (`AS` clause) + * // Array with named key. The name of the key acts as an + * // alias (`AS` clause) * $builder->columns( * [ - * "name", - * "number" => "COUNT(*)", + * "inv_cst_id", + * "total_invoices" => "COUNT(*)", * ] * ); * diff --git a/phalcon/Mvc/Model/Query/BuilderInterface.zep b/phalcon/Mvc/Model/Query/BuilderInterface.zep index d575b57098d..b2ee428dd29 100644 --- a/phalcon/Mvc/Model/Query/BuilderInterface.zep +++ b/phalcon/Mvc/Model/Query/BuilderInterface.zep @@ -42,14 +42,15 @@ interface BuilderInterface /** * Sets the columns to be queried. The columns can be either a `string` or - * an `array`. The string can specify one or more columns, separated by - * commas, the same way that one uses the SQL select statement. You can - * use aliases, aggregate functions etc. If you need to reference other - * models you will need to reference them with their namespaces. + * an `array` of strings. If the argument is a (single, non-embedded) string, + * its content can specify one or more columns, separated by commas, the same + * way that one uses the SQL select statement. You can use aliases, aggregate + * functions, etc. If you need to reference other models you will need to + * reference them with their namespaces. * * When using an array as a parameter, you will need to specify one field - * per element. If a key is defined in our array, it will be used as the - * alias in the query + * per array element. If a non-numeric key is defined in the array, it will + * be used as the alias in the query * *```php * compileSet($source); * // 1]; ?>"; + * ``` * * @param array $statement * From 7dde46079747c9a7faac3dd3f6193b4641845bb0 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sat, 6 Jan 2024 15:22:40 -0600 Subject: [PATCH 3/7] correcting return types for reset --- phalcon/DataMapper/Query/Delete.zep | 4 +++- phalcon/DataMapper/Query/Insert.zep | 4 +++- phalcon/DataMapper/Query/Update.zep | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/phalcon/DataMapper/Query/Delete.zep b/phalcon/DataMapper/Query/Delete.zep index 214dc3ed6f6..efa115bddd8 100644 --- a/phalcon/DataMapper/Query/Delete.zep +++ b/phalcon/DataMapper/Query/Delete.zep @@ -82,11 +82,13 @@ class Delete extends AbstractConditions /** * Resets the internal store */ - public function reset() -> void + public function reset() -> { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; + + return this; } } diff --git a/phalcon/DataMapper/Query/Insert.zep b/phalcon/DataMapper/Query/Insert.zep index 372bfa6ea27..dce87226a15 100644 --- a/phalcon/DataMapper/Query/Insert.zep +++ b/phalcon/DataMapper/Query/Insert.zep @@ -134,12 +134,14 @@ class Insert extends AbstractQuery /** * Resets the internal store */ - public function reset() -> void + public function reset() -> { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; + + return this; } /** diff --git a/phalcon/DataMapper/Query/Update.zep b/phalcon/DataMapper/Query/Update.zep index 5db700f82f5..fe2a8d3b051 100644 --- a/phalcon/DataMapper/Query/Update.zep +++ b/phalcon/DataMapper/Query/Update.zep @@ -133,12 +133,14 @@ class Update extends AbstractConditions /** * Resets the internal store */ - public function reset() -> void + public function reset() -> { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; + + return this; } /** From cbfb63a3a5f68f8045382851547808cf8ae4bd25 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sat, 6 Jan 2024 15:39:53 -0600 Subject: [PATCH 4/7] reverting return types for datamapper --- phalcon/DataMapper/Query/AbstractQuery.zep | 36 ++++++---------------- phalcon/DataMapper/Query/Delete.zep | 4 +-- phalcon/DataMapper/Query/Insert.zep | 4 +-- phalcon/DataMapper/Query/Update.zep | 4 +-- 4 files changed, 12 insertions(+), 36 deletions(-) diff --git a/phalcon/DataMapper/Query/AbstractQuery.zep b/phalcon/DataMapper/Query/AbstractQuery.zep index d97c1a42287..3cba3ae7ef7 100644 --- a/phalcon/DataMapper/Query/AbstractQuery.zep +++ b/phalcon/DataMapper/Query/AbstractQuery.zep @@ -167,7 +167,7 @@ abstract class AbstractQuery /** * Resets the internal array */ - public function reset() -> + public function reset() -> void { let this->store["COLUMNS"] = [], this->store["FLAGS"] = [], @@ -178,89 +178,71 @@ abstract class AbstractQuery this->store["ORDER"] = [], this->store["OFFSET"] = 0, this->store["WHERE"] = []; - - return this; } /** * Resets the columns */ - public function resetColumns() -> + public function resetColumns() -> void { let this->store["COLUMNS"] = []; - - return this; } /** * Resets the from */ - public function resetFrom() -> + public function resetFrom() -> void { let this->store["FROM"] = []; - - return this; } /** * Resets the where */ - public function resetWhere() -> + public function resetWhere() -> void { let this->store["WHERE"] = []; - - return this; } /** * Resets the group by */ - public function resetGroupBy() -> + public function resetGroupBy() -> void { let this->store["GROUP"] = []; - - return this; } /** * Resets the having */ - public function resetHaving() -> + public function resetHaving() -> void { let this->store["HAVING"] = []; - - return this; } /** * Resets the order by */ - public function resetOrderBy() -> + public function resetOrderBy() -> void { let this->store["ORDER"] = []; - - return this; } /** * Resets the limit and offset */ - public function resetLimit() -> + public function resetLimit() -> void { let this->store["LIMIT"] = 0, this->store["OFFSET"] = 0; - - return this; } /** * Resets the flags */ - public function resetFlags() -> + public function resetFlags() -> void { let this->store["FLAGS"] = []; - - return this; } /** diff --git a/phalcon/DataMapper/Query/Delete.zep b/phalcon/DataMapper/Query/Delete.zep index efa115bddd8..214dc3ed6f6 100644 --- a/phalcon/DataMapper/Query/Delete.zep +++ b/phalcon/DataMapper/Query/Delete.zep @@ -82,13 +82,11 @@ class Delete extends AbstractConditions /** * Resets the internal store */ - public function reset() -> + public function reset() -> void { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; - - return this; } } diff --git a/phalcon/DataMapper/Query/Insert.zep b/phalcon/DataMapper/Query/Insert.zep index dce87226a15..372bfa6ea27 100644 --- a/phalcon/DataMapper/Query/Insert.zep +++ b/phalcon/DataMapper/Query/Insert.zep @@ -134,14 +134,12 @@ class Insert extends AbstractQuery /** * Resets the internal store */ - public function reset() -> + public function reset() -> void { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; - - return this; } /** diff --git a/phalcon/DataMapper/Query/Update.zep b/phalcon/DataMapper/Query/Update.zep index fe2a8d3b051..5db700f82f5 100644 --- a/phalcon/DataMapper/Query/Update.zep +++ b/phalcon/DataMapper/Query/Update.zep @@ -133,14 +133,12 @@ class Update extends AbstractConditions /** * Resets the internal store */ - public function reset() -> + public function reset() -> void { parent::reset(); let this->store["FROM"] = "", this->store["RETURNING"] = []; - - return this; } /** From 34b0acddb107387be92e482208e6ba929d4d2657 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sat, 6 Jan 2024 15:48:37 -0600 Subject: [PATCH 5/7] correcting return type for select --- phalcon/DataMapper/Query/Select.zep | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/phalcon/DataMapper/Query/Select.zep b/phalcon/DataMapper/Query/Select.zep index 9582ab53dc1..b3c8eea12cd 100644 --- a/phalcon/DataMapper/Query/Select.zep +++ b/phalcon/DataMapper/Query/Select.zep @@ -352,17 +352,13 @@ class Select extends AbstractConditions /** * Resets the internal collections - * - * @return Select */ - public function reset() ->