phpstan level 1 (#14472)

* level +1
* Install sami/sami globaly to avoid dependency clash

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2018-08-18 19:37:41 +02:00 committed by Maurício Meneghini Fauth
parent ce94e19339
commit 3dce65d913
58 changed files with 541 additions and 470 deletions

View File

@ -44,7 +44,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
/**
* Displays the form
@ -154,7 +154,7 @@ if (! isset($num_tables)) {
if (! isset($unlim_num_rows)) {
$unlim_num_rows = 0;
}
if (! isset($multi_values)) {
if (is_null($multi_values)) {
$multi_values = '';
}
$response = Response::getInstance();

View File

@ -244,7 +244,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
echo "\n";

View File

@ -127,7 +127,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
if ($message_to_display) {
Message::error(

View File

@ -48,7 +48,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
// Work to do?
// (here, do not use $_REQUEST['db] as it can be crafted)

View File

@ -268,7 +268,7 @@ if ($_REQUEST['output_format'] == 'astext') {
$save_on_server = ! empty($cfg['SaveDir']) && $onserver;
}
}
$tables = [];
// Generate error url and check for needed variables
if ($export_type == 'server') {
$err_url = 'server_export.php' . Url::getCommon();

View File

@ -17,7 +17,7 @@ use PhpMyAdmin\Url;
* Escapes special characters if the variable is set.
* Returns an empty string otherwise.
*
* @param string $variable variable to be escaped
* @param string|null $variable variable to be escaped
*
* @return string escaped variable
*/

View File

@ -123,6 +123,7 @@ if (!isset($_SESSION['is_multi_query'])) {
}
$ajax_reload = [];
$import_text = '';
// Are we just executing plain query or sql file?
// (eg. non import, but query box/window run)
if (! empty($sql_query)) {
@ -550,8 +551,8 @@ if (! $error) {
$import->stop($message);
} else {
// Do the real import
$default_fk_check = PhpMyAdmin\Util::handleDisableFKCheckInit();
try {
$default_fk_check = PhpMyAdmin\Util::handleDisableFKCheckInit();
$import_plugin->doImport($sql_data);
PhpMyAdmin\Util::handleDisableFKCheckCleanup($default_fk_check);
} catch (Exception $e) {

View File

@ -156,12 +156,12 @@ class BrowseForeigners
/**
* Function to get html for relational field selection
*
* @param string $db current database
* @param string $table current table
* @param string $field field
* @param array $foreignData foreign column data
* @param string $fieldkey field key
* @param string $current_value current columns's value
* @param string $db current database
* @param string $table current table
* @param string $field field
* @param array $foreignData foreign column data
* @param string|null $fieldkey field key
* @param string $current_value current columns's value
*
* @return string
*/
@ -170,7 +170,7 @@ class BrowseForeigners
string $table,
string $field,
array $foreignData,
string $fieldkey,
?string $fieldkey,
string $current_value
): string {
$gotopage = $this->getHtmlForGotoPage($foreignData);
@ -341,7 +341,7 @@ class BrowseForeigners
/**
* Function to get foreign limit
*
* @param string $foreignShowAll foreign navigation
* @param string|null $foreignShowAll foreign navigation
*
* @return string
*/

View File

@ -115,6 +115,9 @@ class ServerDatabasesController extends Controller
'sort_order' => $this->_sort_order,
];
$column_order = null;
$first_database = null;
if ($this->_database_count > 0 && ! empty($this->_databases)) {
$first_database = reset($this->_databases);
// table col order

View File

@ -65,9 +65,9 @@ class ServerEnginesController extends Controller
*
* @param StorageEngine $engine engine beeing inspected
*
* @return void
* @return string
*/
private function _getHtmlForShowEngine(StorageEngine $engine):string
private function _getHtmlForShowEngine(StorageEngine $engine): string
{
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
$pageOutput = ! empty($page) ? $engine->getPage($page) : '';

View File

@ -187,6 +187,7 @@ class TableSearchController extends TableController
*/
public function indexAction()
{
global $goto;
switch ($this->_searchType) {
case 'replace':
if (isset($_POST['find'])) {
@ -512,6 +513,7 @@ class TableSearchController extends TableController
*/
public function displaySelectionFormAction($dataLabel = null)
{
global $goto;
$this->url_query .= '&amp;goto=tbl_select.php&amp;back=tbl_select.php';
if (! isset($goto)) {
$goto = Util::getScriptNameForOption(

View File

@ -405,7 +405,7 @@ class Common
DatabaseInterface::QUERY_STORE
);
if (isset($default_page_no) && count($default_page_no)) {
if (! is_null($default_page_no) && count($default_page_no)) {
return intval($default_page_no[0]);
}
return -1;

View File

@ -746,6 +746,7 @@ class Qbe
) {
continue;
}
$tmp_criteria = '';
if (isset($this->_criteria[$column_index])) {
$tmp_criteria = $this->_criteria[$column_index];
}
@ -1942,18 +1943,18 @@ class Qbe
/**
* Get best
*
* @param array $search_tables Tables involved in the search
* @param array $where_clause_columns Columns with where clause
* @param array $unique_columns Unique columns
* @param array $index_columns Indexed columns
* @param array $search_tables Tables involved in the search
* @param array|null $where_clause_columns Columns with where clause
* @param array|null $unique_columns Unique columns
* @param array|null $index_columns Indexed columns
*
* @return array
*/
private function _getLeftJoinColumnCandidatesBest(
array $search_tables,
array $where_clause_columns,
array $unique_columns,
array $index_columns
?array $where_clause_columns,
?array $unique_columns,
?array $index_columns
) {
// now we want to find the best.
if (isset($unique_columns) && count($unique_columns) > 0) {

View File

@ -1453,9 +1453,9 @@ class Results
/**
* Prepare sort by key dropdown - html code segment
*
* @param Index[] $indexes the indexes of the table for sort criteria
* @param string $sort_expression the sort expression
* @param string $unsorted_sql_query the unsorted sql query
* @param Index[] $indexes the indexes of the table for sort criteria
* @param string|null $sort_expression the sort expression
* @param string $unsorted_sql_query the unsorted sql query
*
* @return string $drop_down_html html content
*
@ -1465,7 +1465,7 @@ class Results
*/
private function _getSortByKeyDropDown(
$indexes,
$sort_expression,
?string $sort_expression,
$unsorted_sql_query
) {
@ -3155,7 +3155,7 @@ class Results
$display_params['data'][$row_no][$i]
= $this->_getDataCellForNumericColumns(
$row[$i],
(string) $row[$i],
$class,
$condition_field,
$meta,
@ -3611,20 +3611,20 @@ class Results
/**
* Prepare placed links
*
* @param string $dir the direction of links should place
* @param string $del_url the url for delete row
* @param array $displayParts which elements to display
* @param integer $row_no the index of current row
* @param string $where_clause the where clause of the sql
* @param string $where_clause_html the html encoded where clause
* @param array $condition_array array of keys (primary, unique, condition)
* @param string $edit_url the url for edit row
* @param string $copy_url the url for copy row
* @param string $edit_anchor_class the class for html element for edit
* @param string $edit_str the label for edit row
* @param string $copy_str the label for copy row
* @param string $del_str the label for delete row
* @param string $js_conf text for the JS confirmation
* @param string $dir the direction of links should place
* @param string $del_url the url for delete row
* @param array $displayParts which elements to display
* @param integer $row_no the index of current row
* @param string $where_clause the where clause of the sql
* @param string $where_clause_html the html encoded where clause
* @param array $condition_array array of keys (primary, unique, condition)
* @param string $edit_url the url for edit row
* @param string $copy_url the url for copy row
* @param string $edit_anchor_class the class for html element for edit
* @param string $edit_str the label for edit row
* @param string $copy_str the label for copy row
* @param string $del_str the label for delete row
* @param string|null $js_conf text for the JS confirmation
*
* @return string html content
*
@ -3646,7 +3646,7 @@ class Results
$edit_str,
$copy_str,
$del_str,
$js_conf
?string $js_conf
) {
if (! isset($js_conf)) {
@ -3734,7 +3734,7 @@ class Results
/**
* Prepare data cell for numeric type fields
*
* @param string $column the column's value
* @param string|null $column the column's value
* @param string $class the html class for column
* @param boolean $condition_field the column should highlighted
* or not
@ -3756,7 +3756,7 @@ class Results
* @see _getTableBody()
*/
private function _getDataCellForNumericColumns(
$column,
?string $column,
$class,
$condition_field,
$meta,
@ -3810,7 +3810,7 @@ class Results
/**
* Get data cell for geometry type fields
*
* @param string $column the relevant column in data row
* @param string|null $column the relevant column in data row
* @param string $class the html class for column
* @param object $meta the meta-information about
* this field
@ -3832,7 +3832,7 @@ class Results
* @see _getTableBody()
*/
private function _getDataCellForGeometryColumns(
$column,
?string $column,
$class,
$meta,
array $map,
@ -3956,7 +3956,7 @@ class Results
/**
* Get data cell for non numeric type fields
*
* @param string $column the relevant column in data row
* @param string|null $column the relevant column in data row
* @param string $class the html class for column
* @param object $meta the meta-information about
* the field
@ -3985,7 +3985,7 @@ class Results
* @see _getTableBody()
*/
private function _getDataCellForNonNumericColumns(
$column,
?string $column,
$class,
$meta,
array $map,
@ -5322,17 +5322,18 @@ class Results
* Verifies what to do with non-printable contents (binary or BLOB)
* in Browse mode.
*
* @param string $category BLOB|BINARY|GEOMETRY
* @param string $content the binary content
* @param mixed $transformation_plugin transformation plugin.
* Can also be the default function:
* Core::mimeDefaultFunction
* @param string $transform_options transformation parameters
* @param string $default_function default transformation function
* @param object $meta the meta-information about the field
* @param array $url_params parameters that should go to the
* download link
* @param boolean &$is_truncated the result is truncated or not
* @param string $category BLOB|BINARY|GEOMETRY
* @param string|null $content the binary content
* @param mixed $transformation_plugin transformation plugin.
* Can also be the
* default function:
* Core::mimeDefaultFunction
* @param string $transform_options transformation parameters
* @param string $default_function default transformation function
* @param object $meta the meta-information about the field
* @param array $url_params parameters that should go to the
* download link
* @param boolean &$is_truncated the result is truncated or not
*
* @return mixed string or float
*
@ -5344,7 +5345,7 @@ class Results
*/
private function _handleNonPrintableContents(
$category,
$content,
?string $content,
$transformation_plugin,
$transform_options,
$default_function,

View File

@ -882,7 +882,7 @@ class Export
* @param bool $do_comments whether to add comments
* @param bool $do_mime whether to add MIME info
* @param bool $do_dates whether to add dates
* @param string $allrows whether "dump all rows" was ticked
* @param string|null $allrows whether "dump all rows" was ticked
* @param string $limit_to upper limit
* @param string $limit_from starting limit
* @param string $sql_query query for which exporting is requested
@ -902,7 +902,7 @@ class Export
bool $do_comments,
bool $do_mime,
bool $do_dates,
string $allrows,
?string $allrows,
string $limit_to,
string $limit_from,
string $sql_query,
@ -1185,11 +1185,11 @@ class Export
* get all the export options and verify
* call and include the appropriate Schema Class depending on $export_type
*
* @param string $export_type format of the export
* @param string|null $export_type format of the export
*
* @return void
*/
public function processExportSchema(string $export_type): void
public function processExportSchema(?string $export_type): void
{
/**
* default is PDF, otherwise validate it's only letters a-z

View File

@ -34,18 +34,18 @@ abstract class GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS data object
* @param string $label label for the GIS data object
* @param string $color color for the GIS data object
* @param array $scale_data array containing data related to scaling
* @param object $image image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return object the modified image object
* @return resource the modified image object
* @access public
*/
abstract public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$color,
array $scale_data,
$image
@ -54,18 +54,18 @@ abstract class GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS data object
* @param string $label label for the GIS data object
* @param string $color color for the GIS data object
* @param array $scale_data array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS data object
* @param string|null $label label for the GIS data object
* @param string $color color for the GIS data object
* @param array $scale_data array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
abstract public function prepareRowAsPdf(
$spatial,
$label,
?string $label,
$color,
array $scale_data,
$pdf

View File

@ -110,16 +110,16 @@ class GisGeometryCollection extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS GEOMETRYCOLLECTION object
* @param string $label label for the GIS GEOMETRYCOLLECTION object
* @param string $color color for the GIS GEOMETRYCOLLECTION object
* @param array $scale_data array containing data related to scaling
* @param object $image image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $color, array $scale_data, $image)
public function prepareRowAsPng($spatial, ?string $label, $color, array $scale_data, $image)
{
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col
@ -157,16 +157,16 @@ class GisGeometryCollection extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS GEOMETRYCOLLECTION object
* @param string $label label for the GIS GEOMETRYCOLLECTION object
* @param string $color color for the GIS GEOMETRYCOLLECTION object
* @param array $scale_data array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS GEOMETRYCOLLECTION object
* @param string|null $label label for the GIS GEOMETRYCOLLECTION object
* @param string $color color for the GIS GEOMETRYCOLLECTION object
* @param array $scale_data array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $color, array $scale_data, $pdf)
public function prepareRowAsPdf($spatial, ?string $label, $color, array $scale_data, $pdf)
{
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col

View File

@ -70,18 +70,18 @@ class GisLineString extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS LINESTRING object
* @param string $label Label for the GIS LINESTRING object
* @param string $line_color Color for the GIS LINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $line_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$line_color,
array $scale_data,
$image
@ -136,16 +136,16 @@ class GisLineString extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS LINESTRING object
* @param string $label Label for the GIS LINESTRING object
* @param string $line_color Color for the GIS LINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS LINESTRING object
* @param string|null $label Label for the GIS LINESTRING object
* @param string $line_color Color for the GIS LINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $line_color, array $scale_data, $pdf)
public function prepareRowAsPdf($spatial, ?string $label, $line_color, array $scale_data, $pdf)
{
// allocate colors
$red = hexdec(mb_substr($line_color, 1, 2));

View File

@ -78,18 +78,18 @@ class GisMultiLineString extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTILINESTRING object
* @param string $label Label for the GIS MULTILINESTRING object
* @param string $line_color Color for the GIS MULTILINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $line_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return object the modified image object
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$line_color,
array $scale_data,
$image
@ -151,16 +151,16 @@ class GisMultiLineString extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTILINESTRING object
* @param string $label Label for the GIS MULTILINESTRING object
* @param string $line_color Color for the GIS MULTILINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS MULTILINESTRING object
* @param string|null $label Label for the GIS MULTILINESTRING object
* @param string $line_color Color for the GIS MULTILINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $line_color, array $scale_data, $pdf)
public function prepareRowAsPdf($spatial, ?string $label, $line_color, array $scale_data, $pdf)
{
// allocate colors
$red = hexdec(mb_substr($line_color, 1, 2));

View File

@ -70,18 +70,18 @@ class GisMultiPoint extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $point_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return object the modified image object
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$point_color,
array $scale_data,
$image
@ -128,18 +128,18 @@ class GisMultiPoint extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS MULTIPOINT object
* @param string|null $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf(
$spatial,
$label,
?string $label,
$point_color,
array $scale_data,
$pdf

View File

@ -86,18 +86,18 @@ class GisMultiPolygon extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOLYGON object
* @param string $label Label for the GIS MULTIPOLYGON object
* @param string $fill_color Color for the GIS MULTIPOLYGON object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $fill_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return object the modified image object
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$fill_color,
array $scale_data,
$image
@ -120,6 +120,7 @@ class GisMultiPolygon extends GisGeometry
$polygons = explode(")),((", $multipolygon);
$first_poly = true;
$points_arr = [];
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, "),(") === false) {
@ -165,16 +166,16 @@ class GisMultiPolygon extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOLYGON object
* @param string $label Label for the GIS MULTIPOLYGON object
* @param string $fill_color Color for the GIS MULTIPOLYGON object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS MULTIPOLYGON object
* @param string|null $label Label for the GIS MULTIPOLYGON object
* @param string $fill_color Color for the GIS MULTIPOLYGON object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $fill_color, array $scale_data, $pdf)
public function prepareRowAsPdf($spatial, ?string $label, $fill_color, array $scale_data, $pdf)
{
// allocate colors
$red = hexdec(mb_substr($fill_color, 1, 2));

View File

@ -70,18 +70,18 @@ class GisPoint extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $point_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $point_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$point_color,
array $scale_data,
$image
@ -133,18 +133,18 @@ class GisPoint extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POINT object
* @param string $label Label for the GIS POINT object
* @param string $point_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS POINT object
* @param string|null $label Label for the GIS POINT object
* @param string $point_color Color for the GIS POINT object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf(
$spatial,
$label,
?string $label,
$point_color,
array $scale_data,
$pdf

View File

@ -78,18 +78,18 @@ class GisPolygon extends GisGeometry
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POLYGON object
* @param string $label Label for the GIS POLYGON object
* @param string $fill_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $fill_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param resource $image Image object
*
* @return object the modified image object
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng(
$spatial,
$label,
?string $label,
$fill_color,
array $scale_data,
$image
@ -147,16 +147,16 @@ class GisPolygon extends GisGeometry
/**
* Adds to the TCPDF instance, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS POLYGON object
* @param string $label Label for the GIS POLYGON object
* @param string $fill_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
* @param string $spatial GIS POLYGON object
* @param string|null $label Label for the GIS POLYGON object
* @param string $fill_color Color for the GIS POLYGON object
* @param array $scale_data Array containing data related to scaling
* @param TCPDF $pdf TCPDF instance
*
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $fill_color, array $scale_data, $pdf)
public function prepareRowAsPdf($spatial, ?string $label, $fill_color, array $scale_data, $pdf)
{
// allocate colors
$red = hexdec(mb_substr($fill_color, 1, 2));
@ -508,6 +508,10 @@ class GisPolygon extends GisGeometry
*/
public static function getPointOnSurface(array $ring)
{
$x0 = null;
$x1 = null;
$y0 = null;
$y1 = null;
// Find two consecutive distinct points.
for ($i = 0, $nb = count($ring) - 1; $i < $nb; $i++) {
if ($ring[$i]['y'] != $ring[$i + 1]['y']) {

View File

@ -210,7 +210,7 @@ class Header
$this->_scripts->addFile('indexes.js');
$this->_scripts->addFile('common.js');
$this->_scripts->addFile('page_settings.js');
if($GLOBALS['cfg']['enable_drag_drop_import'] === true) {
if ($GLOBALS['cfg']['enable_drag_drop_import'] === true) {
$this->_scripts->addFile('drag_drop_import.js');
}
if (! $GLOBALS['PMA_Config']->get('DisableShortcutKeys')) {

View File

@ -83,7 +83,7 @@ class InsertEdit
public function getFormParametersForInsertForm(
$db,
$table,
$where_clauses,
?array $where_clauses,
array $where_clause_array,
$err_url
) {
@ -248,16 +248,16 @@ class InsertEdit
/**
* Add some url parameters
*
* @param array $url_params containing $db and $table as url parameters
* @param array $where_clause_array where clauses array
* @param string $where_clause where clause
* @param array $url_params containing $db and $table as url parameters
* @param array $where_clause_array where clauses array
* @param string|null $where_clause where clause
*
* @return array Add some url parameters to $url_params array and return it
*/
public function urlParamsInEditMode(
array $url_params,
array $where_clause_array,
$where_clause
?string $where_clause
) {
if (isset($where_clause)) {
foreach ($where_clause_array as $where_clause) {
@ -1315,28 +1315,29 @@ class InsertEdit
/**
* Get HTML for binary and blob column
*
* @param array $column description of column in given table
* @param string $data data to edit
* @param string $special_chars special characters
* @param integer $biggest_max_file_size biggest max file size for uploading
* @param string $backup_field hidden input field
* @param string $column_name_appendix the name attribute
* @param string $onChangeClause onchange clause for fields
* @param integer $tabindex tab index
* @param integer $tabindex_for_value offset for the values tabindex
* @param integer $idindex id index
* @param string $text_dir text direction
* @param string $special_chars_encoded replaced char if the string starts
* with a \r\n pair (0x0d0a) add an extra \n
* @param string $vkey [multi_edit]['row_id']
* @param boolean $is_upload is upload or not
* @param boolean $readOnly is column read only or not
* @param array $column description of column in given table
* @param string|null $data data to edit
* @param string $special_chars special characters
* @param integer $biggest_max_file_size biggest max file size for uploading
* @param string $backup_field hidden input field
* @param string $column_name_appendix the name attribute
* @param string $onChangeClause onchange clause for fields
* @param integer $tabindex tab index
* @param integer $tabindex_for_value offset for the values tabindex
* @param integer $idindex id index
* @param string $text_dir text direction
* @param string $special_chars_encoded replaced char if the string starts
* with a \r\n pair (0x0d0a) add an
* extra \n
* @param string $vkey [multi_edit]['row_id']
* @param boolean $is_upload is upload or not
* @param boolean $readOnly is column read only or not
*
* @return string an html snippet
*/
private function getBinaryAndBlobColumn(
array $column,
$data,
?string $data,
$special_chars,
$biggest_max_file_size,
$backup_field,
@ -2400,7 +2401,7 @@ class InsertEdit
$foreigner['foreign_table']
);
// Field to display from the foreign table?
if (isset($display_field) && strlen($display_field) > 0) {
if (! is_null($display_field) && strlen($display_field) > 0) {
$dispsql = 'SELECT ' . Util::backquote($display_field)
. ' FROM ' . Util::backquote($foreigner['foreign_db'])
. '.' . Util::backquote($foreigner['foreign_table'])
@ -2680,9 +2681,9 @@ class InsertEdit
*
* @param string|false $possibly_uploaded_val uploaded file content
* @param string $key an md5 of the column name
* @param array $multi_edit_columns_type array of multi edit column types
* @param array|null $multi_edit_columns_type array of multi edit column types
* @param string $current_value current column value in the form
* @param array $multi_edit_auto_increment multi edit auto increment
* @param array|null $multi_edit_auto_increment multi edit auto increment
* @param integer $rownumber index of where clause array
* @param array $multi_edit_columns_name multi edit column names array
* @param array $multi_edit_columns_null multi edit columns null array
@ -2698,9 +2699,9 @@ class InsertEdit
public function getCurrentValueForDifferentTypes(
$possibly_uploaded_val,
$key,
$multi_edit_columns_type,
?array $multi_edit_columns_type,
$current_value,
$multi_edit_auto_increment,
?array $multi_edit_auto_increment,
$rownumber,
$multi_edit_columns_name,
$multi_edit_columns_null,

View File

@ -59,7 +59,7 @@ abstract class ListAbstract extends ArrayObject
* checks if the given db names exists in the current list, if there is
* missing at least one item it returns false otherwise true
*
* @param mixed ... $params params
* @param mixed[] ... $params params
* @return bool true if all items exists, otherwise false
*/
public function exists(...$params)

View File

@ -644,7 +644,7 @@ class Message
/**
* wrapper for sprintf()
*
* @param mixed ... $params Params
* @param mixed[] ... $params Params
* @return string formatted
*/
public static function format(...$params): string

View File

@ -83,7 +83,7 @@ class Navigation
}
$retval .= '</div>'; //pma_navi_settings_container
$retval .= '</div>'; // pma_navigation_content
if($GLOBALS['cfg']['enable_drag_drop_import'] === true) { //load drag drop handler only if configuration setting is set to true
if ($GLOBALS['cfg']['enable_drag_drop_import'] === true) { //load drag drop handler only if configuration setting is set to true
$retval .= $this->_getDropHandler();
}
$retval .= '</div>'; // pma_navigation

View File

@ -208,7 +208,7 @@ class Node
$parents[] = $this;
}
$parent = $this->parent;
while (isset($parent)) {
while (! is_null($parent)) {
if (($parent->type != Node::CONTAINER || $containers)
&& (!$parent->is_group || $groups)
) {
@ -688,6 +688,7 @@ class Node
*/
private function _getDatabasesToSearch($searchClause)
{
$databases = [];
if (!empty($searchClause)) {
$databases = [
"%" . $GLOBALS['dbi']->escapeString($searchClause) . "%",

View File

@ -137,7 +137,10 @@ class Normalization
$mimeMap = [];
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mimeMap = $this->transformations->getMime($db, $table);
$availableMime = $this->transformations->getAvailableMimeTypes();
$availableMimeTypes = $this->transformations->getAvailableMimeTypes();
if (! is_null($availableMimeTypes)) {
$availableMime = $availableMimeTypes;
}
}
$commentsMap = $this->relation->getComments($db, $table);
for ($columnNumber = 0; $columnNumber < $numFields; $columnNumber++) {
@ -154,7 +157,7 @@ class Normalization
'is_backup' => true,
'move_columns' => [],
'cfg_relation' => $cfgRelation,
'available_mime' => isset($availableMime) ? $availableMime : [],
'available_mime' => $availableMime,
'mime_map' => $mimeMap
];
}

View File

@ -31,6 +31,7 @@ class ParseAnalyze
*/
public static function sqlQuery($sql_query, $db)
{
global $reload;
// @todo: move to returned results (also in all the calling chain)
$GLOBALS['unparsed_sql'] = $sql_query;

View File

@ -292,6 +292,7 @@ class Plugins
$ret .= '<div class="export_sub_options" id="' . $plugin_name . '_'
. $propertyGroup->getName() . '">';
$text = null;
if (method_exists($propertyGroup, 'getText')) {
$text = $propertyGroup->getText();
}
@ -320,7 +321,7 @@ class Plugins
// each subgroup can have a header, which may also be a form element
/** @var OptionsPropertyItem $subgroup_header */
$subgroup_header = $propertyItem->getSubgroupHeader();
if (isset($subgroup_header)) {
if (! is_null($subgroup_header)) {
$ret .= self::getOneOption(
$section,
$plugin_name,
@ -329,7 +330,7 @@ class Plugins
}
$ret .= '<li class="subgroup"><ul';
if (isset($subgroup_header)) {
if (! is_null($subgroup_header)) {
$ret .= ' id="ul_' . $subgroup_header->getName() . '">';
} else {
$ret .= '>';
@ -541,6 +542,8 @@ class Plugins
// Options for plugins that support them
foreach ($list as $plugin) {
$properties = $plugin->getProperties();
$text = null;
$options = null;
if ($properties != null) {
$text = $properties->getText();
$options = $properties->getOptions();

View File

@ -275,6 +275,7 @@ class ExportPdf extends ExportPlugin
) {
$db_alias = $db;
$table_alias = $table;
$purpose = null;
$this->initAlias($aliases, $db_alias, $table_alias);
$pdf = $this->_getPdf();
// getting purpose to show at top

View File

@ -2827,18 +2827,18 @@ class ExportSql extends ExportPlugin
/**
* Generate comment
*
* @param string $crlf Carriage return character
* @param string $sql_statement SQL statement
* @param string $comment1 Comment for dumped table
* @param string $comment2 Comment for current table
* @param string $table_alias Table alias
* @param string $compat Compatibility mode
* @param string $crlf Carriage return character
* @param string|null $sql_statement SQL statement
* @param string $comment1 Comment for dumped table
* @param string $comment2 Comment for current table
* @param string $table_alias Table alias
* @param string $compat Compatibility mode
*
* @return string
*/
protected function generateComment(
$crlf,
$sql_statement,
?string $sql_statement,
$comment1,
$comment2,
$table_alias,

View File

@ -175,7 +175,8 @@ class ImportCsv extends AbstractImportCsv
$buffer = '';
$required_fields = 0;
$sql_template = '';
$fields = [];
if (!$this->_getAnalyze()) {
$sql_template = 'INSERT';
if (isset($_POST['csv_ignore'])) {
@ -216,7 +217,9 @@ class ImportCsv extends AbstractImportCsv
$error = true;
break;
}
$fields[] = $field;
if (isset($field)) {
$fields[] = $field;
}
$sql_template .= Util::backquote($val);
}
$sql_template .= ') ';

View File

@ -207,18 +207,18 @@ class Svg extends XMLWriter
* and other elements who have x,y co-ordinates are drawn.
* specify their width and height and can give styles too.
*
* @param string $name RelationStatsSvg element name
* @param int $x The x attr defines the left position of the element
* (e.g. x="0" places the element 0 pixels from the
* left of the browser window)
* @param integer $y The y attribute defines the top position of the
* element (e.g. y="0" places the element 0 pixels
* from the top of the browser window)
* @param int|string $width The width attribute defines the width the element
* @param int|string $height The height attribute defines the height the element
* @param string $text The text attribute defines the text the element
* @param string $styles The style attribute defines the style the element
* styles can be defined like CSS styles
* @param string $name RelationStatsSvg element name
* @param int $x The x attr defines the left position of the element
* (e.g. x="0" places the element 0 pixels from the
* left of the browser window)
* @param integer $y The y attribute defines the top position of the
* element (e.g. y="0" places the element 0 pixels
* from the top of the browser window)
* @param int|string $width The width attribute defines the width the element
* @param int|string $height The height attribute defines the height the element
* @param string|null $text The text attribute defines the text the element
* @param string $styles The style attribute defines the style the element
* styles can be defined like CSS styles
*
* @return void
*
@ -231,7 +231,7 @@ class Svg extends XMLWriter
$y,
$width = '',
$height = '',
$text = '',
?string $text = '',
$styles = ''
) {
$this->startElement($name);

View File

@ -1062,11 +1062,7 @@ class Relation
AND `column_name` = \'(db_comment)\'';
}
if (isset($upd_query)) {
return $this->queryAsControlUser($upd_query);
}
return false;
return $this->queryAsControlUser($upd_query);
}
/**
@ -1785,13 +1781,13 @@ class Relation
/**
* Create a PDF page
*
* @param string $newpage name of the new PDF page
* @param array $cfgRelation Relation configuration
* @param string $db database name
* @param string|null $newpage name of the new PDF page
* @param array $cfgRelation Relation configuration
* @param string $db database name
*
* @return int $pdf_page_number
*/
public function createPage($newpage, array $cfgRelation, $db)
public function createPage(?string $newpage, array $cfgRelation, $db)
{
if (! isset($newpage) || $newpage == '') {
$newpage = __('no description');

View File

@ -651,7 +651,8 @@ class Privileges
if ($db == '*') {
$table = '*';
}
$username = '';
$hostname = '';
if (isset($GLOBALS['username'])) {
$username = $GLOBALS['username'];
$hostname = $GLOBALS['hostname'];
@ -2376,6 +2377,8 @@ class Privileges
$current_host = $row['Host'];
$routine = $row['Routine_name'];
$html_output .= '<td>';
$specific_db = '';
$specific_table = '';
if ($GLOBALS['is_grantuser']) {
$specific_db = (isset($row['Db']) && $row['Db'] != '*')
? $row['Db'] : '';
@ -3673,6 +3676,7 @@ class Privileges
{
$relation = new Relation();
$cfgRelation = $relation->getRelationsParam();
$user_group_count = 0;
if ($cfgRelation['menuswork']) {
$users_table = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['users']);
@ -4047,34 +4051,33 @@ class Privileges
);
unset($_REQUEST['change_copy']);
} else {
extract($row, EXTR_OVERWRITE);
foreach ($row as $key => $value) {
$GLOBALS[$key] = $value;
}
$serverVersion = $GLOBALS['dbi']->getVersion();
// Recent MySQL versions have the field "Password" in mysql.user,
// so the previous extract creates $Password but this script
// so the previous extract creates $row['Password'] but this script
// uses $password
if (! isset($password) && isset($Password)) {
$password = $Password;
if (! isset($row['password']) && isset($row['Password'])) {
$row['password'] = $row['Password'];
}
if (Util::getServerType() == 'MySQL'
&& $serverVersion >= 50606
&& $serverVersion < 50706
&& ((isset($authentication_string)
&& empty($password))
|| (isset($plugin)
&& $plugin == 'sha256_password'))
&& ((isset($row['authentication_string'])
&& empty($row['password']))
|| (isset($row['plugin'])
&& $row['plugin'] == 'sha256_password'))
) {
$password = $authentication_string;
$row['password'] = $row['authentication_string'];
}
if (Util::getServerType() == 'MariaDB'
&& $serverVersion >= 50500
&& isset($authentication_string)
&& empty($password)
&& isset($row['authentication_string'])
&& empty($row['password'])
) {
$password = $authentication_string;
$row['password'] = $row['authentication_string'];
}
// Always use 'authentication_string' column
@ -4082,11 +4085,11 @@ class Privileges
// the 'password' column at all
if (Util::getServerType() == 'MySQL'
&& $serverVersion >= 50706
&& isset($authentication_string)
&& isset($row['authentication_string'])
) {
$password = $authentication_string;
$row['password'] = $row['authentication_string'];
}
$password = $row['password'];
$queries = [];
}
}
@ -4191,19 +4194,19 @@ class Privileges
/**
* update Data for information: Adds a user
*
* @param string $dbname db name
* @param string $username user name
* @param string $hostname host name
* @param string $password password
* @param bool $is_menuwork is_menuwork set?
* @param string|null $dbname db name
* @param string $username user name
* @param string $hostname host name
* @param string|null $password password
* @param bool $is_menuwork is_menuwork set?
*
* @return array
*/
public function addUser(
$dbname,
?string $dbname,
$username,
$hostname,
$password,
?string $password,
$is_menuwork
) {
$_add_user_error = false;
@ -4271,7 +4274,7 @@ class Privileges
if (empty($_REQUEST['change_copy'])) {
$_error = false;
if (isset($create_user_real)) {
if (! is_null($create_user_real)) {
if (!$GLOBALS['dbi']->tryQuery($create_user_real)) {
$_error = true;
}
@ -4294,7 +4297,7 @@ class Privileges
$sql_query,
$username,
$hostname,
isset($dbname) ? $dbname : null
$dbname
);
if (!empty($_REQUEST['userGroup']) && $is_menuwork) {
$this->setUserGroup($GLOBALS['username'], $_REQUEST['userGroup']);
@ -4314,7 +4317,7 @@ class Privileges
isset($_REQUEST['old_usergroup']) ? $_REQUEST['old_usergroup'] : null;
$this->setUserGroup($_REQUEST['username'], $old_usergroup);
if (isset($create_user_real)) {
if (is_null($create_user_real)) {
$queries[] = $create_user_real;
}
$queries[] = $real_sql_query;
@ -5299,7 +5302,8 @@ class Privileges
. $_REQUEST['authentication_plugin'];
}
$create_user_real = $create_user_show = $create_user_stmt;
$create_user_real = $create_user_stmt;
$create_user_show = $create_user_stmt;
$password_set_stmt = 'SET PASSWORD FOR \'%s\'@\'%s\' = \'%s\'';
$password_set_show = sprintf(
@ -5427,12 +5431,10 @@ class Privileges
$real_sql_query .= $with_clause;
$sql_query .= $with_clause;
if (isset($create_user_real)) {
$create_user_real .= ';';
$create_user_show .= ';';
}
$real_sql_query .= ';';
$sql_query .= ';';
$create_user_real .= ';';
$create_user_show .= ';';
$real_sql_query .= ';';
$sql_query .= ';';
// No Global GRANT_OPTION privilege
if (!$GLOBALS['is_grantuser']) {
$real_sql_query = '';

View File

@ -568,13 +568,13 @@ EOT;
* Function to get html for bookmark support if bookmarks are enabled. Else will
* return null
*
* @param array $displayParts the parts to display
* @param array $cfgBookmark configuration setting for bookmarking
* @param string $sql_query sql query
* @param string $db current database
* @param string $table current table
* @param string $complete_query complete query
* @param string $bkm_user bookmarking user
* @param array $displayParts the parts to display
* @param array $cfgBookmark configuration setting for bookmarking
* @param string $sql_query sql query
* @param string $db current database
* @param string $table current table
* @param string|null $complete_query complete query
* @param string $bkm_user bookmarking user
*
* @return string $html
*/
@ -584,7 +584,7 @@ EOT;
$sql_query,
$db,
$table,
$complete_query,
?string $complete_query,
$bkm_user
) {
if ($displayParts['bkm_form'] == '1'
@ -701,13 +701,13 @@ EOT;
/**
* Function to check whether this query is for just browsing
*
* @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
* @param boolean $find_real_end whether the real end should be found
* @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
* @param boolean|null $find_real_end whether the real end should be found
*
* @return boolean
*/
public function isJustBrowsing(array $analyzed_sql_results, $find_real_end)
public function isJustBrowsing(array $analyzed_sql_results, ?bool $find_real_end): bool
{
return ! $analyzed_sql_results['is_group']
&& ! $analyzed_sql_results['is_func']
@ -1034,11 +1034,11 @@ EOT;
/**
* Function to store the query as a bookmark
*
* @param string $db the current database
* @param string $bkm_user the bookmarking user
* @param string $sql_query_for_bookmark the query to be stored in bookmark
* @param string $bkm_label bookmark label
* @param boolean $bkm_replace whether to replace existing bookmarks
* @param string $db the current database
* @param string $bkm_user the bookmarking user
* @param string $sql_query_for_bookmark the query to be stored in bookmark
* @param string $bkm_label bookmark label
* @param boolean|null $bkm_replace whether to replace existing bookmarks
*
* @return void
*/
@ -1047,7 +1047,7 @@ EOT;
$bkm_user,
$sql_query_for_bookmark,
$bkm_label,
$bkm_replace
?bool $bkm_replace
) {
$bfields = [
'bkm_database' => $db,
@ -1148,14 +1148,14 @@ EOT;
/**
* If a table, database or column gets dropped, clean comments.
*
* @param string $db current database
* @param string $table current table
* @param string $column current column
* @param bool $purge whether purge set or not
* @param string $db current database
* @param string $table current table
* @param string|null $column current column
* @param bool $purge whether purge set or not
*
* @return array $extra_data
*/
private function cleanupRelations($db, $table, $column, $purge)
private function cleanupRelations($db, $table, ?string $column, $purge)
{
if (! empty($purge) && strlen($db) > 0) {
if (strlen($table) > 0) {
@ -1269,14 +1269,14 @@ EOT;
/**
* Function to handle all aspects relating to executing the query
*
* @param array $analyzed_sql_results analyzed sql results
* @param string $full_sql_query full sql query
* @param boolean $is_gotofile whether to go to a file
* @param string $db current database
* @param string $table current table
* @param boolean $find_real_end whether to find the real end
* @param string $sql_query_for_bookmark sql query to be stored as bookmark
* @param array $extra_data extra data
* @param array $analyzed_sql_results analyzed sql results
* @param string $full_sql_query full sql query
* @param boolean $is_gotofile whether to go to a file
* @param string $db current database
* @param string $table current table
* @param boolean|null $find_real_end whether to find the real end
* @param string $sql_query_for_bookmark sql query to be stored as bookmark
* @param array $extra_data extra data
*
* @return mixed
*/
@ -1286,7 +1286,7 @@ EOT;
$is_gotofile,
$db,
$table,
$find_real_end,
?bool $find_real_end,
$sql_query_for_bookmark,
$extra_data
) {
@ -1505,14 +1505,14 @@ EOT;
* @param array $analyzed_sql_results analyzed sql results
* @param string $db current database
* @param string $table current table
* @param string $message_to_show message to show
* @param string|null $message_to_show message to show
* @param int $num_rows number of rows
* @param DisplayResults $displayResultsObject DisplayResult instance
* @param array $extra_data extra data
* @param array|null $extra_data extra data
* @param string $pmaThemeImage uri of the theme image
* @param object $result executed query results
* @param string $sql_query sql query
* @param string $complete_query complete sql query
* @param string|null $complete_query complete sql query
*
* @return string html
*/
@ -1520,15 +1520,16 @@ EOT;
array $analyzed_sql_results,
$db,
$table,
$message_to_show,
?string $message_to_show,
$num_rows,
$displayResultsObject,
$extra_data,
?array $extra_data,
$pmaThemeImage,
$result,
$sql_query,
$complete_query
?string $complete_query
) {
global $url_query;
if ($this->isDeleteTransformationInfo($analyzed_sql_results)) {
$this->deleteTransformationInfo($db, $table, $analyzed_sql_results);
}
@ -1639,25 +1640,25 @@ EOT;
/**
* Function to get html for the sql query results div
*
* @param string $previous_update_query_html html for the previously executed query
* @param string $profiling_chart_html html for profiling
* @param Message $missing_unique_column_msg message for the missing unique column
* @param Message $bookmark_created_msg message for bookmark creation
* @param string $table_html html for the table for displaying sql
* results
* @param string $indexes_problems_html html for displaying errors in indexes
* @param string $bookmark_support_html html for displaying bookmark form
* @param string|null $previous_update_query_html html for the previously executed query
* @param string|null $profiling_chart_html html for profiling
* @param Message|null $missing_unique_column_msg message for the missing unique column
* @param Message|null $bookmark_created_msg message for bookmark creation
* @param string $table_html html for the table for displaying sql
* results
* @param string|null $indexes_problems_html html for displaying errors in indexes
* @param string|null $bookmark_support_html html for displaying bookmark form
*
* @return string $html_output
*/
private function getHtmlForSqlQueryResults(
$previous_update_query_html,
$profiling_chart_html,
$missing_unique_column_msg,
$bookmark_created_msg,
?string $previous_update_query_html,
?string $profiling_chart_html,
?Message $missing_unique_column_msg,
?Message $bookmark_created_msg,
$table_html,
$indexes_problems_html,
$bookmark_support_html
?string $indexes_problems_html,
?string $bookmark_support_html
) {
//begin the sqlqueryresults div here. container div
$html_output = '<div class="sqlqueryresults ajax">';
@ -1708,7 +1709,7 @@ EOT;
* @param int $unlim_num_rows unlimited number of rows
* @param int $num_rows number of rows
* @param bool $showtable whether to show table or not
* @param object $result result of the executed query
* @param object|null $result result of the executed query
* @param array $analyzed_sql_results analyzed sql results
* @param bool $is_limited_display Show only limited operations or not
*
@ -1723,7 +1724,7 @@ EOT;
$unlim_num_rows,
$num_rows,
$showtable,
$result,
?object $result,
array $analyzed_sql_results,
$is_limited_display = false
) {
@ -1790,6 +1791,8 @@ EOT;
unset($result);
} while ($GLOBALS['dbi']->moreResults() && $GLOBALS['dbi']->nextResult());
} else {
$fields_meta = [];
$fields_cnt = 0;
if (isset($result) && $result !== false) {
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
$fields_cnt = count($fields_meta);
@ -1833,15 +1836,15 @@ EOT;
* Function to get html for the previous query if there is such. If not will return
* null
*
* @param string $disp_query display query
* @param bool $showSql whether to show sql
* @param array $sql_data sql data
* @param string $disp_message display message
* @param string|null $disp_query display query
* @param bool $showSql whether to show sql
* @param array $sql_data sql data
* @param Message|string $disp_message display message
*
* @return string $previous_update_query_html
*/
private function getHtmlForPreviousUpdateQuery(
$disp_query,
?string $disp_query,
$showSql,
$sql_data,
$disp_message
@ -1910,16 +1913,16 @@ EOT;
/**
* Function to get html to display problems in indexes
*
* @param string $query_type query type
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $db current database
* @param string|null $query_type query type
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $db current database
*
* @return string
*/
private function getHtmlForIndexesProblems($query_type, $selectedTables, $db)
private function getHtmlForIndexesProblems(?string $query_type, ?array $selectedTables, string $db)
{
// BEGIN INDEX CHECK See if indexes should be checked.
if (isset($query_type)
@ -1948,49 +1951,50 @@ EOT;
/**
* Function to display results when the executed query returns non empty results
*
* @param object $result executed query results
* @param array $analyzed_sql_results analysed sql results
* @param string $db current database
* @param string $table current table
* @param string $message message to show
* @param array $sql_data sql data
* @param DisplayResults $displayResultsObject Instance of DisplayResults
* @param string $pmaThemeImage uri of the theme image
* @param int $unlim_num_rows unlimited number of rows
* @param int $num_rows number of rows
* @param string $disp_query display query
* @param string $disp_message display message
* @param array $profiling_results profiling results
* @param string $query_type query type
* @param array|null $selectedTables array of table names selected
* from the database structure page, for
* an action like check table,
* optimize table, analyze table or
* repair table
* @param string $sql_query sql query
* @param string $complete_query complete sql query
* @param object|null $result executed query results
* @param array $analyzed_sql_results analysed sql results
* @param string $db current database
* @param string $table current table
* @param string|null $message message to show
* @param array|null $sql_data sql data
* @param DisplayResults $displayResultsObject Instance of DisplayResults
* @param string $pmaThemeImage uri of the theme image
* @param int $unlim_num_rows unlimited number of rows
* @param int $num_rows number of rows
* @param string|null $disp_query display query
* @param Message|string|null $disp_message display message
* @param array|null $profiling_results profiling results
* @param string|null $query_type query type
* @param array|null $selectedTables array of table names selected
* from the database structure page, for
* an action like check table,
* optimize table, analyze table or
* repair table
* @param string $sql_query sql query
* @param string|null $complete_query complete sql query
*
* @return string html
*/
private function getQueryResponseForResultsReturned(
$result,
?object $result,
array $analyzed_sql_results,
$db,
$table,
$message,
$sql_data,
?string $message,
?array $sql_data,
$displayResultsObject,
$pmaThemeImage,
$unlim_num_rows,
$num_rows,
$disp_query,
?string $disp_query,
$disp_message,
$profiling_results,
$query_type,
?array $profiling_results,
?string $query_type,
$selectedTables,
$sql_query,
$complete_query
?string $complete_query
) {
global $showtable, $url_query;
// If we are retrieving the full value of a truncated field or the original
// value of a transformed field, show it here
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
@ -2001,6 +2005,8 @@ EOT;
// Gets the list of fields properties
if (isset($result) && $result) {
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
} else {
$fields_meta = [];
}
// Should be initialized these parameters before parsing
@ -2197,27 +2203,27 @@ EOT;
/**
* Function to execute the query and send the response
*
* @param array $analyzed_sql_results analysed sql results
* @param bool $is_gotofile whether goto file or not
* @param string $db current database
* @param string $table current table
* @param bool|null $find_real_end whether to find real end or not
* @param string $sql_query_for_bookmark the sql query to be stored as bookmark
* @param array|null $extra_data extra data
* @param string $message_to_show message to show
* @param string $message message
* @param array|null $sql_data sql data
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the PMA theme image
* @param string $disp_query display query
* @param string $disp_message display message
* @param string $query_type query type
* @param string $sql_query sql query
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $complete_query complete query
* @param array $analyzed_sql_results analysed sql results
* @param bool $is_gotofile whether goto file or not
* @param string $db current database
* @param string $table current table
* @param bool|null $find_real_end whether to find real end or not
* @param string $sql_query_for_bookmark the sql query to be stored as bookmark
* @param array|null $extra_data extra data
* @param string $message_to_show message to show
* @param string $message message
* @param array|null $sql_data sql data
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the PMA theme image
* @param string $disp_query display query
* @param Message|string $disp_message display message
* @param string $query_type query type
* @param string $sql_query sql query
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $complete_query complete query
*
* @return void
*/
@ -2284,27 +2290,27 @@ EOT;
/**
* Function to execute the query and send the response
*
* @param array $analyzed_sql_results analysed sql results
* @param bool $is_gotofile whether goto file or not
* @param string $db current database
* @param string $table current table
* @param bool|null $find_real_end whether to find real end or not
* @param string $sql_query_for_bookmark the sql query to be stored as bookmark
* @param array|null $extra_data extra data
* @param string $message_to_show message to show
* @param string $message message
* @param array|null $sql_data sql data
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the PMA theme image
* @param string $disp_query display query
* @param string $disp_message display message
* @param string $query_type query type
* @param string $sql_query sql query
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $complete_query complete query
* @param array $analyzed_sql_results analysed sql results
* @param bool $is_gotofile whether goto file or not
* @param string $db current database
* @param string $table current table
* @param bool|null $find_real_end whether to find real end or not
* @param string|null $sql_query_for_bookmark the sql query to be stored as bookmark
* @param array|null $extra_data extra data
* @param string|null $message_to_show message to show
* @param string|null $message message
* @param array|null $sql_data sql data
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the PMA theme image
* @param string|null $disp_query display query
* @param Message|string|null $disp_message display message
* @param string|null $query_type query type
* @param string $sql_query sql query
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string|null $complete_query complete query
*
* @return string html
*/
@ -2314,19 +2320,19 @@ EOT;
$db,
$table,
$find_real_end,
$sql_query_for_bookmark,
?string $sql_query_for_bookmark,
$extra_data,
$message_to_show,
$message,
?string $message_to_show,
?string $message,
$sql_data,
$goto,
$pmaThemeImage,
$disp_query,
?string $disp_query,
$disp_message,
$query_type,
?string $query_type,
$sql_query,
$selectedTables,
$complete_query
?string $complete_query
) {
// Handle disable/enable foreign key checks
$default_fk_check = Util::handleDisableFKCheckInit();

View File

@ -902,20 +902,20 @@ class Table
/**
* Copies or renames table
*
* @param string $source_db source database
* @param string $source_table source table
* @param string $target_db target database
* @param string $target_table target table
* @param string $what what to be moved or copied (data, dataonly)
* @param bool $move whether to move
* @param string $mode mode
* @param string $source_db source database
* @param string $source_table source table
* @param string|null $target_db target database
* @param string $target_table target table
* @param string $what what to be moved or copied (data, dataonly)
* @param bool $move whether to move
* @param string $mode mode
*
* @return bool true if success, false otherwise
*/
public static function moveCopy(
$source_db,
$source_table,
$target_db,
?string $target_db,
$target_table,
$what,
$move,

View File

@ -82,7 +82,7 @@ class Tracker
$pma_table = self::_getTrackingTable();
return isset($pma_table);
return ! is_null($pma_table);
}
/**

View File

@ -69,6 +69,7 @@ class Transformations
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
// '...,
$trimmed = ltrim($option);
$rtrimmed = null;
while (($option = array_shift($transform_options)) !== null) {
// ...,
$trimmed .= ',' . $option;

View File

@ -4351,13 +4351,13 @@ class Util
* Gets the list of tables in the current db and information about these
* tables if possible
*
* @param string $db database name
* @param string $sub_part part of script name
* @param string $db database name
* @param string|null $sub_part part of script name
*
* @return array
*
*/
public static function getDbInfo($db, $sub_part)
public static function getDbInfo($db, ?string $sub_part)
{
global $cfg;
@ -4543,7 +4543,8 @@ class Util
*/
public static function getTablesWhenOpen($db, $db_info_result)
{
$sot_cache = $tables = [];
$sot_cache = [];
$tables = [];
while ($tmp = $GLOBALS['dbi']->fetchAssoc($db_info_result)) {
$sot_cache[$tmp['Table']] = true;
@ -4551,7 +4552,7 @@ class Util
$GLOBALS['dbi']->freeResult($db_info_result);
// is there at least one "in use" table?
if (isset($sot_cache)) {
if (count($sot_cache) > 0) {
$tblGroupSql = "";
$whereAdded = false;
if (Core::isValid($_REQUEST['tbl_group'])) {

View File

@ -183,6 +183,7 @@ class VersionInformation
public function evaluateVersionCondition($type, $condition)
{
$operator = null;
$version = null;
$operators = ["<=", ">=", "!=", "<>", "<", ">", "="]; // preserve order
foreach ($operators as $oneOperator) {
if (strpos($condition, $oneOperator) === 0) {

View File

@ -1,5 +1,5 @@
parameters:
level: 0
level: 1
paths:
- %rootDir%/../../../
bootstrap: %rootDir%/../../../test/bootstrap-phpstan.php
@ -14,14 +14,13 @@ parameters:
- '#Function (get_login_credentials|uploadprogress_get_info) not found#'
- '#Function mysql_(connect|close) not found#'
- '#Instantiated class COM not found#'
- '#Function escape not found#'
- '#Function PMA_gradientGetColor not found#'
- '#Function (escape|PMA_gradientGetColor|recode_string|apc_fetch) not found#'
- '#TableStructureController has an unused parameter#'
- '#RelationCleanupDbiMock::__construct\(\) does not call parent constructor#'
- '#NodeTrans::__construct\(\) does not call parent constructor#'
- '#GisGeomTestCase::\$object#'
- '#Undefined variable: \$array#'
- '#Undefined variable: \$(cfg|db|table|url_query|text_dir|server|pmaThemeImage|action|sql_query|lang|export_type|err_url|collation_connection|filename_template|transform_key|cn|goto|partitionDetails|token_mismatch|auth_plugin|username|hostname|display_query|where_clause)#'# Others
- '#Undefined variable: \$(cfg|db|table|url_query|text_dir|server|pmaThemeImage|action|sql_query|lang|export_type|err_url|collation_connection|filename_template|transform_key|cn|goto|partitionDetails|token_mismatch|auth_plugin|username|hostname|display_query|where_clause)#'#Others
- '#Access to an undefined property PhpMyAdmin\\TwoFactor\:\:\$available#'
- '#Undefined variable: \$(replication_types|selected)#'#Controllers/Server/ServerDatabasesController.php
- '#Undefined variable: \$authentication_string#'#Server/Privileges.php
@ -30,15 +29,33 @@ parameters:
- '#Undefined variable: \$(unsaved_values|is_upload)#'#tbl_change.php
- '#Undefined variable: \$max_upload_size#'#tbl_import.php
- '#Undefined variable: \$(repobase|fullrevision|revision|repobranchbase|branch)#'#Footer.php
- '#Variable \$_(REQUEST|GET|POST|COOKIE|SESSION) in isset\(\) always exists and is not nullable#'#Sanitize.php
- '#Variable \$msg1 might not be defined#'#Twig/I18n/NodeTrans.php
- '#Variable \$(foreign_db|foreign_table) might not be defined#'#Relation.php, do while(false) + break
- '#Variable \$(sql_query|table|db|cfg|import_type|goto) might not be defined#'# Others
- '#Variable \$(sql_query|table|db|cfg|url_query) in isset\(\) always exists and is not nullable#'#Others
- '#Variable \$(last_cumulative_type) in isset\(\) always exists and is not nullable#'#Import.php
- '#Variable \$(authentication_string|Password|password|create_user_real|plugin) is never defined#'#Server/Privileges.php
- '#Variable \$(routine|mode|title|message|output|nbResultsetToDisplay|item) might not be defined#'# Rte
- '#Variable \$time might not be defined#'#DatabaseInterface.php
- '#Variable \$contentPath in isset\(\) always exists and is not nullable#'#DatabaseInterface.php
- '#Variable \$server_info might not be defined#'#DatabaseInterface.php
# - '#Variable \$single_table always exists and is not nullable#'#Display/ExportTest.php
- '#Function mysqli_get_client_info invoked with 0 parameters, 1 required#'#libraries/classes/Dbi/DbiMysqli.php
- '#Variable \$default_fk_check_value might not be defined#'#libraries/mult_submits.inc.php
- '#Variable \$http_response_header in isset\(\) always exists and is not nullable#'
- '#Variable \$(escape_class|escape_method|iconLinks|icons|where_clause|where_clause_html|condition_array|pos_next|pos_prev) might not be defined#'
- '#Call to sprintf contains 3 placeholders, 4 values given.#'#libraries/classes/Menu.php, a phpstan bug
- '#Variable \$(in_table_header|cur_temp_table_headers|cur_temp_table) might not be defined#'#Plugins/Import/ImportMediawiki.php
excludes_analyse:
- %rootDir%/../../../test/EnvironmentTest.php
- %rootDir%/../../../test/libraries/FilesTest.php
- %rootDir%/../../../test/libraries/common/GetCheckboxTest.php
- %rootDir%/../../../tmp/*
- %rootDir%/../../../vendor/*
- %rootDir%/../../../node_modules/*
- %rootDir%/../../../test/bootstrap-phpstan.php
- %rootDir%/../../../test/sami-config.php
- %rootDir%/../../../themes/*/css/*.css.php
- %rootDir%/../../../examples/signon-script.php
- %rootDir%/../../../examples/openid.php

View File

@ -312,7 +312,7 @@ if (isset($_REQUEST['change_copy'])) {
* Reloads the privilege tables into memory
*/
$message_ret = $serverPrivileges->updateMessageForReload();
if (isset($message_ret)) {
if (! is_null($message_ret)) {
$message = $message_ret;
unset($message_ret);
}
@ -369,7 +369,7 @@ if (isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'db') {
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PhpMyAdmin\Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
$content = ob_get_contents();
ob_end_clean();

View File

@ -29,6 +29,8 @@ use PhpMyAdmin\Util;
*/
require_once 'libraries/common.inc.php';
global $url_params;
// Check parameters
Util::checkParameters(['db', 'table', 'goto']);

View File

@ -45,6 +45,14 @@ if (Tracker::isActive()
$url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
$url_params['goto'] = 'tbl_tracking.php';
$url_params['back'] = 'tbl_tracking.php';
$data = [];
$entries = [];
$filter_ts_from = '';
$filter_ts_to = '';
$filter_users = [];
$selection_schema = false;
$selection_data = false;
$selection_both = false;
// Init vars for tracking report
if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
@ -54,9 +62,6 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
$_REQUEST['version']
);
$selection_schema = false;
$selection_data = false;
$selection_both = false;
if (! isset($_REQUEST['logtype'])) {
$_REQUEST['logtype'] = 'schema_and_data';

View File

@ -15,9 +15,22 @@ define('PHPMYADMIN', true);
define('TESTSUITE', true);
require_once 'libraries/config.default.php';
require_once 'libraries/vendor_config.php';
require_once AUTOLOAD_FILE;
$GLOBALS['cfg'] = $cfg;
$GLOBALS['server'] = 0;
$GLOBALS['PMA_Config'] = new Config();
define('PMA_VERSION', $GLOBALS['PMA_Config']->get('PMA_VERSION'));
define('PMA_MAJOR_VERSION', $GLOBALS['PMA_Config']->get('PMA_MAJOR_VERSION'));
define('PROXY_URL', '');
define('PROXY_USER', '');
define('PROXY_PASS', '');
define('PMA_PATH_TO_BASEDIR', '');
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36';
$GLOBALS['PMA_Config']->checkClient();
$GLOBALS['PMA_Config']->checkWebServerOs();
$GLOBALS['PMA_Config']->enableBc();// Defines constants, phpstan:level=1
Loader::loadFunctions();

View File

@ -1,3 +1,3 @@
#!/bin/sh
set -e
./vendor/bin/sami.php --no-interaction --verbose update ./test/sami-config.php
$HOME/.composer/vendor/bin/sami.php --no-interaction --verbose update ./test/sami-config.php

View File

@ -1,3 +1,3 @@
#!/bin/sh
set -e
composer require "sami/sami:^4.0"
composer global require "sami/sami:^4.0"

View File

@ -47,7 +47,7 @@ class ServerEnginesControllerTest extends PmaTestCase
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server'] = array('DisableIS' => false);
$GLOBALS['cfg']['Server'] = ['DisableIS' => false];
$this->container = Container::getDefaultContainer();
$this->container->set('PhpMyAdmin\Response', new ResponseStub());

View File

@ -160,7 +160,7 @@ class ExportTest extends TestCase
'libraries/classes/Plugins/Export/',
[
'export_type' => $export_type,
'single_table' => isset($single_table)
'single_table' => true,// isset($single_table)
]
);

View File

@ -58,10 +58,10 @@ class AuthenticationHttpTest extends PmaTestCase
}
/**
* @param mixed $set_minimal set minimal
* @param mixed $body_id body id
* @param mixed $set_title set title
* @param mixed ... $headers headers
* @param mixed $set_minimal set minimal
* @param mixed $body_id body id
* @param mixed $set_title set title
* @param mixed[] ... $headers headers
*
* @return void
*/

View File

@ -43,7 +43,7 @@ class PmaTestCase extends TestCase
/**
* Creates mock of Response object for header testing
*
* @param mixed ... $param parameter for header method
* @param mixed[] ... $param parameter for header method
*
* @return \PHPUnit\Framework\MockObject\MockBuilder
*/

View File

@ -440,6 +440,8 @@ class TrackerTest extends PmaTestCase
$GLOBALS['dbi'] = $dbi;
$result = null;
if ($type == null) {
$method = new \ReflectionMethod('PhpMyAdmin\Tracker', '_changeTracking');
$method->setAccessible(true);

View File

@ -1,5 +1,6 @@
<?php
/**
* @package PhpMyAdmin-test
* This file has been generated by phpmyadmin/scripts:/develdocs/build.sh
* @see https://github.com/phpmyadmin/scripts/blob/master/develdocs/sami.php
* @see https://github.com/phpmyadmin/scripts/blob/master/develdocs/build.sh
@ -13,9 +14,8 @@ $iterator = Finder::create()
->in("./libraries")
;
return new Sami($iterator, array(
return new Sami($iterator, [
"title" => "MySQL web administration tool",
"build_dir" => "./build/apidocs/",
"cache_dir" => "./tmp"
));
]);

View File

@ -149,30 +149,29 @@ if (! isset($_REQUEST['resize'])) {
if ($_REQUEST['resize']) {
$destImage = imagecreatetruecolor($destWidth, $destHeight);
}
// ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0,
// $destWidth, $destHeight, $srcWidth, $srcHeight);
// better quality but slower:
imagecopyresampled(
$destImage,
$srcImage,
0,
0,
0,
0,
$destWidth,
$destHeight,
$srcWidth,
$srcHeight
);
if ($_REQUEST['resize'] == 'jpeg') {
imagejpeg($destImage, null, 75);
}
if ($_REQUEST['resize'] == 'png') {
imagepng($destImage);
// ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0,
// $destWidth, $destHeight, $srcWidth, $srcHeight);
// better quality but slower:
imagecopyresampled(
$destImage,
$srcImage,
0,
0,
0,
0,
$destWidth,
$destHeight,
$srcWidth,
$srcHeight
);
if ($_REQUEST['resize'] == 'jpeg') {
imagejpeg($destImage, null, 75);
}
if ($_REQUEST['resize'] == 'png') {
imagepng($destImage);
}
imagedestroy($destImage);
}
imagedestroy($srcImage);
imagedestroy($destImage);
}