Skip to content

Commit e79b807

Browse files
feat(php 8.2): Updates for PHP 8.2 compatibility
2 parents 765e1bd + 1624b79 commit e79b807

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- Do not cache bypass decision in stream mode
1313
- Replace unauthorized chars by underscore `_` in cache key
1414

15+
### Added
16+
- Add compatibility with PHP 8.2
17+
1518
### Fixed
1619
- Fix decision duration parsing when it uses milliseconds
1720

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"ext-json": "*"
5151
},
5252
"require-dev": {
53-
"phpunit/phpunit": "8.5.27",
53+
"phpunit/phpunit": "^8.5.30 || ^9.3",
5454
"ext-curl": "*"
5555
},
5656
"suggest": {

src/AbstractCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ private function configureAdapter(): void
583583
$this->adapter = new RedisTagAwareAdapter((RedisAdapter::createConnection($redisDsn)));
584584
} catch (Exception $e) {
585585
throw new BouncerException('Error when connecting to Redis.' .
586-
' Please fix the Redis DSN or select another cache technology.');
586+
' Please fix the Redis DSN or select another cache technology.' .
587+
' Initial error was: ' . $e->getMessage());
587588
}
588589
break;
589590

@@ -619,7 +620,7 @@ private static function parseDurationToSeconds(string $duration): int
619620
$re = '/(-?)(?:(?:(\d+)h)?(\d+)m)?(\d+).\d+(m?)s/m';
620621
preg_match($re, $duration, $matches);
621622
if (!\count($matches)) {
622-
throw new BouncerException("Unable to parse the following duration: ${$duration}.");
623+
throw new BouncerException('Unable to parse the following duration: ' . $duration);
623624
}
624625
$seconds = 0;
625626
if (isset($matches[2])) {

src/Fixes/Gregwar/Captcha/CaptchaBuilder.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55
use Gregwar\Captcha\CaptchaBuilder as GregwarCaptchaBuilder;
66

77
/**
8-
* Override to fix "implicit conversion error on PHP 8.1"
8+
* Override to :
9+
* - fix "implicit conversion error on PHP 8.1"
10+
* - fix "creation of dynamic property $background error on PHP 8.2"
11+
*
12+
*
913
* @see https://github.com/crowdsecurity/php-cs-bouncer/issues/62 and
1014
* @see https://github.com/Gregwar/Captcha/pull/101/files
1115
* @SuppressWarnings(PHPMD.ElseExpression)
1216
*
1317
*/
1418
class CaptchaBuilder extends GregwarCaptchaBuilder
1519
{
20+
/**
21+
* @var false|int
22+
*/
23+
protected $background = false;
1624
/**
1725
* Writes the phrase on the image
1826
*/

src/Remediation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public static function sortRemediationByPriority(array $remediations): array
5757
}
5858

5959
// Sort by priorities.
60-
/** @var callable $compareFunction */
61-
$compareFunction = 'self::comparePriorities';
60+
/** @var callable $compareFunction */
61+
$compareFunction = self::class . '::comparePriorities';
6262
usort($remediationsWithPriorities, $compareFunction);
6363

6464
return $remediationsWithPriorities;

tests/end-to-end/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"jest-playwright-preset": "^1.4.3",
2424
"jest-runner": "^26.6.3",
2525
"lodash": "^4.17.21",
26-
"playwright-chromium": "1.22.2",
27-
"soap": "^0.42.0",
26+
"playwright-chromium": "^1.27.1",
2827
"ws": "^7.4.6"
2928
}
3029
}

0 commit comments

Comments
 (0)