Skip to content

Commit d68fa1c

Browse files
committed
Use PHPStan level 1 + fixes
1 parent 954aa63 commit d68fa1c

25 files changed

+125
-8
lines changed

.github/workflows/analyse.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: analyse
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '*.x'
8+
pull_request:
9+
10+
jobs:
11+
analyse:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [8.3]
17+
stability: [prefer-stable]
18+
include:
19+
- laravel: 10.*
20+
testbench: 8.*
21+
- laravel: 11.*
22+
testbench: 9.*
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
ref: ${{ github.head_ref }}
28+
token: ${{ secrets.RAPIDEZ_ACTIONS_ACCOUNT_PAT }}
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
35+
coverage: none
36+
37+
- name: Install dependencies
38+
run: |
39+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
40+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
41+
- name: Analyse
42+
run: composer analyse

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
"tormjens/eventy": "^0.8"
3030
},
3131
"require-dev": {
32+
"larastan/larastan": "^2.9",
3233
"laravel/dusk": "^8.2",
3334
"orchestra/testbench": "^9.4",
3435
"orchestra/testbench-dusk": "^9.7",
36+
"phpstan/phpstan": "^1.12",
3537
"phpunit/phpunit": "^10.5.34|^11.3.5"
3638
},
3739
"autoload": {
@@ -61,6 +63,7 @@
6163
}
6264
},
6365
"scripts": {
66+
"analyse": "phpstan --memory-limit=256M",
6467
"dusk:prepare": [
6568
"./vendor/bin/dusk-updater detect --auto-update",
6669
"@php -r \"file_exists('phpunit.dusk.xml') || copy('phpunit.dusk.xml.dist', 'phpunit.dusk.xml'); \""

config/rapidez/models.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'attribute' => Rapidez\Core\Models\Attribute::class,
77
'product' => Rapidez\Core\Models\Product::class,
88
'category' => Rapidez\Core\Models\Category::class,
9+
'customer_group' => Rapidez\Core\Models\CustomerGroup::class,
910
'category_product' => Rapidez\Core\Models\CategoryProduct::class,
1011
'customer' => Rapidez\Core\Models\Customer::class,
1112
'config' => Rapidez\Core\Models\Config::class,

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
includes:
2+
- ./vendor/larastan/larastan/extension.neon
3+
4+
parameters:
5+
paths:
6+
- src/
7+
- tests/
8+
- routes/
9+
ignoreErrors:
10+
- '#^Result of static method TorMorten\\Eventy\\Events::#'
11+
level: 1

src/Actions/DecodeJwt.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Lcobucci\JWT\Validation\Constraint\SignedWith;
1616
use Lcobucci\JWT\Validation\ConstraintViolation;
1717
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
18+
use Rapidez\Core\Exceptions\DecryptionException;
1819

1920
class DecodeJwt
2021
{
@@ -39,7 +40,7 @@ public static function decode(string $jwt): UnencryptedToken
3940
}
4041
}
4142

42-
throw $exception;
43+
throw $exception ?? new DecryptionException('No crypt keys defined.');
4344
}
4445

4546
/**

src/Auth/MagentoCartTokenGuard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static function register()
1616
});
1717

1818
auth()->extend('magento-cart', function (Application $app, string $name, array $config) {
19-
return new static(auth()->createUserProvider($config['provider']), request(), 'mask', 'mask');
19+
return new self(auth()->createUserProvider($config['provider']), request(), 'mask', 'mask');
2020
});
2121

2222
config([

src/Auth/MagentoCustomerTokenGuard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static function register()
1717
});
1818

1919
auth()->extend('magento-customer', function (Application $app, string $name, array $config) {
20-
return new static(auth()->createUserProvider($config['provider']), request(), 'token', 'token');
20+
return new self(auth()->createUserProvider($config['provider']), request(), 'token', 'token');
2121
});
2222

2323
config([

src/Casts/QuoteItems.php

Whitespace-only changes.

src/ContentVariables/Widget.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ public function __invoke($content)
99
return preg_replace_callback('/{{widget type="(.*?)" (.*?)}}/ms', function ($matches) {
1010
[$full, $type, $parameters] = $matches;
1111
preg_match_all('/(.*?)="(.*?)"/ms', $parameters, $parameters, PREG_SET_ORDER);
12+
13+
$options = [];
1214
foreach ($parameters as $parameter) {
1315
[$full, $parameter, $value] = $parameter;
1416
$options[trim($parameter)] = trim($value);
1517
}
1618

17-
if (! isset($type)) {
19+
if (! $type) {
1820
return '';
1921
}
2022

src/Facades/Rapidez.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @method static array getStores($storeId = null)
1515
* @method static array getStore($storeId)
1616
* @method static void setStore($store)
17+
* @method static mixed withStore(\Rapidez\Core\Models\Store|array|callable|int|string $store, callable $callback, mixed ...$args)
1718
*
1819
* @see \Rapidez\Core\Rapidez
1920
*/

0 commit comments

Comments
 (0)