Skip to content

Commit 26889a3

Browse files
committed
AC-3110 fixed logic affected by "RFC: Deprecate passing null" issue
1 parent d74bbf7 commit 26889a3

File tree

14 files changed

+88
-81
lines changed

14 files changed

+88
-81
lines changed

app/code/Magento/Payment/Block/Form/Cc.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ public function hasVerification()
117117
*/
118118
public function hasSsCardType()
119119
{
120-
$availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
120+
$ccTypes = $this->getMethod()->getConfigData('cctypes');
121+
if ($ccTypes === null) {
122+
return false;
123+
}
124+
125+
$availableTypes = explode(',', $ccTypes);
121126
$ssPresenations = array_intersect(['SS', 'SM', 'SO'], $availableTypes);
122127
if ($availableTypes && count($ssPresenations) > 0) {
123128
return true;

app/code/Magento/Payment/Block/Transparent/Form.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ protected function _toHtml()
5959
}
6060

6161
/**
62-
* Checks whether block should be rendered
63-
* basing on TransparentInterface presence in checkout session
62+
* Checks whether block should be rendered basing on TransparentInterface presence in checkout session
6463
*
6564
* @return bool
6665
*/
@@ -123,15 +122,14 @@ public function getDateDelim()
123122
}
124123

125124
/**
126-
* Get map of cc_code, cc_num, cc_expdate for gateway
127-
* Returns json formatted string
125+
* Get map of cc_code, cc_num, cc_expdate for gateway. Returns json formatted string
128126
*
129127
* @return string
130128
*/
131129
public function getCardFieldsMap()
132130
{
133131
$keys = ['cccvv', 'ccexpdate', 'ccnum'];
134-
$ccfields = array_combine($keys, explode(',', $this->getMethodConfigData('ccfields')));
132+
$ccfields = array_combine($keys, explode(',', $this->getMethodConfigData('ccfields') ?? ''));
135133
return json_encode($ccfields);
136134
}
137135

app/code/Magento/Payment/Gateway/Validator/CountryValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
1111

1212
/**
13-
* Class CountryValidator
14-
* @package Magento\Payment\Gateway\Validator
1513
* @api
1614
* @since 100.0.2
1715
*/
@@ -35,6 +33,8 @@ public function __construct(
3533
}
3634

3735
/**
36+
* Validate country
37+
*
3838
* @param array $validationSubject
3939
* @return bool
4040
* @throws NotFoundException
@@ -48,7 +48,7 @@ public function validate(array $validationSubject)
4848
if ((int)$this->config->getValue('allowspecific', $storeId) === 1) {
4949
$availableCountries = explode(
5050
',',
51-
$this->config->getValue('specificcountry', $storeId)
51+
$this->config->getValue('specificcountry', $storeId) ?? ''
5252
);
5353

5454
if (!in_array($validationSubject['country'], $availableCountries)) {

app/code/Magento/Payment/Model/CcGenericConfigProvider.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
}
4646

4747
/**
48-
* {@inheritdoc}
48+
* @inheritdoc
4949
*/
5050
public function getConfig()
5151
{
@@ -155,12 +155,16 @@ protected function hasVerification($methodCode)
155155
*/
156156
protected function hasSsCardType($methodCode)
157157
{
158-
$result = false;
159-
$availableTypes = explode(',', $this->methods[$methodCode]->getConfigData('cctypes'));
158+
$ccTypes = $this->methods[$methodCode]->getConfigData('cctypes');
159+
if ($ccTypes === null) {
160+
return false;
161+
}
162+
163+
$availableTypes = explode(',', $ccTypes);
160164
$ssPresentations = array_intersect(['SS', 'SM', 'SO'], $availableTypes);
161165
if ($availableTypes && count($ssPresentations) > 0) {
162-
$result = true;
166+
return true;
163167
}
164-
return $result;
168+
return false;
165169
}
166170
}

app/code/Magento/Payment/Model/Method/AbstractMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public function canUseForCountry($country)
437437
for specific country, the flag will set up as 1
438438
*/
439439
if ($this->getConfigData('allowspecific') == 1) {
440-
$availableCountries = explode(',', $this->getConfigData('specificcountry'));
440+
$availableCountries = explode(',', $this->getConfigData('specificcountry') ?? '');
441441
if (!in_array($country, $availableCountries)) {
442442
return false;
443443
}

app/code/Magento/Payment/Model/Method/Cc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public function validate()
106106

107107
$info = $this->getInfoInstance();
108108
$errorMsg = false;
109-
$availableTypes = explode(',', $this->getConfigData('cctypes'));
109+
$availableTypes = explode(',', $this->getConfigData('cctypes') ?? '');
110110

111-
$ccNumber = $info->getCcNumber();
111+
$ccNumber = $info->getCcNumber() ?? '';
112112

113113
// remove credit card number delimiters such as "-" and space
114114
$ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
@@ -322,7 +322,7 @@ public function otherCcType($type)
322322
*/
323323
public function validateCcNum($ccNumber)
324324
{
325-
$cardNumber = strrev($ccNumber);
325+
$cardNumber = $ccNumber !== null ? strrev($ccNumber) : '';
326326
$numSum = 0;
327327
$length = strlen($cardNumber);
328328

@@ -363,7 +363,7 @@ public function validateCcNum($ccNumber)
363363
*/
364364
public function validateCcNumOther($ccNumber)
365365
{
366-
return preg_match('/^\\d+$/', $ccNumber);
366+
return preg_match('/^\\d+$/', (string)$ccNumber);
367367
}
368368

369369
/**

app/code/Magento/Paypal/Block/Iframe.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class Iframe extends \Magento\Payment\Block\Form
2828
protected $_order;
2929

3030
/**
31-
* Payment method code
32-
*
3331
* @var string
3432
*/
3533
protected $_paymentMethodCode;
@@ -109,7 +107,7 @@ protected function _construct()
109107
$paymentCode = $this->_getCheckout()->getQuote()->getPayment()->getMethod();
110108
if (in_array($paymentCode, $this->_hssHelper->getHssMethods())) {
111109
$this->_paymentMethodCode = $paymentCode;
112-
$templatePath = str_replace('_', '', $paymentCode);
110+
$templatePath = $paymentCode !== null ? str_replace('_', '', $paymentCode) : '';
113111
$templateFile = "Magento_Paypal::{$templatePath}/iframe.phtml";
114112
$directory = $this->readFactory->create($this->reader->getModuleDir('', 'Magento_Paypal'));
115113
$file = $this->resolver->getTemplateFileName($templateFile, ['module' => 'Magento_Paypal']);
@@ -134,7 +132,7 @@ protected function _getBlock()
134132
'Magento\\Paypal\\Block\\' . str_replace(
135133
' ',
136134
'\\',
137-
ucwords(str_replace('_', ' ', $this->_paymentMethodCode))
135+
$this->_paymentMethodCode !== null ? ucwords(str_replace('_', ' ', $this->_paymentMethodCode)) : ''
138136
) . '\\Iframe'
139137
);
140138
if (!$this->_block instanceof \Magento\Paypal\Block\Iframe) {

app/code/Magento/Paypal/Model/AbstractIpn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected function _postBack()
117117
}
118118

119119
$response = preg_split('/^\r?$/m', $postbackResult, 2);
120-
$response = trim($response[1]);
120+
$response = isset($response[1]) ? trim($response[1]) : '';
121121
if ($response != 'VERIFIED') {
122122
$this->_addDebugData('postback', $postbackQuery);
123123
$this->_addDebugData('postback_result', $postbackResult);

app/code/Magento/Paypal/Model/Api/Nvp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ public function call($methodName, array $request)
11981198
}
11991199

12001200
$response = preg_split('/^\r?$/m', $response, 2);
1201-
$response = trim($response[1]);
1201+
$response = trim($response[1] ?? '');
12021202
$response = $this->_deformatNVP($response);
12031203

12041204
$debugData['response'] = $response;

app/code/Magento/Paypal/Model/Config.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,160 +23,160 @@ class Config extends AbstractConfig
2323
/**
2424
* PayPal Express
2525
*/
26-
const METHOD_EXPRESS = 'paypal_express';
26+
public const METHOD_EXPRESS = 'paypal_express';
2727

2828
/**
2929
* PayPal Standard - alias METHOD_WPP_EXPRESS
3030
*/
31-
const METHOD_WPS_EXPRESS = 'wps_express';
31+
public const METHOD_WPS_EXPRESS = 'wps_express';
3232

3333
/**
3434
* PayPal Standard Bml - alias METHOD_WPP_BML
3535
*/
36-
const METHOD_WPS_BML = 'wps_express_bml';
36+
public const METHOD_WPS_BML = 'wps_express_bml';
3737

3838
/**
3939
* PayPal Bill Me Later - Express Checkout
4040
*/
41-
const METHOD_WPP_BML = 'paypal_express_bml';
41+
public const METHOD_WPP_BML = 'paypal_express_bml';
4242

4343
/**
4444
* PayPal Website Payments Pro - Direct Payments
4545
*/
46-
const METHOD_WPP_DIRECT = 'paypal_direct';
46+
public const METHOD_WPP_DIRECT = 'paypal_direct';
4747

4848
/**
4949
* PayPal Website Payments Pro - Direct Payments - alias METHOD_PAYFLOWPRO
5050
*/
51-
const METHOD_PAYMENT_PRO = 'paypal_payment_pro';
51+
public const METHOD_PAYMENT_PRO = 'paypal_payment_pro';
5252

5353
/**
5454
* Express Checkout (Payflow Edition)
5555
*/
56-
const METHOD_WPP_PE_EXPRESS = 'payflow_express';
56+
public const METHOD_WPP_PE_EXPRESS = 'payflow_express';
5757

5858
/**
5959
* PayPal Bill Me Later - Express Checkout (Payflow Edition)
6060
*/
61-
const METHOD_WPP_PE_BML = 'payflow_express_bml';
61+
public const METHOD_WPP_PE_BML = 'payflow_express_bml';
6262

6363
/**
6464
* Payflow Pro Gateway
6565
*/
66-
const METHOD_PAYFLOWPRO = 'payflowpro';
66+
public const METHOD_PAYFLOWPRO = 'payflowpro';
6767

68-
const METHOD_PAYFLOWLINK = 'payflow_link';
68+
public const METHOD_PAYFLOWLINK = 'payflow_link';
6969

70-
const METHOD_PAYFLOWADVANCED = 'payflow_advanced';
70+
public const METHOD_PAYFLOWADVANCED = 'payflow_advanced';
7171

72-
const METHOD_HOSTEDPRO = 'hosted_pro';
72+
public const METHOD_HOSTEDPRO = 'hosted_pro';
7373

74-
const METHOD_BILLING_AGREEMENT = 'paypal_billing_agreement';
74+
public const METHOD_BILLING_AGREEMENT = 'paypal_billing_agreement';
7575

7676
/**#@+
7777
* Buttons and images
7878
*/
79-
const EC_FLAVOR_DYNAMIC = 'dynamic';
79+
public const EC_FLAVOR_DYNAMIC = 'dynamic';
8080

81-
const EC_FLAVOR_STATIC = 'static';
81+
public const EC_FLAVOR_STATIC = 'static';
8282

83-
const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
83+
public const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
8484

85-
const EC_BUTTON_TYPE_MARK = 'ecmark';
85+
public const EC_BUTTON_TYPE_MARK = 'ecmark';
8686

87-
const PAYMENT_MARK_SMALL = 'small';
87+
public const PAYMENT_MARK_SMALL = 'small';
8888

89-
const PAYMENT_MARK_MEDIUM = 'medium';
89+
public const PAYMENT_MARK_MEDIUM = 'medium';
9090

91-
const PAYMENT_MARK_LARGE = 'large';
91+
public const PAYMENT_MARK_LARGE = 'large';
9292

9393
/**#@-*/
94-
const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
94+
public const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
9595

9696
/**#@+
9797
* Payment actions
9898
*/
99-
const AUTHORIZATION_AMOUNT_ONE = 1;
99+
public const AUTHORIZATION_AMOUNT_ONE = 1;
100100

101-
const AUTHORIZATION_AMOUNT_FULL = 2;
101+
public const AUTHORIZATION_AMOUNT_FULL = 2;
102102

103103
/**#@-*/
104104

105105
/**#@+
106106
* Require Billing Address
107107
*/
108-
const REQUIRE_BILLING_ADDRESS_NO = 0;
108+
public const REQUIRE_BILLING_ADDRESS_NO = 0;
109109

110-
const REQUIRE_BILLING_ADDRESS_ALL = 1;
110+
public const REQUIRE_BILLING_ADDRESS_ALL = 1;
111111

112-
const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
112+
public const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
113113

114114
/**#@-*/
115115

116116
/**#@+
117117
* Fraud management actions
118118
*/
119-
const FRAUD_ACTION_ACCEPT = 'Acept';
119+
public const FRAUD_ACTION_ACCEPT = 'Acept';
120120

121-
const FRAUD_ACTION_DENY = 'Deny';
121+
public const FRAUD_ACTION_DENY = 'Deny';
122122

123123
/**#@-*/
124124

125125
/**#@+
126126
* Refund types
127127
*/
128-
const REFUND_TYPE_FULL = 'Full';
128+
public const REFUND_TYPE_FULL = 'Full';
129129

130-
const REFUND_TYPE_PARTIAL = 'Partial';
130+
public const REFUND_TYPE_PARTIAL = 'Partial';
131131

132132
/**#@-*/
133133

134134
/**#@+
135135
* Express Checkout flows
136136
*/
137-
const EC_SOLUTION_TYPE_SOLE = 'Sole';
137+
public const EC_SOLUTION_TYPE_SOLE = 'Sole';
138138

139-
const EC_SOLUTION_TYPE_MARK = 'Mark';
139+
public const EC_SOLUTION_TYPE_MARK = 'Mark';
140140

141141
/**#@-*/
142142

143143
/**#@+
144144
* Payment data transfer methods (Standard)
145145
*/
146-
const WPS_TRANSPORT_IPN = 'ipn';
146+
public const WPS_TRANSPORT_IPN = 'ipn';
147147

148-
const WPS_TRANSPORT_PDT = 'pdt';
148+
public const WPS_TRANSPORT_PDT = 'pdt';
149149

150-
const WPS_TRANSPORT_IPN_PDT = 'ipn_n_pdt';
150+
public const WPS_TRANSPORT_IPN_PDT = 'ipn_n_pdt';
151151

152152
/**#@-*/
153153

154154
/**#@+
155155
* Billing Agreement Signup type
156156
*/
157-
const EC_BA_SIGNUP_AUTO = 'auto';
157+
public const EC_BA_SIGNUP_AUTO = 'auto';
158158

159-
const EC_BA_SIGNUP_ASK = 'ask';
159+
public const EC_BA_SIGNUP_ASK = 'ask';
160160

161-
const EC_BA_SIGNUP_NEVER = 'never';
161+
public const EC_BA_SIGNUP_NEVER = 'never';
162162

163163
/**
164164
* Paypal setting
165165
*/
166-
const TRANSFER_CART_LINE_ITEMS = 'lineItemsEnabled';
167-
const TRANSFER_SHIPPING_OPTIONS = 'transferShippingOptions';
166+
public const TRANSFER_CART_LINE_ITEMS = 'lineItemsEnabled';
167+
public const TRANSFER_SHIPPING_OPTIONS = 'transferShippingOptions';
168168

169169
/**#@-*/
170170

171171
/**
172172
* Config path for enabling/disabling order review step in express checkout
173173
*/
174-
const XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG = 'payment/paypal_express/skip_order_review_step';
174+
public const XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG = 'payment/paypal_express/skip_order_review_step';
175175

176176
/**
177177
* PayPal PayLater
178178
*/
179-
const PAYLATER = 'paypal_paylater';
179+
public const PAYLATER = 'paypal_paylater';
180180

181181
/**
182182
*
@@ -1058,7 +1058,7 @@ public function getPaymentMarkWhatIsPaypalUrl(\Magento\Framework\Locale\Resolver
10581058
}
10591059
return sprintf(
10601060
'https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
1061-
strtolower($countryCode)
1061+
$countryCode !== null ? strtolower($countryCode) : ''
10621062
);
10631063
}
10641064

0 commit comments

Comments
 (0)