1212namespace CodeIgniter ;
1313
1414use Closure ;
15+ use CodeIgniter \Database \BaseConnection ;
1516use CodeIgniter \Database \BaseResult ;
1617use CodeIgniter \Database \Exceptions \DatabaseException ;
1718use CodeIgniter \Database \Exceptions \DataException ;
1819use CodeIgniter \Exceptions \ModelException ;
1920use CodeIgniter \I18n \Time ;
2021use CodeIgniter \Pager \Pager ;
22+ use CodeIgniter \Validation \Validation ;
2123use CodeIgniter \Validation \ValidationInterface ;
2224use Config \Services ;
2325use InvalidArgumentException ;
4446 */
4547abstract class BaseModel
4648{
47- // region Properties
48-
4949 /**
5050 * Pager instance.
5151 * Populated after calling $this->paginate()
@@ -160,7 +160,7 @@ abstract class BaseModel
160160 /**
161161 * Database Connection
162162 *
163- * @var object
163+ * @var BaseConnection
164164 */
165165 protected $ db ;
166166
@@ -200,7 +200,7 @@ abstract class BaseModel
200200 /**
201201 * Our validator instance.
202202 *
203- * @var ValidationInterface
203+ * @var Validation
204204 */
205205 protected $ validation ;
206206
@@ -288,10 +288,6 @@ abstract class BaseModel
288288 */
289289 protected $ afterDelete = [];
290290
291- // endregion
292-
293- // region Constructor
294-
295291 /**
296292 * BaseModel constructor.
297293 *
@@ -302,12 +298,12 @@ public function __construct(ValidationInterface $validation = null)
302298 $ this ->tempReturnType = $ this ->returnType ;
303299 $ this ->tempUseSoftDeletes = $ this ->useSoftDeletes ;
304300 $ this ->tempAllowCallbacks = $ this ->allowCallbacks ;
305- $ this ->validation = $ validation ?? Services::validation (null , false );
306- }
307301
308- // endregion
302+ /** @var Validation $validation */
303+ $ validation = $ validation ?? Services::validation (null , false );
309304
310- // region Abstract Methods
305+ $ this ->validation = $ validation ;
306+ }
311307
312308 /**
313309 * Fetches the row of database
@@ -483,10 +479,6 @@ abstract public function countAllResults(bool $reset = true, bool $test = false)
483479 */
484480 abstract public function chunk (int $ size , Closure $ userFunc );
485481
486- // endregion
487-
488- // region CRUD & Finders
489-
490482 /**
491483 * Fetches the row of database
492484 *
@@ -1101,10 +1093,6 @@ public function errors(bool $forceDB = false)
11011093 return $ this ->doErrors ();
11021094 }
11031095
1104- // endregion
1105-
1106- // region Pager
1107-
11081096 /**
11091097 * Works with Pager to get the size and offset parameters.
11101098 * Expects a GET variable (?page=2) that specifies the page of results
@@ -1135,10 +1123,6 @@ public function paginate(int $perPage = null, string $group = 'default', int $pa
11351123 return $ this ->findAll ($ perPage , $ offset );
11361124 }
11371125
1138- // endregion
1139-
1140- // region Allowed Fields
1141-
11421126 /**
11431127 * It could be used when you have to change default or override current allowed fields.
11441128 *
@@ -1204,10 +1188,6 @@ protected function doProtectFields(array $data): array
12041188 return $ data ;
12051189 }
12061190
1207- // endregion
1208-
1209- // region Timestamps
1210-
12111191 /**
12121192 * Sets the date or current date if null value is passed
12131193 *
@@ -1282,10 +1262,6 @@ protected function timeToDate(Time $value)
12821262 }
12831263 }
12841264
1285- // endregion
1286-
1287- // region Validation
1288-
12891265 /**
12901266 * Set the value of the skipValidation flag.
12911267 *
@@ -1428,7 +1404,6 @@ public function getValidationRules(array $options = []): array
14281404 // or an array of rules.
14291405 if (is_string ($ rules ))
14301406 {
1431- // @phpstan-ignore-next-line
14321407 $ rules = $ this ->validation ->loadRuleGroup ($ rules );
14331408 }
14341409
@@ -1483,10 +1458,6 @@ protected function cleanValidationRules(array $rules, array $data = null): array
14831458 return $ rules ;
14841459 }
14851460
1486- // endregion
1487-
1488- // region Callbacks
1489-
14901461 /**
14911462 * Sets $tempAllowCallbacks value so that we can temporarily override
14921463 * the setting. Resets after the next method that uses triggers.
@@ -1545,10 +1516,6 @@ protected function trigger(string $event, array $eventData)
15451516 return $ eventData ;
15461517 }
15471518
1548- // endregion
1549-
1550- // region Utility
1551-
15521519 /**
15531520 * Sets the return type of the results to be as an associative array.
15541521 *
@@ -1698,10 +1665,6 @@ protected function transformDataToArray($data, string $type): array
16981665 return $ data ;
16991666 }
17001667
1701- // endregion
1702-
1703- // region Magic
1704-
17051668 /**
17061669 * Provides the db connection and model's properties.
17071670 *
@@ -1758,10 +1721,6 @@ public function __call(string $name, array $params)
17581721 return null ;
17591722 }
17601723
1761- // endregion
1762-
1763- // region Deprecated
1764-
17651724 /**
17661725 * Replace any placeholders within the rules with the values that
17671726 * match the 'key' of any properties being set. For example, if
@@ -1822,6 +1781,4 @@ protected function fillPlaceholders(array $rules, array $data): array
18221781
18231782 return $ rules ;
18241783 }
1825-
1826- // endregion
18271784}
0 commit comments