-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: fix PHPDoc and comments in Models #6822
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use CodeIgniter\Database\BaseResult; | ||
use CodeIgniter\Database\Exceptions\DatabaseException; | ||
use CodeIgniter\Database\Exceptions\DataException; | ||
use CodeIgniter\Database\Query; | ||
use CodeIgniter\Exceptions\ModelException; | ||
use CodeIgniter\I18n\Time; | ||
use CodeIgniter\Pager\Pager; | ||
|
@@ -311,8 +312,8 @@ protected function initialize() | |
} | ||
|
||
/** | ||
* Fetches the row of database | ||
* This methods works only with dbCalls | ||
* Fetches the row of database. | ||
* This method works only with dbCalls. | ||
* | ||
* @param bool $singleton Single or multiple results | ||
* @param array|int|string|null $id One primary key or an array of primary keys | ||
|
@@ -322,8 +323,8 @@ protected function initialize() | |
abstract protected function doFind(bool $singleton, $id = null); | ||
|
||
/** | ||
* Fetches the column of database | ||
* This methods works only with dbCalls | ||
* Fetches the column of database. | ||
* This method works only with dbCalls. | ||
* | ||
* @param string $columnName Column Name | ||
* | ||
|
@@ -335,7 +336,7 @@ abstract protected function doFindColumn(string $columnName); | |
|
||
/** | ||
* Fetches all results, while optionally limiting them. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @param int $limit Limit | ||
* @param int $offset Offset | ||
|
@@ -346,15 +347,15 @@ abstract protected function doFindAll(int $limit = 0, int $offset = 0); | |
|
||
/** | ||
* Returns the first row of the result set. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @return array|object|null | ||
*/ | ||
abstract protected function doFirst(); | ||
|
||
/** | ||
* Inserts data into the current database | ||
* This method works only with dbCalls | ||
* Inserts data into the current database. | ||
* This method works only with dbCalls. | ||
* | ||
* @param array $data Data | ||
* | ||
|
@@ -364,7 +365,7 @@ abstract protected function doInsert(array $data); | |
|
||
/** | ||
* Compiles batch insert and runs the queries, validating each row prior. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @param array|null $set An associative array of insert values | ||
* @param bool|null $escape Whether to escape values | ||
|
@@ -377,31 +378,31 @@ abstract protected function doInsertBatch(?array $set = null, ?bool $escape = nu | |
|
||
/** | ||
* Updates a single record in the database. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @param array|int|string|null $id ID | ||
* @param array|null $data Data | ||
*/ | ||
abstract protected function doUpdate($id = null, $data = null): bool; | ||
|
||
/** | ||
* Compiles an update and runs the query | ||
* This methods works only with dbCalls | ||
* Compiles an update and runs the query. | ||
* This method works only with dbCalls. | ||
* | ||
* @param array|null $set An associative array of update values | ||
* @param string|null $index The where key | ||
* @param int $batchSize The size of the batch to run | ||
* @param bool $returnSQL True means SQL is returned, false will execute the query | ||
* | ||
* @return mixed Number of rows affected or FALSE on failure | ||
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode | ||
* | ||
* @throws DatabaseException | ||
*/ | ||
abstract protected function doUpdateBatch(?array $set = null, ?string $index = null, int $batchSize = 100, bool $returnSQL = false); | ||
|
||
/** | ||
* Deletes a single record from the database where $id matches | ||
* This methods works only with dbCalls | ||
* Deletes a single record from the database where $id matches. | ||
* This method works only with dbCalls. | ||
* | ||
* @param array|int|string|null $id The rows primary key(s) | ||
* @param bool $purge Allows overriding the soft deletes setting. | ||
|
@@ -413,9 +414,9 @@ abstract protected function doUpdateBatch(?array $set = null, ?string $index = n | |
abstract protected function doDelete($id = null, bool $purge = false); | ||
|
||
/** | ||
* Permanently deletes all rows that have been marked as deleted | ||
* through soft deletes (deleted = 1) | ||
* This methods works only with dbCalls | ||
* Permanently deletes all rows that have been marked as deleted. | ||
* through soft deletes (deleted = 1). | ||
* This method works only with dbCalls. | ||
* | ||
* @return bool|string Returns a string if in test mode. | ||
*/ | ||
|
@@ -424,31 +425,31 @@ abstract protected function doPurgeDeleted(); | |
/** | ||
* Works with the find* methods to return only the rows that | ||
* have been deleted. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
*/ | ||
abstract protected function doOnlyDeleted(); | ||
|
||
/** | ||
* Compiles a replace and runs the query | ||
* This methods works only with dbCalls | ||
* Compiles a replace and runs the query. | ||
* This method works only with dbCalls. | ||
* | ||
* @param array|null $data Data | ||
* @param bool $returnSQL Set to true to return Query String | ||
* | ||
* @return mixed | ||
* @return BaseResult|false|Query|string | ||
*/ | ||
abstract protected function doReplace(?array $data = null, bool $returnSQL = false); | ||
|
||
/** | ||
* Grabs the last error(s) that occurred from the Database connection. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @return array|null | ||
*/ | ||
abstract protected function doErrors(); | ||
|
||
/** | ||
* Returns the id value for the data array or object | ||
* Returns the id value for the data array or object. | ||
* | ||
* @param array|object $data Data | ||
* | ||
|
@@ -459,8 +460,8 @@ abstract protected function doErrors(); | |
abstract protected function idValue($data); | ||
|
||
/** | ||
* Public getter to return the id value using the idValue() method | ||
* For example with SQL this will return $data->$this->primaryKey | ||
* Public getter to return the id value using the idValue() method. | ||
* For example with SQL this will return $data->$this->primaryKey. | ||
* | ||
* @param array|object $data | ||
* | ||
|
@@ -475,18 +476,18 @@ public function getIdValue($data) | |
|
||
/** | ||
* Override countAllResults to account for soft deleted accounts. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @param bool $reset Reset | ||
* @param bool $test Test | ||
* | ||
* @return mixed | ||
* @return int|string | ||
*/ | ||
abstract public function countAllResults(bool $reset = true, bool $test = false); | ||
|
||
/** | ||
* Loops over records in batches, allowing you to operate on them. | ||
* This methods works only with dbCalls | ||
* This method works only with dbCalls. | ||
* | ||
* @param int $size Size | ||
* @param Closure $userFunc Callback Function | ||
|
@@ -496,7 +497,7 @@ abstract public function countAllResults(bool $reset = true, bool $test = false) | |
abstract public function chunk(int $size, Closure $userFunc); | ||
|
||
/** | ||
* Fetches the row of database | ||
* Fetches the row of database. | ||
* | ||
* @param array|int|string|null $id One primary key or an array of primary keys | ||
* | ||
|
@@ -538,7 +539,7 @@ public function find($id = null) | |
} | ||
|
||
/** | ||
* Fetches the column of database | ||
* Fetches the column of database. | ||
* | ||
* @param string $columnName Column Name | ||
* | ||
|
@@ -667,8 +668,8 @@ public function save($data): bool | |
} | ||
|
||
/** | ||
* This method is called on save to determine if entry have to be updated | ||
* If this method return false insert operation will be executed | ||
* This method is called on save to determine if entry have to be updated. | ||
* If this method returns false insert operation will be executed | ||
* | ||
* @param array|object $data Data | ||
*/ | ||
|
@@ -719,7 +720,7 @@ public function insert($data = null, bool $returnID = true) | |
// Restore $cleanValidationRules | ||
$this->cleanValidationRules = $cleanValidationRules; | ||
|
||
// Must be called first so we don't | ||
// Must be called first, so we don't | ||
// strip out created_at values. | ||
$data = $this->doProtectFields($data); | ||
|
||
|
@@ -896,14 +897,14 @@ public function update($id = null, $data = null): bool | |
} | ||
|
||
/** | ||
* Compiles an update and runs the query | ||
* Compiles an update and runs the query. | ||
* | ||
* @param array|null $set An associative array of update values | ||
* @param string|null $index The where key | ||
* @param int $batchSize The size of the batch to run | ||
* @param bool $returnSQL True means SQL is returned, false will execute the query | ||
* | ||
* @return mixed Number of rows affected or FALSE on failure | ||
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode | ||
* | ||
* @throws DatabaseException | ||
* @throws ReflectionException | ||
|
@@ -953,7 +954,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc | |
} | ||
|
||
/** | ||
* Deletes a single record from the database where $id matches | ||
* Deletes a single record from the database where $id matches. | ||
* | ||
* @param array|int|string|null $id The rows primary key(s) | ||
* @param bool $purge Allows overriding the soft deletes setting. | ||
|
@@ -995,9 +996,9 @@ public function delete($id = null, bool $purge = false) | |
|
||
/** | ||
* Permanently deletes all rows that have been marked as deleted | ||
* through soft deletes (deleted = 1) | ||
* through soft deletes (deleted = 1). | ||
* | ||
* @return mixed | ||
* @return bool|string Returns a string if in test mode. | ||
*/ | ||
public function purgeDeleted() | ||
{ | ||
|
@@ -1038,12 +1039,12 @@ public function onlyDeleted() | |
} | ||
|
||
/** | ||
* Compiles a replace and runs the query | ||
* Compiles a replace and runs the query. | ||
* | ||
* @param array|null $data Data | ||
* @param bool $returnSQL Set to true to return Query String | ||
* | ||
* @return mixed | ||
* @return BaseResult|false|Query|string | ||
*/ | ||
public function replace(?array $data = null, bool $returnSQL = false) | ||
{ | ||
|
@@ -1063,6 +1064,7 @@ public function replace(?array $data = null, bool $returnSQL = false) | |
* Grabs the last error(s) that occurred. If data was validated, | ||
* it will first check for errors there, otherwise will try to | ||
* grab the last error from the Database connection. | ||
* | ||
* The return array should be in the following format: | ||
* ['source' => 'message'] | ||
* | ||
|
@@ -1170,11 +1172,11 @@ protected function doProtectFields(array $data): array | |
} | ||
|
||
/** | ||
* Sets the date or current date if null value is passed | ||
* Sets the date or current date if null value is passed. | ||
* | ||
* @param int|null $userData An optional PHP timestamp to be converted. | ||
* | ||
* @return mixed | ||
* @return int|string | ||
* | ||
* @throws ModelException | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I sent a PR #6825 |
||
|
@@ -1220,7 +1222,7 @@ protected function intToDate(int $value) | |
} | ||
|
||
/** | ||
* Converts Time value to string using $this->dateFormat | ||
* Converts Time value to string using $this->dateFormat. | ||
* | ||
* The available time formats are: | ||
* - 'int' - Stores the date as an integer timestamp | ||
|
@@ -1397,7 +1399,7 @@ public function getValidationRules(array $options = []): array | |
} | ||
|
||
/** | ||
* Returns the model's define validation messages so they | ||
* Returns the model's define validation messages, so they | ||
kenjis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* can be used elsewhere, if needed. | ||
*/ | ||
public function getValidationMessages(): array | ||
|
@@ -1454,14 +1456,14 @@ public function allowCallbacks(bool $val = true) | |
* | ||
* Each $eventData array MUST have a 'data' key with the relevant | ||
* data for callback methods (like an array of key/value pairs to insert | ||
* or update, an array of results, etc) | ||
* or update, an array of results, etc.) | ||
* | ||
* If callbacks are not allowed then returns $eventData immediately. | ||
* | ||
* @param string $event Event | ||
* @param array $eventData Event Data | ||
* | ||
* @return mixed | ||
* @return array | ||
* | ||
* @throws DataException | ||
*/ | ||
|
@@ -1513,14 +1515,14 @@ public function asObject(string $class = 'object') | |
} | ||
|
||
/** | ||
* Takes a class and returns an array of it's public and protected | ||
* Takes a class and returns an array of its public and protected | ||
* properties as an array suitable for use in creates and updates. | ||
* This method uses objectToRawArray() internally and does conversion | ||
* to string on all Time instances | ||
* | ||
* @param object|string $data Data | ||
* @param bool $onlyChanged Only Changed Property | ||
* @param bool $recursive If true, inner entities will be casted as array as well | ||
* @param bool $recursive If true, inner entities will be cast as array as well | ||
* | ||
* @return array Array | ||
* | ||
|
@@ -1579,7 +1581,7 @@ protected function objectToRawArray($data, bool $onlyChanged = true, bool $recur | |
} | ||
|
||
/** | ||
* Transform data to array | ||
* Transform data to array. | ||
* | ||
* @param array|object|null $data Data | ||
* @param string $type Type of data (insert|update) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are annoying to support. I would like to see in v5 some kind of Database Proxy that passes requests through to the driver for most cases but "captures" the actual SQL query for Test Mode. I think that would be a much better approach than trying to adjust all our return types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the return types are not good, should be
bool
only.