phpmyadmin/libraries/classes
Kamil Tekiela 56a832948c
Refactor DatabaseInterface.php (#17209)
* Use str_starts_with()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant !empty()

!empty() on a declared variable is redundant.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace loop with array_column()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simpify assignment by removing temporary variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant if statements and array_merge

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove temporary variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Unindent code

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add helper method fetchByMode()

This is done to avoid calling methods through variables. It is the same
in terms of performance.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Move if statements to where they are relevant

I had a choice to either move the while loop out of the if statements
or move the if statements inside. I decided it made more sense to move
them inside.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add NULL to phpdoc for the two parameters that can be null

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simplify return statement

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Improve performance and simplify code

Since we are always using STORE mode then we can use data_seek() method.
This will allow us to get rid of the loop and use fetchByMode() method.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Inline value defaulting

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant check

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* [bugfix] getColumnNames() should return an array of strings

There were multiple issues here. If we are selecting only a certain
column from the SQL then let's use the handy function instead of
array_keys. We will never get anything other than an array so checking
if it is not an array makes no sense. Returning null only to cast it to
an array is pointless. If really necessary, we could still check for an
empty array. The ColumnController returned the value without even
casting it to an array. I am not sure how jQuery/JavaScript dealt with it.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getColumnMapFromSql and add type hint

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getVirtualTables

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant loop

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant usage of freeResult()

If there was no chance for the object to leak the scope and it is the
end of the scope then there's no reason to call this method.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace dynamic variable with declare one

It's always the same name. If we were creating more than one, we could
use associative array, but in this case there seems to be absolutely no
need for any of this. Dynamic variables make it harder to debug the code.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Update psalm-baseline.xml

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Widen the condition per williamdes suggestion

This will allow value such as '' and '0' to pass through. Previously
`if(! empty($database))` and `if($database)` dissallowed them.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* fetchResult() should return only arrays

Tests fixed to return arrays. Non-empty in case of true, empty in case
of false.
Fixed a lot of Psalm issues where the condition was always true.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-26 20:17:46 -03:00
..
Charsets Fix some errors found by Psalm 2021-11-08 00:52:30 -03:00
Command Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Config Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
Controllers Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Database Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Dbal Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Display Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
Engines Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Exceptions Fix some coding standard issues 2020-05-25 22:42:37 -03:00
Export Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Gis Hoist $label trimming and null check 2021-11-19 19:45:40 +00:00
Html Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
Http Add ServerRequest::getParsedBodyParam method 2021-07-06 12:24:02 -03:00
Image Fix some PHP 8.1 issues 2021-08-21 20:16:59 -03:00
Import Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Navigation Merge branch 'QA_5_1' 2021-11-21 15:00:06 -03:00
Partitioning Use ServerRequest for Table\Partition controllers 2021-09-30 16:56:34 -03:00
Plugins Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Properties Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Providers/ServerVariables Use PSR-12 for namespace use statements 2021-03-05 14:18:35 -03:00
Query Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Server Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Setup Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Table Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Twig Redesign the export/import pages to use Bootstrap components 2021-11-25 13:37:47 -03:00
Utils Use composer/ca-bundle to manage the CA cert file 2021-10-09 12:50:51 -03:00
Advisor.php Replace pow function with the ** operator 2021-09-27 19:12:11 -03:00
Bookmark.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
BrowseForeigners.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Cache.php Add bool return type where possible 2021-09-14 20:11:51 -03:00
Charsets.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
CheckUserPrivileges.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Common.php Rename TableName|DatabaseName create method to fromString 2021-09-30 22:14:51 -03:00
Config.php Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
Console.php Improve type definitions of Scripts class 2021-11-18 15:25:00 -03:00
Core.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
CreateAddField.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
DatabaseInterface.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
DbTableExists.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Encoding.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Error.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
ErrorHandler.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
ErrorReport.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Export.php Redesign the export/import pages to use Bootstrap components 2021-11-25 13:37:47 -03:00
FieldMetadata.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
File.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
FileListing.php Use PSR-12 for control structures spacing 2021-03-05 15:27:03 -03:00
FlashMessages.php Fix coding standard errors 2021-06-03 16:50:33 -03:00
Font.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Footer.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Git.php Wrap variable variables in curly braces 2021-09-27 19:18:48 -03:00
Header.php Remove print view mode 2021-10-31 13:22:07 -03:00
Import.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Index.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
IndexColumn.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
InsertEdit.php Merge pull request #17204 from kamil-tekiela/Refactor-DatabaseInterface-getColumns() 2021-11-26 15:07:20 -03:00
InternalRelations.php Fix some coding standard issues 2020-05-25 22:42:37 -03:00
IpAllowDeny.php Replace pow function with the ** operator 2021-09-27 19:12:11 -03:00
Language.php Add bool return type where possible 2021-09-14 20:11:51 -03:00
LanguageManager.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Linter.php Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
ListAbstract.php Add bool return type where possible 2021-09-14 20:11:51 -03:00
ListDatabase.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Logging.php Add void return type where possible 2021-09-13 15:29:11 -03:00
Menu.php Remove unnecessary @var annotations 2021-11-18 12:15:30 -03:00
Message.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Mime.php Use PSR-12 for control structures spacing 2021-03-05 15:27:03 -03:00
Normalization.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
OpenDocument.php Fix some PHP 8.1 issues 2021-08-21 20:16:59 -03:00
Operations.php Add Warning value object for SHOW WARNINGS rows 2021-10-09 00:09:01 -03:00
OutputBuffering.php Add void return type where possible 2021-09-13 15:29:11 -03:00
ParseAnalyze.php Rename Response class to ResponseRenderer 2021-06-30 12:35:22 -03:00
Pdf.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Plugins.php Redesign the export/import pages to use Bootstrap components 2021-11-25 13:37:47 -03:00
Profiling.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
RecentFavoriteTable.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Relation.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
RelationCleanup.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
RelationParameters.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Replication.php Merge branch 'QA_5_1' 2021-04-28 02:12:17 +02:00
ReplicationGui.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
ReplicationInfo.php Fix some errors found by Psalm 2021-05-23 00:24:59 -03:00
ResponseRenderer.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Routing.php Use only callable controllers 2021-09-11 15:20:46 -03:00
Sanitize.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
SavedSearches.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Scripts.php Improve type definitions of Scripts class 2021-11-18 15:25:00 -03:00
Session.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Sql.php Add test for Sql::executeQueryAndSendQueryResponse 2021-11-15 19:51:16 -03:00
SqlQueryForm.php Refactor DatabaseInterface::getColumns() 2021-11-25 10:28:39 +00:00
StorageEngine.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
SystemDatabase.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Table.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Template.php Remove PhpMyAdmin\Twig\PluginsExtension class 2021-08-25 11:00:21 -03:00
Theme.php Remove the unused Theme::cssFiles property 2021-11-03 09:21:43 -03:00
ThemeManager.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Tracker.php Refactor DatabaseInterface::getColumns() 2021-11-25 10:28:39 +00:00
Tracking.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Transformations.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
TwoFactor.php Replace class strings with the ::class constant 2021-09-27 19:17:45 -03:00
Types.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
Url.php Merge branch 'QA_5_1' 2021-09-23 13:10:38 -03:00
UserPassword.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
UserPreferences.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Util.php Remove array support from Util::backquote 2021-11-10 19:33:09 -03:00
Version.php Fix some errors found by PHPStan 2021-06-09 13:07:40 -03:00
VersionInformation.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
ZipExtension.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00