Skip to content
Snippets Groups Projects

Issue #3498582 by bohart: Added Drupal 11 support and remove D9 after its EOL.

Files
7
@@ -19,21 +19,21 @@ class ReverseProxyHeaderClientIpRestore implements EventSubscriberInterface {
*
* @var \GuzzleHttp\ClientInterface
*/
protected $httpClient;
protected ClientInterface $httpClient;
/**
* The settings object.
*
* @var \Drupal\Core\Site\Settings
*/
protected $settings;
protected Settings $settings;
/**
* The logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
protected LoggerInterface $logger;
/**
* Constructs a ReverseProxyHeaderClientIpRestore.
@@ -45,7 +45,11 @@ class ReverseProxyHeaderClientIpRestore implements EventSubscriberInterface {
* @param \Psr\Log\LoggerInterface $logger
* The reverse_proxy_header logger channel.
*/
public function __construct(ClientInterface $http_client, Settings $settings, LoggerInterface $logger) {
public function __construct(
ClientInterface $http_client,
Settings $settings,
LoggerInterface $logger,
) {
$this->httpClient = $http_client;
$this->settings = $settings;
$this->logger = $logger;
@@ -54,7 +58,7 @@ class ReverseProxyHeaderClientIpRestore implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
// Priority is set to 350 (to run before RouterListener::onKernelRequest).
// Which allows AuthenticationSubscriber methods to use the request IP.
// @see \Symfony\Component\HttpKernel\EventListener\RouterListener::getSubscribedEvents
@@ -67,7 +71,7 @@ class ReverseProxyHeaderClientIpRestore implements EventSubscriberInterface {
/**
* Restores the origination client IP from the custom HTTP header.
*/
public function onRequest(RequestEvent $event) {
public function onRequest(RequestEvent $event): void {
// Check the available settings.
$reverse_proxy_header_name = $this->settings->get('reverse_proxy_header');
@@ -101,7 +105,10 @@ class ReverseProxyHeaderClientIpRestore implements EventSubscriberInterface {
* @return bool
* Return TRUE if IP address is invalid.
*/
protected function isInvalidIpAddress($ip_address, $header_name) {
protected function isInvalidIpAddress(
string $ip_address,
string $header_name,
): bool {
$variables = [
'@ip_address' => $ip_address,
'@header_name' => $header_name,
Loading