Skip to content

Commit bd0ef71

Browse files
committed
php 8.1 support
1 parent 6af0f92 commit bd0ef71

19 files changed

Lines changed: 92 additions & 132 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ clover.xml
44
infection-log.txt
55
vendor/
66
.phan/
7-
.phpunit.result.cache
7+
.php-cs-fixer.cache
8+
.phpunit.result.cache
9+
phpunit.local.xml

.php-cs-fixer.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$config = new PhpCsFixer\Config();
4+
return $config
5+
->setRiskyAllowed(true)
6+
->setRules([
7+
'@PSR12' => true,
8+
'no_whitespace_in_blank_line' => true,
9+
'return_type_declaration' => true,
10+
'native_function_invocation' => ['include' => ['@all']],
11+
])
12+
->setFinder(PhpCsFixer\Finder::create()
13+
->exclude('vendor')
14+
->in(__DIR__)
15+
);

.scrutinizer.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212

1313
<div align="center">
1414

15-
[![Build Status](https://travis-ci.org/linna/auth-mapper-pgsql.svg?branch=master)](https://travis-ci.org/linna/auth-mapper-pgsql)
16-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/linna/auth-mapper-pgsql/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/linna/auth-mapper-pgsql/?branch=master)
17-
[![Code Coverage](https://scrutinizer-ci.com/g/linna/auth-mapper-pgsql/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/linna/auth-mapper-pgsql/?branch=master)
1815
[![StyleCI](https://github.styleci.io/repos/209962835/shield?branch=master&style=flat)](https://github.styleci.io/repos/209962835)
1916
[![PDS Skeleton](https://img.shields.io/badge/pds-skeleton-blue.svg?style=flat)](https://github.com/php-pds/skeleton)
20-
[![PHP 7.4](https://img.shields.io/badge/PHP-7.4-8892BF.svg)](http://php.net)
17+
[![PHP 8.1](https://img.shields.io/badge/PHP-8.1-8892BF.svg)](http://php.net)
2118

2219
</div>
2320

21+
> **_NOTE:_** Code porting to PHP 8.1 ongoing.
22+
2423
# About
2524
This package provide a concrete implementation for authentication interfaces and
2625
for the authorization interfaces of the framework.
@@ -29,7 +28,7 @@ Mappers use as persistent storage postgresql through php pdo.
2928

3029
# Requirements
3130

32-
* PHP >= 7.4
31+
* PHP >= 8.1
3332
* PDO extension
3433
* Postgresql extension
3534
* linna/framework v0.27.0

composer.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.4",
20+
"php": ">=8.1",
2121
"ext-pdo": "*",
2222
"ext-pdo_pgsql": "*",
2323
"ext-pgsql": "*"
2424
},
2525
"require-dev": {
26-
"infection/infection": "^0.15",
26+
"infection/infection": "^0.21",
2727
"phpstan/phpstan": "^0.12",
2828
"phpunit/phpunit": "^9.0",
2929
"linna/framework": "dev-master",
@@ -32,13 +32,17 @@
3232
},
3333
"autoload": {
3434
"psr-4": {
35-
"Linna\\Authentication\\": "src/Authentication/",
36-
"Linna\\Authorization\\": "src/Authorization/"
35+
"Linna\\": "src/Linna/"
3736
}
3837
},
3938
"autoload-dev": {
40-
"psr-4": {
41-
"Linna\\Tests\\": ["tests/Authentication", "tests/Authorization"]
39+
"psr-4": {
40+
"Linna\\": "tests/Linna/"
41+
}
42+
},
43+
"config": {
44+
"allow-plugins": {
45+
"infection/extension-installer": true
4246
}
4347
}
4448
}

phpunit.scrutinizer.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Authentication/EnhancedAuthenticationMapper.php renamed to src/Linna/Authentication/EnhancedAuthenticationMapper.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public function __construct(ExtendedPDO $pdo)
4747
/**
4848
* Fetch a login attempt by id.
4949
*
50-
* @param int $loginAttemptId
50+
* @param string|int $loginAttemptId
5151
*
5252
* @return DomainObjectInterface
5353
*/
54-
public function fetchById(int $loginAttemptId): DomainObjectInterface
54+
public function fetchById(string|int $loginAttemptId): DomainObjectInterface
5555
{
5656
$pdos = $this->pdo->prepare("{$this->baseQuery} WHERE login_attempt_id = :id");
5757

@@ -201,8 +201,10 @@ protected function concreteCreate(): DomainObjectInterface
201201
* storage record.
202202
*
203203
* @param DomainObjectInterface $loginAttempt
204+
*
205+
* @return void
204206
*/
205-
protected function concreteInsert(DomainObjectInterface &$loginAttempt)
207+
protected function concreteInsert(DomainObjectInterface &$loginAttempt): void
206208
{
207209
$this->checkDomainObjectType($loginAttempt);
208210

@@ -226,8 +228,10 @@ protected function concreteInsert(DomainObjectInterface &$loginAttempt)
226228
* Update a LoginAttempt object in persistent storage.
227229
*
228230
* @param DomainObjectInterface $loginAttempt
231+
*
232+
* @return void
229233
*/
230-
protected function concreteUpdate(DomainObjectInterface $loginAttempt)
234+
protected function concreteUpdate(DomainObjectInterface $loginAttempt): void
231235
{
232236
$this->checkDomainObjectType($loginAttempt);
233237

@@ -255,8 +259,10 @@ protected function concreteUpdate(DomainObjectInterface $loginAttempt)
255259
* deletion.
256260
*
257261
* @param DomainObjectInterface $domainObject
262+
*
263+
* @return void
258264
*/
259-
protected function concreteDelete(DomainObjectInterface &$loginAttempt)
265+
protected function concreteDelete(DomainObjectInterface &$loginAttempt): void
260266
{
261267
$this->checkDomainObjectType($loginAttempt);
262268

@@ -278,9 +284,11 @@ protected function concreteDelete(DomainObjectInterface &$loginAttempt)
278284
*
279285
* @param DomainObjectInterface $domainObject
280286
*
287+
* @return void
288+
*
281289
* @throws InvalidArgumentException if the domain object isn't of the type required by mapper
282290
*/
283-
protected function checkDomainObjectType(DomainObjectInterface $domainObject)
291+
protected function checkDomainObjectType(DomainObjectInterface $domainObject): void
284292
{
285293
if (!($domainObject instanceof LoginAttempt)) {
286294
throw new InvalidArgumentException('Domain Object parameter must be instance of LoginAttempt class');
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public function __construct(ExtendedPDO $pdo, Password $password)
5656
/**
5757
* Fetch a user by id.
5858
*
59-
* @param int $userId
59+
* @param string|int $userId
6060
*
6161
* @return DomainObjectInterface
6262
*/
63-
public function fetchById(int $userId): DomainObjectInterface
63+
public function fetchById(string|int $userId): DomainObjectInterface
6464
{
6565
$pdos = $this->pdo->prepare("{$this->baseQuery} WHERE user_id = :id");
6666

@@ -146,8 +146,10 @@ protected function concreteCreate(): DomainObjectInterface
146146
* storage record.
147147
*
148148
* @param DomainObjectInterface $user
149+
*
150+
* @return void
149151
*/
150-
protected function concreteInsert(DomainObjectInterface &$user)
152+
protected function concreteInsert(DomainObjectInterface &$user): void
151153
{
152154
$this->checkDomainObjectType($user);
153155

@@ -171,8 +173,10 @@ protected function concreteInsert(DomainObjectInterface &$user)
171173
* Update a User object in persistent storage.
172174
*
173175
* @param DomainObjectInterface $user
176+
*
177+
* @return void
174178
*/
175-
protected function concreteUpdate(DomainObjectInterface $user)
179+
protected function concreteUpdate(DomainObjectInterface $user): void
176180
{
177181
$this->checkDomainObjectType($user);
178182

@@ -200,8 +204,10 @@ protected function concreteUpdate(DomainObjectInterface $user)
200204
* deletion.
201205
*
202206
* @param DomainObjectInterface $domainObject
207+
*
208+
* @return void
203209
*/
204-
protected function concreteDelete(DomainObjectInterface &$user)
210+
protected function concreteDelete(DomainObjectInterface &$user): void
205211
{
206212
$this->checkDomainObjectType($user);
207213

@@ -223,9 +229,11 @@ protected function concreteDelete(DomainObjectInterface &$user)
223229
*
224230
* @param DomainObjectInterface $domainObject
225231
*
232+
* @return void
233+
*
226234
* @throws InvalidArgumentException if the domain object isn't of the type required by mapper
227235
*/
228-
protected function checkDomainObjectType(DomainObjectInterface $domainObject)
236+
protected function checkDomainObjectType(DomainObjectInterface $domainObject): void
229237
{
230238
if (!($domainObject instanceof User)) {
231239
throw new InvalidArgumentException('Domain Object parameter must be instance of User class');

src/Authorization/EnhancedUserMapper.php renamed to src/Linna/Authorization/EnhancedUserMapper.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function fetchById(int $userId): DomainObjectInterface
65+
public function fetchById(string|int $userId): DomainObjectInterface
6666
{
6767
$roles = $this->roleToUserMapper->fetchByUserId($userId);
6868
$permissions = $this->permissionMapper->fetchByUserId($userId);
@@ -132,7 +132,7 @@ public function fetchByPermission(Permission $permission): array
132132
/**
133133
* {@inheritdoc}
134134
*/
135-
public function fetchByPermissionId(int $permissionId): array
135+
public function fetchByPermissionId(string|int $permissionId): array
136136
{
137137
$pdos = $this->pdo->prepare('
138138
(SELECT u.user_id AS "id", u.uuid, u.name, u.email, u.description,
@@ -163,7 +163,7 @@ public function fetchByPermissionName(string $permissionName): array
163163
{
164164
$permission = $this->permissionMapper->fetchByName($permissionName);
165165

166-
return $this->fetchByPermissionId($permission->getId());
166+
return $this->fetchByPermissionId((int) $permission->getId());
167167
}
168168

169169
/**
@@ -177,7 +177,7 @@ public function fetchByRole(Role $role): array
177177
/**
178178
* {@inheritdoc}
179179
*/
180-
public function fetchByRoleId(int $roleId): array
180+
public function fetchByRoleId(string|int $roleId): array
181181
{
182182
$pdos = $this->pdo->prepare('
183183
SELECT u.user_id AS "id", u.uuid, u.name, u.email, u.description,
@@ -263,7 +263,7 @@ public function grantPermission(EnhancedUser &$user, Permission $permission)
263263
/**
264264
* {@inheritdoc}
265265
*/
266-
public function grantPermissionById(EnhancedUser &$user, int $permissionId)
266+
public function grantPermissionById(EnhancedUser &$user, string|int $permissionId)
267267
{
268268
$userId = $user->getId();
269269

@@ -301,7 +301,7 @@ public function revokePermission(EnhancedUser &$user, Permission $permission)
301301
/**
302302
* {@inheritdoc}
303303
*/
304-
public function revokePermissionById(EnhancedUser &$user, int $permissionId)
304+
public function revokePermissionById(EnhancedUser &$user, string|int $permissionId)
305305
{
306306
$userId = $user->getId();
307307

@@ -335,7 +335,7 @@ public function addRole(EnhancedUser &$user, Role $role)
335335
/**
336336
* {@inheritdoc}
337337
*/
338-
public function addRoleById(EnhancedUser &$user, int $roleId)
338+
public function addRoleById(EnhancedUser &$user, string|int $roleId)
339339
{
340340
$userId = $user->getId();
341341

@@ -383,7 +383,7 @@ public function removeRole(EnhancedUser &$user, Role $role)
383383
/**
384384
* {@inheritdoc}
385385
*/
386-
public function removeRoleById(EnhancedUser &$user, int $roleId)
386+
public function removeRoleById(EnhancedUser &$user, string|int $roleId)
387387
{
388388
$userId = $user->getId();
389389

@@ -423,7 +423,7 @@ protected function concreteCreate(): DomainObjectInterface
423423
/**
424424
* {@inheritdoc}
425425
*/
426-
protected function checkDomainObjectType(DomainObjectInterface $domainObject)
426+
protected function checkDomainObjectType(DomainObjectInterface $domainObject): void
427427
{
428428
if (!($domainObject instanceof EnhancedUser)) {
429429
throw new InvalidArgumentException('Domain Object parameter must be instance of EnhancedUser class');

0 commit comments

Comments
 (0)