Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop legacy PHP 7.4-8.0 support #426

Merged
merged 12 commits into from
Dec 18, 2023
7 changes: 0 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ on:
jobs:
test:
uses: SymfonyCasts/.github/.github/workflows/phpunit.yaml@main
with:
php-version-matrix: '["7.4", "8.0", "8.1", "8.2", "8.3"]'
php-version-lowest: '7.4'

composer-validate:
uses: SymfonyCasts/.github/.github/workflows/composer-validate.yaml@main

cs:
uses: SymfonyCasts/.github/.github/workflows/php-cs-fixer.yaml@main
with:
php: '7.4'

sca:
uses: SymfonyCasts/.github/.github/workflows/phpstan.yaml@main
with:
php: '8.0'
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"symfony/framework-bundle": "^4.4|^5.0|^6.0|^7.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0|^7.0",
"symfony/routing": "^4.4|^5.0|^6.0|^7.0",
Expand All @@ -25,7 +25,7 @@
"symfony/phpunit-bridge": "^5.3.1|^6.0|^7.0",
"symfony/security-guard": "^4.4|^5.0|^6.0|^7.0",
"symfony/yaml": "^4.4|^5.0|^6.0|^7.0",
"phpstan/phpstan": "^0.12"
"phpstan/phpstan": "^1.0"
},
"autoload": {
"psr-4": { "KnpU\\OAuth2ClientBundle\\": "src/" }
Expand Down
22 changes: 9 additions & 13 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ parameters:
inferPrivatePropertyTypeFromConstructor: true
paths:
- ./src/
excludes_analyse:
excludePaths:
- */cache/*
ignoreErrors:
# False positive: clients are not dependencies of this project.
-
message: '#Return typehint of method KnpU\\OAuth2ClientBundle\\Client\\Provider\\[a-zA-Z0-9\\_]+::fetchUserFromToken\(\) has invalid type [a-zA-Z0-9\\_]#'
path: ./src/Client/Provider
message: '#Method KnpU\\OAuth2ClientBundle\\Client\\Provider\\\w+::fetchUserFromToken\(\) has invalid return type .+#'
path: ./src/Client/Provider/
-
message: '#Return typehint of method KnpU\\OAuth2ClientBundle\\Client\\Provider\\[a-zA-Z0-9\\_]+::fetchUser\(\) has invalid type [a-zA-Z0-9\\_]#'
path: ./src/Client/Provider
message: '#Method KnpU\\OAuth2ClientBundle\\Client\\Provider\\\w+::fetchUser\(\) has invalid return type .+#'
path: ./src/Client/Provider/
-
message: '#Class League\\OAuth2\\Client\\Provider\\[a-zA-Z0-9\\_]+ not found\.#'
message: '#Class League\\OAuth2\\Client\\Provider\\Passage not found\.#'
path: ./src/Client/Provider
-
message: '#Call to method [a-zA-Z0-9\\_]+\(\) on an unknown class League\\OAuth2\\Client\\Provider\\[a-zA-Z0-9\\_]+\.#'
message: '#Call to method getLogoutUrl\(\) on an unknown class League\\OAuth2\\Client\\Provider\\Passage\.#'
path: ./src/Client/Provider

# False positive: using `::class` is not an error for those providers `::getProviderClass()` method.
-
message: '#Class [a-zA-Z0-9\\_]+ not found#'
Expand All @@ -28,14 +29,9 @@ parameters:
-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::scalarNode\(\)\.#'
path: ./src/DependencyInjection/Providers

-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::arrayNode\(\)\.#'
path: ./src/DependencyInjection/Providers
-
message: '#.*NodeDefinition::children.*#'
path: ./src/DependencyInjection
# Searches for root(), for backward compatibility with Symfony <4.2. Removed in 5.0
-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root\(\)\.#'
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#'
path: ./src/DependencyInjection
2 changes: 1 addition & 1 deletion src/Client/Provider/PassageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function logout(): RedirectResponse
$provider = $this->getOAuth2Provider();

if (!($provider instanceof Passage)) {
throw new \RuntimeException('Invalid provider "'.\get_class($provider).'", expected provider "'.Passage::class.'"');
throw new \RuntimeException('Invalid provider "'.$provider::class.'", expected provider "'.Passage::class.'"');
}

return new RedirectResponse($provider->getLogoutUrl());
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('knpu_oauth2_client');
$rootNode = method_exists($treeBuilder, 'getRootNode')
? $treeBuilder->getRootNode()
: $treeBuilder->root('knpu_oauth2_client');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/KnpUOAuth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ public function load(array $configs, ContainerBuilder $container): void

// process the configuration
$tree = new TreeBuilder('knpu_oauth2_client/clients/'.$key);
$node = method_exists($tree, 'getRootNode')
? $tree->getRootNode()
: $tree->root('knpu_oauth2_client/clients/'.$key);
$node = $tree->getRootNode();

$this->buildConfigurationForType($node, $type);
$processor = new Processor();
Expand Down
2 changes: 1 addition & 1 deletion src/Security/User/OAuthUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
public function refreshUser(UserInterface $user): UserInterface
{
if (!$user instanceof OAuthUser) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}

return $this->loadUserByUsername(
Expand Down