Skip to content

Commit fc7e72b

Browse files
committed
phpstan and phpcs fixes
1 parent 7824da0 commit fc7e72b

37 files changed

+223
-99
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
"firebase/php-jwt": "^6.2"
3636
},
3737
"require-dev": {
38-
"cakephp/cakephp-codesniffer": "~4.4.0",
38+
"cakephp/cakephp-codesniffer": "^4.5",
3939
"league/flysystem-vfs": "^1.0",
40+
"phpstan/phpstan": "^1.8",
4041
"phpunit/phpunit": "^9.5",
42+
"robthree/twofactorauth": "^1.6",
43+
"web-auth/webauthn-lib": "^3.3.11",
4144
"vlucas/phpdotenv": "^3.3"
4245
},
4346
"autoload": {

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 4
6-
autoload_files:
5+
level: 2
6+
bootstrapFiles:
77
- tests/bootstrap.php
88
ignoreErrors:
99

src/Command/ServiceRoutesCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
6868
$service = ServiceRegistry::getServiceLocator()->get($serviceName);
6969
if ($service === null) {
7070
$io->error(__('Service "{0}" not found', $serviceName));
71+
7172
return Command::CODE_ERROR;
7273
}
7374

src/Model/Entity/AuthStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* AuthStore Entity
1010
*
1111
* @property string $id
12-
* @property string|null $store
12+
* @property array|null $store
1313
* @property \Cake\I18n\FrozenTime $created
1414
* @property \Cake\I18n\FrozenTime $modified
1515
*/

src/Model/Entity/JwtRefreshToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JwtRefreshToken extends Entity
3535
* be mass assigned. For security purposes, it is advised to set '*' to false
3636
* (or remove it), and explicitly make individual fields accessible as needed.
3737
*
38-
* @var array
38+
* @var array<string, bool>
3939
*/
4040
protected $_accessible = [
4141
'*' => true,
@@ -45,7 +45,7 @@ class JwtRefreshToken extends Entity
4545
/**
4646
* Fields that are excluded from JSON versions of the entity.
4747
*
48-
* @var array
48+
* @var array<string>
4949
*/
5050
protected $_hidden = [
5151
'token',

src/Model/Table/AuthStoreTable.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
namespace CakeDC\Api\Model\Table;
55

66
use Cake\Database\Schema\TableSchemaInterface;
7-
use Cake\ORM\Query;
8-
use Cake\ORM\RulesChecker;
97
use Cake\ORM\Table;
108
use Cake\Validation\Validator;
119

@@ -25,7 +23,6 @@
2523
* @method \CakeDC\Api\Model\Entity\AuthStore[]|\Cake\Datasource\ResultSetInterface saveManyOrFail(iterable $entities, $options = [])
2624
* @method \CakeDC\Api\Model\Entity\AuthStore[]|\Cake\Datasource\ResultSetInterface|false deleteMany(iterable $entities, $options = [])
2725
* @method \CakeDC\Api\Model\Entity\AuthStore[]|\Cake\Datasource\ResultSetInterface deleteManyOrFail(iterable $entities, $options = [])
28-
*
2926
* @mixin \Cake\ORM\Behavior\TimestampBehavior
3027
*/
3128
class AuthStoreTable extends Table
@@ -62,8 +59,6 @@ public function validationDefault(Validator $validator): Validator
6259
return $validator;
6360
}
6461

65-
66-
6762
/**
6863
* Initialize schema
6964
*

src/Rbac/Rules/TwoFactorPassedScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
namespace CakeDC\Api\Rbac\Rules;
1414

1515
use Authentication\Authenticator\JwtAuthenticator;
16-
use CakeDC\Auth\Rbac\Rules\AbstractRule;
17-
use Cake\Utility\Hash;
1816
use Cake\Routing\Router;
19-
use OutOfBoundsException;
17+
use CakeDC\Auth\Rbac\Rules\AbstractRule;
2018
use Psr\Http\Message\ServerRequestInterface;
2119

2220
/**
2321
* Owner rule class, used to match ownership permissions
2422
*/
2523
class TwoFactorPassedScope extends AbstractRule
2624
{
27-
2825
protected $_defaultConfig = [
2926
];
3027

src/Rbac/Rules/TwoFactorScope.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
namespace CakeDC\Api\Rbac\Rules;
1414

1515
use Authentication\Authenticator\JwtAuthenticator;
16-
use CakeDC\Auth\Rbac\Rules\AbstractRule;
17-
use Cake\Utility\Hash;
1816
use Cake\Routing\Router;
19-
use OutOfBoundsException;
17+
use CakeDC\Auth\Rbac\Rules\AbstractRule;
2018
use Psr\Http\Message\ServerRequestInterface;
2119

2220
/**
2321
* Owner rule class, used to match ownership permissions
2422
*/
2523
class TwoFactorScope extends AbstractRule
2624
{
27-
2825
protected $_defaultConfig = [
2926
];
3027

src/Routing/ApiRouter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ class ApiRouter extends Router
9595
/**
9696
* A hash of request context data.
9797
*
98-
* @var array
98+
* @var array<string, mixed>
9999
*/
100100
protected static $_requestContext = [];
101101

102102
/**
103103
* Named expressions
104104
*
105-
* @var array
105+
* @var array<string, string>
106106
*/
107107
protected static $_namedExpressions = [
108108
'Action' => Router::ACTION,
@@ -132,14 +132,14 @@ class ApiRouter extends Router
132132
* The stack of URL filters to apply against routing URLs before passing the
133133
* parameters to the route collection.
134134
*
135-
* @var array
135+
* @var array<callable(): mixed>
136136
*/
137137
protected static $_urlFilters = [];
138138

139139
/**
140140
* Default extensions defined with Router::extensions()
141141
*
142-
* @var array
142+
* @var array<string>
143143
*/
144144
protected static $_defaultExtensions = [];
145145
}

src/Service/Action/Auth/JwtSocialLoginAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class JwtSocialLoginAction extends Action
2828
* Execute action.
2929
*
3030
* @return mixed
31-
* @throws \CakeDC\Api\Service\Action\Exception
31+
* @throws \Exception
3232
*/
3333
public function execute()
3434
{
@@ -38,6 +38,6 @@ public function execute()
3838
return false;
3939
}
4040

41-
return $this->generateTokenResponse($user);
41+
return $this->generateTokenResponse($user, 'login');
4242
}
4343
}

0 commit comments

Comments
 (0)