Skip to content

Commit

Permalink
Merge pull request #837 from datamweb/refactor-phpstan-rules
Browse files Browse the repository at this point in the history
refactor: refactor for phpstan errors
  • Loading branch information
kenjis authored Sep 16, 2023
2 parents df8c1d4 + 3a03a5a commit 9106a0c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 52 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"mockery/mockery": "^1.0",
"firebase/php-jwt": "^6.4",
"rector/rector": "0.18.3",
"codeigniter/phpstan-codeigniter": "^1.1",
"codeigniter/phpstan-codeigniter": "^1.2",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5"
},
Expand Down
54 changes: 3 additions & 51 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types = 1);
<?php

declare(strict_types=1);

$ignoreErrors = [];
$ignoreErrors[] = [
Expand Down Expand Up @@ -255,22 +257,12 @@
'count' => 1,
'path' => __DIR__ . '/src/Models/TokenLoginModel.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/TokenLoginModel.php',
];
$ignoreErrors[] = [
'message' => '#^Call to deprecated function random_string\\(\\)\\:
The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserIdentityModel.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserIdentityModel.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 2,
Expand All @@ -296,21 +288,11 @@
'count' => 1,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 2,
'path' => __DIR__ . '/tests/Authentication/AuthHelperTest.php',
];
$ignoreErrors[] = [
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#',
'count' => 2,
'path' => __DIR__ . '/tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 2,
'path' => __DIR__ . '/tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php',
];
$ignoreErrors[] = [
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#',
'count' => 3,
Expand All @@ -326,11 +308,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/Authentication/Filters/AbstractFilterTestCase.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 6,
'path' => __DIR__ . '/tests/Authentication/Filters/SessionFilterTest.php',
];
$ignoreErrors[] = [
'message' => '#^Implicit array creation is not allowed \\- variable \\$users might not exist\\.$#',
'count' => 1,
Expand All @@ -346,16 +323,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/Authentication/HasAccessTokensTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 2,
'path' => __DIR__ . '/tests/Authentication/HasAccessTokensTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 4,
'path' => __DIR__ . '/tests/Authorization/AuthorizableTest.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a ternary operator condition, string\\|null given\\.$#',
'count' => 2,
Expand All @@ -366,11 +333,6 @@
'count' => 6,
'path' => __DIR__ . '/tests/Unit/Authentication/JWT/JWTManagerTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Unit/UserModelTest.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:getLastQuery\\(\\)\\.$#',
'count' => 1,
Expand All @@ -386,16 +348,6 @@
'count' => 2,
'path' => __DIR__ . '/tests/Unit/UserTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$email on array\\|object\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/Unit/UserTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$id on array\\|object\\.$#',
'count' => 4,
'path' => __DIR__ . '/tests/Unit/UserTest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$password_hash on array\\|object\\.$#',
'count' => 1,
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public function testUpdateEmail(): void
$users = model(UserModel::class);
$users->save($this->user);

/** @var User $user */
$user = $users->find($this->user->id);

$this->seeInDatabase($this->tables['identities'], [
Expand Down Expand Up @@ -250,6 +251,7 @@ public function testUpdatePasswordHash(): void
$users = model(UserModel::class);
$users->save($this->user);

/** @var User $user */
$user = $users->find($this->user->id);

$this->seeInDatabase($this->tables['identities'], [
Expand Down

0 comments on commit 9106a0c

Please sign in to comment.