Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Introduce some Static analysis. (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored Jun 23, 2021
1 parent 76c9f29 commit e2ce71f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
/.gitignore export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CONTRIBUTING.md export-ignore
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- '7.3'
- '7.4'
- '8.0'
analysis: [ false ]
coverage: [ 'none' ]
normalize: [ false ]
validate: [ false ]
Expand All @@ -30,6 +31,7 @@ jobs:
include:
- php: '8.0'
laravel: '8.22'
analysis: true
coverage: 'xdebug'
normalize: true
validate: true
Expand Down Expand Up @@ -64,7 +66,7 @@ jobs:

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

- name: Install Laravel and Orchestra Testbench
run: composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
Expand All @@ -79,6 +81,10 @@ jobs:
- name: Run test suite
run: vendor/bin/phpunit -v

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

- name: Upload coverage results
if: matrix.coverage != 'none'
env:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"mockery/mockery": "^1.0",
"orchestra/database": "~3.8 || ~4.0 || ~5.0 || ~6.0",
"orchestra/testbench": "~3.8 || ~4.0 || ~5.0 || ~6.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "~8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.0"
},
Expand Down
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
level: 1
paths:
- src
- tests
ignoreErrors:
- '#Access to an undefined property Osiset\\ShopifyApp\\Storage\\Models\\.*::\$.*\.#'
- '#Access to an undefined property Osiset\\ShopifyApp\\Test\\Stubs\\.*::\$.*\.#'
- '#Variable \$factory might not be defined\.#'
parallel:
maximumNumberOfProcesses: 2
7 changes: 1 addition & 6 deletions src/ShopifyApp/ShopifyAppProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@ public function register()

// Queriers
IShopQuery::class => [self::CSINGLETON, function () {
$model = $this->app['config']->get('auth.providers.users.model');
$modelInstance = new $model();

return new ShopQuery(
$modelInstance
);
return new ShopQuery();
}],
IPlanQuery::class => [self::CSINGLETON, function () {
return new PlanQuery();
Expand Down
4 changes: 2 additions & 2 deletions src/ShopifyApp/Storage/Queries/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function getByReference(ChargeReference $chargeRef, array $with = []): ?C
*/
public function getByReferenceAndShopId(ChargeReference $chargeRef, ShopId $shopId): ?ChargeModel
{
return ChargeModel
::where('charge_id', $chargeRef->toNative())
return ChargeModel::query()
->where('charge_id', $chargeRef->toNative())
->where('user_id', $shopId->toNative())
->get()
->first();
Expand Down
3 changes: 2 additions & 1 deletion tests/Stubs/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public static function stubResponses(array $stubFiles): void

public function rest(string $method, string $path, array $params = null, array $headers = [], bool $sync = true): array
{
$filename = array_shift(self::$stubFiles);

try {
$filename = array_shift(self::$stubFiles);
$response = json_decode(file_get_contents(__DIR__."/../fixtures/{$filename}.json"), true);
} catch (ErrorException $error) {
throw new Exception("Missing fixture for {$method} @ {$path}, tried: '{$filename}.json'");
Expand Down

0 comments on commit e2ce71f

Please sign in to comment.