From 4bf9e88eb9b0a3d0b2633a07eafd2fa3576bc415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 7 Dec 2023 11:34:31 +0100 Subject: [PATCH] fix phpstan --- Editor/Field.php | 2 +- Editor/Join.php | 2 +- Ext.php | 4 +- phpstan-baseline.neon | 86 ++++--------------------------------------- 4 files changed, 12 insertions(+), 82 deletions(-) diff --git a/Editor/Field.php b/Editor/Field.php index 66091a0..3a0f208 100644 --- a/Editor/Field.php +++ b/Editor/Field.php @@ -500,7 +500,7 @@ public function upload($_ = null) * date formatting string, or a required flag. The actual options available * depend upon the validation function used. * - * @return ($_ is null ? callable|string : $this) The validation method if no parameter is given. + * @return ($_ is null ? array[] : $this) The validation method if no parameter is given. */ public function validator($_ = null, $opts = null) { diff --git a/Editor/Join.php b/Editor/Join.php index 234366c..b6a1a4e 100644 --- a/Editor/Join.php +++ b/Editor/Join.php @@ -239,7 +239,7 @@ public function get($_ = null) * link table. * @param string $table Join table name, if using a link table * - * @return ($parent is null ? Join : $this) + * @return ($parent is null ? array : $this) * * @deprecated 1.5 Please use the {@see Join->link()} method rather than this * method now. diff --git a/Ext.php b/Ext.php index f98cacf..2d76d8d 100644 --- a/Ext.php +++ b/Ext.php @@ -27,7 +27,7 @@ class Ext * If using PHP 5.4 or later, simply create a 'new' instance of the * target class and chain methods as normal. * - * @return \DataTables\Editor|\DataTables\Editor\Field|\DataTables\Editor\Join|\DataTables\Editor\Upload Instantiated class + * @return static Instantiated class */ public static function instantiate() { @@ -44,7 +44,7 @@ public static function instantiate() * This method performs exactly the same actions as the 'instantiate' * static method, but is simply shorter and easier to type! * - * @return \DataTables\Editor|\DataTables\Editor\Field|\DataTables\Editor\Join|\DataTables\Editor\Upload class + * @return static class */ public static function inst() { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1cb96bf..9113d50 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6,7 +6,7 @@ parameters: path: Database/Driver/Db2Query.php - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\Db2Query\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns resource\\.$#" + message: "#^Method DataTables\\\\Database\\\\Driver\\\\Db2Query\\:\\:connect\\(\\) should return PDO but returns resource\\.$#" count: 1 path: Database/Driver/Db2Query.php @@ -26,7 +26,7 @@ parameters: path: Database/Driver/Db2Result.php - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\FirebirdQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns PDO\\.$#" + message: "#^Call to function is_array\\(\\) with non\\-empty\\-array\\ will always evaluate to true\\.$#" count: 1 path: Database/Driver/FirebirdQuery.php @@ -41,12 +41,12 @@ parameters: path: Database/Driver/FirebirdResult.php - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\MysqlQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns PDO\\.$#" + message: "#^Call to function is_array\\(\\) with non\\-empty\\-array\\ will always evaluate to true\\.$#" count: 1 - path: Database/Driver/MysqlQuery.php + path: Database/Driver/OracleQuery.php - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\OracleQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns resource\\.$#" + message: "#^Method DataTables\\\\Database\\\\Driver\\\\OracleQuery\\:\\:connect\\(\\) should return PDO but returns resource\\.$#" count: 1 path: Database/Driver/OracleQuery.php @@ -80,11 +80,6 @@ parameters: count: 1 path: Database/Driver/OracleResult.php - - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\PostgresQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns PDO\\.$#" - count: 1 - path: Database/Driver/PostgresQuery.php - - message: "#^Property DataTables\\\\Database\\\\Driver\\\\PostgresQuery\\:\\:\\$_identifier_limiter \\(string\\) does not accept default value of type array\\\\.$#" count: 1 @@ -95,16 +90,6 @@ parameters: count: 1 path: Database/Driver/PostgresResult.php - - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\SqliteQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns PDO\\.$#" - count: 1 - path: Database/Driver/SqliteQuery.php - - - - message: "#^Method DataTables\\\\Database\\\\Driver\\\\SqlserverQuery\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but returns PDO\\.$#" - count: 1 - path: Database/Driver/SqlserverQuery.php - - message: "#^Property DataTables\\\\Database\\\\Driver\\\\SqlserverQuery\\:\\:\\$_identifier_limiter \\(string\\) does not accept default value of type array\\\\.$#" count: 1 @@ -116,7 +101,7 @@ parameters: path: Database/Query.php - - message: "#^Method DataTables\\\\Database\\\\Query\\:\\:connect\\(\\) should return DataTables\\\\Database\\\\Query but return statement is missing\\.$#" + message: "#^Method DataTables\\\\Database\\\\Query\\:\\:connect\\(\\) should return PDO but return statement is missing\\.$#" count: 1 path: Database/Query.php @@ -162,7 +147,7 @@ parameters: - message: "#^If condition is always true\\.$#" - count: 4 + count: 3 path: Editor.php - @@ -245,11 +230,6 @@ parameters: count: 1 path: Editor.php - - - message: "#^Property DataTables\\\\Editor\\:\\:\\$_validator \\(callable\\(\\)\\: mixed\\) does not accept default value of type array\\{\\}\\.$#" - count: 1 - path: Editor.php - - message: "#^Result of && is always false\\.$#" count: 2 @@ -276,7 +256,7 @@ parameters: path: Editor.php - - message: "#^Strict comparison using \\=\\=\\= between \\(callable\\(\\)\\: mixed\\)\\|DataTables\\\\Editor\\\\Field\\|string and null will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between \\(callable\\(\\)\\: mixed\\)\\|string and null will always evaluate to false\\.$#" count: 1 path: Editor.php @@ -300,26 +280,6 @@ parameters: count: 1 path: Editor.php - - - message: "#^Call to function is_callable\\(\\) with callable\\(\\)\\: mixed will always evaluate to true\\.$#" - count: 2 - path: Editor/Field.php - - - - message: "#^Cannot call method value\\(\\) on array\\\\|DataTables\\\\Editor\\|DataTables\\\\Editor\\\\Join\\|string\\.$#" - count: 1 - path: Editor/Field.php - - - - message: "#^Method DataTables\\\\Editor\\\\Field\\:\\:options\\(\\) should return DataTables\\\\Editor\\\\Field but returns DataTables\\\\Editor\\\\Options\\|null\\.$#" - count: 1 - path: Editor/Field.php - - - - message: "#^Method DataTables\\\\Editor\\\\Field\\:\\:searchBuilderOptions\\(\\) should return DataTables\\\\Editor\\\\Field but returns DataTables\\\\Editor\\\\SearchBuilderOptions\\|null\\.$#" - count: 1 - path: Editor/Field.php - - message: "#^Method DataTables\\\\Editor\\\\Field\\:\\:searchBuilderOptionsExec\\(\\) has invalid return type DataTables\\\\Editor\\\\IOption\\.$#" count: 1 @@ -335,11 +295,6 @@ parameters: count: 1 path: Editor/Field.php - - - message: "#^Method DataTables\\\\Editor\\\\Field\\:\\:searchPaneOptions\\(\\) should return DataTables\\\\Editor\\\\Field but returns DataTables\\\\Editor\\\\SearchPaneOptions\\|null\\.$#" - count: 1 - path: Editor/Field.php - - message: "#^Method DataTables\\\\Editor\\\\Field\\:\\:xssSafety\\(\\) should return string but returns array\\\\.$#" count: 1 @@ -575,11 +530,6 @@ parameters: count: 1 path: Editor/SearchBuilderOptions.php - - - message: "#^Method DataTables\\\\Editor\\\\SearchBuilderOptions\\:\\:label\\(\\) should return array\\\\|DataTables\\\\Editor\\\\Options but returns \\$this\\(DataTables\\\\Editor\\\\SearchBuilderOptions\\)\\.$#" - count: 2 - path: Editor/SearchBuilderOptions.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -625,11 +575,6 @@ parameters: count: 1 path: Editor/SearchPaneOptions.php - - - message: "#^Method DataTables\\\\Editor\\\\SearchPaneOptions\\:\\:label\\(\\) should return array\\\\|DataTables\\\\Editor\\\\Options but returns \\$this\\(DataTables\\\\Editor\\\\SearchPaneOptions\\)\\.$#" - count: 2 - path: Editor/SearchPaneOptions.php - - message: "#^Property DataTables\\\\Editor\\\\SearchPaneOptions\\:\\:\\$_order is never written, only read\\.$#" count: 1 @@ -790,18 +735,3 @@ parameters: count: 1 path: Editor/Validate.php - - - message: "#^Method DataTables\\\\Editor\\\\ValidateOptions\\:\\:__construct\\(\\) with return type void returns \\$this\\(DataTables\\\\Editor\\\\ValidateOptions\\) but should not return anything\\.$#" - count: 1 - path: Editor/ValidateOptions.php - - - - message: "#^Method DataTables\\\\Ext\\:\\:inst\\(\\) should return DataTables\\\\Editor\\|DataTables\\\\Editor\\\\Field\\|DataTables\\\\Editor\\\\Join\\|DataTables\\\\Editor\\\\Upload but returns static\\(DataTables\\\\Ext\\)\\.$#" - count: 1 - path: Ext.php - - - - message: "#^Method DataTables\\\\Ext\\:\\:instantiate\\(\\) should return DataTables\\\\Editor\\|DataTables\\\\Editor\\\\Field\\|DataTables\\\\Editor\\\\Join\\|DataTables\\\\Editor\\\\Upload but returns static\\(DataTables\\\\Ext\\)\\.$#" - count: 1 - path: Ext.php -