From ae92e9cc0a6993abaaf136b320ce2e8ecf3dc693 Mon Sep 17 00:00:00 2001 From: Jonathan Danse Date: Thu, 3 Jul 2025 10:56:24 +0200 Subject: [PATCH] feat: add compare with 8/9 versions --- phppsinfo.php | 95 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/phppsinfo.php b/phppsinfo.php index 7e05b7a..5a8acf1 100644 --- a/phppsinfo.php +++ b/phppsinfo.php @@ -11,16 +11,24 @@ class PhpPsInfo const TYPE_OK = true; const TYPE_ERROR = false; const TYPE_WARNING = null; - + const TYPE_SUCCESS_CLASS = 'table-success'; const TYPE_ERROR_CLASS = 'table-danger'; const TYPE_INFO_CLASS = 'table-info'; const TYPE_WARNING_CLASS = 'table-warning'; protected $requirements = [ - 'versions' => [ - 'php' => '7.1', - 'mysql' => '5.5', + '8' => [ + 'versions' => [ + 'php' => '7.1', + 'mysql' => '5.5', + ], + ], + '9' => [ + 'versions' => [ + 'php' => '8.1', + 'mysql' => '5.7', + ], ], 'extensions' => [ 'bcmath' => false, @@ -74,9 +82,17 @@ class PhpPsInfo ]; protected $recommended = [ - 'versions' => [ - 'php' => '8.1', - 'mysql' => '8.0', + '8' => [ + 'versions' => [ + 'php' => '8.1', + 'mysql' => '8.0', + ], + ], + '9' => [ + 'versions' => [ + 'php' => '8.4', + 'mysql' => '8.0', + ], ], 'extensions' => [ 'bcmath' => true, @@ -179,30 +195,53 @@ public function getVersions() ]; $data['PHP Version'] = [ - $this->requirements['versions']['php'], - $this->recommended['versions']['php'], + // PrestaShop 8 + $this->requirements['8']['versions']['php'], + $this->recommended['8']['versions']['php'], + version_compare(PHP_VERSION, $this->recommended['8']['versions']['php'], '>=') ? + self::TYPE_OK : ( + version_compare(PHP_VERSION, $this->requirements['8']['versions']['php'], '>=') ? + self::TYPE_WARNING : + self::TYPE_ERROR + ), PHP_VERSION, - version_compare(PHP_VERSION, $this->recommended['versions']['php'], '>=') ? + // PrestaShop 9 + $this->requirements['9']['versions']['php'], + $this->recommended['9']['versions']['php'], + version_compare(PHP_VERSION, $this->recommended['9']['versions']['php'], '>=') ? self::TYPE_OK : ( - version_compare(PHP_VERSION, $this->requirements['versions']['php'], '>=') ? + version_compare(PHP_VERSION, $this->requirements['9']['versions']['php'], '>=') ? self::TYPE_WARNING : self::TYPE_ERROR - ) + ), + PHP_VERSION ]; if (!extension_loaded('mysqli') || !is_callable('mysqli_connect')) { $data['MySQLi Extension'] = [ + // PrestaShop 8 + true, + true, + 'Not installed', + // PrestaShop 9 true, true, 'Not installed', + // Global self::TYPE_ERROR, ]; } else { $data['MySQLi Extension'] = [ - $this->requirements['versions']['mysql'], - $this->recommended['versions']['mysql'], + // PrestaShop 8 + $this->requirements['8']['versions']['mysql'], + $this->recommended['8']['versions']['mysql'], + self::TYPE_ERROR, mysqli_get_client_info(), + // PrestaShop 9 + $this->requirements['9']['versions']['mysql'], + $this->recommended['9']['versions']['mysql'], self::TYPE_OK, + mysqli_get_client_info(), ]; } @@ -211,6 +250,10 @@ public function getVersions() true, gethostbyname('www.prestashop.com') !== 'www.prestashop.com', gethostbyname('www.prestashop.com') !== 'www.prestashop.com', + false, + true, + gethostbyname('www.prestashop.com') !== 'www.prestashop.com', + gethostbyname('www.prestashop.com') !== 'www.prestashop.com', ]; return $data; @@ -421,17 +464,16 @@ public function toString($value) * @param array $data * @return string */ - public function toHtmlClass(array $data) + public function toHtmlClass(array $data, int $index = 2) { if (count($data) === 1 && !is_bool($data[0])) { return self::TYPE_INFO_CLASS; } - if (count($data) === 1 && is_bool($data[0])) { $result = $data[0]; - } elseif (array_key_exists(3, $data)) { - $result = $data[3]; + } elseif (count($data) === 8 && array_key_exists($index, $data)) { + $result = $data[$index]; } else { if ($data[2] >= $data[1]) { $result = self::TYPE_OK; @@ -543,10 +585,18 @@ protected function commandExists($command)
+ + + + + + + + @@ -555,14 +605,17 @@ protected function commandExists($command) - + - + + + + @@ -676,7 +729,7 @@ protected function commandExists($command)
 PrestaShop 8PrestaShop 9
# Required RecommendedCurrentRequiredRecommended Current
toString($data[0]) ?>toString($data[0]) ?>
toString($data[0]) ?> toString($data[1]) ?>toString($data[2]) ?>toString($data[3]) ?>toString($data[4]) ?>toString($data[5]) ?>toString($data[7]) ?>