From 08fd01559f0eb5dac796417711754c6f7cfe9320 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 09:42:27 +0100 Subject: [PATCH 1/7] Bumping PHP to supported version from 8.0 to 8.2 and using the same version to run tests as CS fixer warns about not using higher version --- .github/workflows/tests.yml | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a89bffc..895f6bb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,7 +49,7 @@ jobs: - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.2 ini-values: session.save_handler=redis, session.save_path="tcp://127.0.0.1:6379" extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql coverage: pcov @@ -159,7 +159,7 @@ jobs: - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.2 extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql - name: Install dependencies diff --git a/composer.json b/composer.json index 783515b..5229488 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } }, "require": { - "php": ">=8.0", + "php": ">=8.2", "ext-json": "*", "psr/log": "~1.0 || ~2.0 || ~3.0", "psr/http-client": "^1.0", From 68945bd3fd9e190478a9b9ee8eb5386f10b6fdf9 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 10:52:39 +0100 Subject: [PATCH 2/7] composer update friendsofphp/php-cs-fixer -W --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5229488..1429891 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "kint-php/kint": "^4.1", - "friendsofphp/php-cs-fixer": "^3.73", + "friendsofphp/php-cs-fixer": "^3.93", "phpunit/phpunit": "~9.5.0", "guzzlehttp/guzzle": "^7.5", "phpstan/phpstan": "^1.11" From 4f16ff0d9c3934a82eb1e2f92ab4be4219e9be2b Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 10:52:46 +0100 Subject: [PATCH 3/7] Running CS Fixer --- lib/Api/Api.php | 2 +- lib/Auth/OAuth.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Api/Api.php b/lib/Api/Api.php index ed351c5..46df3be 100644 --- a/lib/Api/Api.php +++ b/lib/Api/Api.php @@ -111,7 +111,7 @@ public function __construct(AuthInterface $auth, $baseUrl = '') public function getLogger() { // If a logger hasn't been set, use NullLogger - if (!($this->logger instanceof LoggerInterface)) { + if (!$this->logger instanceof LoggerInterface) { $this->logger = new NullLogger(); } diff --git a/lib/Auth/OAuth.php b/lib/Auth/OAuth.php index 36d3089..e2c0d3c 100755 --- a/lib/Auth/OAuth.php +++ b/lib/Auth/OAuth.php @@ -471,9 +471,8 @@ protected function authorize(array $scope = [], $scope_separator = ',', $attach if (!$this->_do_not_redirect) { header('Location: '.$authUrl); exit; - } else { - throw new AuthorizationRequiredException($authUrl); } + throw new AuthorizationRequiredException($authUrl); } /** From c10dc868d39c7de673c728155b79ca9449f4fef8 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 10:55:16 +0100 Subject: [PATCH 4/7] Updating PHPSTAN, adding 1G RAM limit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1429891..5c6fa29 100644 --- a/composer.json +++ b/composer.json @@ -27,14 +27,14 @@ "friendsofphp/php-cs-fixer": "^3.93", "phpunit/phpunit": "~9.5.0", "guzzlehttp/guzzle": "^7.5", - "phpstan/phpstan": "^1.11" + "phpstan/phpstan": "^2.1" }, "suggest": { "guzzlehttp/guzzle": "A popular HTTP client that implements psr/http-client-implementation." }, "scripts": { "test": "vendor/bin/phpunit", - "phpstan": "vendor/bin/phpstan analyse" + "phpstan": "php -d memory_limit=1G vendor/bin/phpstan analyse" }, "config": { "allow-plugins": { From 1852343f685365d35e7a272f5377f1608d10e0db Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 10:58:21 +0100 Subject: [PATCH 5/7] Adding and running Rector --- composer.json | 3 ++- rector.php | 16 ++++++++++++++++ tests/Api/CampaignsTest.php | 2 +- tests/Api/ContactsTest.php | 2 +- tests/Api/FormsTest.php | 2 +- tests/Api/PointTriggersTest.php | 2 +- tests/Api/SegmentsTest.php | 2 +- 7 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 5c6fa29..e02ab38 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "friendsofphp/php-cs-fixer": "^3.93", "phpunit/phpunit": "~9.5.0", "guzzlehttp/guzzle": "^7.5", - "phpstan/phpstan": "^2.1" + "phpstan/phpstan": "^2.1", + "rector/rector": "^2.3" }, "suggest": { "guzzlehttp/guzzle": "A popular HTTP client that implements psr/http-client-implementation." diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..6c35c4b --- /dev/null +++ b/rector.php @@ -0,0 +1,16 @@ +withPaths([ + __DIR__ . '/lib', + __DIR__ . '/tests', + ]) + // uncomment to reach your current PHP version + // ->withPhpSets() + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/tests/Api/CampaignsTest.php b/tests/Api/CampaignsTest.php index 263d4f5..a17ee92 100644 --- a/tests/Api/CampaignsTest.php +++ b/tests/Api/CampaignsTest.php @@ -308,7 +308,7 @@ public function testAddAndRemove() public function testBatchEndpoints() { - $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action) { + $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action): void { switch ($action) { case 'create': foreach ($batch as &$item) { diff --git a/tests/Api/ContactsTest.php b/tests/Api/ContactsTest.php index b526d0b..09d6934 100644 --- a/tests/Api/ContactsTest.php +++ b/tests/Api/ContactsTest.php @@ -52,7 +52,7 @@ protected function assertEventResponse($response, $expectedEvents = null) $this->assertTrue(isset($response['filters'])); if ($expectedEvents) { - foreach ($expectedEvents as $key => $eventName) { + foreach ($expectedEvents as $eventName) { $actual = 'oops Missing'; foreach ($response['events'] as $event) { if ($eventName == $event['event']) { diff --git a/tests/Api/FormsTest.php b/tests/Api/FormsTest.php index 536e0f1..ae509cf 100644 --- a/tests/Api/FormsTest.php +++ b/tests/Api/FormsTest.php @@ -196,7 +196,7 @@ public function testFieldAndActionDeleteViaPut() public function testBatchEndpoints() { - $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action) { + $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action): void { switch ($action) { case 'create': foreach ($batch as &$item) { diff --git a/tests/Api/PointTriggersTest.php b/tests/Api/PointTriggersTest.php index a05cf46..36f8226 100644 --- a/tests/Api/PointTriggersTest.php +++ b/tests/Api/PointTriggersTest.php @@ -146,7 +146,7 @@ public function testGetEventTypes() public function testBatchEndpoints() { - $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action) { + $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action): void { switch ($action) { case 'create': foreach ($batch as &$item) { diff --git a/tests/Api/SegmentsTest.php b/tests/Api/SegmentsTest.php index 7bdb6cb..c68d2a3 100644 --- a/tests/Api/SegmentsTest.php +++ b/tests/Api/SegmentsTest.php @@ -161,7 +161,7 @@ public function testAddAndRemove() public function testBatchEndpoints() { - $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action) { + $this->standardTestBatchEndpoints(null, function ($response, &$batch, $action): void { switch ($action) { // Add extra values to the batch after create, as the API returns them in the response. // This is probably related to https://github.com/mautic/mautic/pull/8649 From dff5c9b3f53fc646647d3e3020313445a44278f6 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 11:23:19 +0100 Subject: [PATCH 6/7] Adding Rector to CI --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 895f6bb..b85c50d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,4 +171,7 @@ jobs: run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --using-cache=no --show-progress=dots --diff $(git diff -- '*.php' --name-only --diff-filter=ACMRTUXB "HEAD~..HEAD") - name: Run PHPSTAN tests - run: composer phpstan \ No newline at end of file + run: composer phpstan + + - name: Run Rector tests + run: vendor/bin/rector process --dry-run \ No newline at end of file From 047b37306c48fcc49eaf56fdc8e3a2d2eacb210a Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 26 Jan 2026 13:58:21 +0100 Subject: [PATCH 7/7] Updating readme with requirements --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6eabaa1..540afc1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # Using the Mautic API Library ## Requirements -* PHP 8.0 or newer +* PHP 8.2 or newer ## Installing the API Library You can install the API Library with the following command: