Skip to content

Commit 3e26f42

Browse files
committed
apply rector rules for PHP upto 7.4
1 parent c3968a2 commit 3e26f42

File tree

75 files changed

+201
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+201
-414
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@
7272
"test": "phpunit --stderr",
7373
"stan": "phpstan analyse src/",
7474
"psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/ ",
75-
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.7 psalm/phar:~3.8.0 && mv composer.backup composer.json",
75+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.94 psalm/phar:~4.9.2 && mv composer.backup composer.json",
7676
"stan-rebuild-baseline": "phpstan analyse --configuration phpstan.neon --error-format baselineNeon src/ > phpstan-baseline.neon",
7777
"psalm-rebuild-baseline": "php vendor/psalm/phar/psalm.phar --show-info=false --set-baseline=psalm-baseline.xml src/",
7878
"rector": "rector process src/",
79-
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.4.11 && mv composer.backup composer.json",
79+
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.11.2 && mv composer.backup composer.json",
8080
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
8181
}
8282
}

src/Collection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ abstract class Collection extends ObjectRegistry implements IteratorAggregate
2424

2525
/**
2626
* Config array.
27-
*
28-
* @var array
2927
*/
30-
protected $_defaultConfig = [];
28+
protected array $_defaultConfig = [];
3129

3230
/**
3331
* Constructor

src/Exception/ValidationException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ class ValidationException extends ServiceException
2222

2323
/**
2424
* Validation errors
25-
*
26-
* @var array
2725
*/
28-
protected $_validationErrors = [];
26+
protected array $_validationErrors = [];
2927

3028
/**
3129
* Construct method, for fast instantiation

src/Middleware/ParseApiRequestMiddleware.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
7878
*/
7979
protected function _matchRequest(ServerRequestInterface $request, RequestHandlerInterface $handler, $matches)
8080
{
81+
$service = null;
8182
$version = $matches['version'] ?? null;
8283
$serviceName = $matches['service'];
8384

src/Rbac/ApiRbac.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ class ApiRbac implements RbacInterface
3838
/**
3939
* @var array default configuration
4040
*/
41-
protected $_defaultConfig = [
41+
protected array $_defaultConfig = [
4242
// autoload permissions based on a configuration
4343
'autoload_config' => 'api_permissions',
4444
// role field in the Users table
4545
'role_field' => 'role',
4646
// default role, used in new users registered and also as role matcher when no role is available
4747
'default_role' => 'user',
4848
// Class used to provide the RBAC rules, by default from a config file, must extend AbstractProvider
49-
'permissions_provider_class' => '\CakeDC\Api\Rbac\Permissions\ApiConfigProvider',
49+
'permissions_provider_class' => \CakeDC\Api\Rbac\Permissions\ApiConfigProvider::class,
5050
// Used to set permissions array from configuration, ignoring the permissionsProvider
5151
'permissions' => null,
5252
// 'log' will match the value of 'debug' if not set on configuration
@@ -59,7 +59,7 @@ class ApiRbac implements RbacInterface
5959
*
6060
* @var array[] rules array
6161
*/
62-
protected $permissions;
62+
protected ?array $permissions = null;
6363

6464
/**
6565
* Rbac constructor.
@@ -204,8 +204,8 @@ protected function _matchPermission(array $permission, $user, $role, ServerReque
204204
if ($key === 'allowed' || $key === 'bypassAuth') {
205205
$reason = sprintf(
206206
'For %s --> Rule matched %s with result = %s',
207-
json_encode($reserved),
208-
json_encode($permission),
207+
json_encode($reserved, JSON_THROW_ON_ERROR),
208+
json_encode($permission, JSON_THROW_ON_ERROR),
209209
$return
210210
);
211211

src/Rbac/Permissions/AbstractProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ abstract class AbstractProvider
2727

2828
/**
2929
* Default permissions to be loaded if no provided permissions
30-
*
31-
* @var array
3230
*/
33-
protected $defaultPermissions;
31+
protected array $defaultPermissions;
3432

3533
/**
3634
* AbstractProvider constructor.

src/Rbac/Permissions/ApiConfigProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ApiConfigProvider extends AbstractProvider
2626
/**
2727
* @var array default configuration
2828
*/
29-
protected $_defaultConfig = [
29+
protected array $_defaultConfig = [
3030
'autoload_config' => 'api_permissions',
3131
];
3232

@@ -55,6 +55,7 @@ public function getPermissions()
5555
*/
5656
protected function _loadPermissions($key)
5757
{
58+
$permissions = null;
5859
try {
5960
Configure::load($key, 'default');
6061
$permissions = Configure::read('CakeDC/Auth.api_permissions');

src/Routing/ApiRouter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class ApiRouter extends Router
2525
{
2626
/**
2727
* Have routes been loaded
28-
*
29-
* @var bool
3028
*/
31-
public static $initialized = false;
29+
public static bool $initialized = false;
3230

3331
/**
3432
* Default route class.
@@ -118,10 +116,8 @@ class ApiRouter extends Router
118116
/**
119117
* Maintains the request object stack for the current request.
120118
* This will contain more than one request object when requestAction is used.
121-
*
122-
* @var array
123119
*/
124-
protected static $_requests = [];
120+
protected static array $_requests = [];
125121

126122
/**
127123
* Initial state is populated the first time reload() is called which is at the bottom

src/Service/Action/Action.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,13 @@ abstract class Action implements EventListenerInterface, EventDispatcherInterfac
4949

5050
/**
5151
* An Auth instance.
52-
*
53-
* @var \CakeDC\Api\Service\Auth\Auth
5452
*/
55-
public $Auth;
53+
public ?\CakeDC\Api\Service\Auth\Auth $Auth = null;
5654

5755
/**
5856
* Default Action options.
59-
*
60-
* @var array
6157
*/
62-
protected $_defaultConfig = [];
58+
protected array $_defaultConfig = [];
6359

6460
/**
6561
* A Service reference.
@@ -70,24 +66,18 @@ abstract class Action implements EventListenerInterface, EventDispatcherInterfac
7066

7167
/**
7268
* Activated route.
73-
*
74-
* @var array
7569
*/
76-
protected $_route = null;
70+
protected ?array $_route = null;
7771

7872
/**
7973
* Extension registry.
80-
*
81-
* @var \CakeDC\Api\Service\Action\ExtensionRegistry
8274
*/
83-
protected $_extensions;
75+
protected ?\CakeDC\Api\Service\Action\ExtensionRegistry $_extensions = null;
8476

8577
/**
8678
* Action name.
87-
*
88-
* @var string
8979
*/
90-
protected $_name;
80+
protected ?string $_name = null;
9181

9282
/**
9383
* Action constructor.

src/Service/Action/Auth/LoginAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class LoginAction extends Action
2929
{
3030
use LoginTrait;
3131

32-
protected $_identifiedField = 'username';
33-
protected $_passwordField = 'password';
32+
protected string $_identifiedField = 'username';
33+
protected string $_passwordField = 'password';
3434

3535
/**
3636
* Initialize an action instance

0 commit comments

Comments
 (0)