From 3c5da1f817921c315037433c70b8c2051e789242 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:25:37 +0200 Subject: [PATCH 01/13] Remove return type from docblock. Fixes: - base/CComponent.php:148 PhanTypeMagicVoidWithReturn Found a return statement with a value in the implementation of the magic method \CComponent::__set, expected void return type - base/CComponent.php:215 PhanTypeMagicVoidWithReturn Found a return statement with a value in the implementation of the magic method \CComponent::__unset, expected void return type --- framework/base/CComponent.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/base/CComponent.php b/framework/base/CComponent.php index e229c0eb99..26d648cbb2 100644 --- a/framework/base/CComponent.php +++ b/framework/base/CComponent.php @@ -141,7 +141,6 @@ public function __get($name) * * @param string $name the property name or the event name * @param mixed $value the property value or callback - * @return mixed * @throws CException if the property/event is not defined or the property is read only. * @see __get */ @@ -210,7 +209,6 @@ public function __isset($name) * to allow using unset() to set a component property to be null. * @param string $name the property name or the event name * @throws CException if the property is read only. - * @return mixed */ public function __unset($name) { From b2cd43b19d7f640ad72e8747de54937d0808dd10 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:27:51 +0200 Subject: [PATCH 02/13] Remove return type from docblock. Fixes: - base/CSecurityManager.php:528 PhanTypeMissingReturn Method \CSecurityManager::validateEncryptionKey is declared to return bool in phpdoc but has no return value --- framework/base/CSecurityManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/base/CSecurityManager.php b/framework/base/CSecurityManager.php index 525f7d10bf..cdd82f911c 100644 --- a/framework/base/CSecurityManager.php +++ b/framework/base/CSecurityManager.php @@ -522,7 +522,6 @@ private function substr($string,$start,$length) /** * Checks if a key is valid for {@link cryptAlgorithm}. * @param string $key the key to check - * @return boolean the validation result * @throws CException if the supported key lengths of the cipher are unknown */ protected function validateEncryptionKey($key) From 0259dd5afa73b4a87648b36849b42fb485ed221f Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:31:38 +0200 Subject: [PATCH 03/13] Remove return type from docblock. Fixes: - caching/CCache.php:376 PhanTypeMissingReturn Method \CCache::offsetUnset is declared to return bool in phpdoc but has no return value - caching/CDummyCache.php:164 PhanTypeMissingReturn Method \CDummyCache::offsetUnset is declared to return bool in phpdoc but has no return value --- framework/caching/CCache.php | 1 - framework/caching/CDummyCache.php | 1 - 2 files changed, 2 deletions(-) diff --git a/framework/caching/CCache.php b/framework/caching/CCache.php index 4dc82848d0..1143efe2a2 100644 --- a/framework/caching/CCache.php +++ b/framework/caching/CCache.php @@ -370,7 +370,6 @@ public function offsetSet($id, $value) * Deletes the value with the specified key from cache * This method is required by the interface ArrayAccess. * @param string $id the key of the value to be deleted - * @return boolean if no error happens during deletion */ #[ReturnTypeWillChange] public function offsetUnset($id) diff --git a/framework/caching/CDummyCache.php b/framework/caching/CDummyCache.php index db2635cf67..0932b5fe52 100644 --- a/framework/caching/CDummyCache.php +++ b/framework/caching/CDummyCache.php @@ -158,7 +158,6 @@ public function offsetSet($id, $value) * Deletes the value with the specified key from cache * This method is required by the interface ArrayAccess. * @param string $id the key of the value to be deleted - * @return boolean if no error happens during deletion */ #[ReturnTypeWillChange] public function offsetUnset($id) From bd71ed35dde844708fece17c50192af4654cac0a Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:39:04 +0200 Subject: [PATCH 04/13] Remove return type from docblock. Fixes: - cli/commands/shell/ModelCommand.php:127 PhanTypeMissingReturn Method \ModelCommand::generateRelations is declared to return array in phpdoc but has no return value --- framework/cli/commands/shell/ModelCommand.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/cli/commands/shell/ModelCommand.php b/framework/cli/commands/shell/ModelCommand.php index 6c335fa22c..cc2b192245 100644 --- a/framework/cli/commands/shell/ModelCommand.php +++ b/framework/cli/commands/shell/ModelCommand.php @@ -121,8 +121,6 @@ protected function isRelationTable($table) /** * Generate code to put in ActiveRecord class's relations() function. - * @return array indexed by table names, each entry contains array of php code to go in appropriate ActiveRecord class. - * Empty array is returned if database couldn't be connected. */ protected function generateRelations() { From a163dad1f533159397cfd285a8e585c1b091405a Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:43:08 +0200 Subject: [PATCH 05/13] Set argument name in docblock. Fixes: - db/schema/mssql/CMssqlPdoAdapter.php:23 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string|null sequence name. Defaults to null': after string|null, did not see an element name (will guess based on comment order) --- framework/db/schema/mssql/CMssqlPdoAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/db/schema/mssql/CMssqlPdoAdapter.php b/framework/db/schema/mssql/CMssqlPdoAdapter.php index c0ec530b38..9862d55792 100644 --- a/framework/db/schema/mssql/CMssqlPdoAdapter.php +++ b/framework/db/schema/mssql/CMssqlPdoAdapter.php @@ -20,7 +20,7 @@ class CMssqlPdoAdapter extends PDO * Get the last inserted id value * MSSQL doesn't support sequence, so, argument is ignored * - * @param string|null sequence name. Defaults to null + * @param string|null $sequence sequence name. Defaults to null * @return integer last inserted id */ #[ReturnTypeWillChange] From 9a4506c4a911871b0aff435ab93666080803dfa9 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:51:32 +0200 Subject: [PATCH 06/13] Add missing argument names to docblocks. Fixes: - gii/generators/model/ModelCode.php:365 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param CDbTableSchema table to inspect': after CDbTableSchema, did not see an element name (will guess based on comment order) - gii/generators/model/ModelCode.php:397 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string the name of the table to hold the relation': after string, did not see an element name (will guess based on comment order) - gii/generators/model/ModelCode.php:398 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param string the foreign key name': after string, did not see an element name (will guess based on comment order) - gii/generators/model/ModelCode.php:399 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param boolean whether the relation would contain multiple objects': after boolean, did not see an element name (will guess based on comment order) --- framework/gii/generators/model/ModelCode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/gii/generators/model/ModelCode.php b/framework/gii/generators/model/ModelCode.php index 4908fec06c..81dd117cc0 100644 --- a/framework/gii/generators/model/ModelCode.php +++ b/framework/gii/generators/model/ModelCode.php @@ -362,7 +362,7 @@ protected function generateRelations() /** * Checks if the given table is a "many to many" pivot table. * Their PK has 2 fields, and both of those fields are also FK to other separate tables. - * @param CDbTableSchema table to inspect + * @param CDbTableSchema $table table to inspect * @return boolean true if table matches description of helper table. */ protected function isRelationTable($table) @@ -394,9 +394,9 @@ protected function generateClassName($tableName) /** * Generate a name for use as a relation name (inside relations() function in a model). - * @param string the name of the table to hold the relation - * @param string the foreign key name - * @param boolean whether the relation would contain multiple objects + * @param string $tableName the name of the table to hold the relation + * @param string $fkName the foreign key name + * @param boolean $multiple whether the relation would contain multiple objects * @return string the relation name */ protected function generateRelationName($tableName, $fkName, $multiple) From f6ec8de5156e851822f3b1437af7ff871d30c78d Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:53:03 +0200 Subject: [PATCH 07/13] Remove return type from docblock. Fixes: - gii/generators/model/ModelGenerator.php:12 PhanTypeMissingReturn Method \ModelGenerator::actionGetTableNames is declared to return string in phpdoc but has no return value --- framework/gii/generators/model/ModelGenerator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/gii/generators/model/ModelGenerator.php b/framework/gii/generators/model/ModelGenerator.php index 819507ee07..e5e12db464 100644 --- a/framework/gii/generators/model/ModelGenerator.php +++ b/framework/gii/generators/model/ModelGenerator.php @@ -7,7 +7,6 @@ class ModelGenerator extends CCodeGenerator /** * Provides autocomplete table names * @param string $db the database connection component id - * @return string the json array of tablenames that contains the entered term $q */ public function actionGetTableNames($db) { From 7784c94e92ac93c98474c607b13f7bb7ed3ce2ff Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 16:55:35 +0200 Subject: [PATCH 08/13] Remove ignored overwritten array key Fixes: - messages/ca/yii.php:88 PhanPluginDuplicateArrayKey Duplicate/Equivalent array key value('Alias "{alias}" is invalid. Make sure it points to an existing directory or file.') detected in array - the earlier entry 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' at line 87 will be ignored. --- framework/messages/ca/yii.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/messages/ca/yii.php b/framework/messages/ca/yii.php index 504691441c..a1d30a3cfc 100644 --- a/framework/messages/ca/yii.php +++ b/framework/messages/ca/yii.php @@ -84,7 +84,6 @@ 'Active Record requires a "db" CDbConnection application component.' => 'Active Record requiereix un component d\'aplicació "db" de tipus CDbConnection.', 'Active record "{class}" has an invalid configuration for relation "{relation}". It must specify the relation type, the related active record class and the foreign key.' => 'Active record "{class}" conté una configuració de relació invàlida "{relation}". La mateixa ha d\'especificar el tipus de relació, la clase active record relacionada i la clau forània.', 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.' => 'Active Record "{class}" esta intentant seleccionar una columna que no és vàlida {"column"}. Nota: la columna pot existir a la BDD o ser una expressió amb àlies.', - 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' => 'Alias "{alias}" es inválido. Verifique que el mismo apunta a un directorio o archivo exisitente.', 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' => 'L\'àlies "{alias}" no és vàlid. Verifiqui que el mateix apunta a un directori o arxiu exisitent.', 'Application base path "{path}" is not a valid directory.' => 'Ruta base de l\'aplicació "{path}" no és un directori vàlid.', 'Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.' => 'Ruta de runtime d\'aplicació "{path}" no és vàlida. Asseguri\'s de que sigui un directori amb permisos d\'escriptura pel procés que corre el servidor Web.', From 679f11bd4db2520ba5c777673287e07e5f328dad Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 17:11:44 +0200 Subject: [PATCH 09/13] Remove argument from docblock Fixes: - web/CHttpSessionIterator.php:33 PhanUnextractableAnnotationElementName Saw possibly unextractable annotation for a fragment of comment '* @param array the data to be iterated through': after array, did not see an element name (will guess based on comment order) --- framework/web/CHttpSessionIterator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/web/CHttpSessionIterator.php b/framework/web/CHttpSessionIterator.php index fe51332e5a..2b3f14c0c9 100644 --- a/framework/web/CHttpSessionIterator.php +++ b/framework/web/CHttpSessionIterator.php @@ -30,7 +30,6 @@ class CHttpSessionIterator implements Iterator /** * Constructor. - * @param array the data to be iterated through */ public function __construct() { From 3ca2acca6bc819a6326e3e245612b1c81c1433d3 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 17:13:12 +0200 Subject: [PATCH 10/13] Remove return type from docblock. Fixes: - web/actions/CViewAction.php:98 PhanTypeMissingReturn Method \CViewAction::resolveView is declared to return string in phpdoc but has no return value --- framework/web/actions/CViewAction.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/web/actions/CViewAction.php b/framework/web/actions/CViewAction.php index afaf886888..9bacbab681 100644 --- a/framework/web/actions/CViewAction.php +++ b/framework/web/actions/CViewAction.php @@ -92,7 +92,6 @@ public function getRequestedView() /** * Resolves the user-specified view into a valid view name. * @param string $viewPath user-specified view in the format of 'path.to.view'. - * @return string fully resolved view in the format of 'path/to/view'. * @throws CHttpException if the user-specified view is invalid */ protected function resolveView($viewPath) From 71be1d23bb1027417668249d55821aa024d8f0d5 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 17:18:12 +0200 Subject: [PATCH 11/13] Remove return type from docblock. Fixes: - web/widgets/COutputCache.php:162 PhanTypeMissingReturn Method \COutputCache::filter is declared to return bool in phpdoc but has no return value --- framework/web/widgets/COutputCache.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/web/widgets/COutputCache.php b/framework/web/widgets/COutputCache.php index d3acb326cd..6723dbc5b9 100644 --- a/framework/web/widgets/COutputCache.php +++ b/framework/web/widgets/COutputCache.php @@ -157,7 +157,6 @@ class COutputCache extends CFilterWidget * Performs filtering before the action is executed. * This method is meant to be overridden by child classes if begin-filtering is needed. * @param CFilterChain $filterChain list of filters being applied to an action - * @return boolean whether the filtering process should stop after this filter. Defaults to false. */ public function filter($filterChain) { From dd77c679295df05a953001f3abbe14f1aa81347d Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 17:24:20 +0200 Subject: [PATCH 12/13] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index d82c62930f..874c6bc7be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ Version 1.1.29 under development - Bug #4516: PHP 8 compatibility: Allow union types and intersection types in action declarations (wtommyw) - Bug #4523: Fixed translated in Greek class messages in framework requirements view, which they should not be translated (lourdas) - Enh #4529: Exceptions thrown while loading fixture file rows now contain more details (eduardor2k) +- Enh #4533: Various refactorings applied based on PHPStan checks (marcovtwout) Version 1.1.28 February 28, 2023 -------------------------------- From ab7b70f0b83ba1ec05794db9d6e346aef4072ab2 Mon Sep 17 00:00:00 2001 From: Marco van 't Wout Date: Wed, 27 Sep 2023 17:27:53 +0200 Subject: [PATCH 13/13] Update CHANGELOG Typo --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 874c6bc7be..77f4df572b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ Version 1.1.29 under development - Bug #4516: PHP 8 compatibility: Allow union types and intersection types in action declarations (wtommyw) - Bug #4523: Fixed translated in Greek class messages in framework requirements view, which they should not be translated (lourdas) - Enh #4529: Exceptions thrown while loading fixture file rows now contain more details (eduardor2k) -- Enh #4533: Various refactorings applied based on PHPStan checks (marcovtwout) +- Enh #4533: Various refactorings applied based on PHAN checks (marcovtwout) Version 1.1.28 February 28, 2023 --------------------------------