Skip to content

Commit d2860ce

Browse files
committed
Fix the static test failures and improve code readability
1 parent 899e339 commit d2860ce

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

app/code/Magento/Captcha/Plugin/CheckCaptchaOnStorefront.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -17,34 +17,19 @@
1717
*/
1818
class CheckCaptchaOnStorefront
1919
{
20-
/**
21-
* @var HelperCaptcha
22-
*/
23-
private $helper;
24-
25-
/**
26-
* Customer session
27-
*
28-
* @var HttpContext
29-
*/
30-
private $httpContext;
31-
3220
/**
3321
* CheckCaptchaOnStorefront constructor
3422
*
3523
* @param HelperCaptcha $helper
3624
* @param HttpContext $httpContext
3725
*/
3826
public function __construct(
39-
HelperCaptcha $helper,
40-
HttpContext $httpContext
41-
) {
42-
$this->helper = $helper;
43-
$this->httpContext = $httpContext;
44-
}
27+
private readonly HelperCaptcha $helper,
28+
private readonly HttpContext $httpContext
29+
) {}
4530

4631
/**
47-
* Remove template when loggin or disable captcha storefront
32+
* Remove template when login or disable captcha storefront
4833
*
4934
* @param AuthenticationPopup $subject
5035
* @param string $result
@@ -54,8 +39,8 @@ public function __construct(
5439
*/
5540
public function afterGetTemplate(
5641
AuthenticationPopup $subject,
57-
$result
58-
) {
42+
string $result
43+
): string {
5944
if ($this->isLoggedIn() || !$this->helper->getConfig('enable')) {
6045
return '';
6146
}
@@ -68,7 +53,7 @@ public function afterGetTemplate(
6853
*
6954
* @return bool
7055
*/
71-
private function isLoggedIn()
56+
private function isLoggedIn(): bool
7257
{
7358
return $this->httpContext->getValue(Context::CONTEXT_AUTH);
7459
}

app/code/Magento/Captcha/etc/frontend/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

0 commit comments

Comments
 (0)