Skip to content

Commit 7b65618

Browse files
authored
Merge pull request #1402 from thephpleague/fix-passport-compatibility
Fix Passport Compatibility for V9
2 parents f7a19cd + 26b33a6 commit 7b65618

28 files changed

+163
-115
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Fixed
99
- Basic authorization is now case insensitive (PR #1403)
1010

11+
### Changed
12+
- Request parameters are now parsed into strings to use internally in the library (PR #1402)
13+
1114
## [9.0.0-RC1] - released 2024-03-27
1215
### Added
1316
- Device Authorization Grant added (PR #1074)

examples/src/Entities/UserEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class UserEntity implements UserEntityInterface
1919
/**
2020
* Return the user's identifier.
2121
*/
22-
public function getIdentifier(): mixed
22+
public function getIdentifier(): string
2323
{
24-
return 1;
24+
return '1';
2525
}
2626
}

phpcs.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<file>tests</file>
1515
<file>examples</file>
1616

17+
<exclude-pattern>examples/vendor/*</exclude-pattern>
18+
1719
<rule ref="PSR12">
1820
<exclude name="Generic.Files.LineLength.TooLong" />
1921
</rule>

phpstan.neon.dist

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@ parameters:
22
level: 8
33
paths:
44
- src
5-
- tests
6-
ignoreErrors:
7-
-
8-
message: '#Call to an undefined method League\\OAuth2\\Server\\ResponseTypes\\ResponseTypeInterface::getAccessToken\(\)\.#'
9-
path: tests/Grant/ClientCredentialsGrantTest.php
5+
- tests

src/CryptKey.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ class CryptKey implements CryptKeyInterface
4343

4444
public function __construct(string $keyPath, protected ?string $passPhrase = null, bool $keyPermissionsCheck = true)
4545
{
46-
if (strpos($keyPath, self::FILE_PREFIX) !== 0 && $this->isValidKey($keyPath, $this->passPhrase ?? '')) {
46+
if (str_starts_with($keyPath, self::FILE_PREFIX) === false && $this->isValidKey($keyPath, $this->passPhrase ?? '')) {
4747
$this->keyContents = $keyPath;
4848
$this->keyPath = '';
4949
// There's no file, so no need for permission check.
5050
$keyPermissionsCheck = false;
5151
} elseif (is_file($keyPath)) {
52-
if (strpos($keyPath, self::FILE_PREFIX) !== 0) {
52+
if (str_starts_with($keyPath, self::FILE_PREFIX) === false) {
5353
$keyPath = self::FILE_PREFIX . $keyPath;
5454
}
5555

src/Entities/RefreshTokenEntityInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ interface RefreshTokenEntityInterface
1818
{
1919
/**
2020
* Get the token's identifier.
21+
*
22+
* @return non-empty-string
2123
*/
2224
public function getIdentifier(): string;
2325

2426
/**
2527
* Set the token's identifier.
28+
*
29+
* @param non-empty-string $identifier
2630
*/
27-
public function setIdentifier(mixed $identifier): void;
31+
public function setIdentifier(string $identifier): void;
2832

2933
/**
3034
* Get the token's expiry date time.

src/Entities/ScopeEntityInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface ScopeEntityInterface extends JsonSerializable
1818
{
1919
/**
2020
* Get the scope's identifier.
21+
*
22+
* @return non-empty-string
2123
*/
2224
public function getIdentifier(): string;
2325
}

src/Entities/TokenInterface.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ interface TokenInterface
1818
{
1919
/**
2020
* Get the token's identifier.
21+
*
22+
* @return non-empty-string
2123
*/
2224
public function getIdentifier(): string;
2325

2426
/**
2527
* Set the token's identifier.
28+
*
29+
* @param non-empty-string $identifier
2630
*/
27-
public function setIdentifier(mixed $identifier): void;
31+
public function setIdentifier(string $identifier): void;
2832

2933
/**
3034
* Get the token's expiry date time.
@@ -45,8 +49,10 @@ public function setUserIdentifier(string $identifier): void;
4549

4650
/**
4751
* Get the token user's identifier.
52+
*
53+
* @return non-empty-string|null
4854
*/
49-
public function getUserIdentifier(): string|int|null;
55+
public function getUserIdentifier(): string|null;
5056

5157
/**
5258
* Get the client that the token was issued to.

src/Entities/Traits/DeviceCodeTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ abstract public function getExpiryDateTime(): DateTimeImmutable;
5959
*/
6060
abstract public function getScopes(): array;
6161

62+
/**
63+
* @return non-empty-string
64+
*/
6265
abstract public function getIdentifier(): string;
6366

6467
public function getLastPolledAt(): ?DateTimeImmutable

src/Entities/Traits/EntityTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ public function getIdentifier(): string
2727
return $this->identifier;
2828
}
2929

30-
public function setIdentifier(mixed $identifier): void
30+
/**
31+
* @param non-empty-string $identifier
32+
*/
33+
public function setIdentifier(string $identifier): void
3134
{
3235
$this->identifier = $identifier;
3336
}

0 commit comments

Comments
 (0)