diff --git a/README.md b/README.md
index d99d06f..1ea645a 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@
## Dependencies
-- [v5.6 <= PHP <= v7.0.15](http://php.net/downloads.php)
+- [PHP >= 8.1](http://php.net/downloads.php)
## Installation
diff --git a/composer.json b/composer.json
index 8dae19f..61d4b04 100644
--- a/composer.json
+++ b/composer.json
@@ -14,8 +14,8 @@
"type": "library",
"require": {
"mustache/mustache": "^2.11.1",
- "guzzlehttp/guzzle": "~6.0",
- "php": ">=5.5",
+ "guzzlehttp/guzzle": "^7.0",
+ "php": ">=8.1",
"psr/log": "^1.0.2"
},
"config": {
@@ -27,8 +27,8 @@
}
},
"require-dev": {
- "phpunit/phpunit": "5.6.*",
- "mockery/mockery": "0.9.*",
+ "phpunit/phpunit": "^7.5",
+ "mockery/mockery": "^1.3",
"overtrue/phplint": "^1.1"
},
"autoload-dev": {
diff --git a/src/CookieV3.php b/src/CookieV3.php
index 3d51a9f..49f8d16 100644
--- a/src/CookieV3.php
+++ b/src/CookieV3.php
@@ -19,7 +19,7 @@ public function __construct($pxCtx, $pxConfig)
$payloadParts = explode(":", $pxCtx->getPxCookie());
if (count($payloadParts) < $cookieValidPartsNumber) {
- return null;
+ throw new PerimeterxException("Invalid cookie format: expected at least {$cookieValidPartsNumber} parts");
}
list($hash, $cookie) = explode(":", $pxCtx->getPxCookie(), 2);
$this->pxPayload = $cookie;
diff --git a/src/PerimeterxContext.php b/src/PerimeterxContext.php
index 4dd5c91..0ff697b 100644
--- a/src/PerimeterxContext.php
+++ b/src/PerimeterxContext.php
@@ -54,8 +54,8 @@ public function __construct($pxConfig, $additionalFields = null)
}
$this->http_method = $_SERVER['REQUEST_METHOD'];
$this->sensitive_route = $this->checkSensitiveRoutePrefix($pxConfig['sensitive_routes'], $this->uri);
- $this->loginCredentials = array_key_exists('loginCredentials', $additionalFields) ? $additionalFields['loginCredentials'] : null;
- $this->graphqlFields = array_key_exists('graphqlFields', $additionalFields) ? $additionalFields['graphqlFields'] : null;
+ $this->loginCredentials = (is_array($additionalFields) && array_key_exists('loginCredentials', $additionalFields)) ? $additionalFields['loginCredentials'] : null;
+ $this->graphqlFields = (is_array($additionalFields) && array_key_exists('graphqlFields', $additionalFields)) ? $additionalFields['graphqlFields'] : null;
$this->requestId = PerimeterxUtils::createUuidV4();
}
diff --git a/src/TokenV3.php b/src/TokenV3.php
index ad27898..be8974f 100644
--- a/src/TokenV3.php
+++ b/src/TokenV3.php
@@ -20,7 +20,7 @@ public function __construct($pxCtx, $pxConfig, $payload)
$payloadParts = explode(":", $payload);
if (count($payloadParts) < $cookieValidPartsNumber) {
- return null;
+ throw new PerimeterxException("Invalid token format: expected at least {$cookieValidPartsNumber} parts");
}
list($hash, $token) = explode(":", $payload, 2);
diff --git a/tests/CredentialsIntelligence/Protocol/V2CredentialsIntelligenceProtocolTest.php b/tests/CredentialsIntelligence/Protocol/V2CredentialsIntelligenceProtocolTest.php
index 65a12f9..0cc828c 100644
--- a/tests/CredentialsIntelligence/Protocol/V2CredentialsIntelligenceProtocolTest.php
+++ b/tests/CredentialsIntelligence/Protocol/V2CredentialsIntelligenceProtocolTest.php
@@ -1,10 +1,11 @@
params = [
'app_id' => 'PX_APP_ID',
@@ -20,7 +20,7 @@ protected function setUp()
];
}
- protected function tearDown()
+ protected function tearDown(): void
{
$reflection = new ReflectionClass($this->px);
$instance = $reflection->getProperty('instance');
diff --git a/tests/PerimeterxCookieV3ValidatorTest.php b/tests/PerimeterxCookieV3ValidatorTest.php
index de029dd..7f2fdb5 100644
--- a/tests/PerimeterxCookieV3ValidatorTest.php
+++ b/tests/PerimeterxCookieV3ValidatorTest.php
@@ -6,7 +6,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\AbstractLogger;
-class PerimeterxCookieV3ValidatorTest extends PHPUnit_Framework_TestCase
+class PerimeterxCookieV3ValidatorTest extends PHPUnit\Framework\TestCase
{
// randomly generated fake values
diff --git a/tests/PerimeterxCookieValidatorTest.php b/tests/PerimeterxCookieValidatorTest.php
index 8e8c9b5..8e5cb34 100644
--- a/tests/PerimeterxCookieValidatorTest.php
+++ b/tests/PerimeterxCookieValidatorTest.php
@@ -6,7 +6,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\AbstractLogger;
-class PerimeterxCookieValidatorTest extends PHPUnit_Framework_TestCase
+class PerimeterxCookieValidatorTest extends PHPUnit\Framework\TestCase
{
// randomly generated fake values
diff --git a/tests/PerimeterxDataEnrichmentTest.php b/tests/PerimeterxDataEnrichmentTest.php
index 9f23491..ae8360d 100644
--- a/tests/PerimeterxDataEnrichmentTest.php
+++ b/tests/PerimeterxDataEnrichmentTest.php
@@ -8,7 +8,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\AbstractLogger;
-class PerimeterxDataEnrichmentTest extends PHPUnit_Framework_TestCase {
+class PerimeterxDataEnrichmentTest extends PHPUnit\Framework\TestCase {
const COOKIE_KEY = '549Z5UsasvfmVS6kAR3r4ydPnQdnnW4Gcwk35hj5tatZ5B2dqjrQvMMyLAJN5de3';
public function testNoPxdeCookie() {
diff --git a/tests/PerimeterxFieldExtractorManagerTest.php b/tests/PerimeterxFieldExtractorManagerTest.php
index 2011d8a..79d630a 100644
--- a/tests/PerimeterxFieldExtractorManagerTest.php
+++ b/tests/PerimeterxFieldExtractorManagerTest.php
@@ -4,8 +4,9 @@
use Perimeterx\CredentialsIntelligence\PerimeterxFieldExtractor;
use Perimeterx\CredentialsIntelligence\PerimeterxFieldExtractorManager;
use Perimeterx\CredentialsIntelligence\Protocol\V1CredentialsIntelligenceProtocol;
+use PHPUnit\Framework\TestCase;
-class PerimeterxFieldExtractorManagerTest extends PHPUnit_Framework_TestCase
+class PerimeterxFieldExtractorManagerTest extends TestCase
{
const LOGIN_REQUEST_URI = "/login";
const LOGIN_REQUEST_METHOD = "POST";
@@ -32,7 +33,7 @@ class PerimeterxFieldExtractorManagerTest extends PHPUnit_Framework_TestCase
*/
private $fieldExtractorManager;
- public function setUp() {
+ protected function setUp(): void {
$mapKey = PerimeterxFieldExtractorManager::generateMapKey(self::LOGIN_REQUEST_URI, self::LOGIN_REQUEST_METHOD);
$mockExtractor = $this->createMock(PerimeterxFieldExtractor::class);
$mockExtractor
diff --git a/tests/PerimeterxFirstPartyClientTest.php b/tests/PerimeterxFirstPartyClientTest.php
index 07f9d7b..8ab034c 100644
--- a/tests/PerimeterxFirstPartyClientTest.php
+++ b/tests/PerimeterxFirstPartyClientTest.php
@@ -1,4 +1,5 @@
'PX_APP_ID',
diff --git a/tests/PerimeterxOriginalTokenValidatorTest.php b/tests/PerimeterxOriginalTokenValidatorTest.php
index b0c814a..a7ca257 100644
--- a/tests/PerimeterxOriginalTokenValidatorTest.php
+++ b/tests/PerimeterxOriginalTokenValidatorTest.php
@@ -6,7 +6,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Log\AbstractLogger;
-class PerimeterxOriginalTokenValidatorTest extends PHPUnit_Framework_TestCase
+class PerimeterxOriginalTokenValidatorTest extends PHPUnit\Framework\TestCase
{
// randomly generated fake values
const COOKIE_KEY = '549Z5UsasvfmVS6kAR3r4ydPnQdnnW4Gcwk35hj5tatZ5B2dqjrQvMMyLAJN5de3';
diff --git a/tests/PerimeterxS2SValidatorTest.php b/tests/PerimeterxS2SValidatorTest.php
index dbd6f34..bf2f8e9 100644
--- a/tests/PerimeterxS2SValidatorTest.php
+++ b/tests/PerimeterxS2SValidatorTest.php
@@ -1,4 +1,5 @@