diff --git a/libraries/classes/Common.php b/libraries/classes/Common.php index 4f5a4007bd..948c30ac1d 100644 --- a/libraries/classes/Common.php +++ b/libraries/classes/Common.php @@ -45,6 +45,8 @@ use function trigger_error; use function urldecode; use const E_USER_ERROR; +use const E_USER_WARNING; +use const PHP_VERSION_ID; final class Common { @@ -497,7 +499,7 @@ final class Common __( 'Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.' ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 24cd4b7d00..bf3139a803 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -63,6 +63,7 @@ use function trim; use const ARRAY_FILTER_USE_KEY; use const DIRECTORY_SEPARATOR; use const E_USER_ERROR; +use const E_USER_WARNING; use const PHP_OS; use const PHP_URL_PATH; use const PHP_URL_SCHEME; @@ -707,7 +708,7 @@ class Config . __('This usually means there is a syntax error in it, please check any errors shown below.') . '[br][br]' . '[conferr]'; - trigger_error($error, E_USER_ERROR); + trigger_error($error, PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING); } /** @@ -1232,7 +1233,7 @@ class Config if (! is_int($server_index) || $server_index < 1) { trigger_error( sprintf(__('Invalid server index: %s'), $server_index), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } diff --git a/libraries/classes/Config/Form.php b/libraries/classes/Config/Form.php index aa01acb3bb..a186a3df99 100644 --- a/libraries/classes/Config/Form.php +++ b/libraries/classes/Config/Form.php @@ -24,6 +24,8 @@ use function str_replace; use function trigger_error; use const E_USER_ERROR; +use const E_USER_WARNING; +use const PHP_VERSION_ID; /** * Base class for forms, loads default configuration options, checks allowed @@ -130,13 +132,19 @@ class Form { $value = $this->configFile->getDbEntry($optionPath); if ($value === null) { - trigger_error($optionPath . ' - select options not defined', E_USER_ERROR); + trigger_error( + $optionPath . ' - select options not defined', + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING + ); return []; } if (! is_array($value)) { - trigger_error($optionPath . ' - not a static value list', E_USER_ERROR); + trigger_error( + $optionPath . ' - not a static value list', + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING + ); return []; } diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 03e6c65175..c6a214076b 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -57,6 +57,7 @@ use const DATE_RFC1123; use const E_USER_ERROR; use const E_USER_WARNING; use const FILTER_VALIDATE_IP; +use const PHP_VERSION_ID; /** * Core functions used all over the scripts. @@ -375,7 +376,10 @@ class Core session_write_close(); if ($response->headersSent()) { - trigger_error('Core::sendHeaderLocation called when headers are already sent!', E_USER_ERROR); + trigger_error( + 'Core::sendHeaderLocation called when headers are already sent!', + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING + ); } // bug #1523784: IE6 does not like 'Refresh: 0', it diff --git a/libraries/classes/Dbal/DbiMysqli.php b/libraries/classes/Dbal/DbiMysqli.php index 6247cedf16..7d1deca5db 100644 --- a/libraries/classes/Dbal/DbiMysqli.php +++ b/libraries/classes/Dbal/DbiMysqli.php @@ -33,6 +33,7 @@ use const MYSQLI_OPT_SSL_VERIFY_SERVER_CERT; use const MYSQLI_REPORT_OFF; use const MYSQLI_STORE_RESULT; use const MYSQLI_USE_RESULT; +use const PHP_VERSION_ID; /** * Interface to the MySQL Improved extension (MySQLi) @@ -167,7 +168,7 @@ class DbiMysqli implements DbiExtension '[code][doc@cfg_Servers_hide_connection_errors]' . '$cfg[\'Servers\'][$i][\'hide_connection_errors\'][/doc][/code]' ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } diff --git a/libraries/classes/LanguageManager.php b/libraries/classes/LanguageManager.php index e4692a8263..b5ee5a9ea5 100644 --- a/libraries/classes/LanguageManager.php +++ b/libraries/classes/LanguageManager.php @@ -19,6 +19,8 @@ use function uasort; use function ucfirst; use const E_USER_ERROR; +use const E_USER_WARNING; +use const PHP_VERSION_ID; /** * Language selection manager @@ -978,7 +980,7 @@ class LanguageManager trigger_error( __('Ignoring unsupported language code.'), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } } diff --git a/libraries/classes/Navigation/NodeFactory.php b/libraries/classes/Navigation/NodeFactory.php index ae1989528b..5ed2a82588 100644 --- a/libraries/classes/Navigation/NodeFactory.php +++ b/libraries/classes/Navigation/NodeFactory.php @@ -16,6 +16,8 @@ use function sprintf; use function trigger_error; use const E_USER_ERROR; +use const E_USER_WARNING; +use const PHP_VERSION_ID; /** * Node factory - instantiates Node objects or objects derived from the Node class @@ -43,7 +45,7 @@ class NodeFactory __('Invalid class name "%1$s", using default of "Node"'), $class ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } @@ -73,7 +75,7 @@ class NodeFactory __('Could not load class "%1$s"'), $class ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); } diff --git a/libraries/classes/Plugins/Export/ExportSql.php b/libraries/classes/Plugins/Export/ExportSql.php index 6dcdfcdd39..ddee7a8b51 100644 --- a/libraries/classes/Plugins/Export/ExportSql.php +++ b/libraries/classes/Plugins/Export/ExportSql.php @@ -53,7 +53,9 @@ use function strtoupper; use function trigger_error; use const E_USER_ERROR; +use const E_USER_WARNING; use const PHP_VERSION; +use const PHP_VERSION_ID; /** * Handles the export for the SQL class @@ -1541,7 +1543,7 @@ class ExportSql extends ExportPlugin $message = sprintf(__('Error reading structure for table %s:'), $db . '.' . $table); $message .= ' ' . $tmpError; if (! defined('TESTSUITE')) { - trigger_error($message, E_USER_ERROR); + trigger_error($message, PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING); } return $this->exportComment($message); @@ -2270,7 +2272,7 @@ class ExportSql extends ExportPlugin $message = sprintf(__('Error reading data for table %s:'), $db . '.' . $table); $message .= ' ' . $tmpError; if (! defined('TESTSUITE')) { - trigger_error($message, E_USER_ERROR); + trigger_error($message, PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING); } return $this->export->outputHandler( diff --git a/libraries/classes/Theme.php b/libraries/classes/Theme.php index 6dcb7950df..a9c889ee24 100644 --- a/libraries/classes/Theme.php +++ b/libraries/classes/Theme.php @@ -20,8 +20,9 @@ use function trim; use function version_compare; use const DIRECTORY_SEPARATOR; - use const E_USER_ERROR; +use const E_USER_WARNING; +use const PHP_VERSION_ID; /** * handles theme @@ -168,7 +169,7 @@ class Theme __('No valid image path for theme %s found!'), $this->getName() ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); return false; diff --git a/libraries/classes/ThemeManager.php b/libraries/classes/ThemeManager.php index 9c10859f21..cc820224e3 100644 --- a/libraries/classes/ThemeManager.php +++ b/libraries/classes/ThemeManager.php @@ -18,6 +18,7 @@ use function trigger_error; use const DIRECTORY_SEPARATOR; use const E_USER_ERROR; use const E_USER_WARNING; +use const PHP_VERSION_ID; /** * phpMyAdmin theme manager @@ -83,7 +84,7 @@ class ThemeManager __('Default theme %s not found!'), htmlspecialchars($GLOBALS['cfg']['ThemeDefault']) ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); $configThemeExists = false; } else { @@ -142,7 +143,7 @@ class ThemeManager __('Theme %s not found!'), htmlspecialchars((string) $theme) ), - E_USER_ERROR + PHP_VERSION_ID < 80400 ? E_USER_ERROR : E_USER_WARNING ); return false; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 578ba2e768..64691e7d31 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1197,7 +1197,7 @@ parameters: - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 + count: 2 path: libraries/classes/Config.php - @@ -1550,11 +1550,6 @@ parameters: count: 1 path: libraries/classes/Config/Form.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 2 - path: libraries/classes/Config/Form.php - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 2 @@ -36000,11 +35995,6 @@ parameters: count: 1 path: libraries/classes/Theme.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: libraries/classes/Theme.php - - message: "#^Cannot access offset 'ThemeDefault' on mixed\\.$#" count: 3 @@ -36050,11 +36040,6 @@ parameters: count: 1 path: libraries/classes/ThemeManager.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: libraries/classes/ThemeManager.php - - message: "#^Method PhpMyAdmin\\\\ThemeManager\\:\\:getThemeCookie\\(\\) should return string\\|false but returns mixed\\.$#" count: 1 @@ -36105,11 +36090,6 @@ parameters: count: 1 path: libraries/classes/ThemeManager.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 2 - path: libraries/classes/ThemeManager.php - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -46420,6 +46400,11 @@ parameters: count: 6 path: test/classes/Plugins/Auth/AuthenticationHttpTest.php + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{lifetime\\: 0, path\\: '/', domain\\: '', secure\\: false, partitioned\\?\\: false, httponly\\: false, samesite\\?\\: ''\\} and array\\{lifetime\\: int\\<0, max\\>, path\\: non\\-falsy\\-string, domain\\: string, secure\\: bool, httponly\\: bool, samesite\\: string\\} will always evaluate to false\\.$#" + count: 1 + path: test/classes/Plugins/Auth/AuthenticationSignonTest.php + - message: "#^Cannot access offset 'LoginCookieValidity' on mixed\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5e127407a3..993ffc702e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -329,7 +329,7 @@ $cfg['Server']['hide_connection_errors'] - + $collation_connection $config_data $config_data @@ -340,6 +340,7 @@ $path $server['verbose'] $server_index + $server_index $this->settings['Servers'] $this->settings['ThemeDefault'] $this->settings['ThemeDefault'] @@ -365,11 +366,12 @@ $_SESSION['cache'][$cache_key] $temp_dir[$name] - + + $new_servers[$server_index] $this->settings['Servers'][$server] $this->settings['Servers'][$this->settings['ServerDefault']] - + $cfg['LoginCookieValidity'] $collation_connection $config_data @@ -390,6 +392,7 @@ $server['host'] $server['port'] $server[substr($key, 8)] + $server_index $url $url $user @@ -536,8 +539,7 @@ $v $value - - array + string|null @@ -558,10 +560,6 @@ $fieldsTypes $name - - return []; - return []; - @@ -13843,9 +13841,6 @@ $data['name'] $data['version'] - - return false; - @@ -13873,16 +13868,9 @@ (bool) $perServer (string) $this->theme->id - - $configThemeExists - $this->theme !== null - - $configThemeExists = false; - return false; - diff --git a/test/classes/AbstractNetworkTestCase.php b/test/classes/AbstractNetworkTestCase.php index c00075fc5b..3e59e80ab6 100644 --- a/test/classes/AbstractNetworkTestCase.php +++ b/test/classes/AbstractNetworkTestCase.php @@ -20,6 +20,8 @@ use function end; use function is_array; use function is_int; +use const PHP_VERSION_ID; + /** * Base class for phpMyAdmin tests */ @@ -89,7 +91,10 @@ abstract class AbstractNetworkTestCase extends AbstractTestCase } $attrInstance = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $attrInstance->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrInstance->setAccessible(true); + } + $attrInstance->setValue(null, $mockResponse); return $mockResponse; @@ -102,8 +107,15 @@ abstract class AbstractNetworkTestCase extends AbstractTestCase { parent::tearDown(); $response = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, null); + if (PHP_VERSION_ID >= 80100) { + return; + } + $response->setAccessible(false); } } diff --git a/test/classes/AbstractTestCase.php b/test/classes/AbstractTestCase.php index 3760e2b11d..83bb6dfbbd 100644 --- a/test/classes/AbstractTestCase.php +++ b/test/classes/AbstractTestCase.php @@ -24,6 +24,7 @@ use function in_array; use function method_exists; use const DIRECTORY_SEPARATOR; +use const PHP_VERSION_ID; /** * Abstract class to hold some usefull methods used in tests @@ -302,7 +303,9 @@ abstract class AbstractTestCase extends TestCase { $class = new ReflectionClass($className); $method = $class->getMethod($methodName); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } return $method->invokeArgs($object, $params); } @@ -321,7 +324,9 @@ abstract class AbstractTestCase extends TestCase { $class = new ReflectionClass($className); $property = $class->getProperty($propertyName); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } return $property->getValue($object); } diff --git a/test/classes/Config/FormDisplayTest.php b/test/classes/Config/FormDisplayTest.php index 7dd7455a37..4e435840da 100644 --- a/test/classes/Config/FormDisplayTest.php +++ b/test/classes/Config/FormDisplayTest.php @@ -15,6 +15,8 @@ use ReflectionProperty; use function function_exists; use function gettype; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Config\FormDisplay */ @@ -55,7 +57,9 @@ class FormDisplayTest extends AbstractTestCase $reflection = new ReflectionClass(FormDisplay::class); $attrForms = $reflection->getProperty('forms'); - $attrForms->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrForms->setAccessible(true); + } $array = [ 'Servers' => [ @@ -71,7 +75,9 @@ class FormDisplayTest extends AbstractTestCase self::assertInstanceOf(Form::class, $_forms['pma_testform']); $attrSystemPaths = $reflection->getProperty('systemPaths'); - $attrSystemPaths->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrSystemPaths->setAccessible(true); + } self::assertSame([ 'Servers/2/test' => 'Servers/1/test', @@ -79,7 +85,9 @@ class FormDisplayTest extends AbstractTestCase ], $attrSystemPaths->getValue($this->object)); $attrTranslatedPaths = $reflection->getProperty('translatedPaths'); - $attrTranslatedPaths->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrTranslatedPaths->setAccessible(true); + } self::assertSame([ 'Servers/2/test' => 'Servers-2-test', @@ -102,7 +110,10 @@ class FormDisplayTest extends AbstractTestCase ->getMock(); $attrForms = new ReflectionProperty(FormDisplay::class, 'forms'); - $attrForms->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrForms->setAccessible(true); + } + $attrForms->setValue($this->object, [1, 2, 3]); $this->object->expects($this->once()) @@ -125,11 +136,17 @@ class FormDisplayTest extends AbstractTestCase $reflection = new ReflectionClass(FormDisplay::class); $attrIsValidated = $reflection->getProperty('isValidated'); - $attrIsValidated->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrIsValidated->setAccessible(true); + } + $attrIsValidated->setValue($this->object, true); $attrIsValidated = $reflection->getProperty('errors'); - $attrIsValidated->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrIsValidated->setAccessible(true); + } + $attrIsValidated->setValue($this->object, []); $result = $this->object->displayErrors(); @@ -147,7 +164,10 @@ class FormDisplayTest extends AbstractTestCase $sysArr = ['Servers/1/test' => 'Servers/1/test2']; $attrSystemPaths = $reflection->getProperty('systemPaths'); - $attrSystemPaths->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrSystemPaths->setAccessible(true); + } + $attrSystemPaths->setValue($this->object, $sysArr); $attrIsValidated->setValue($this->object, $arr); @@ -170,11 +190,17 @@ class FormDisplayTest extends AbstractTestCase $reflection = new ReflectionClass(FormDisplay::class); $attrIsValidated = $reflection->getProperty('isValidated'); - $attrIsValidated->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrIsValidated->setAccessible(true); + } + $attrIsValidated->setValue($this->object, true); $attrIsValidated = $reflection->getProperty('errors'); - $attrIsValidated->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrIsValidated->setAccessible(true); + } + $attrIsValidated->setValue($this->object, []); $this->object->fixErrors(); @@ -191,7 +217,10 @@ class FormDisplayTest extends AbstractTestCase $sysArr = ['Servers/1/test' => 'Servers/1/host']; $attrSystemPaths = $reflection->getProperty('systemPaths'); - $attrSystemPaths->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrSystemPaths->setAccessible(true); + } + $attrSystemPaths->setValue($this->object, $sysArr); $attrIsValidated->setValue($this->object, $arr); @@ -211,7 +240,9 @@ class FormDisplayTest extends AbstractTestCase public function testValidateSelect(): void { $attrValidateSelect = new ReflectionMethod(FormDisplay::class, 'validateSelect'); - $attrValidateSelect->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrValidateSelect->setAccessible(true); + } $arr = ['foo' => 'var']; $value = 'foo'; @@ -261,7 +292,9 @@ class FormDisplayTest extends AbstractTestCase public function testHasErrors(): void { $attrErrors = new ReflectionProperty(FormDisplay::class, 'errors'); - $attrErrors->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrErrors->setAccessible(true); + } self::assertFalse($this->object->hasErrors()); @@ -297,7 +330,9 @@ class FormDisplayTest extends AbstractTestCase public function testGetOptName(): void { $method = new ReflectionMethod(FormDisplay::class, 'getOptName'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } self::assertSame('Servers_', $method->invoke($this->object, 'Servers/1/')); @@ -310,11 +345,16 @@ class FormDisplayTest extends AbstractTestCase public function testLoadUserprefsInfo(): void { $method = new ReflectionMethod(FormDisplay::class, 'loadUserprefsInfo'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $attrUserprefs = new ReflectionProperty(FormDisplay::class, 'userprefsDisallow'); - $attrUserprefs->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrUserprefs->setAccessible(true); + } + $method->invoke($this->object, null); self::assertSame([], $attrUserprefs->getValue($this->object)); } @@ -325,7 +365,9 @@ class FormDisplayTest extends AbstractTestCase public function testSetComments(): void { $method = new ReflectionMethod(FormDisplay::class, 'setComments'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } // recoding $opts = ['values' => []]; diff --git a/test/classes/Config/FormTest.php b/test/classes/Config/FormTest.php index c6f5400f4b..5394728323 100644 --- a/test/classes/Config/FormTest.php +++ b/test/classes/Config/FormTest.php @@ -13,6 +13,8 @@ use ReflectionProperty; use function array_keys; use function preg_match; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Config\Form */ @@ -68,7 +70,10 @@ class FormTest extends AbstractTestCase public function testGetOptionType(): void { $attrFieldsTypes = new ReflectionProperty(Form::class, 'fieldsTypes'); - $attrFieldsTypes->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrFieldsTypes->setAccessible(true); + } + $attrFieldsTypes->setValue( $this->object, ['7' => 'Seven'] @@ -110,7 +115,9 @@ class FormTest extends AbstractTestCase { $reflection = new ReflectionClass(Form::class); $method = $reflection->getMethod('readFormPathsCallback'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $array = [ 'foo' => [ @@ -146,7 +153,9 @@ class FormTest extends AbstractTestCase { $reflection = new ReflectionClass(Form::class); $method = $reflection->getMethod('readFormPaths'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $array = [ 'foo' => [ @@ -187,7 +196,9 @@ class FormTest extends AbstractTestCase { $reflection = new ReflectionClass(Form::class); $method = $reflection->getMethod('readTypes'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $this->object->fields = [ 'pma_form1' => 'Servers/1/port', @@ -197,7 +208,9 @@ class FormTest extends AbstractTestCase ]; $attrFieldsTypes = $reflection->getProperty('fieldsTypes'); - $attrFieldsTypes->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrFieldsTypes->setAccessible(true); + } $method->invoke($this->object, null); diff --git a/test/classes/Config/ServerConfigChecksTest.php b/test/classes/Config/ServerConfigChecksTest.php index 27909eb55c..3fa7a865d6 100644 --- a/test/classes/Config/ServerConfigChecksTest.php +++ b/test/classes/Config/ServerConfigChecksTest.php @@ -14,6 +14,7 @@ use function array_keys; use function mb_strlen; use function str_repeat; +use const PHP_VERSION_ID; use const SODIUM_CRYPTO_SECRETBOX_KEYBYTES; /** @@ -39,7 +40,10 @@ class ServerConfigChecksTest extends AbstractTestCase $GLOBALS['ConfigFile'] = $cf; $reflection = new ReflectionProperty(ConfigFile::class, 'id'); - $reflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } + $this->sessionID = $reflection->getValue($cf); unset($_SESSION['messages']); diff --git a/test/classes/ConfigStorage/RelationTest.php b/test/classes/ConfigStorage/RelationTest.php index 429a1f74cb..d3e786604a 100644 --- a/test/classes/ConfigStorage/RelationTest.php +++ b/test/classes/ConfigStorage/RelationTest.php @@ -14,6 +14,8 @@ use ReflectionClass; use function implode; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\ConfigStorage\Relation * @group medium @@ -1939,7 +1941,10 @@ class RelationTest extends AbstractTestCase $_SESSION['relation'] = []; $_SESSION['tmpval'] = []; $recentFavoriteTableInstances = (new ReflectionClass(RecentFavoriteTable::class))->getProperty('instances'); - $recentFavoriteTableInstances->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $recentFavoriteTableInstances->setAccessible(true); + } + $recentFavoriteTableInstances->setValue(null, []); $relation = new Relation($this->dbi); diff --git a/test/classes/ConsoleTest.php b/test/classes/ConsoleTest.php index cd5967835d..234405e6c4 100644 --- a/test/classes/ConsoleTest.php +++ b/test/classes/ConsoleTest.php @@ -7,6 +7,8 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\Console; use ReflectionProperty; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Console */ @@ -21,7 +23,10 @@ class ConsoleTest extends AbstractTestCase public function testSetAjax(): void { $isAjax = new ReflectionProperty(Console::class, 'isAjax'); - $isAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $isAjax->setAccessible(true); + } + $console = new Console(); self::assertFalse($isAjax->getValue($console)); diff --git a/test/classes/Controllers/Database/Structure/FavoriteTableControllerTest.php b/test/classes/Controllers/Database/Structure/FavoriteTableControllerTest.php index c3d0277e08..1a60ec8701 100644 --- a/test/classes/Controllers/Database/Structure/FavoriteTableControllerTest.php +++ b/test/classes/Controllers/Database/Structure/FavoriteTableControllerTest.php @@ -14,6 +14,8 @@ use ReflectionClass; use function json_encode; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Database\Structure\FavoriteTableController */ @@ -34,7 +36,9 @@ class FavoriteTableControllerTest extends AbstractTestCase $class = new ReflectionClass(FavoriteTableController::class); $method = $class->getMethod('synchronizeFavoriteTables'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $controller = new FavoriteTableController( new ResponseStub(), diff --git a/test/classes/Controllers/Database/StructureControllerTest.php b/test/classes/Controllers/Database/StructureControllerTest.php index ea72bfa1df..b2aa7495bd 100644 --- a/test/classes/Controllers/Database/StructureControllerTest.php +++ b/test/classes/Controllers/Database/StructureControllerTest.php @@ -19,6 +19,8 @@ use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub; use ReflectionClass; use ReflectionException; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Database\StructureController */ @@ -92,7 +94,10 @@ class StructureControllerTest extends AbstractTestCase { $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('getValuesForInnodbTable'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $controller = new StructureController( $this->response, $this->template, @@ -106,7 +111,10 @@ class StructureControllerTest extends AbstractTestCase ); // Showing statistics $property = $class->getProperty('isShowStats'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($controller, true); $GLOBALS['cfg']['MaxExactCount'] = 10; @@ -171,7 +179,9 @@ class StructureControllerTest extends AbstractTestCase { $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('getValuesForAriaTable'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $controller = new StructureController( $this->response, @@ -186,10 +196,16 @@ class StructureControllerTest extends AbstractTestCase ); // Showing statistics $property = $class->getProperty('isShowStats'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($controller, true); $property = $class->getProperty('dbIsSystemSchema'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($controller, true); $currentTable = [ @@ -287,7 +303,9 @@ class StructureControllerTest extends AbstractTestCase { $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('hasTable'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $controller = new StructureController( $this->response, @@ -320,7 +338,9 @@ class StructureControllerTest extends AbstractTestCase { $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('checkFavoriteTable'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $GLOBALS['db'] = 'sakila'; $GLOBALS['dbi'] = $this->dbi; @@ -374,7 +394,9 @@ class StructureControllerTest extends AbstractTestCase { $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('displayTableList'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $controller = new StructureController( $this->response, @@ -390,14 +412,22 @@ class StructureControllerTest extends AbstractTestCase // Showing statistics $class = new ReflectionClass(StructureController::class); $showStatsProperty = $class->getProperty('isShowStats'); - $showStatsProperty->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $showStatsProperty->setAccessible(true); + } + $showStatsProperty->setValue($controller, true); $tablesProperty = $class->getProperty('tables'); - $tablesProperty->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $tablesProperty->setAccessible(true); + } $numTables = $class->getProperty('numTables'); - $numTables->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $numTables->setAccessible(true); + } + $numTables->setValue($controller, 1); //no tables diff --git a/test/classes/Controllers/Server/VariablesControllerTest.php b/test/classes/Controllers/Server/VariablesControllerTest.php index 565ddd17ee..e38c687a3a 100644 --- a/test/classes/Controllers/Server/VariablesControllerTest.php +++ b/test/classes/Controllers/Server/VariablesControllerTest.php @@ -21,6 +21,8 @@ use function __; use function htmlspecialchars; use function str_replace; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Server\VariablesController */ @@ -137,7 +139,10 @@ class VariablesControllerTest extends AbstractTestCase ->willReturnOnConsecutiveCalls('byte', 'string'); $response = new ReflectionProperty(ServerVariablesProvider::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, $voidProviderMock); [$formattedValue, $isHtmlFormatted] = $this->callFunction( @@ -189,7 +194,10 @@ class VariablesControllerTest extends AbstractTestCase } $response = new ReflectionProperty(ServerVariablesProvider::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, null); $controller = new VariablesController(ResponseRenderer::getInstance(), new Template(), $GLOBALS['dbi']); @@ -248,7 +256,10 @@ class VariablesControllerTest extends AbstractTestCase public function testFormatVariableVoidProvider(): void { $response = new ReflectionProperty(ServerVariablesProvider::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, new ServerVariablesVoidProvider()); $controller = new VariablesController(ResponseRenderer::getInstance(), new Template(), $GLOBALS['dbi']); diff --git a/test/classes/Controllers/Table/IndexRenameControllerTest.php b/test/classes/Controllers/Table/IndexRenameControllerTest.php index f2ec09a41d..627c7832d4 100644 --- a/test/classes/Controllers/Table/IndexRenameControllerTest.php +++ b/test/classes/Controllers/Table/IndexRenameControllerTest.php @@ -14,13 +14,18 @@ use PhpMyAdmin\Tests\Stubs\DbiDummy; use PhpMyAdmin\Tests\Stubs\ResponseRenderer; use ReflectionProperty; +use const PHP_VERSION_ID; + /** @covers \PhpMyAdmin\Controllers\Table\IndexRenameController */ final class IndexRenameControllerTest extends AbstractTestCase { public function testPreviewSqlWithOldStatement(): void { $indexRegistry = new ReflectionProperty(Index::class, 'registry'); - $indexRegistry->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $indexRegistry->setAccessible(true); + } + $indexRegistry->setValue(null, []); $GLOBALS['cfg']['Server'] = $GLOBALS['cfg']['Servers'][1]; diff --git a/test/classes/Controllers/Table/IndexesControllerTest.php b/test/classes/Controllers/Table/IndexesControllerTest.php index 74cac49b7e..ae98773323 100644 --- a/test/classes/Controllers/Table/IndexesControllerTest.php +++ b/test/classes/Controllers/Table/IndexesControllerTest.php @@ -21,6 +21,8 @@ use ReflectionMethod; use function __; use function sprintf; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Table\IndexesController */ @@ -102,7 +104,9 @@ class IndexesControllerTest extends AbstractTestCase $template = new Template(); $method = new ReflectionMethod(IndexesController::class, 'displayForm'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $ctrl = new IndexesController( $response, diff --git a/test/classes/Controllers/Table/Structure/ChangeControllerTest.php b/test/classes/Controllers/Table/Structure/ChangeControllerTest.php index 4d435a7f3a..bb997e39a5 100644 --- a/test/classes/Controllers/Table/Structure/ChangeControllerTest.php +++ b/test/classes/Controllers/Table/Structure/ChangeControllerTest.php @@ -12,6 +12,8 @@ use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub; use PhpMyAdmin\Transformations; use ReflectionClass; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Table\Structure\ChangeController */ @@ -31,7 +33,9 @@ class ChangeControllerTest extends AbstractTestCase $class = new ReflectionClass(ChangeController::class); $method = $class->getMethod('displayHtmlForColumnChange'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $ctrl = new ChangeController( $response, diff --git a/test/classes/Controllers/Table/Structure/MoveColumnsControllerTest.php b/test/classes/Controllers/Table/Structure/MoveColumnsControllerTest.php index 0937bef821..15ad5e2e02 100644 --- a/test/classes/Controllers/Table/Structure/MoveColumnsControllerTest.php +++ b/test/classes/Controllers/Table/Structure/MoveColumnsControllerTest.php @@ -12,6 +12,8 @@ use ReflectionClass; use function preg_replace; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Table\Structure\MoveColumnsController */ @@ -27,7 +29,9 @@ class MoveColumnsControllerTest extends AbstractTestCase { $class = new ReflectionClass(MoveColumnsController::class); $method = $class->getMethod('generateAlterTableSql'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $controller = new MoveColumnsController( new ResponseStub(), diff --git a/test/classes/Controllers/Table/Structure/SaveControllerTest.php b/test/classes/Controllers/Table/Structure/SaveControllerTest.php index 8d3752feee..1969116fc9 100644 --- a/test/classes/Controllers/Table/Structure/SaveControllerTest.php +++ b/test/classes/Controllers/Table/Structure/SaveControllerTest.php @@ -13,6 +13,8 @@ use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseStub; use PhpMyAdmin\Transformations; use ReflectionClass; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Controllers\Table\Structure\SaveController */ @@ -28,7 +30,9 @@ class SaveControllerTest extends AbstractTestCase $class = new ReflectionClass(SaveController::class); $method = $class->getMethod('adjustColumnPrivileges'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $ctrl = new SaveController( new ResponseStub(), diff --git a/test/classes/Database/DesignerTest.php b/test/classes/Database/DesignerTest.php index 54f2d91662..a44d919f0c 100644 --- a/test/classes/Database/DesignerTest.php +++ b/test/classes/Database/DesignerTest.php @@ -13,6 +13,8 @@ use PhpMyAdmin\Tests\Stubs\DummyResult; use PhpMyAdmin\Version; use ReflectionMethod; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Database\Designer */ @@ -105,7 +107,10 @@ class DesignerTest extends AbstractTestCase $this->designer = new Designer($GLOBALS['dbi'], new Relation($GLOBALS['dbi']), new Template()); $method = new ReflectionMethod(Designer::class, 'getPageIdsAndNames'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invokeArgs($this->designer, [$db]); self::assertSame([ diff --git a/test/classes/ErrorHandlerTest.php b/test/classes/ErrorHandlerTest.php index 3163d05968..3b0697cbb1 100644 --- a/test/classes/ErrorHandlerTest.php +++ b/test/classes/ErrorHandlerTest.php @@ -25,6 +25,7 @@ use const E_USER_ERROR; use const E_USER_NOTICE; use const E_USER_WARNING; use const E_WARNING; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\ErrorHandler @@ -317,7 +318,10 @@ class ErrorHandlerTest extends AbstractTestCase $GLOBALS['config']->set('environment', 'development'); $responseStub = new ResponseRendererStub(); $property = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue(null, $responseStub); $responseStub->setHeadersSent(true); $errorHandler = new ErrorHandler(); @@ -343,7 +347,10 @@ class ErrorHandlerTest extends AbstractTestCase $GLOBALS['config']->set('environment', 'production'); $responseStub = new ResponseRendererStub(); $property = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue(null, $responseStub); $responseStub->setHeadersSent(true); $errorHandler = new ErrorHandler(); @@ -369,7 +376,10 @@ class ErrorHandlerTest extends AbstractTestCase $GLOBALS['config']->set('environment', 'production'); $responseStub = new ResponseRendererStub(); $property = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue(null, $responseStub); $responseStub->setHeadersSent(true); $errorHandler = new ErrorHandler(); @@ -395,7 +405,10 @@ HTML; $GLOBALS['config']->set('environment', 'production'); $responseStub = new ResponseRendererStub(); $property = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue(null, $responseStub); $responseStub->setHeadersSent(false); $errorHandler = new ErrorHandler(); diff --git a/test/classes/FooterTest.php b/test/classes/FooterTest.php index 594f1dd6b3..34eb4b7f6d 100644 --- a/test/classes/FooterTest.php +++ b/test/classes/FooterTest.php @@ -11,6 +11,8 @@ use ReflectionProperty; use function json_encode; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Footer */ @@ -154,7 +156,10 @@ class FooterTest extends AbstractTestCase public function testSetAjax(): void { $isAjax = new ReflectionProperty(Footer::class, 'isAjax'); - $isAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $isAjax->setAccessible(true); + } + $footer = new Footer(); self::assertFalse($isAjax->getValue($footer)); diff --git a/test/classes/HeaderTest.php b/test/classes/HeaderTest.php index 585dd3fc19..d174a245c0 100644 --- a/test/classes/HeaderTest.php +++ b/test/classes/HeaderTest.php @@ -12,6 +12,7 @@ use ReflectionProperty; use function gmdate; use const DATE_RFC1123; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Header @@ -106,7 +107,9 @@ class HeaderTest extends AbstractTestCase public function testDisableWarnings(): void { $reflection = new ReflectionProperty(Header::class, 'warningsEnabled'); - $reflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } $header = new Header(); $header->disableWarnings(); @@ -233,13 +236,21 @@ class HeaderTest extends AbstractTestCase { $header = new Header(); $consoleReflection = new ReflectionProperty(Header::class, 'console'); - $consoleReflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $consoleReflection->setAccessible(true); + } + $console = $consoleReflection->getValue($header); self::assertInstanceOf(Console::class, $console); $isAjax = new ReflectionProperty(Header::class, 'isAjax'); - $isAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $isAjax->setAccessible(true); + } + $consoleIsAjax = new ReflectionProperty(Console::class, 'isAjax'); - $consoleIsAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $consoleIsAjax->setAccessible(true); + } self::assertFalse($isAjax->getValue($header)); self::assertFalse($consoleIsAjax->getValue($console)); diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index d6e9f64124..c0af09367c 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -30,6 +30,7 @@ use const MYSQLI_PRI_KEY_FLAG; use const MYSQLI_TYPE_DECIMAL; use const MYSQLI_TYPE_TIMESTAMP; use const MYSQLI_TYPE_TINY; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\InsertEdit @@ -94,8 +95,15 @@ class InsertEditTest extends AbstractTestCase { parent::tearDown(); $response = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, null); + if (PHP_VERSION_ID >= 80100) { + return; + } + $response->setAccessible(false); } @@ -312,7 +320,10 @@ class InsertEditTest extends AbstractTestCase $restoreInstance = ResponseRenderer::getInstance(); $response = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, $responseMock); $result = $this->callFunction( @@ -2693,7 +2704,10 @@ class InsertEditTest extends AbstractTestCase $restoreInstance = ResponseRenderer::getInstance(); $response = new ReflectionProperty(ResponseRenderer::class, 'instance'); - $response->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $response->setAccessible(true); + } + $response->setValue(null, $responseMock); $this->insertEdit = new InsertEdit($dbi); diff --git a/test/classes/Navigation/Nodes/NodeTest.php b/test/classes/Navigation/Nodes/NodeTest.php index 3d99b2f8e6..c8863bea4f 100644 --- a/test/classes/Navigation/Nodes/NodeTest.php +++ b/test/classes/Navigation/Nodes/NodeTest.php @@ -11,6 +11,8 @@ use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; use ReflectionMethod; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Navigation\Nodes\Node */ @@ -221,7 +223,9 @@ class NodeTest extends AbstractTestCase public function testGetWhereClause(): void { $method = new ReflectionMethod(Node::class, 'getWhereClause'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } // Vanilla case $node = NodeFactory::getInstance(); diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index 3e8cc56c9e..40e205b9c0 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -26,6 +26,7 @@ use function str_repeat; use function str_shuffle; use function time; +use const PHP_VERSION_ID; use const SODIUM_CRYPTO_SECRETBOX_KEYBYTES; /** @@ -878,7 +879,9 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase public function testGetEncryptionSecretEmpty(): void { $method = new ReflectionMethod(AuthenticationCookie::class, 'getEncryptionSecret'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $GLOBALS['cfg']['blowfish_secret'] = ''; $_SESSION['encryption_key'] = ''; @@ -892,7 +895,9 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase public function testGetEncryptionSecretConfigured(): void { $method = new ReflectionMethod(AuthenticationCookie::class, 'getEncryptionSecret'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $key = str_repeat('a', SODIUM_CRYPTO_SECRETBOX_KEYBYTES); $GLOBALS['cfg']['blowfish_secret'] = $key; @@ -906,7 +911,9 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase public function testGetSessionEncryptionSecretConfigured(): void { $method = new ReflectionMethod(AuthenticationCookie::class, 'getEncryptionSecret'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $key = str_repeat('a', SODIUM_CRYPTO_SECRETBOX_KEYBYTES); $GLOBALS['cfg']['blowfish_secret'] = 'blowfish_secret'; diff --git a/test/classes/Plugins/Auth/AuthenticationSignonTest.php b/test/classes/Plugins/Auth/AuthenticationSignonTest.php index af3f77e58d..dfe9f8faf0 100644 --- a/test/classes/Plugins/Auth/AuthenticationSignonTest.php +++ b/test/classes/Plugins/Auth/AuthenticationSignonTest.php @@ -17,6 +17,8 @@ use function session_id; use function session_name; use function version_compare; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Auth\AuthenticationSignon */ @@ -324,6 +326,7 @@ class AuthenticationSignonTest extends AbstractNetworkTestCase 'path' => '/', 'domain' => '', 'secure' => false, + 'partitioned' => false, 'httponly' => false, 'samesite' => '', ]; @@ -332,6 +335,10 @@ class AuthenticationSignonTest extends AbstractNetworkTestCase unset($defaultOptions['samesite']); } + if (PHP_VERSION_ID < 80500) { + unset($defaultOptions['partitioned']); + } + self::assertSame($defaultOptions, session_get_cookie_params()); } } diff --git a/test/classes/Plugins/Export/ExportCodegenTest.php b/test/classes/Plugins/Export/ExportCodegenTest.php index 03da6a2199..6e07bb705e 100644 --- a/test/classes/Plugins/Export/ExportCodegenTest.php +++ b/test/classes/Plugins/Export/ExportCodegenTest.php @@ -18,6 +18,8 @@ use ReflectionProperty; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportCodegen * @group medium @@ -49,11 +51,16 @@ class ExportCodegenTest extends AbstractTestCase public function testInitSpecificVariables(): void { $method = new ReflectionMethod(ExportCodegen::class, 'init'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrCgFormats = new ReflectionProperty(ExportCodegen::class, 'cgFormats'); - $attrCgFormats->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrCgFormats->setAccessible(true); + } self::assertSame([ 'NHibernate C# DO', @@ -64,11 +71,17 @@ class ExportCodegenTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportCodegen::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportCodegen::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -185,7 +198,10 @@ class ExportCodegenTest extends AbstractTestCase public function testHandleNHibernateCSBody(): void { $method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateCSBody'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'test_db', 'test_table', "\n"); self::assertSame('using System;' . "\n" . @@ -235,7 +251,10 @@ class ExportCodegenTest extends AbstractTestCase public function testHandleNHibernateXMLBody(): void { $method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateXMLBody'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'test_db', 'test_table', "\n"); self::assertSame('' . "\n" . @@ -267,8 +286,10 @@ class ExportCodegenTest extends AbstractTestCase $getter = $reflection->getMethod('getCgFormats'); $setter = $reflection->getMethod('setCgFormats'); - $getter->setAccessible(true); - $setter->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $getter->setAccessible(true); + $setter->setAccessible(true); + } $setter->invoke($this->object, [1, 2]); diff --git a/test/classes/Plugins/Export/ExportCsvTest.php b/test/classes/Plugins/Export/ExportCsvTest.php index b81a52314c..93506cf01a 100644 --- a/test/classes/Plugins/Export/ExportCsvTest.php +++ b/test/classes/Plugins/Export/ExportCsvTest.php @@ -19,6 +19,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportCsv * @group medium @@ -55,11 +57,17 @@ class ExportCsvTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportCsv::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportCsv::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportExcelTest.php b/test/classes/Plugins/Export/ExportExcelTest.php index 35781cfb3c..46efacfe34 100644 --- a/test/classes/Plugins/Export/ExportExcelTest.php +++ b/test/classes/Plugins/Export/ExportExcelTest.php @@ -18,6 +18,8 @@ use ReflectionProperty; use function array_shift; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportExcel * @group medium @@ -49,11 +51,17 @@ class ExportExcelTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportExcel::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportExcel::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportHtmlwordTest.php b/test/classes/Plugins/Export/ExportHtmlwordTest.php index 45e7aee363..781e40cdb7 100644 --- a/test/classes/Plugins/Export/ExportHtmlwordTest.php +++ b/test/classes/Plugins/Export/ExportHtmlwordTest.php @@ -24,6 +24,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportHtmlword * @group medium @@ -66,11 +68,17 @@ class ExportHtmlwordTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportHtmlword::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportHtmlword::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -529,7 +537,10 @@ class ExportHtmlwordTest extends AbstractTestCase $GLOBALS['dbi'] = $dbi; $method = new ReflectionMethod(ExportHtmlword::class, 'getTriggers'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'database', 'table'); self::assertStringContainsString('tna"me' . @@ -633,7 +644,9 @@ class ExportHtmlwordTest extends AbstractTestCase public function testFormatOneColumnDefinition(): void { $method = new ReflectionMethod(ExportHtmlword::class, 'formatOneColumnDefinition'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $cols = [ 'Null' => 'Yes', diff --git a/test/classes/Plugins/Export/ExportJsonTest.php b/test/classes/Plugins/Export/ExportJsonTest.php index af0fd3ba6a..bbb60c9ead 100644 --- a/test/classes/Plugins/Export/ExportJsonTest.php +++ b/test/classes/Plugins/Export/ExportJsonTest.php @@ -16,6 +16,8 @@ use ReflectionProperty; use function array_shift; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportJson * @group medium @@ -52,11 +54,17 @@ class ExportJsonTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportJson::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportJson::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportLatexTest.php b/test/classes/Plugins/Export/ExportLatexTest.php index 094fa0b39d..3750e48d46 100644 --- a/test/classes/Plugins/Export/ExportLatexTest.php +++ b/test/classes/Plugins/Export/ExportLatexTest.php @@ -23,6 +23,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportLatex * @group medium @@ -76,7 +78,10 @@ class ExportLatexTest extends AbstractTestCase $_SESSION = ['relation' => [$GLOBALS['server'] => $relationParameters->toArray()]]; $method = new ReflectionMethod(ExportLatex::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $properties = $method->invoke($this->object, null); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportMediawikiTest.php b/test/classes/Plugins/Export/ExportMediawikiTest.php index e26233e0ca..183532759c 100644 --- a/test/classes/Plugins/Export/ExportMediawikiTest.php +++ b/test/classes/Plugins/Export/ExportMediawikiTest.php @@ -21,6 +21,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportMediawiki * @group medium @@ -62,11 +64,17 @@ class ExportMediawikiTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportMediawiki::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportMediawiki::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportOdsTest.php b/test/classes/Plugins/Export/ExportOdsTest.php index fef9bf2411..205abcac0e 100644 --- a/test/classes/Plugins/Export/ExportOdsTest.php +++ b/test/classes/Plugins/Export/ExportOdsTest.php @@ -28,6 +28,7 @@ use const MYSQLI_TYPE_DECIMAL; use const MYSQLI_TYPE_STRING; use const MYSQLI_TYPE_TIME; use const MYSQLI_TYPE_TINY_BLOB; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Plugins\Export\ExportOds @@ -66,11 +67,17 @@ class ExportOdsTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportOds::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportOds::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index 7bfc47cb91..c39f765c83 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -28,6 +28,7 @@ use const MYSQLI_NUM_FLAG; use const MYSQLI_TYPE_BLOB; use const MYSQLI_TYPE_DECIMAL; use const MYSQLI_TYPE_STRING; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Plugins\Export\ExportOdt @@ -82,7 +83,10 @@ class ExportOdtTest extends AbstractTestCase $_SESSION = ['relation' => [$GLOBALS['server'] => $relationParameters->toArray()]]; $method = new ReflectionMethod(ExportOdt::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $properties = $method->invoke($this->object, null); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -647,7 +651,10 @@ class ExportOdtTest extends AbstractTestCase $GLOBALS['dbi'] = $dbi; $method = new ReflectionMethod(ExportOdt::class, 'getTriggers'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'database', 'tasetAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $cols = [ 'Null' => 'Yes', diff --git a/test/classes/Plugins/Export/ExportPdfTest.php b/test/classes/Plugins/Export/ExportPdfTest.php index ff0fd77a40..9f48cc1d40 100644 --- a/test/classes/Plugins/Export/ExportPdfTest.php +++ b/test/classes/Plugins/Export/ExportPdfTest.php @@ -18,6 +18,8 @@ use ReflectionProperty; use function __; use function array_shift; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportPdf * @group medium @@ -54,11 +56,17 @@ class ExportPdfTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportPdf::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportPdf::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -131,7 +139,10 @@ class ExportPdfTest extends AbstractTestCase ->method('setTopMargin'); $attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf'); - $attrPdf->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrPdf->setAccessible(true); + } + $attrPdf->setValue($this->object, $pdf); self::assertTrue($this->object->exportHeader()); @@ -147,7 +158,10 @@ class ExportPdfTest extends AbstractTestCase ->method('getPDFData'); $attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf'); - $attrPdf->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrPdf->setAccessible(true); + } + $attrPdf->setValue($this->object, $pdf); self::assertTrue($this->object->exportFooter()); @@ -179,7 +193,10 @@ class ExportPdfTest extends AbstractTestCase ->with('SELECT'); $attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf'); - $attrPdf->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrPdf->setAccessible(true); + } + $attrPdf->setValue($this->object, $pdf); self::assertTrue($this->object->exportData( @@ -199,11 +216,17 @@ class ExportPdfTest extends AbstractTestCase public function testSetGetPdf(): void { $setter = new ReflectionMethod(ExportPdf::class, 'setPdf'); - $setter->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $setter->setAccessible(true); + } + $setter->invoke($this->object, new Pdf()); $getter = new ReflectionMethod(ExportPdf::class, 'getPdf'); - $getter->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $getter->setAccessible(true); + } + self::assertInstanceOf(Pdf::class, $getter->invoke($this->object)); } } diff --git a/test/classes/Plugins/Export/ExportPhparrayTest.php b/test/classes/Plugins/Export/ExportPhparrayTest.php index e6a7876963..79ff9b1481 100644 --- a/test/classes/Plugins/Export/ExportPhparrayTest.php +++ b/test/classes/Plugins/Export/ExportPhparrayTest.php @@ -17,6 +17,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportPhparray * @group medium @@ -58,11 +60,17 @@ class ExportPhparrayTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportPhparray::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportPhparray::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportSqlTest.php b/test/classes/Plugins/Export/ExportSqlTest.php index eee9d1188e..032fb52ffb 100644 --- a/test/classes/Plugins/Export/ExportSqlTest.php +++ b/test/classes/Plugins/Export/ExportSqlTest.php @@ -36,6 +36,7 @@ use const MYSQLI_TYPE_FLOAT; use const MYSQLI_TYPE_LONG; use const MYSQLI_TYPE_STRING; use const MYSQLI_UNIQUE_KEY_FLAG; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Plugins\Export\ExportSql @@ -88,7 +89,10 @@ class ExportSqlTest extends AbstractTestCase $GLOBALS['plugin_param']['single_table'] = false; $method = new ReflectionMethod(ExportSql::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $properties = $method->invoke($this->object, null); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -127,7 +131,10 @@ class ExportSqlTest extends AbstractTestCase $_SESSION = ['relation' => [$GLOBALS['server'] => $relationParameters->toArray()]]; $method = new ReflectionMethod(ExportSql::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $properties = $method->invoke($this->object, null); self::assertInstanceOf(ExportPluginProperties::class, $properties); @@ -267,7 +274,9 @@ class ExportSqlTest extends AbstractTestCase public function testExportComment(): void { $method = new ReflectionMethod(ExportSql::class, 'exportComment'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $GLOBALS['crlf'] = '##'; $GLOBALS['sql_include_comments'] = true; @@ -288,7 +297,9 @@ class ExportSqlTest extends AbstractTestCase public function testPossibleCRLF(): void { $method = new ReflectionMethod(ExportSql::class, 'possibleCRLF'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $GLOBALS['crlf'] = '##'; $GLOBALS['sql_include_comments'] = true; @@ -629,7 +640,10 @@ class ExportSqlTest extends AbstractTestCase $GLOBALS['sql_compatibility'] = 'MSSQL'; $method = new ReflectionMethod(ExportSql::class, 'getTableDefForView'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'db', 'view', "\n"); self::assertSame("CREATE TABLE `view`(\n" . @@ -921,7 +935,10 @@ class ExportSqlTest extends AbstractTestCase $this->object->relation = new Relation($dbi); $method = new ReflectionMethod(ExportSql::class, 'getTableComments'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, 'db', '', true, true); self::assertStringContainsString("-- MEDIA TYPES FOR TABLE :\n" . @@ -1001,7 +1018,10 @@ class ExportSqlTest extends AbstractTestCase )); $result = ob_get_clean(); $sqlViewsProp = new ReflectionProperty(ExportSql::class, 'sqlViews'); - $sqlViewsProp->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $sqlViewsProp->setAccessible(true); + } + $sqlViews = $sqlViewsProp->getValue($this->object); self::assertSame('', $result); @@ -1358,7 +1378,10 @@ class ExportSqlTest extends AbstractTestCase " \" double NOT NULL DEFAULT '213'\n"; $method = new ReflectionMethod(ExportSql::class, 'makeCreateTableMSSQLCompatible'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $result = $method->invoke($this->object, $query); self::assertSame("CREATE TABLE (\" datetime DEFAULT NULL,\n" . diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 8bb5d8d5d6..b90017ccbe 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -22,6 +22,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportTexytext * @group medium @@ -66,11 +68,17 @@ class ExportTexytextTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportTexytext::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportTexytext::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportXmlTest.php b/test/classes/Plugins/Export/ExportXmlTest.php index 721c7ef38b..2ffd882532 100644 --- a/test/classes/Plugins/Export/ExportXmlTest.php +++ b/test/classes/Plugins/Export/ExportXmlTest.php @@ -20,6 +20,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportXml * @group medium @@ -63,11 +65,17 @@ class ExportXmlTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportXml::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportXml::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Plugins/Export/ExportYamlTest.php b/test/classes/Plugins/Export/ExportYamlTest.php index 0e1538859f..f152fb5431 100644 --- a/test/classes/Plugins/Export/ExportYamlTest.php +++ b/test/classes/Plugins/Export/ExportYamlTest.php @@ -17,6 +17,8 @@ use function array_shift; use function ob_get_clean; use function ob_start; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Plugins\Export\ExportYaml * @group medium @@ -58,11 +60,17 @@ class ExportYamlTest extends AbstractTestCase public function testSetProperties(): void { $method = new ReflectionMethod(ExportYaml::class, 'setProperties'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke($this->object, null); $attrProperties = new ReflectionProperty(ExportYaml::class, 'properties'); - $attrProperties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $attrProperties->setAccessible(true); + } + $properties = $attrProperties->getValue($this->object); self::assertInstanceOf(ExportPluginProperties::class, $properties); diff --git a/test/classes/Properties/Options/OptionsPropertyGroupTest.php b/test/classes/Properties/Options/OptionsPropertyGroupTest.php index 94d7dd5462..cefacb8a7d 100644 --- a/test/classes/Properties/Options/OptionsPropertyGroupTest.php +++ b/test/classes/Properties/Options/OptionsPropertyGroupTest.php @@ -9,6 +9,8 @@ use PhpMyAdmin\Tests\AbstractTestCase; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Properties\Options\OptionsPropertyGroup */ @@ -38,7 +40,9 @@ class OptionsPropertyGroupTest extends AbstractTestCase public function testAddProperty(): void { $properties = new ReflectionProperty(OptionsPropertyGroup::class, 'properties'); - $properties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $properties->setAccessible(true); + } $properties->setValue($this->stub, [1, 2, 3]); @@ -56,7 +60,9 @@ class OptionsPropertyGroupTest extends AbstractTestCase public function testRemoveProperty(): void { $properties = new ReflectionProperty(OptionsPropertyGroup::class, 'properties'); - $properties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $properties->setAccessible(true); + } $properties->setValue($this->stub, [1, 2, 'test', 3]); $this->stub->removeProperty('test'); @@ -76,7 +82,10 @@ class OptionsPropertyGroupTest extends AbstractTestCase public function testGetProperties(): void { $properties = new ReflectionProperty(OptionsPropertyGroup::class, 'properties'); - $properties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $properties->setAccessible(true); + } + $properties->setValue($this->stub, [1, 2, 3]); self::assertSame([ @@ -89,7 +98,10 @@ class OptionsPropertyGroupTest extends AbstractTestCase public function testGetNrOfProperties(): void { $properties = new ReflectionProperty(OptionsPropertyGroup::class, 'properties'); - $properties->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $properties->setAccessible(true); + } + $properties->setValue($this->stub, [1, 2, 3]); self::assertSame(3, $this->stub->getNrOfProperties()); diff --git a/test/classes/ResponseRendererTest.php b/test/classes/ResponseRendererTest.php index c855a1e383..a019b42808 100644 --- a/test/classes/ResponseRendererTest.php +++ b/test/classes/ResponseRendererTest.php @@ -9,6 +9,8 @@ use PhpMyAdmin\Header; use PhpMyAdmin\ResponseRenderer; use ReflectionProperty; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\ResponseRenderer */ @@ -34,13 +36,21 @@ class ResponseRendererTest extends AbstractTestCase $response = ResponseRenderer::getInstance(); $header = $response->getHeader(); $footerReflection = new ReflectionProperty(ResponseRenderer::class, 'footer'); - $footerReflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $footerReflection->setAccessible(true); + } + $footer = $footerReflection->getValue($response); self::assertInstanceOf(Footer::class, $footer); $headerIsAjax = new ReflectionProperty(Header::class, 'isAjax'); - $headerIsAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $headerIsAjax->setAccessible(true); + } + $footerIsAjax = new ReflectionProperty(Footer::class, 'isAjax'); - $footerIsAjax->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $footerIsAjax->setAccessible(true); + } self::assertFalse($response->isAjax()); self::assertFalse($headerIsAjax->getValue($header)); diff --git a/test/classes/ScriptsTest.php b/test/classes/ScriptsTest.php index 709d14793c..64efd0064c 100644 --- a/test/classes/ScriptsTest.php +++ b/test/classes/ScriptsTest.php @@ -10,6 +10,8 @@ use ReflectionProperty; use function rawurlencode; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Scripts */ @@ -91,7 +93,9 @@ class ScriptsTest extends AbstractTestCase public function testAddFile(): void { $reflection = new ReflectionProperty(Scripts::class, 'files'); - $reflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } // Assert empty _files property of // Scripts @@ -117,7 +121,9 @@ class ScriptsTest extends AbstractTestCase public function testAddFiles(): void { $reflection = new ReflectionProperty(Scripts::class, 'files'); - $reflection->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } $filenames = [ 'common.js', diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php index b506be7a6f..88d1f5e90c 100644 --- a/test/classes/Server/PrivilegesTest.php +++ b/test/classes/Server/PrivilegesTest.php @@ -30,6 +30,8 @@ use function htmlspecialchars; use function implode; use function preg_quote; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Server\Privileges */ @@ -1669,7 +1671,9 @@ class PrivilegesTest extends AbstractTestCase new Plugins($this->dbi) ); $method = new ReflectionMethod(Privileges::class, 'getUserPrivileges'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } /** @var array|null $actual */ $actual = $method->invokeArgs($serverPrivileges, ['test.user', 'test.host', true]); diff --git a/test/classes/Setup/ConfigGeneratorTest.php b/test/classes/Setup/ConfigGeneratorTest.php index 62fa39d018..552273607f 100644 --- a/test/classes/Setup/ConfigGeneratorTest.php +++ b/test/classes/Setup/ConfigGeneratorTest.php @@ -15,6 +15,7 @@ use function hex2bin; use function mb_strlen; use function str_repeat; +use const PHP_VERSION_ID; use const SODIUM_CRYPTO_SECRETBOX_KEYBYTES; /** @@ -74,7 +75,9 @@ class ConfigGeneratorTest extends AbstractTestCase { $reflection = new ReflectionClass(ConfigGenerator::class); $method = $reflection->getMethod('getVarExport'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } self::assertSame('$cfg[\'var_name\'] = 1;' . "\n", $method->invoke(null, 'var_name', 1, "\n")); @@ -108,7 +111,9 @@ class ConfigGeneratorTest extends AbstractTestCase { $reflection = new ReflectionClass(ConfigGenerator::class); $method = $reflection->getMethod('getVarExport'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } self::assertSame( '$cfg[\'blowfish_secret\'] = \sodium_hex2bin(\'' @@ -134,7 +139,9 @@ class ConfigGeneratorTest extends AbstractTestCase { $reflection = new ReflectionClass(ConfigGenerator::class); $method = $reflection->getMethod('isZeroBasedArray'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } self::assertFalse($method->invoke( null, @@ -175,7 +182,9 @@ class ConfigGeneratorTest extends AbstractTestCase { $reflection = new ReflectionClass(ConfigGenerator::class); $method = $reflection->getMethod('exportZeroBasedArray'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $arr = [ 1, diff --git a/test/classes/SqlTest.php b/test/classes/SqlTest.php index e0ad892385..a3dcd17694 100644 --- a/test/classes/SqlTest.php +++ b/test/classes/SqlTest.php @@ -18,6 +18,7 @@ use stdClass; use const MYSQLI_TYPE_SHORT; use const MYSQLI_TYPE_TIMESTAMP; use const MYSQLI_TYPE_VAR_STRING; +use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Sql @@ -760,7 +761,10 @@ class SqlTest extends AbstractTestCase public function testGetDetailedProfilingStatsWithoutData(): void { $method = new ReflectionMethod($this->sql, 'getDetailedProfilingStats'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + self::assertSame( ['total_time' => 0, 'states' => [], 'chart' => [], 'profile' => []], $method->invoke($this->sql, []) @@ -770,7 +774,10 @@ class SqlTest extends AbstractTestCase public function testGetDetailedProfilingStatsWithData(): void { $method = new ReflectionMethod($this->sql, 'getDetailedProfilingStats'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $profiling = [ ['Status' => 'Starting', 'Duration' => '0.000017'], ['Status' => 'checking permissions', 'Duration' => '0.000003'], diff --git a/test/classes/TrackerTest.php b/test/classes/TrackerTest.php index 8936fe1535..c510c85f22 100644 --- a/test/classes/TrackerTest.php +++ b/test/classes/TrackerTest.php @@ -12,6 +12,8 @@ use PhpMyAdmin\Tracker; use PhpMyAdmin\Util; use ReflectionMethod; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Tracker */ @@ -331,7 +333,10 @@ class TrackerTest extends AbstractTestCase if ($type === null) { $method = new ReflectionMethod(Tracker::class, 'changeTracking'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + $method->invoke(null, $dbname, $tablename, $version, $new_state); } elseif ($type === 'activate') { Tracker::activateTracking($dbname, $tablename, $version); diff --git a/test/classes/UrlTest.php b/test/classes/UrlTest.php index 4baea9264e..ed7dd6d28a 100644 --- a/test/classes/UrlTest.php +++ b/test/classes/UrlTest.php @@ -13,6 +13,8 @@ use function parse_str; use function str_repeat; use function urldecode; +use const PHP_VERSION_ID; + /** * @covers \PhpMyAdmin\Url */ @@ -246,7 +248,10 @@ class UrlTest extends AbstractTestCase public function testGetArgSeparator(string $expected, $iniValue, ?string $cacheValue): void { $property = new ReflectionProperty(Url::class, 'inputArgSeparator'); - $property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue(null, $cacheValue); self::$inputArgSeparator = $iniValue;