Skip to content

Commit

Permalink
Merge pull request #1969 from stloyd/drop-old-php
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd authored Dec 5, 2023
2 parents 29abf68 + de71c53 commit c36bf22
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 31 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: pecl, composer, php-cs-fixer
tools: php-cs-fixer

- name: Run PHP-CS-Fixer fix
run: php-cs-fixer fix --dry-run --diff --ansi
Expand All @@ -46,13 +46,17 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: composer

- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require symfony/flex --no-progress --no-scripts --no-plugins
composer config extra.symfony.require "5.4"
composer update --no-interaction --no-progress --ansi
- name: Run phpstan
run: composer phpstan
Expand All @@ -64,12 +68,10 @@ jobs:
strategy:
matrix:
include:
- php: '7.4'
symfony-version: '^5.4'
- php: '7.4'
- php: '8.1'
symfony-version: '^5.4'
bc: true
- php: '8.0'
- php: '8.1'
symfony-version: '^5.4'
- php: '8.1'
symfony-version: '^6.3'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changelog
=========
## 2.2.0 (202x-xx-xx)
* BC Break: Dropped support for PHP 7.4 & 8.0,

## 2.1.0 (2023-11-30)
* BC Break: Dropped support for Symfony: `>6.0, <6.3`,
* Added: New Passage resource owner,
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ Installation

All the installation instructions are located in the documentation, check it for a specific version:

* [__2.x__](https://github.com/hwi/HWIOAuthBundle/blob/master/docs/1-setting_up_the_bundle.md) (current) - with support for Symfony: `^5.4`, `^6.3` & `^7.0` (PHP: `^7.4`, `^8.0`),

* [__1.4__](https://github.com/hwi/HWIOAuthBundle/blob/1.4/Resources/doc/1-setting_up_the_bundle.md) (unsupported) - with support for Symfony: `^4.4` & `^5.1` (PHP: `^7.3` & `^8.0`),
* [__2.x__](https://github.com/hwi/HWIOAuthBundle/blob/master/docs/1-setting_up_the_bundle.md) (current) - with support for Symfony: `^5.4`, `^6.3` & `^7.0` (PHP: `^8.1`),

Documentation
-------------
Expand All @@ -23,7 +21,6 @@ The bulk of the documentation is stored in the `Resources/doc/index.md`
file in this bundle. Read the documentation for version:

* [__2.x__](https://github.com/hwi/HWIOAuthBundle/blob/master/docs/index.md)
* [__1.4__](https://github.com/hwi/HWIOAuthBundle/blob/1.4/Resources/doc/index.md) (unsupported)

This bundle contains support for 58 different providers:
* 37signals,
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
],

"require": {
"php": "^7.4 || ^8.0",
"symfony/deprecation-contracts": "^2.5 || ^3.0",
"php": "^8.1",
"symfony/deprecation-contracts": "^3.0",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/security-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.3 || ^7.0",
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function getConfigTreeBuilder(): TreeBuilder

private function addResourceOwnersConfiguration(ArrayNodeDefinition $node): void
{
/* @phpstan-ignore-next-line */
$node
->fixXmlConfig('resource_owner')
->children()
Expand Down
2 changes: 1 addition & 1 deletion src/OAuth/RequestDataStorage/SessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function getStorageKey($value): string
if (\is_array($value)) {
$storageKey = reset($value);
} elseif (\is_object($value)) {
$storageKey = \get_class($value);
$storageKey = $value::class;
} else {
$storageKey = $value;
}
Expand Down
10 changes: 4 additions & 6 deletions src/OAuth/Response/SensioConnectUserResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ final class SensioConnectUserResponse extends AbstractUserResponse
* @var \DOMNode
*/
protected $data;
/**
* @var \DOMXPath|null
*/
private $xpath;

private ?\DOMXPath $xpath;

/**
* {@inheritdoc}
*/
public function getUserIdentifier(): string
{
/** @var \DOMAttr $attribute */
/** @var \DOMAttr|null $attribute */
$attribute = $this->data->attributes->getNamedItem('id');
if (null === $attribute->value) {
if (null === $attribute) {
throw new \InvalidArgumentException('User identifier was not found in response.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function createOAuthToken(
OAuthToken $oldToken,
?UserInterface $user
): OAuthToken {
$tokenClass = \get_class($oldToken);
$tokenClass = $oldToken::class;
if (null !== $user) {
$token = new $tokenClass($data, $user->getRoles());
$token->setUser($user);
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Core/User/EntityUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function refreshUser(UserInterface $user): UserInterface
{
$accessor = PropertyAccess::createPropertyAccessor();
$identifier = $this->properties['identifier'];
if (!$accessor->isReadable($user, $identifier) || !$this->supportsClass(\get_class($user))) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
if (!$accessor->isReadable($user, $identifier) || !$this->supportsClass($user::class)) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}

$userId = $accessor->getValue($user, $identifier);
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Core/User/OAuthUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function loadUserByOAuthUserResponse(UserResponseInterface $response): Us

public function refreshUser(UserInterface $user): UserInterface
{
if (!$this->supportsClass(\get_class($user))) {
throw new UnsupportedUserException(sprintf('Unsupported user class "%s"', \get_class($user)));
if (!$this->supportsClass($user::class)) {
throw new UnsupportedUserException(sprintf('Unsupported user class "%s"', $user::class));
}

// @phpstan-ignore-next-line Symfony <5.4 BC layer
Expand Down
6 changes: 3 additions & 3 deletions src/Security/Http/Authenticator/OAuthAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function refreshToken(OAuthToken $token): OAuthToken
if ($token->isExpired()) {
$expiredToken = $token;
if ($refreshToken = $expiredToken->getRefreshToken()) {
$tokenClass = \get_class($expiredToken);
$tokenClass = $expiredToken::class;
$token = new $tokenClass($resourceOwner->refreshAccessToken($refreshToken));
$token->setResourceOwnerName($expiredToken->getResourceOwnerName());
if (!$token->getRefreshToken()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ public function recreateToken(OAuthToken $token, UserInterface $user = null): OA
{
$user = $user instanceof UserInterface ? $user : $token->getUser();

$tokenClass = \get_class($token);
$tokenClass = $token::class;
if ($user) {
$newToken = new $tokenClass(
$token->getRawToken(),
Expand Down Expand Up @@ -254,7 +254,7 @@ public function createAuthenticatedToken($passport, string $firewallName): Token
return $passport->getToken();
}

throw new \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, SelfValidatedOAuthPassport::class, \get_class($passport)));
throw new \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, SelfValidatedOAuthPassport::class, $passport::class));
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ protected function createResourceOwner(
/** @var GenericOAuth2ResourceOwner $resourceOwner */
$resourceOwner = parent::createResourceOwner($options, $paths, $responses);

$reflection = new \ReflectionClass(\get_class($resourceOwner));
$reflection = new \ReflectionClass($resourceOwner::class);
$stateProperty = $reflection->getProperty('state');
$stateProperty->setAccessible(true);
$stateProperty->setValue($resourceOwner, $state ?: new State($this->state));
Expand Down
2 changes: 1 addition & 1 deletion tests/OAuth/RequestDataStorage/SessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testFetchOtherThenToken(): void
->method('remove')
->with($key);

$data = $this->storage->fetch($this->resourceOwner, \get_class($class), 'state');
$data = $this->storage->fetch($this->resourceOwner, $class::class, 'state');
self::assertEquals(serialize($class), $data);
}
}

0 comments on commit c36bf22

Please sign in to comment.