Skip to content

Commit 143a34b

Browse files
authored
Merge pull request #23 from boite/symfony-5
Compatible with Symfony 5
2 parents 4124c9f + 9e6f9b6 commit 143a34b

17 files changed

+252
-128
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.php_cs
2+
/.php_cs.cache
13
vendor/*
24
.env
35
composer.lock

.php_cs.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__.'/src')
5+
;
6+
7+
return PhpCsFixer\Config::create()
8+
->setRules([
9+
'@PSR1' => true,
10+
'@PSR2' => true,
11+
'@Symfony' => true,
12+
'single_line_throw' => false,
13+
'no_superfluous_phpdoc_tags' => false,
14+
'ordered_imports' => true,
15+
'phpdoc_align' => false,
16+
'no_extra_consecutive_blank_lines' => false,
17+
'blank_line_before_statement' => [
18+
'statements' => [
19+
'declare',
20+
]
21+
],
22+
'array_syntax' => false,
23+
])
24+
->setFinder($finder)
25+
;

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ Please refer to the `examples/` directory for other examples.
5252

5353
A Silex Provider is available [here](https://github.com/linkorb/silex-provider-userbase-client)
5454

55-
### Symfony 4
55+
### Symfony
5656

57-
A Symfony 4 bundle can be found [here](https://github.com/linkorb/userbase-client-bundle)
57+
A Symfony bundle can be found [here](https://github.com/linkorb/userbase-client-bundle).
58+
It works with Symfony 4 and 5 projects.
5859

5960
## License
6061

UPGRADE-2.0.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UPGRADE FROM 1.9 to 2.0
2+
=======================
3+
4+
- The User class no longer implements Symfony's `AdvancedUserInterface` which
5+
it has been removed from Symfony 5. Use of the methods of this interface
6+
should be replaced by performing User and Account checks in UserCheckers.
7+
8+
A temporary replacement for the removed interface is
9+
`UserBase\Client\Model\LegacyAdvancedUserInterface`, but use this only as a
10+
last resort and as a temporary fix.

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
],
1919
"require": {
2020
"php": ">=5.3.0",
21-
"linkorb/userbase-role-contracts": "^1.0",
22-
"symfony/security": "~2.6 || ~3.0 || ^4.0|| ^5.0",
21+
"linkorb/envoi": "^1.1",
22+
"linkorb/userbase-role-contracts": "^2.0",
2323
"psr/cache": "~1.0",
24-
"symfony/cache": "~3.0|| ^4.0 || ^5.0 ",
25-
"linkorb/envoi": "^1.1"
24+
"symfony/cache": "~3.0 || ^4.0 || ^5.0",
25+
"symfony/security-core": "~2.6 || ~3.0 || ^4.0 || ^5.0"
2626
},
2727
"require-dev": {
28-
"symfony/dotenv": "~3.0 || ^4.0"
28+
"symfony/dotenv": "~3.0 || ^4.0 || ^5.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

src/Client.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
namespace UserBase\Client;
44

5-
use UserBase\Client\Model\User;
5+
use Psr\Cache\CacheItemPoolInterface;
6+
use RuntimeException;
7+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
8+
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
69
use UserBase\Client\Model\Account;
7-
use UserBase\Client\Model\AccountUser;
810
use UserBase\Client\Model\AccountEmail;
911
use UserBase\Client\Model\AccountProperty;
12+
use UserBase\Client\Model\AccountUser;
1013
use UserBase\Client\Model\Policy;
11-
use Psr\Cache\CacheItemPoolInterface;
12-
use RuntimeException;
14+
use UserBase\Client\Model\User;
1315

1416
if (!function_exists('curl_file_create')) {
1517
function curl_file_create($filename, $mimetype = '', $postname = '')
@@ -52,7 +54,7 @@ public function __construct($url, $username = null, $password = null, $partition
5254
}
5355

5456
$this->partition = $partition;
55-
$this->cache = new \Symfony\Component\Cache\Adapter\ArrayAdapter();
57+
$this->cache = new ArrayAdapter();
5658
}
5759

5860
private function parse_dsn(array $parts)
@@ -285,8 +287,7 @@ public function getData($uri, $jsonData = null)
285287

286288
$json = curl_exec($ch);
287289

288-
if($json === false)
289-
{
290+
if (false === $json) {
290291
throw new RuntimeException('Curl error: '.curl_error($ch));
291292
}
292293

@@ -296,7 +297,6 @@ public function getData($uri, $jsonData = null)
296297
$this->timeDataCollector->stopMeasure('getData');
297298
}
298299

299-
300300
if (200 != $code) {
301301
throw new RuntimeException('HTTP Status code: '.$code.'message: '.$json);
302302
}
@@ -313,7 +313,7 @@ public function checkCredentials($username, $password)
313313
} catch (\Exception $e) {
314314
return false;
315315
}
316-
$encoder = new \Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder();
316+
$encoder = new MessageDigestPasswordEncoder();
317317
$valid = $encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt());
318318

319319
return $valid;

0 commit comments

Comments
 (0)