Skip to content

Commit 69e2446

Browse files
committed
!!! Make getServiceType() a static function
This change makes OAuthController::getServiceType() a static public function and therefore requires implementations which sub class OAuthController to be adjusted accordingly. It is changed in order to allow PHP 8 based applications detect service types properly in `OAuthController` without having to instantiate all client implementations. Resolves #28
1 parent 23ae631 commit 69e2446

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Classes/Controller/OAuthController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected static function detectServiceTypes(ObjectManagerInterface $objectManag
9595
if ($reflectionService->isClassAbstract($serviceTypeClassName)) {
9696
continue;
9797
}
98-
$serviceType = call_user_func_array([$serviceTypeClassName, 'getServiceType'], []);
98+
$serviceType = $serviceTypeClassName::getServiceType();
9999
$serviceTypes[$serviceType] = $serviceTypeClassName;
100100
}
101101
return $serviceTypes;

Classes/OAuthClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function injectEntityManager(EntityManagerInterface $entityManager): void
132132
*
133133
* @return string For example, "Github", "oidc", ...
134134
*/
135-
abstract public function getServiceType(): string;
135+
abstract public static function getServiceType(): string;
136136

137137
/**
138138
* Returns the service name, i.e. something like an instance name of the concrete implementation of this client

Tests/Unit/Fixtures/OAuthTestClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class OAuthTestClient extends OAuthClient
2121
public const TEST_BASE_URI = 'https://localbeach.net/';
2222
public const TEST_CLIENT_ID = 'my-client-id';
2323

24-
public function getServiceType(): string
24+
public static function getServiceType(): string
2525
{
2626
return self::TEST_SERVICE_TYPE;
2727
}

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
"support": {
1515
"email": "[email protected]"
1616
},
17+
"funding": [
18+
{
19+
"type": "github",
20+
"url": "https://github.com/sponsors/robertlemke"
21+
}
22+
],
1723
"require": {
24+
"php": "^7.4 || ^8.0",
1825
"neos/flow": "^6.0 || ^7.0 || dev-master",
1926
"guzzlehttp/guzzle": "^6.3",
2027
"league/oauth2-client": "^2.0",
@@ -49,4 +56,4 @@
4956
"Neos.Flow-20201207104500"
5057
]
5158
}
52-
}
59+
}

0 commit comments

Comments
 (0)