diff --git a/index.php b/index.php index 87c77d2f74..a5a8ea20fa 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ if ($routeInfo[0] === Dispatcher::NOT_FOUND) { $response->setHttpResponseCode(404); Message::error(sprintf( __('Error 404! The page %s was not found.'), - '' . ($route) . '' + '' . $route . '' ))->display(); } elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) { /** @var Response $response */ diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 67d78d27fc..ac632ae68e 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -1530,7 +1530,7 @@ class Config */ public function getCookieName(string $cookieName): string { - return $cookieName . ( ($this->isHttps()) ? '_https' : '' ); + return $cookieName . ( $this->isHttps() ? '_https' : '' ); } /** diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php index edc4c81d07..02ab28cad4 100644 --- a/libraries/classes/Console.php +++ b/libraries/classes/Console.php @@ -132,7 +132,7 @@ class Console */ public function getDisplay(): string { - if ((! $this->_isAjax) && $this->_isEnabled) { + if (! $this->_isAjax && $this->_isEnabled) { $cfgBookmark = Bookmark::getParams( $GLOBALS['cfg']['Server']['user'] ); diff --git a/libraries/classes/Controllers/ErrorReportController.php b/libraries/classes/Controllers/ErrorReportController.php index 892194c803..a84bda8e24 100644 --- a/libraries/classes/Controllers/ErrorReportController.php +++ b/libraries/classes/Controllers/ErrorReportController.php @@ -81,7 +81,7 @@ class ErrorReportController extends AbstractController $_SESSION['prev_error_subm_time'] = time(); $_SESSION['error_subm_count'] = ( isset($_SESSION['error_subm_count']) - ? ($_SESSION['error_subm_count'] + 1) + ? $_SESSION['error_subm_count'] + 1 : 0 ); } diff --git a/libraries/classes/Controllers/GisDataEditorController.php b/libraries/classes/Controllers/GisDataEditorController.php index d96d695f9a..c8f5b8c7ef 100644 --- a/libraries/classes/Controllers/GisDataEditorController.php +++ b/libraries/classes/Controllers/GisDataEditorController.php @@ -52,7 +52,7 @@ class GisDataEditorController extends AbstractController $gis_data['gis_type'] = mb_strtoupper($_POST['type']); } if (isset($_POST['value']) && trim($_POST['value']) != '') { - $start = (substr($_POST['value'], 0, 1) == "'") ? 1 : 0; + $start = substr($_POST['value'], 0, 1) == "'" ? 1 : 0; $gis_data['gis_type'] = mb_substr( $_POST['value'], $start, @@ -77,7 +77,7 @@ class GisDataEditorController extends AbstractController } // Generate Well Known Text - $srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') ? $gis_data['srid'] : 0; + $srid = isset($gis_data['srid']) && $gis_data['srid'] != '' ? $gis_data['srid'] : 0; $wkt = $gis_obj->generateWkt($gis_data, 0); $wkt_with_zero = $gis_obj->generateWkt($gis_data, 0, '0'); $result = "'" . $wkt . "'," . $srid; diff --git a/libraries/classes/Controllers/ImportStatusController.php b/libraries/classes/Controllers/ImportStatusController.php index d97acb9988..f07d7692a9 100644 --- a/libraries/classes/Controllers/ImportStatusController.php +++ b/libraries/classes/Controllers/ImportStatusController.php @@ -62,7 +62,7 @@ class ImportStatusController // reopen session session_start(); - if ((time() - $timestamp) > $maximumTime) { + if (time() - $timestamp > $maximumTime) { $_SESSION['Import_message']['message'] = Message::error( __('Could not load the progress of the import.') )->getDisplay(); diff --git a/libraries/classes/Controllers/Server/Status/VariablesController.php b/libraries/classes/Controllers/Server/Status/VariablesController.php index f2e56ac79e..8328a182e8 100644 --- a/libraries/classes/Controllers/Server/Status/VariablesController.php +++ b/libraries/classes/Controllers/Server/Status/VariablesController.php @@ -178,11 +178,11 @@ class VariablesController extends AbstractController // depends on Key_read_requests // normally lower then 1:0.01 'Key_reads' => isset($this->data->status['Key_read_requests']) - ? (0.01 * $this->data->status['Key_read_requests']) : 0, + ? 0.01 * $this->data->status['Key_read_requests'] : 0, // depends on Key_write_requests // normally nearly 1:1 'Key_writes' => isset($this->data->status['Key_write_requests']) - ? (0.9 * $this->data->status['Key_write_requests']) : 0, + ? 0.9 * $this->data->status['Key_write_requests'] : 0, 'Key_buffer_fraction' => 0.5, diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 85b03c9112..c90af35d38 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -55,7 +55,7 @@ class Common public function getTablesInfo(string $db = null, string $table = null): array { $designerTables = []; - $db = ($db === null) ? $GLOBALS['db'] : $db; + $db = $db === null ? $GLOBALS['db'] : $db; // seems to be needed later $this->dbi->selectDb($db); if ($db === null && $table === null) { @@ -67,7 +67,7 @@ class Common foreach ($tables as $one_table) { $DF = $this->relation->getDisplayField($db, $one_table['TABLE_NAME']); $DF = is_string($DF) ? $DF : ''; - $DF = ($DF !== '') ? $DF : null; + $DF = $DF !== '' ? $DF : null; $designerTables[] = new DesignerTable( $db, $one_table['TABLE_NAME'], @@ -313,7 +313,7 @@ class Common DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ); - return ( is_array($page_name) && isset($page_name[0]) ) ? $page_name[0] : null; + return is_array($page_name) && isset($page_name[0]) ? $page_name[0] : null; } /** diff --git a/libraries/classes/Database/Search.php b/libraries/classes/Database/Search.php index cebc492e14..072959d285 100644 --- a/libraries/classes/Database/Search.php +++ b/libraries/classes/Database/Search.php @@ -227,8 +227,8 @@ class Search $allColumns = $this->dbi->getColumns($GLOBALS['db'], $table); $likeClauses = []; // Based on search type, decide like/regex & '%'/'' - $like_or_regex = (($this->criteriaSearchType == 5) ? 'REGEXP' : 'LIKE'); - $automatic_wildcard = (($this->criteriaSearchType < 4) ? '%' : ''); + $like_or_regex = ($this->criteriaSearchType == 5 ? 'REGEXP' : 'LIKE'); + $automatic_wildcard = ($this->criteriaSearchType < 4 ? '%' : ''); // For "as regular expression" (search option 5), LIKE won't be used // Usage example: If user is searching for a literal $ in a regexp search, // they should enter \$ as the value. @@ -236,9 +236,9 @@ class Search $this->criteriaSearchString ); // Extract search words or pattern - $search_words = (($this->criteriaSearchType > 2) + $search_words = $this->criteriaSearchType > 2 ? [$criteriaSearchStringEscaped] - : explode(' ', $criteriaSearchStringEscaped)); + : explode(' ', $criteriaSearchStringEscaped); foreach ($search_words as $search_word) { // Eliminates empty values diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 720bd2642b..3404cce537 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -1685,7 +1685,7 @@ class DatabaseInterface implements DbalInterface // return false if result is empty or false // or requested row is larger than rows in result - if ($this->numRows($result) < ($row_number + 1)) { + if ($this->numRows($result) < $row_number + 1) { return $value; } diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 0c07a6d0be..1cbc5c961f 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1009,10 +1009,10 @@ class Results $buttons_html .= $this->_getTableNavigationButton( '>>', _pgettext('Last page', 'End'), - @((ceil( + @(ceil( $this->__get('unlim_num_rows') / $_SESSION['tmpval']['max_rows'] - ) - 1) * $maxRows), + ) - 1) * $maxRows, $html_sql_query, false, $onsubmit, @@ -2491,7 +2491,7 @@ class Results while ($row = $GLOBALS['dbi']->fetchRow($dt_result)) { // add repeating headers if (($row_no != 0) && ($_SESSION['tmpval']['repeat_cells'] != 0) - && ! ($row_no % $_SESSION['tmpval']['repeat_cells']) + && ! $row_no % $_SESSION['tmpval']['repeat_cells'] ) { $table_body_html .= $this->_getRepeatingHeaders( $display_params diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php index 6424f373f6..2832bf0f96 100644 --- a/libraries/classes/Export.php +++ b/libraries/classes/Export.php @@ -731,7 +731,7 @@ class Export $size = $this->dbi->fetchValue($query); //Converting the size to MB - $size = ($size / 1024) / 1024; + $size = $size / 1024 / 1024; if ($size > $table_size) { continue; } diff --git a/libraries/classes/Font.php b/libraries/classes/Font.php index 169a265e24..052922a778 100644 --- a/libraries/classes/Font.php +++ b/libraries/classes/Font.php @@ -194,14 +194,14 @@ class Font $count = 0; foreach ($charLists as $charList) { - $count += ((mb_strlen($text) + $count += (mb_strlen($text) - mb_strlen(str_replace($charList['chars'], '', $text)) - ) * $charList['modifier']); + ) * $charList['modifier']; } $text = str_replace(' ', '', $text);//remove the " "'s //all other chars - $count += (mb_strlen(preg_replace('/[a-z0-9]/i', '', $text)) * 0.3); + $count += mb_strlen(preg_replace('/[a-z0-9]/i', '', $text)) * 0.3; $modifier = 1; $font = mb_strtolower($font); diff --git a/libraries/classes/Gis/GisLineString.php b/libraries/classes/Gis/GisLineString.php index 5ca2df997e..ac5acc2858 100644 --- a/libraries/classes/Gis/GisLineString.php +++ b/libraries/classes/Gis/GisLineString.php @@ -296,11 +296,11 @@ class GisLineString extends GisGeometry } $wkt = 'LINESTRING('; for ($i = 0; $i < $no_of_points; $i++) { - $wkt .= ((isset($gis_data[$index]['LINESTRING'][$i]['x']) - && trim((string) $gis_data[$index]['LINESTRING'][$i]['x']) != '') + $wkt .= (isset($gis_data[$index]['LINESTRING'][$i]['x']) + && trim((string) $gis_data[$index]['LINESTRING'][$i]['x']) != '' ? $gis_data[$index]['LINESTRING'][$i]['x'] : $empty) - . ' ' . ((isset($gis_data[$index]['LINESTRING'][$i]['y']) - && trim((string) $gis_data[$index]['LINESTRING'][$i]['y']) != '') + . ' ' . (isset($gis_data[$index]['LINESTRING'][$i]['y']) + && trim((string) $gis_data[$index]['LINESTRING'][$i]['y']) != '' ? $gis_data[$index]['LINESTRING'][$i]['y'] : $empty) . ','; } diff --git a/libraries/classes/Gis/GisMultiLineString.php b/libraries/classes/Gis/GisMultiLineString.php index 40ff2ee18e..9135bb2935 100644 --- a/libraries/classes/Gis/GisMultiLineString.php +++ b/libraries/classes/Gis/GisMultiLineString.php @@ -335,11 +335,11 @@ class GisMultiLineString extends GisGeometry } $wkt .= '('; for ($j = 0; $j < $no_of_points; $j++) { - $wkt .= ((isset($data_row[$i][$j]['x']) - && trim((string) $data_row[$i][$j]['x']) != '') + $wkt .= (isset($data_row[$i][$j]['x']) + && trim((string) $data_row[$i][$j]['x']) != '' ? $data_row[$i][$j]['x'] : $empty) - . ' ' . ((isset($data_row[$i][$j]['y']) - && trim((string) $data_row[$i][$j]['y']) != '') + . ' ' . (isset($data_row[$i][$j]['y']) + && trim((string) $data_row[$i][$j]['y']) != '' ? $data_row[$i][$j]['y'] : $empty) . ','; } $wkt diff --git a/libraries/classes/Gis/GisMultiPoint.php b/libraries/classes/Gis/GisMultiPoint.php index 6f759b8dd0..73c9870646 100644 --- a/libraries/classes/Gis/GisMultiPoint.php +++ b/libraries/classes/Gis/GisMultiPoint.php @@ -297,11 +297,11 @@ class GisMultiPoint extends GisGeometry } $wkt = 'MULTIPOINT('; for ($i = 0; $i < $no_of_points; $i++) { - $wkt .= ((isset($gis_data[$index]['MULTIPOINT'][$i]['x']) - && trim((string) $gis_data[$index]['MULTIPOINT'][$i]['x']) != '') + $wkt .= (isset($gis_data[$index]['MULTIPOINT'][$i]['x']) + && trim((string) $gis_data[$index]['MULTIPOINT'][$i]['x']) != '' ? $gis_data[$index]['MULTIPOINT'][$i]['x'] : '') - . ' ' . ((isset($gis_data[$index]['MULTIPOINT'][$i]['y']) - && trim((string) $gis_data[$index]['MULTIPOINT'][$i]['y']) != '') + . ' ' . (isset($gis_data[$index]['MULTIPOINT'][$i]['y']) + && trim((string) $gis_data[$index]['MULTIPOINT'][$i]['y']) != '' ? $gis_data[$index]['MULTIPOINT'][$i]['y'] : '') . ','; } diff --git a/libraries/classes/Gis/GisMultiPolygon.php b/libraries/classes/Gis/GisMultiPolygon.php index c432367a55..416a889030 100644 --- a/libraries/classes/Gis/GisMultiPolygon.php +++ b/libraries/classes/Gis/GisMultiPolygon.php @@ -406,11 +406,11 @@ class GisMultiPolygon extends GisGeometry } $wkt .= '('; for ($j = 0; $j < $no_of_points; $j++) { - $wkt .= ((isset($data_row[$k][$i][$j]['x']) - && trim((string) $data_row[$k][$i][$j]['x']) != '') + $wkt .= (isset($data_row[$k][$i][$j]['x']) + && trim((string) $data_row[$k][$i][$j]['x']) != '' ? $data_row[$k][$i][$j]['x'] : $empty) - . ' ' . ((isset($data_row[$k][$i][$j]['y']) - && trim((string) $data_row[$k][$i][$j]['y']) != '') + . ' ' . (isset($data_row[$k][$i][$j]['y']) + && trim((string) $data_row[$k][$i][$j]['y']) != '' ? $data_row[$k][$i][$j]['y'] : $empty) . ','; } $wkt diff --git a/libraries/classes/Gis/GisPoint.php b/libraries/classes/Gis/GisPoint.php index ce9966cd1a..9066143fcd 100644 --- a/libraries/classes/Gis/GisPoint.php +++ b/libraries/classes/Gis/GisPoint.php @@ -300,12 +300,12 @@ class GisPoint extends GisGeometry public function generateWkt(array $gis_data, $index, $empty = '') { return 'POINT(' - . ((isset($gis_data[$index]['POINT']['x']) - && trim((string) $gis_data[$index]['POINT']['x']) != '') + . (isset($gis_data[$index]['POINT']['x']) + && trim((string) $gis_data[$index]['POINT']['x']) != '' ? $gis_data[$index]['POINT']['x'] : '') . ' ' - . ((isset($gis_data[$index]['POINT']['y']) - && trim((string) $gis_data[$index]['POINT']['y']) != '') + . (isset($gis_data[$index]['POINT']['y']) + && trim((string) $gis_data[$index]['POINT']['y']) != '' ? $gis_data[$index]['POINT']['y'] : '') . ')'; } diff --git a/libraries/classes/Gis/GisPolygon.php b/libraries/classes/Gis/GisPolygon.php index 42c3412cb9..c8d8b88ae2 100644 --- a/libraries/classes/Gis/GisPolygon.php +++ b/libraries/classes/Gis/GisPolygon.php @@ -357,11 +357,11 @@ class GisPolygon extends GisGeometry } $wkt .= '('; for ($j = 0; $j < $no_of_points; $j++) { - $wkt .= ((isset($gis_data[$index]['POLYGON'][$i][$j]['x']) - && trim((string) $gis_data[$index]['POLYGON'][$i][$j]['x']) != '') + $wkt .= (isset($gis_data[$index]['POLYGON'][$i][$j]['x']) + && trim((string) $gis_data[$index]['POLYGON'][$i][$j]['x']) != '' ? $gis_data[$index]['POLYGON'][$i][$j]['x'] : $empty) - . ' ' . ((isset($gis_data[$index]['POLYGON'][$i][$j]['y']) - && trim((string) $gis_data[$index]['POLYGON'][$i][$j]['y']) != '') + . ' ' . (isset($gis_data[$index]['POLYGON'][$i][$j]['y']) + && trim((string) $gis_data[$index]['POLYGON'][$i][$j]['y']) != '' ? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) . ','; } $wkt diff --git a/libraries/classes/Gis/GisVisualization.php b/libraries/classes/Gis/GisVisualization.php index 943d8aba9f..c5e8c0987a 100644 --- a/libraries/classes/Gis/GisVisualization.php +++ b/libraries/classes/Gis/GisVisualization.php @@ -341,7 +341,7 @@ class GisVisualization { $img = $this->_svg(); $this->_toFile($file_name, 'image/svg+xml', 'svg'); - echo($img); + echo$img; } /** @@ -606,9 +606,9 @@ class GisVisualization // scale the visualization $x_ratio = ($min_max['maxX'] - $min_max['minX']) / $plot_width; $y_ratio = ($min_max['maxY'] - $min_max['minY']) / $plot_height; - $ratio = ($x_ratio > $y_ratio) ? $x_ratio : $y_ratio; + $ratio = $x_ratio > $y_ratio ? $x_ratio : $y_ratio; - $scale = ($ratio != 0) ? (1 / $ratio) : 1; + $scale = $ratio != 0 ? 1 / $ratio : 1; if ($x_ratio < $y_ratio) { // center horizontally diff --git a/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php b/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php index adfaa24b8e..2c46c1155c 100644 --- a/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php +++ b/libraries/classes/Html/Forms/Fields/DropDownUploadFileBlock.php @@ -54,7 +54,7 @@ class DropDownUploadFileBlock implements FieldGenerator $matcher = '@\.(' . $extensions . ')(\.(' . $fileListing->supportedDecompressions() . '))?$@'; - $active = (isset($GLOBALS['timeout_passed'], $GLOBALS['local_import_file']) && $GLOBALS['timeout_passed']) + $active = isset($GLOBALS['timeout_passed'], $GLOBALS['local_import_file']) && $GLOBALS['timeout_passed'] ? $GLOBALS['local_import_file'] : ''; diff --git a/libraries/classes/Html/Generator.php b/libraries/classes/Html/Generator.php index 0de5fd7d2b..0423dc271d 100644 --- a/libraries/classes/Html/Generator.php +++ b/libraries/classes/Html/Generator.php @@ -324,7 +324,7 @@ class Generator 'div_for_slider_effect', [ 'id' => $id, - 'initial_sliders_state' => ($overrideDefault != null) ? $overrideDefault + 'initial_sliders_state' => $overrideDefault != null ? $overrideDefault : $GLOBALS['cfg']['InitialSlidersState'], 'message' => $message, ] @@ -658,7 +658,7 @@ class Generator $pos = $_SESSION['tmpval']['pos']; } else { $number_of_line = (int) $_REQUEST['unlim_num_rows']; - $pos = ((ceil($number_of_line / $rows) - 1) * $rows); + $pos = (ceil($number_of_line / $rows) - 1) * $rows; $_SESSION['tmpval']['pos'] = $pos; } diff --git a/libraries/classes/Import.php b/libraries/classes/Import.php index 976494be8e..5342ae8e5a 100644 --- a/libraries/classes/Import.php +++ b/libraries/classes/Import.php @@ -67,7 +67,7 @@ class Import } elseif ($timeout_passed) { return true; /* 5 in next row might be too much */ - } elseif ((time() - $timestamp) > ($maximum_time - 5)) { + } elseif (time() - $timestamp > $maximum_time - 5) { $timeout_passed = true; return true; } @@ -472,10 +472,10 @@ class Import if ($num == 0) { // use 'Z' if column number is 0, // this is necessary because A-Z has no 'zero' - $col_name .= mb_chr(($A + 26) - 1); + $col_name .= mb_chr($A + 26 - 1); } else { // convert column number to ASCII character - $col_name .= mb_chr(($A + $num) - 1); + $col_name .= mb_chr($A + $num - 1); } return $col_name; @@ -506,7 +506,7 @@ class Import $column_number = 0; for ($i = 0; $i < $num_chars; ++$i) { // read string from back to front - $char_pos = ($num_chars - 1) - $i; + $char_pos = $num_chars - 1 - $i; // convert capital character to ASCII value // and subtract 64 to get corresponding decimal value @@ -570,7 +570,7 @@ class Import { $curr_size = mb_strlen($cell); $decPos = mb_strpos($cell, '.'); - $decPrecision = ($curr_size - 1) - $decPos; + $decPrecision = $curr_size - 1 - $decPos; $m = $curr_size - 1; $d = $decPrecision; @@ -686,8 +686,8 @@ class Import /* New val if M or D is greater than current largest */ if ($size[self::M] > $oldM || $size[self::D] > $oldD) { /* Take the largest of both types */ - return (string) ((($size[self::M] > $oldM) ? $size[self::M] : $oldM) - . ',' . (($size[self::D] > $oldD) ? $size[self::D] : $oldD)); + return (string) (($size[self::M] > $oldM ? $size[self::M] : $oldM) + . ',' . ($size[self::D] > $oldD ? $size[self::D] : $oldD)); } return $last_cumulative_size; @@ -1080,7 +1080,7 @@ class Import $tempSQLStr .= '(' . $size . ')'; } - if ($j != (count($tables[$i][self::COL_NAMES]) - 1)) { + if ($j != count($tables[$i][self::COL_NAMES]) - 1) { $tempSQLStr .= ', '; } } @@ -1114,7 +1114,7 @@ class Import for ($m = 0; $m < $num_cols; ++$m) { $tempSQLStr .= Util::backquote($tables[$i][self::COL_NAMES][$m]); - if ($m != ($num_cols - 1)) { + if ($m != $num_cols - 1) { $tempSQLStr .= ', '; } } @@ -1151,11 +1151,11 @@ class Import $tempSQLStr .= $is_varchar ? "'" : ''; } - if ($k != ($num_cols - 1)) { + if ($k != $num_cols - 1) { $tempSQLStr .= ', '; } - if ($col_count == ($num_cols - 1)) { + if ($col_count == $num_cols - 1) { $col_count = 0; } else { $col_count++; @@ -1167,7 +1167,7 @@ class Import $tempSQLStr .= ')'; - if ($j != ($num_rows - 1)) { + if ($j != $num_rows - 1) { $tempSQLStr .= ",\n "; } diff --git a/libraries/classes/IpAllowDeny.php b/libraries/classes/IpAllowDeny.php index 9fa4326e3f..046c97265b 100644 --- a/libraries/classes/IpAllowDeny.php +++ b/libraries/classes/IpAllowDeny.php @@ -199,7 +199,7 @@ class IpAllowDeny $origval = hexdec($orig); // OR it with (2^flexbits)-1, with flexbits limited to 4 at a time - $newval = $origval | (pow(2, min(4, $flexbits)) - 1); + $newval = $origval | pow(2, min(4, $flexbits)) - 1; // Convert it back to a hexadecimal character $new = dechex($newval); diff --git a/libraries/classes/Linter.php b/libraries/classes/Linter.php index 34247ced5b..2694978ea4 100644 --- a/libraries/classes/Linter.php +++ b/libraries/classes/Linter.php @@ -51,7 +51,7 @@ class Linter // first byte of the third character. The fourth and the last one // (which is actually a new line) aren't going to be processed at // all. - $len = ($str instanceof UtfString) ? + $len = $str instanceof UtfString ? $str->length() : strlen($str); $lines = [0]; diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index cdbef41137..ee51dc823f 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -1321,7 +1321,7 @@ class Operations * old versions of MySQL/MariaDB must be returning something or not empty. * This patch is to support newer MySQL/MariaDB while also for backward compatibilities. */ - if (( ('Barracuda' == $innodb_file_format) || ($innodb_file_format == '') ) + if (('Barracuda' == $innodb_file_format) || ($innodb_file_format == '') && $innodbEnginePlugin->supportsFilePerTable() ) { $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC'; diff --git a/libraries/classes/Plugins/Export/ExportHtmlword.php b/libraries/classes/Plugins/Export/ExportHtmlword.php index d3e77f8cb7..7f8ec71ec9 100644 --- a/libraries/classes/Plugins/Export/ExportHtmlword.php +++ b/libraries/classes/Plugins/Export/ExportHtmlword.php @@ -653,7 +653,7 @@ class ExportHtmlword extends ExportPlugin . htmlspecialchars($col_alias) . $fmt_post . ''; $definition .= '' . htmlspecialchars($type) . ''; $definition .= '' - . (($column['Null'] == '' || $column['Null'] == 'NO') + . ($column['Null'] == '' || $column['Null'] == 'NO' ? __('No') : __('Yes')) . ''; diff --git a/libraries/classes/Plugins/Export/ExportLatex.php b/libraries/classes/Plugins/Export/ExportLatex.php index a5e7cac589..de237ebcee 100644 --- a/libraries/classes/Plugins/Export/ExportLatex.php +++ b/libraries/classes/Plugins/Export/ExportLatex.php @@ -419,7 +419,7 @@ class ExportLatex extends ExportPlugin } // last column ... no need for & character - if ($i == ($columns_cnt - 1)) { + if ($i == $columns_cnt - 1) { $buffer .= $column_value; } else { $buffer .= $column_value . ' & '; @@ -617,7 +617,7 @@ class ExportLatex extends ExportPlugin } $local_buffer = $col_as . "\000" . $type . "\000" - . (($row['Null'] == '' || $row['Null'] == 'NO') + . ($row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes')) . "\000" . ($row['Default'] ?? ''); diff --git a/libraries/classes/Plugins/Export/ExportOdt.php b/libraries/classes/Plugins/Export/ExportOdt.php index 4d9c40c146..f262617eb3 100644 --- a/libraries/classes/Plugins/Export/ExportOdt.php +++ b/libraries/classes/Plugins/Export/ExportOdt.php @@ -790,7 +790,7 @@ class ExportOdt extends ExportPlugin } $definition .= '' . '' - . (($column['Null'] == '' || $column['Null'] == 'NO') + . ($column['Null'] == '' || $column['Null'] == 'NO' ? __('No') : __('Yes')) . '' diff --git a/libraries/classes/Plugins/Export/ExportPhparray.php b/libraries/classes/Plugins/Export/ExportPhparray.php index 33380d86af..d116d5c822 100644 --- a/libraries/classes/Plugins/Export/ExportPhparray.php +++ b/libraries/classes/Plugins/Export/ExportPhparray.php @@ -239,7 +239,7 @@ class ExportPhparray extends ExportPlugin for ($i = 0; $i < $columns_cnt; $i++) { $buffer .= var_export($columns[$i], true) . ' => ' . var_export($record[$i], true) - . (($i + 1 >= $columns_cnt) ? '' : ','); + . ($i + 1 >= $columns_cnt ? '' : ','); } $buffer .= ')'; diff --git a/libraries/classes/Plugins/Export/ExportTexytext.php b/libraries/classes/Plugins/Export/ExportTexytext.php index d0a3f08ff0..362169284a 100644 --- a/libraries/classes/Plugins/Export/ExportTexytext.php +++ b/libraries/classes/Plugins/Export/ExportTexytext.php @@ -608,7 +608,7 @@ class ExportTexytext extends ExportPlugin . $fmt_pre . htmlspecialchars($col_alias) . $fmt_post; $definition .= '|' . htmlspecialchars($type); $definition .= '|' - . (($column['Null'] == '' || $column['Null'] == 'NO') + . ($column['Null'] == '' || $column['Null'] == 'NO' ? __('No') : __('Yes')); $definition .= '|' . htmlspecialchars( diff --git a/libraries/classes/Plugins/Export/Helpers/Pdf.php b/libraries/classes/Plugins/Export/Helpers/Pdf.php index 55fba5ff57..def4ab7881 100644 --- a/libraries/classes/Plugins/Export/Helpers/Pdf.php +++ b/libraries/classes/Plugins/Export/Helpers/Pdf.php @@ -110,7 +110,7 @@ class Pdf extends PdfLib $y = $this->y; } $current_page = $this->page; - if ((($y + $h) > $this->PageBreakTrigger) + if (($y + $h > $this->PageBreakTrigger) && (! $this->InFooter) && $this->AcceptPageBreak() ) { @@ -133,7 +133,7 @@ class Pdf extends PdfLib } } else { if ($this_page_olm != $old_page_olm) { - $this->x = $x + ($this_page_olm - $old_page_olm); + $this->x = $x + $this_page_olm - $old_page_olm; } else { $this->x = $x; } @@ -785,7 +785,7 @@ class Pdf extends PdfLib // enlarge the column (but avoid enlarging it if the // data's width is very big) if ($stringWidth > $val - && $stringWidth < ($this->sColWidth * 3) + && $stringWidth < $this->sColWidth * 3 ) { $colFits[$key] = $stringWidth; } diff --git a/libraries/classes/Plugins/Export/Helpers/TableProperty.php b/libraries/classes/Plugins/Export/Helpers/TableProperty.php index 2a8415ec0e..776e4f0753 100644 --- a/libraries/classes/Plugins/Export/Helpers/TableProperty.php +++ b/libraries/classes/Plugins/Export/Helpers/TableProperty.php @@ -107,7 +107,7 @@ class TableProperty */ public function isUnique(): string { - return ($this->key === 'PRI' || $this->key === 'UNI') ? 'true' : 'false'; + return $this->key === 'PRI' || $this->key === 'UNI' ? 'true' : 'false'; } /** diff --git a/libraries/classes/Plugins/Import/ImportLdi.php b/libraries/classes/Plugins/Import/ImportLdi.php index 6efb304817..07623d32c0 100644 --- a/libraries/classes/Plugins/Import/ImportLdi.php +++ b/libraries/classes/Plugins/Import/ImportLdi.php @@ -141,7 +141,7 @@ class ImportLdi extends AbstractImportCsv if (strlen((string) $ldi_new_line) > 0) { if ($ldi_new_line == 'auto') { $ldi_new_line - = (PHP_EOL == "\n") + = PHP_EOL == "\n" ? '\n' : '\r\n'; } diff --git a/libraries/classes/Plugins/Import/ImportSql.php b/libraries/classes/Plugins/Import/ImportSql.php index 81f4b15245..f6dac001ed 100644 --- a/libraries/classes/Plugins/Import/ImportSql.php +++ b/libraries/classes/Plugins/Import/ImportSql.php @@ -125,7 +125,7 @@ class ImportSql extends ImportPlugin */ $GLOBALS['finished'] = false; - while ((! $error) && (! $timeout_passed)) { + while (! $error && (! $timeout_passed)) { // Getting the first statement, the remaining data and the last // delimiter. $statement = $bq->extract(); diff --git a/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php b/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php index 3401aa11c2..c60c4926ea 100644 --- a/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php +++ b/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php @@ -764,7 +764,7 @@ class PdfRelationSchema extends ExportRelationSchema $field_name, $type, $attribute, - ($row['Null'] == '' || $row['Null'] == 'NO') + $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes'), $row['Default'] ?? '', diff --git a/libraries/classes/Plugins/Schema/Pdf/RelationStatsPdf.php b/libraries/classes/Plugins/Schema/Pdf/RelationStatsPdf.php index ebb5f3b3b6..04be18c346 100644 --- a/libraries/classes/Plugins/Schema/Pdf/RelationStatsPdf.php +++ b/libraries/classes/Plugins/Schema/Pdf/RelationStatsPdf.php @@ -103,7 +103,7 @@ class RelationStatsPdf extends RelationStats ], ]; list ($a, $b, $c) = $case[$d]; - $e = (1 - ($j - 1) / 6); + $e = 1 - ($j - 1) / 6; $this->diagram->SetDrawColor($a * 255 * $e, $b * 255 * $e, $c * 255 * $e); } else { $this->diagram->SetDrawColor(0); diff --git a/libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php b/libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php index d951a21ee0..d879117536 100644 --- a/libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php +++ b/libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php @@ -69,7 +69,7 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin $newtext = $options[2] . $newtext; } - if (($length + (int) $options[0]) != $baselength) { + if ($length + (int) $options[0] != $baselength) { $newtext .= $options[2]; } } diff --git a/libraries/classes/Plugins/Transformations/Abs/TextLinkTransformationsPlugin.php b/libraries/classes/Plugins/Transformations/Abs/TextLinkTransformationsPlugin.php index 9883fc9e80..7e6908f627 100644 --- a/libraries/classes/Plugins/Transformations/Abs/TextLinkTransformationsPlugin.php +++ b/libraries/classes/Plugins/Transformations/Abs/TextLinkTransformationsPlugin.php @@ -47,7 +47,7 @@ abstract class TextLinkTransformationsPlugin extends TransformationsPlugin { $cfg = $GLOBALS['cfg']; $options = $this->getOptions($options, $cfg['DefaultTransformations']['TextLink']); - $url = ($options[0] ?? '') . ((isset($options[2]) && $options[2]) ? '' : $buffer); + $url = ($options[0] ?? '') . (isset($options[2]) && $options[2] ? '' : $buffer); /* Do not allow javascript links */ if (! Sanitize::checkLink($url, true, true)) { return htmlspecialchars($url); diff --git a/libraries/classes/Rte/Routines.php b/libraries/classes/Rte/Routines.php index 3312517886..5dd8a794ac 100644 --- a/libraries/classes/Rte/Routines.php +++ b/libraries/classes/Rte/Routines.php @@ -1244,7 +1244,7 @@ class Routines ); } } - if ($i != (count($item_param_name) - 1)) { + if ($i != count($item_param_name) - 1) { $params .= ', '; } } else { diff --git a/libraries/classes/Setup/ConfigGenerator.php b/libraries/classes/Setup/ConfigGenerator.php index f9289575ee..b3bb01fbbe 100644 --- a/libraries/classes/Setup/ConfigGenerator.php +++ b/libraries/classes/Setup/ConfigGenerator.php @@ -26,7 +26,7 @@ class ConfigGenerator */ public static function getConfigFile(ConfigFile $cf) { - $crlf = (isset($_SESSION['eol']) && $_SESSION['eol'] == 'win') + $crlf = isset($_SESSION['eol']) && $_SESSION['eol'] == 'win' ? "\r\n" : "\n"; $conf = $cf->getConfig(); diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php index 951fa1bd93..adcacf4c79 100644 --- a/libraries/classes/Sql.php +++ b/libraries/classes/Sql.php @@ -438,7 +438,7 @@ class Sql ); $selected_values = explode(',', $converted_curr_value); - $select_size = (count($values) > 10) ? 10 : count($values); + $select_size = count($values) > 10 ? 10 : count($values); return $this->template->render('sql/set_column', [ 'size' => $select_size, @@ -2299,7 +2299,7 @@ class Sql $max_rows = $_SESSION['tmpval']['max_rows']; } - return @((ceil($number_of_line / $max_rows) - 1) * $max_rows); + return @(ceil($number_of_line / $max_rows) - 1) * $max_rows; } /** diff --git a/libraries/classes/SystemDatabase.php b/libraries/classes/SystemDatabase.php index a613e59782..d11ea027a2 100644 --- a/libraries/classes/SystemDatabase.php +++ b/libraries/classes/SystemDatabase.php @@ -129,6 +129,6 @@ class SystemDatabase } } - return ($column_count > 0) ? $new_transformations_sql : ''; + return $column_count > 0 ? $new_transformations_sql : ''; } } diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 97a65de191..df23cadb6a 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -454,7 +454,7 @@ class Table } } // we need explicit DEFAULT value here (different from '0') - $create_options['pack_keys'] = (! isset($create_options['pack_keys']) || strlen($create_options['pack_keys']) == 0) + $create_options['pack_keys'] = ! isset($create_options['pack_keys']) || strlen($create_options['pack_keys']) == 0 ? 'DEFAULT' : $create_options['pack_keys']; return $create_options; diff --git a/libraries/classes/UserPassword.php b/libraries/classes/UserPassword.php index 0409b5c13a..2c3c8d3103 100644 --- a/libraries/classes/UserPassword.php +++ b/libraries/classes/UserPassword.php @@ -132,14 +132,14 @@ class UserPassword } $sql_query = 'SET password = ' - . (($password == '') ? '\'\'' : $hashing_function . '(\'***\')'); + . ($password == '' ? '\'\'' : $hashing_function . '(\'***\')'); if ($serverType == 'MySQL' && $serverVersion >= 50706 ) { $sql_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\' IDENTIFIED WITH ' . $orig_auth_plugin . ' BY ' - . (($password == '') ? '\'\'' : '\'***\''); + . ($password == '' ? '\'\'' : '\'***\''); } elseif (($serverType == 'MySQL' && $serverVersion >= 50507) || ($serverType == 'MariaDB' @@ -218,7 +218,7 @@ class UserPassword if ($serverType == 'MySQL' && $serverVersion >= 50706) { $local_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\'' . ' IDENTIFIED with ' . $orig_auth_plugin . ' BY ' - . (($password == '') + . ($password == '' ? '\'\'' : '\'' . $GLOBALS['dbi']->escapeString($password) . '\''); } elseif ($serverType == 'MariaDB' @@ -245,7 +245,7 @@ class UserPassword . " WHERE `User` = '" . $username . "' AND Host = '" . $hostname . "';"; } else { - $local_query = 'SET password = ' . (($password == '') + $local_query = 'SET password = ' . ($password == '' ? '\'\'' : $hashing_function . '(\'' . $GLOBALS['dbi']->escapeString($password) . '\')'); diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 1fd6741f2e..f87e35c44e 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -954,7 +954,7 @@ class Util && ($meta->type != 'real') ) { $con_val = '= ' . $row[$i]; - } elseif ((($meta->type == 'blob') || ($meta->type == 'string')) + } elseif (($meta->type == 'blob') || ($meta->type == 'string') && false !== stripos($field_flags, 'BINARY') && ! empty($row[$i]) ) { @@ -1088,8 +1088,8 @@ class Util $prompt = '' ) { $increment = floor($nbTotalPage / $percent); - $pageNowMinusRange = ($pageNow - $range); - $pageNowPlusRange = ($pageNow + $range); + $pageNowMinusRange = $pageNow - $range; + $pageNowPlusRange = $pageNow + $range; $gotopage = $prompt . '