Skip to content

Commit

Permalink
PHP 8.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Nov 26, 2024
1 parent 52e8306 commit eb1429a
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 56 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
matrix:
include:
- {php-version: "8.2"} # Lint on lower PHP version to detected too early usage of new syntaxes
- {php-version: "8.3"} # Lint on higher PHP version to detected deprecated elements usage
- {php-version: "8.4"} # Lint on higher PHP version to detected deprecated elements usage
env:
COMPOSE_FILE: ".github/actions/docker-compose-app.yml"
APPLICATION_ROOT: "${{ github.workspace }}"
Expand Down Expand Up @@ -116,20 +116,20 @@ jobs:
MATRIX='
{
"include": [
{"php-version": "8.3", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mysql:8.4"},
{"php-version": "8.4", "db-image": "mariadb:11.4"},
{"php-version": "8.4", "db-image": "mysql:8.4"},
{"php-version": "8.2", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mariadb:10.5"},
{"php-version": "8.3", "db-image": "percona:8.0"}
{"php-version": "8.4", "db-image": "mariadb:10.5"},
{"php-version": "8.4", "db-image": "percona:8.0"}
]
}
'
else
MATRIX='
{
"include": [
{"php-version": "8.3", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mysql:8.4"}
{"php-version": "8.4", "db-image": "mariadb:11.4"},
{"php-version": "8.4", "db-image": "mysql:8.4"}
]
}
'
Expand Down
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
},
"require-dev": {
"ext-xml": "*",
"atoum/atoum": "^4.2",
"atoum/stubs": "^2.6",
"atoum/atoum": "dev-main#e43a6a84809635cf5dcdf80bf3c773e7cf1d5a04",
"atoum/stubs": "dev-master#fb8890f347a7ecf1e3cf2b5a139a8b038359a6ab",
"friendsoftwig/twigcs": "^6.4",
"glpi-project/tools": "^0.7",
"mikey179/vfsstream": "^1.6",
Expand Down Expand Up @@ -188,19 +188,21 @@
"post-install-cmd": [
"@php -r \"file_put_contents('.composer.hash', sha1_file('composer.lock'));\"",
"@php -f vendor/bin/build_hw_jsons",
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-invalid-header-ignore.patch || true",
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-address-no-length-check.patch || true",
"patch -f -p1 -d vendor/guzzlehttp/guzzle/ < tools/patches/guzzle-http-client-restrict-http-methods.patch || true"
"@patch"
],
"post-update-cmd": [
"@php -r \"file_put_contents('.composer.hash', sha1_file('composer.lock'));\"",
"@php -f vendor/bin/build_hw_jsons",
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-invalid-header-ignore.patch || true",
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-address-no-length-check.patch || true",
"patch -f -p1 -d vendor/guzzlehttp/guzzle/ < tools/patches/guzzle-http-client-restrict-http-methods.patch || true"
"@patch"
],
"build": [
"bin/console dependencies install"
],
"patch": [
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-invalid-header-ignore.patch || true",
"patch -f -p1 -d vendor/laminas/laminas-mail/ < tools/patches/laminas-mail-address-no-length-check.patch || true",
"patch -f -p1 -d vendor/guzzlehttp/guzzle/ < tools/patches/guzzle-http-client-restrict-http-methods.patch || true",
"patch -f -p1 -d vendor/apereo/phpcas/ < tools/patches/apereo-phpcas-php84.patch || true"
]
}
}
31 changes: 18 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

// Check PHP version not to have trouble
// Need to be the very fist step before any include
if (version_compare(PHP_VERSION, '8.2.0', '<') || version_compare(PHP_VERSION, '8.3.999', '>')) {
exit('PHP version must be between 8.2 and 8.3.');
if (version_compare(PHP_VERSION, '8.2.0', '<') || version_compare(PHP_VERSION, '8.4.999', '>')) {
exit('PHP version must be between 8.2 and 8.4.');
}

// Check the resources state before trying to instanciate the Kernel.
Expand Down
2 changes: 1 addition & 1 deletion src/Consumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static function getMassiveActionsForItemtype(
array &$actions,
$itemtype,
$is_deleted = 0,
CommonDBTM $checkitem = null
?CommonDBTM $checkitem = null
) {
// Special actions only for self
if ($itemtype !== static::class) {
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Asset/Asset_PeripheralAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static function getMassiveActionsForItemtype(
array &$actions,
$itemtype,
$is_deleted = false,
CommonDBTM $checkitem = null
?CommonDBTM $checkitem = null
) {
$action_prefix = __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR;
$specificities = self::getRelationMassiveActionsSpecificities();
Expand Down
6 changes: 3 additions & 3 deletions src/Glpi/DBAL/QueryFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static function ifnull(string|QueryExpression $expression, string|QueryEx
* @param string|null $alias Function result alias (will be automatically quoted)
* @return QueryExpression
*/
public static function groupConcat(string|QueryExpression $expression, ?string $separator = null, bool $distinct = false, array|string $order_by = null, ?string $alias = null): QueryExpression
public static function groupConcat(string|QueryExpression $expression, ?string $separator = null, bool $distinct = false, array|string|null $order_by = null, ?string $alias = null): QueryExpression
{
/** @var \DBmysql $DB */
global $DB;
Expand Down Expand Up @@ -309,7 +309,7 @@ public static function replace(string|QueryExpression $expression, string|QueryE
* @param string|null $alias Function result alias (will be automatically quoted)
* @return QueryExpression
*/
public static function fromUnixtime(string|QueryExpression $expression, string|QueryExpression $format = null, ?string $alias = null): QueryExpression
public static function fromUnixtime(string|QueryExpression $expression, string|QueryExpression|null $format = null, ?string $alias = null): QueryExpression
{
$params = [$expression];
if ($format !== null) {
Expand Down Expand Up @@ -433,7 +433,7 @@ public static function timediff(string|QueryExpression $expression1, string|Quer
* @param string|null $alias Function result alias (will be automatically quoted)
* @return QueryExpression
*/
public static function unixTimestamp(string|QueryExpression $expression = null, ?string $alias = null): QueryExpression
public static function unixTimestamp(string|QueryExpression|null $expression = null, ?string $alias = null): QueryExpression
{
$params = [];
if ($expression !== null) {
Expand Down
6 changes: 3 additions & 3 deletions src/Glpi/Dashboard/FakeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static function getItemCount(?string $itemtype = null)
return $values[$itemtype] ?? null;
}

public static function bigNumberItem(CommonDBTM $item = null, array $params = []): array
public static function bigNumberItem(?CommonDBTM $item = null, array $params = []): array
{
return [
'number' => self::getItemCount($item::class) ?? 1500,
Expand Down Expand Up @@ -278,7 +278,7 @@ public static function nbTicketsByAgreementStatusAndTechnicianGroup(array $param
];
}

public static function nbItemByFk(CommonDBTM $item = null, CommonDBTM $fk_item = null, array $params = []): array
public static function nbItemByFk(?CommonDBTM $item = null, ?CommonDBTM $fk_item = null, array $params = []): array
{
$item_counts = self::getItemCount();
$number_fk = $item_counts[$fk_item::class] ?? 20;
Expand Down Expand Up @@ -306,7 +306,7 @@ public static function nbItemByFk(CommonDBTM $item = null, CommonDBTM $fk_item =
];
}

public static function articleListItem(CommonDBTM $item = null, array $params = []): array
public static function articleListItem(?CommonDBTM $item = null, array $params = []): array
{
$data = [];
for ($i = 0; $i < 5; $i++) {
Expand Down
5 changes: 2 additions & 3 deletions src/Glpi/Features/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ private function checkSetup(): void
global $CFG_GLPI;

if (!in_array(static::class, $CFG_GLPI['state_types'])) {
trigger_error(
throw new \LogicException(
sprintf(
'Class %s must be present in $CFG_GLPI[\'state_types\']',
static::class
),
E_USER_ERROR
)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Form/ServiceCatalog/ServiceCatalogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function (ServiceCatalogItemInterface $item) use ($item_request) {

private function hasChildren(
ItemRequest $item_request,
ServiceCatalogCompositeInterface $composite = null,
?ServiceCatalogCompositeInterface $composite = null,
): bool {
$leaf_providers = array_filter(
$this->providers,
Expand Down
4 changes: 2 additions & 2 deletions src/Glpi/Marketplace/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static function getPluginVersionInfo(array $plugin, string $version): ?a
* @param ?string $version Download a specific version of the plugin
* @return bool
*/
public function downloadPlugin($auto_install = true, string $version = null): bool
public function downloadPlugin($auto_install = true, ?string $version = null): bool
{
if (!self::hasWriteAccess()) {
return false;
Expand Down Expand Up @@ -464,7 +464,7 @@ public function getRequiredOffers(): array
*
* @return bool
*/
public function canBeDownloaded(string $version = null)
public function canBeDownloaded(?string $version = null)
{
$api = self::getAPI();
$api_plugin = $api->getPlugin($this->plugin_key);
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/System/Log/LogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getLogFileInfo(string $filepath): ?array
*
* @return array|null
*/
public function parseLogFile(string $filepath, int $max_nb_lines = null): ?array
public function parseLogFile(string $filepath, ?int $max_nb_lines = null): ?array
{
/** @var array $CFG_GLPI */
global $CFG_GLPI;
Expand Down
6 changes: 3 additions & 3 deletions src/IPAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,9 @@ private static function getCriteriaLinkedToNetwork(IPNetwork $network): array
* @param array $options
**/
public static function getHTMLTableCellsForItem(
HTMLTableRow $row = null,
CommonDBTM $item = null,
HTMLTableCell $father = null,
?HTMLTableRow $row = null,
?CommonDBTM $item = null,
?HTMLTableCell $father = null,
array $options = []
) {
/** @var \DBmysql $DB */
Expand Down
2 changes: 1 addition & 1 deletion src/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public static function getIcon()
return "ti ti-phone-calling";
}

public static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, CommonDBTM $checkitem = null)
public static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, ?CommonDBTM $checkitem = null)
{
/** @var array $CFG_GLPI */
global $CFG_GLPI;
Expand Down
4 changes: 2 additions & 2 deletions src/QueuedWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public static function getPendings($send_time = null, $limit = 20, $extra_where
*
* @return integer either 0 or 1
**/
public static function cronQueuedWebhook(CronTask $task = null)
public static function cronQueuedWebhook(?CronTask $task = null)
{
$cron_status = 0;

Expand All @@ -589,7 +589,7 @@ public static function cronQueuedWebhook(CronTask $task = null)
*
* @return integer either 0 or 1
**/
public static function cronQueuedWebhookClean(CronTask $task = null)
public static function cronQueuedWebhookClean(?CronTask $task = null)
{
/** @var \DBmysql $DB */
global $DB;
Expand Down
2 changes: 1 addition & 1 deletion src/Reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ public static function getIcon()
return "ti ti-calendar-event";
}

public static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, CommonDBTM $checkitem = null)
public static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, ?CommonDBTM $checkitem = null)
{
/** @var array $CFG_GLPI */
global $CFG_GLPI;
Expand Down
2 changes: 1 addition & 1 deletion src/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static function decodeFromUtf8($string, $to_charset = "ISO-8859-1")
*
* @return void
**/
private static function log(LoggerInterface $logger = null, $level = LogLevel::WARNING, $args = null)
private static function log(?LoggerInterface $logger = null, $level = LogLevel::WARNING, $args = null)
{
static $tps = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/autoload/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
);

define('GLPI_MIN_PHP', '8.2'); // Must also be changed in top of public/index.php
define('GLPI_MAX_PHP', '8.3'); // Must also be changed in top of public/index.php
define('GLPI_MAX_PHP', '8.4'); // Must also be changed in top of public/index.php
define('GLPI_YEAR', '2024');

//Define a global recipient address for email notifications
Expand Down
4 changes: 2 additions & 2 deletions tests/src/FormTesterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected function createForm(FormBuilder $builder): Form
protected function getQuestionId(
Form $form,
string $question_name,
string $section_name = null,
?string $section_name = null,
): int {
// Make sure form is up to date
$form->getFromDB($form->getID());
Expand Down Expand Up @@ -239,7 +239,7 @@ protected function getSectionId(
protected function getCommentId(
Form $form,
string $comment_name,
string $section_name = null,
?string $section_name = null,
): int {
// Make sure form is up to date
$form->getFromDB($form->getID());
Expand Down
Loading

0 comments on commit eb1429a

Please sign in to comment.