From 8033d6ec29c3ed9b8223122f75ad6fb9655779c3 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Wed, 7 Aug 2024 12:52:32 -0400 Subject: [PATCH] PHP 8.4 - implicit nulls are deprecated `MobileDetect::__construct(): Implicitly marking parameter $cache as nullable is deprecated, the explicit nullable type must be used instead` `CacheException::__construct(): Implicitly marking parameter $previous as nullable is deprecated, the explicit nullable type must be used instead` Updated Github Actions workflow to include PHP 8.4 Fixes #956 Replaces #957 --- .github/workflows/4.8.x-test.yml | 12 +++++------- composer.json | 4 ++-- src/Cache/CacheException.php | 2 +- src/MobileDetect.php | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/4.8.x-test.yml b/.github/workflows/4.8.x-test.yml index 6ccd106e..9c72d4d7 100644 --- a/.github/workflows/4.8.x-test.yml +++ b/.github/workflows/4.8.x-test.yml @@ -4,14 +4,14 @@ name: 4.8.x on PHP 8.x on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - + push: branches: ['4.8.x'] paths-ignore: - '*.md' - '.github/**' - 'scripts/**' - + pull_request: branches: ['4.8.x'] paths-ignore: @@ -24,12 +24,10 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - php-version: [8.0, 8.1, 8.2, 8.3] + php-version: [8.0, 8.1, 8.2, 8.3, 8.4] os: ['ubuntu-latest'] - include: - - os: 'ubuntu-latest' - phpunit-version: '9.6.10' - composer-version: 'latest' + composer-version: ['latest'] + phpunit-version: ['^9.6.18'] steps: - name: Checkout uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index e789b8c2..a56408bf 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,10 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^v3.35.1", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^9.6.18", "squizlabs/php_codesniffer": "^3.7", "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.12.x-dev" }, "autoload": { "psr-4": { diff --git a/src/Cache/CacheException.php b/src/Cache/CacheException.php index 7b65809d..e23bcd8a 100644 --- a/src/Cache/CacheException.php +++ b/src/Cache/CacheException.php @@ -6,7 +6,7 @@ class CacheException extends \Exception { - public function __construct($message, $code = 0, \Throwable $previous = null) + public function __construct($message, $code = 0, ?\Throwable $previous = null) { // some code diff --git a/src/MobileDetect.php b/src/MobileDetect.php index 243e06a0..7ae308b5 100644 --- a/src/MobileDetect.php +++ b/src/MobileDetect.php @@ -1028,11 +1028,11 @@ class MobileDetect * Construct an instance of this class. */ public function __construct( - Cache $cache = null, + ?Cache $cache = null, array $config = [], ) { // If no custom cache provided then use our own. - $this->cache = $cache == null ? new Cache() : $cache; + $this->cache = $cache ?? new Cache(); // Override config from user. $this->config = array_merge($this->config, $config);