Skip to content

Upgrade PHP requirement: 8.0 → 8.1, code adjustments #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
max-parallel: 3
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
Expand All @@ -20,33 +19,17 @@ jobs:
normalize: [ false ]
validate: [ false ]
laravel:
- '8.22'
- '9.0'
- '10.0'
- '11.0.3'
- '12.0'
- '10.48.29'
- '11.45.1'
- '12.19.3'
exclude:
- php: '8.0'
laravel: '9.0'
- php: '8.0'
laravel: '10.0'
- php: '8.1'
laravel: '8.22'
laravel: '11.45.1'
- php: '8.1'
laravel: '9.0'
- php: '8.2'
laravel: '8.22'
- php: '8.2'
laravel: '9.0'
- php: '8.3'
laravel: '8.22'
- php: '8.3'
laravel: '9.0'
- php: '8.4'
laravel: '12.0'
laravel: '12.19.3'
include:
- php: '8.0'
laravel: '9.39.0'
- php: '8.1'
laravel: '10.48.29'
analysis: true
coverage: 'xdebug'
normalize: true
Expand All @@ -69,9 +52,6 @@ jobs:
if: matrix.validate == true
run: composer validate --strict

- name: Install Laravel legacy factories support
if: matrix.laravel != '7.0'
run: composer require "laravel/legacy-factories:^1.1" --dev --no-interaction --no-update

#- name: Install Laravel and Orchestra Testbench
# run: composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
Expand All @@ -94,14 +74,13 @@ jobs:
run: composer install --prefer-dist --no-progress

- name: Normalize composer file
if: matrix.normalize == true && matrix.php != '8.0'
if: matrix.normalize == true
run: composer normalize --dry-run

- name: Run test suite
run: vendor/bin/phpunit -v
run: vendor/bin/phpunit

- name: Run static code analysis
if: matrix.analysis == true
run: vendor/bin/phpstan --memory-limit=-1

- name: Upload coverage results
Expand Down
1 change: 1 addition & 0 deletions .phpunit.cache/test-results

Large diffs are not rendered by default.

57 changes: 28 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "kyon147/laravel-shopify",
"description": "Shopify package for Laravel to aide in app development",
"license": "MIT",
"keywords": [
"api",
"callback-url",
Expand All @@ -16,36 +17,52 @@
"shopify-app",
"webhook"
],
"license": "MIT",
"authors": [
{
"name": "Luke (Kyon147)",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/Kyon147/laravel-shopify/issues",
"forum": "https://github.com/Kyon147/laravel-shopify/discussions",
"wiki": "https://github.com/Kyon147/laravel-shopify/wiki",
"source": "https://github.com/Kyon147/laravel-shopify"
},
"require": {
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
"php": ">=8.1",
"ext-json": "*",
"funeralzone/valueobjects": "^0.5",
"gnikyt/basic-shopify-api": "^11.0",
"jenssegers/agent": "^2.6",
"laravel/framework": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"gnikyt/basic-shopify-api": "^9.0 || ^10.0 || ^11.0"
"laravel/framework": "^10.0 || ^11.0 || ^12.0"
},
"require-dev": {
"laravel/legacy-factories": "^v1.3.0",
"ergebnis/composer-normalize": "^2.8",
"friendsofphp/php-cs-fixer": "^3.0",
"laravel/legacy-factories": "^1.3.0",
"mockery/mockery": "^1.0",
"orchestra/database": "~3.8 || ~4.0 || ~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0",
"orchestra/testbench": "~3.8 || ~4.0 || ~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "~8.0 || ^9.0 || ^10.0 || ^11.0"
"orchestra/testbench": "^8.0 || ^9.0",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Osiset\\ShopifyApp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Osiset\\ShopifyApp\\Test\\": "tests/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"ergebnis/composer-normalize": true
}
},
"sort-packages": true
},
"extra": {
"laravel": {
Expand All @@ -54,28 +71,10 @@
]
}
},
"autoload": {
"psr-4": {
"Osiset\\ShopifyApp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Osiset\\ShopifyApp\\Test\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"lint": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/phpunit",
"test-html-cov": "vendor/bin/phpunit --coverage-html ./build/html/",
"test-no-cov": "vendor/bin/phpunit --no-coverage"
},
"support": {
"issues": "https://github.com/Kyon147/laravel-shopify/issues",
"forum": "https://github.com/Kyon147/laravel-shopify/discussions",
"wiki": "https://github.com/Kyon147/laravel-shopify/wiki",
"source": "https://github.com/Kyon147/laravel-shopify"
}
}
20 changes: 20 additions & 0 deletions ignore-by-php-version.neon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use PHPStan\DependencyInjection\NeonAdapter;

$adapter = new NeonAdapter();

$config = [];


if (PHP_VERSION_ID >= 80408) {
$config = array_merge_recursive($config, $adapter->load(__DIR__.'/phpstan-baseline-84.neon'));
}

if (PHP_VERSION_ID < 80408) {
$config = array_merge_recursive($config, $adapter->load(__DIR__.'/phpstan-baseline-81.neon'));
}

return $config;
7 changes: 7 additions & 0 deletions phpstan-baseline-81.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Variable \$queryString on left side of \?\? always exists and is not nullable\.$#'
identifier: nullCoalesce.variable
count: 1
path: src/Util.php
49 changes: 49 additions & 0 deletions phpstan-baseline-84.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
parameters:
ignoreErrors:
-
message: '#^Deprecated in PHP 8\.4\: Parameter \#1 \$session \(Gnikyt\\BasicShopifyAPI\\Session\) is implicitly nullable via default value null\.$#'
Copy link
Owner

@Kyon147 Kyon147 Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking, these errors will need to be fixed eventually, as 8.1 / 8.2 won't be support for a lot longer so we will need to move over the 8.3 but might be worth just jumping to 8.4 when that refactor happens.

This would mean bringing in our own API package I think. Unless we can use something Shopify already has but I've not looked.

Thoughts @enmaboya

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kyon147 Fork of the package is currently on hold due to work commitments. However, I expect to publish it soon with fixes for the issues flagged by PHPStan and a minimum PHP version of 8.1 (with further updates planned in the future).

identifier: parameter.implicitlyNullable
count: 1
path: src/Contracts/ApiHelper.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#1 \$session \(Gnikyt\\BasicShopifyAPI\\Session\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 2
path: src/Services/ApiHelper.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#3 \$payload \(array\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: src/Services/ApiHelper.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#2 \$delimiter \(string\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: src/Util.php

-
message: '#^Variable \$queryString on left side of \?\? always exists and is not nullable\.$#'
identifier: nullCoalesce.variable
count: 1
path: src/Util.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#3 \$params \(array\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/Stubs/Api.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#2 \$requestInstance \(Illuminate\\Http\\Request\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/TestCase.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#3 \$cb \(Closure\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/TestCase.php
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- ignore-by-php-version.neon.php

parameters:
level: 1
paths:
Expand Down
56 changes: 25 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<coverage>
<testsuites>
<testsuite name="Laravel Shopify Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging />
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF" />
<env name="SHOPIFY_API_KEY" value="00000000000000000000000000000000" />
<env name="SHOPIFY_API_SECRET" value="00000000000000000000000000000000" />
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
Expand All @@ -26,20 +35,5 @@
<directory>src/Messaging/Events/</directory>
<file>src/ShopifyAppProvider.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<testsuites>
<testsuite name="Laravel Shopify Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="SHOPIFY_API_KEY" value="00000000000000000000000000000000"/>
<env name="SHOPIFY_API_SECRET" value="00000000000000000000000000000000"/>
</php>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/resources/database/factories/ChargeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$factory->define($chargeModel, function (Faker $faker) {
return [
'charge_id' => $faker->randomNumber(8),
'name' => $faker->word,
'name' => $faker->word(),
'price' => $faker->randomFloat(),
'status' => ChargeStatus::ACCEPTED()->toNative(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/resources/database/factories/PlanFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

$factory->define($planModel, function (Faker $faker) {
return [
'name' => $faker->word,
'name' => $faker->word(),
'price' => $faker->randomFloat(),
];
});

$factory->state($planModel, 'usage', function ($faker) {
return [
'capped_amount' => $faker->randomFloat(),
'terms' => $faker->sentence,
'terms' => $faker->sentence(),
];
});

Expand Down
6 changes: 3 additions & 3 deletions src/resources/database/factories/ShopFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

$factory->define($model, function (Faker $faker) {
return [
'name' => "{$faker->domainWord}.myshopify.com",
'password' => str_replace('-', '', $faker->uuid),
'email' => $faker->email,
'name' => "{$faker->domainWord()}.myshopify.com",
'password' => str_replace('-', '', $faker->uuid()),
'email' => $faker->email(),
];
});

Expand Down
2 changes: 0 additions & 2 deletions tests/Stubs/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Orchestra\Testbench\Http\Middleware\RedirectIfAuthenticated;
use Osiset\ShopifyApp\Http\Middleware\AuthProxy;
use Osiset\ShopifyApp\Http\Middleware\AuthWebhook;
use Osiset\ShopifyApp\Http\Middleware\Billable;
Expand All @@ -27,7 +26,6 @@ class Kernel extends \Orchestra\Testbench\Foundation\Http\Kernel
'auth.basic' => AuthenticateWithBasicAuth::class,
'bindings' => SubstituteBindings::class,
'can' => Authorize::class,
'guest' => RedirectIfAuthenticated::class,
'throttle' => ThrottleRequests::class,

// Added for testing
Expand Down
Loading
Loading