Skip to content

Commit

Permalink
Fix error issues reported by phpcs with severity 9 (#1880)
Browse files Browse the repository at this point in the history
Co-authored-by: thanhnd0905 <[email protected]>
  • Loading branch information
thanhnd0905 and johnmccombs1 authored Jan 23, 2024
1 parent 2a0b69c commit 179988e
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Helper/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ protected function updateQuoteTimestamp($quoteId)
try {
// get table name with prefix
$tableName = $this->resourceConnection->getTableName('quote');

// phpcs:ignore
$sql = "UPDATE {$tableName} SET updated_at = CURRENT_TIMESTAMP WHERE entity_id = :entity_id";
$bind = [
'entity_id' => $quoteId
Expand Down
5 changes: 4 additions & 1 deletion Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\Request\Http;
use Magento\Framework\Composer\ComposerFactory;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Module\ResourceInterface;
Expand Down Expand Up @@ -2312,7 +2313,9 @@ public function isPickupInStoreShippingMethodCode($rateCode)
*/
public function isTestEnvSet()
{
return isset($_SERVER['TEST_ENV']);
/** @var Http $request */
$request = $this->_request;
return $request->getServer('TEST_ENV');
}

/**
Expand Down
1 change: 0 additions & 1 deletion Helper/MetricsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public function waitForFile()
usleep(500);
} else {
return null;
break;
}
}
return $workingFile;
Expand Down
1 change: 0 additions & 1 deletion Helper/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,6 @@ public function updateOrderPayment($order, $transaction = null, $reference = nul
'Unhandled transaction state : %1',
$transactionState
));
break;
}

// format the last transaction data for storing within the order payment record instance
Expand Down
2 changes: 0 additions & 2 deletions Model/Api/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,6 @@ public function hasItemErrors($quoteItem)
null,
$boltErrorCode
);

return false;
}

/**
Expand Down
1 change: 0 additions & 1 deletion Model/Api/UniversalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public function execute(
null,
BoltErrorResponse::ERR_SERVICE
);
break;
}

//not everything returns a value for result here. They send their own responses for now.
Expand Down
2 changes: 1 addition & 1 deletion Test/scripts/phpcs_meqp2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ composer create-project magento/magento-coding-standard --stability=dev magento-

cd magento-coding-standard

vendor/bin/phpcs ../project --standard=Magento2 --colors --severity=10 -p
vendor/bin/phpcs ../project --standard=Magento2 --colors --severity=9 -p

cd ../project
export MAGENTO_VERSION="2.3.0"
Expand Down
1 change: 1 addition & 0 deletions ThirdPartyModules/Amasty/Affiliate.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function beforeGetOrderByIdProcessNewOrder($result, $amastyAffiliateObser
*/
private function addToCookies($accountCode)
{
// phpcs:ignore
$_COOKIE[self::AMASTY_CURRENT_AFFILIATE_ACCOUNT_CODE] = $accountCode;
}
}
14 changes: 7 additions & 7 deletions ThirdPartyModules/Amasty/GiftCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function filterRemovingGiftCardCode(
}
try {
$giftCardTable = $this->resourceConnection->getTableName('amasty_amgiftcard_quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE code_id = :code_id AND quote_id = :quote_id";
$this->resourceConnection->getConnection()->query(
$sql,
Expand Down Expand Up @@ -319,13 +319,13 @@ public function replicateQuoteData(
$giftCardTable = $this->resourceConnection->getTableName('amasty_amgiftcard_quote');

// Clear previously applied gift cart codes from the immutable quote
// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :destination_quote_id";
$connection->query($sql, ['destination_quote_id' => $destination->getId()]);

// Copy all gift cart codes applied to the parent quote to the immutable quote
$sql = "INSERT INTO {$giftCardTable} (quote_id, code_id, account_id, base_gift_amount, code)
SELECT :destination_quote_id, code_id, account_id, base_gift_amount, code
FROM {$giftCardTable} WHERE quote_id = :source_quote_id";
// phpcs:ignore
$sql = "INSERT INTO {$giftCardTable} (quote_id, code_id, account_id, base_gift_amount, code) SELECT :destination_quote_id, code_id, account_id, base_gift_amount, code FROM {$giftCardTable} WHERE quote_id = :source_quote_id";

$connection->query(
$sql,
Expand All @@ -347,7 +347,7 @@ public function clearExternalData($quote)
$connection = $this->resourceConnection->getConnection();
try {
$giftCardTable = $this->resourceConnection->getTableName('amasty_amgiftcard_quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :quote_id";
$bind = [
'quote_id' => $quote->getId()
Expand All @@ -368,7 +368,7 @@ public function deleteRedundantDiscounts($quote)
try {
$giftCardTable = $this->resourceConnection->getTableName('amasty_amgiftcard_quote');
$quoteTable = $this->resourceConnection->getTableName('quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id IN
(SELECT entity_id FROM {$quoteTable}
WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)";
Expand Down Expand Up @@ -396,7 +396,7 @@ public function removeAmastyGiftCard($codeId, $quote)
$connection = $this->resourceConnection->getConnection();

$giftCardTable = $this->resourceConnection->getTableName('amasty_amgiftcard_quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE code_id = :code_id AND quote_id = :quote_id";
$connection->query($sql, ['code_id' => $codeId, 'quote_id' => $quote->getId()]);

Expand Down
10 changes: 5 additions & 5 deletions ThirdPartyModules/Amasty/GiftCardAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ public function replicateQuoteData(
$giftCardTable = $this->resourceConnection->getTableName('amasty_giftcard_quote');

// Clear previously applied gift cart codes from the immutable quote
// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :destination_quote_id";
$connection->query($sql, ['destination_quote_id' => $destination->getId()]);

// Copy all gift cart codes applied to the parent quote to the immutable quote
$sql = "INSERT INTO {$giftCardTable} (quote_id, gift_cards, gift_amount, base_gift_amount, gift_amount_used, base_gift_amount_used)
SELECT :destination_quote_id, gift_cards, gift_amount, base_gift_amount, gift_amount_used, base_gift_amount_used
FROM {$giftCardTable} WHERE quote_id = :source_quote_id";
// phpcs:ignore
$sql = "INSERT INTO {$giftCardTable} (quote_id, gift_cards, gift_amount, base_gift_amount, gift_amount_used, base_gift_amount_used) SELECT :destination_quote_id, gift_cards, gift_amount, base_gift_amount, gift_amount_used, base_gift_amount_used FROM {$giftCardTable} WHERE quote_id = :source_quote_id";

$connection->query(
$sql,
Expand All @@ -351,7 +351,7 @@ public function clearExternalData($quote)
try {
$connection = $this->resourceConnection->getConnection();
$giftCardTable = $this->resourceConnection->getTableName('amasty_giftcard_quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id = :quote_id";
$bind = [
'quote_id' => $quote->getId()
Expand All @@ -372,7 +372,7 @@ public function deleteRedundantDiscounts($quote)
$connection = $this->resourceConnection->getConnection();
$giftCardTable = $this->resourceConnection->getTableName('amasty_giftcard_quote');
$quoteTable = $this->resourceConnection->getTableName('quote');

// phpcs:ignore
$sql = "DELETE FROM {$giftCardTable} WHERE quote_id IN
(SELECT entity_id FROM {$quoteTable}
WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)";
Expand Down
4 changes: 2 additions & 2 deletions ThirdPartyModules/Amasty/Rewards.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function deleteRedundantDiscounts($quote)
try {
$rewardsTable = $this->resourceConnection->getTableName('amasty_rewards_quote');
$quoteTable = $this->resourceConnection->getTableName('quote');

// phpcs:ignore
$sql = "DELETE FROM {$rewardsTable} WHERE quote_id IN
(SELECT entity_id FROM {$quoteTable}
WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)";
Expand All @@ -285,7 +285,7 @@ public function clearExternalData($quote)
$connection = $this->resourceConnection->getConnection();
try {
$rewardsTable = $this->resourceConnection->getTableName('amasty_rewards_quote');

// phpcs:ignore
$sql = "DELETE FROM {$rewardsTable} WHERE quote_id = :quote_id";
$bind = [
'quote_id' => $quote->getId()
Expand Down
4 changes: 4 additions & 0 deletions ThirdPartyModules/MageWorld/Affiliate.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ public function beforeGetOrderByIdProcessNewOrder($result, $mwAffiliateHelperDat
private function setAffiliateCookies($sessionData)
{
if (isset($sessionData["mwAffiliateCustomer"])) {
// phpcs:ignore
$_COOKIE['customer'] = $sessionData["mwAffiliateCustomer"];
}
if (isset($sessionData["mwAffiliateReferralFrom"])) {
// phpcs:ignore
$_COOKIE['mw_referral_from'] = $sessionData["mwAffiliateReferralFrom"];
}
if (isset($sessionData["mwAffiliateReferralFromDomain"])) {
// phpcs:ignore
$_COOKIE['mw_referral_from_domain'] = $sessionData["mwAffiliateReferralFromDomain"];
}
if (isset($sessionData["mwAffiliateReferralTo"])) {
// phpcs:ignore
$_COOKIE['mw_referral_to'] = $sessionData["mwAffiliateReferralTo"];
}
}
Expand Down
4 changes: 2 additions & 2 deletions ThirdPartyModules/Zonos/DutyTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function beforeOrderDeleteRedundantQuotes($quote)

$zonosShippingQuotesTable = $this->resourceConnection->getTableName('zonos_shipping_quotes');
$quoteTable = $this->resourceConnection->getTableName('quote');

// phpcs:ignore
$sql = "DELETE FROM {$zonosShippingQuotesTable} WHERE quote_id IN
(SELECT entity_id FROM {$quoteTable}
WHERE bolt_parent_quote_id = :bolt_parent_quote_id AND entity_id != :entity_id)";
Expand Down Expand Up @@ -89,7 +89,7 @@ public function beforeCartDeleteQuote($quote)
$connection = $this->resourceConnection->getConnection();

$zonosShippingQuotesTable = $this->resourceConnection->getTableName('zonos_shipping_quotes');

// phpcs:ignore
$sql = "DELETE FROM {$zonosShippingQuotesTable} WHERE quote_id = :quote_id";
$bind = [
'quote_id' => $quote->getId()
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/templates/boltpay/button.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ foreach ($block->getAdditionalCheckoutButtonAttributes() as $attrName => $attrVa
<div class="bolt-checkout-options-separator" style="padding: 20px; display: none;">-- <?= /* @noEscape */ __('OR')?> --</div>
<div class="bolt-checkout-pay-by-link-generate" style="display: none;">
<button id='bolt-pay-by-link-generate' class="action-default">
<span><?= __('Generate order link') ?></span>
<span><?= /* @noEscape */ __('Generate order link') ?></span>
</button>
</div>
<div class="bolt-checkout-pay-by-link"></div>
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/templates/order/comment.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if (!$orderCommentModel->shouldDisplayForOrder($order)) {
</div>
<div class="admin__page-section-content">
<div class="admin__page-section-item">
<?php echo nl2br($block->escapeHtml($orderCommentModel->getCommentForOrder($order))); ?>
<?php /* @noEscape */ echo nl2br($block->escapeHtml($orderCommentModel->getCommentForOrder($order))); ?>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ $integrationStatus = $block->getIntegrationStatus();
'prototype'
], function(jQuery){
var collectSpan = jQuery('#bolt_integration_keys_span');
var keysValueId = jQuery('#<?= trim($block->getInputId()) ?>');
var keysValueId = jQuery('#<?= /* @noEscape */ trim($block->getInputId()) ?>');
jQuery('#bolt_integration_token_button').click(function () {
new Ajax.Request('<?= $block->escapeUrl($block->getProcessIntegrationTokenAjaxUrl()) ?>', {
parameters: {'store_id': '<?= trim($block->getStoreId()) ?>'},
parameters: {'store_id': '<?= /* @noEscape */ trim($block->getStoreId()) ?>'},
loaderArea: false,
asynchronous: true,
onCreate: function() {
Expand Down Expand Up @@ -74,17 +74,17 @@ $integrationStatus = $block->getIntegrationStatus();
});
</script>
<span id="bolt_integration_keys_span">
<img class="processing" hidden="hidden" alt="Processing" style="margin:0 5px" src="<?php echo $block->getViewFileUrl('images/process_spinner.gif') ?>"/>
<img class="created" hidden="hidden" alt="Created" style="margin:-3px 5px" src="<?php echo $block->getViewFileUrl('images/rule_component_apply.gif') ?>"/>
<img class="failure" hidden="hidden" alt="failure" style="margin:-3px 5px" src="<?php echo $block->getViewFileUrl('images/rule_component_remove.gif') ?>"/>
<img class="processing" hidden="hidden" alt="Processing" style="margin:0 5px" src="<?php /* @noEscape */ echo $block->getViewFileUrl('images/process_spinner.gif') ?>"/>
<img class="created" hidden="hidden" alt="Created" style="margin:-3px 5px" src="<?php /* @noEscape */ echo $block->getViewFileUrl('images/rule_component_apply.gif') ?>"/>
<img class="failure" hidden="hidden" alt="failure" style="margin:-3px 5px" src="<?php /* @noEscape */ echo $block->getViewFileUrl('images/rule_component_remove.gif') ?>"/>
<span id="bolt_integration_keys_message_span"></span>
</span>
<div class="message message-notice" id="bolt_integration_exits_proper" <?= $integrationStatus !== '1' ? 'hidden="hidden"' : '' ?>>
<div>It looks like Magento API keys successfully sent to Bolt. If you need to send keys again please click button above.
</div>
</div>
<div class="message message-notice" id="bolt_integration_exits_improper" <?= $integrationStatus !== '2' ? 'hidden="hidden"' : '' ?>>
<div>It looks like Magento API keys were created for <?= trim($block->getBoltOppositeMode()) ?> and now this store is in <?= trim($block->getBoltCurrentMode()) ?> mode.
<div>It looks like Magento API keys were created for <?= /* @noEscape */ trim($block->getBoltOppositeMode()) ?> and now this store is in <?= /* @noEscape */ trim($block->getBoltCurrentMode()) ?> mode.
Please delete keys and generate them again.
</div>
</div>
8 changes: 4 additions & 4 deletions view/frontend/templates/button_product_page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ foreach ($block->getAdditionalCheckoutButtonAttributes() as $attrName => $attrVa
<?php else: ?>
<style>.bolt-product-checkout-button-disabled svg[class*="__bolt"] rect.brect{opacity:.5 !important;cursor:default!important;pointer-events:none!important;}</style>
<div data-tid="instant-bolt-checkout-button" class="bolt-product-checkout-button-disabled <?= /* @noEscape */ $additionalClass;?>">
<object data="<?=$block->getCheckoutCdnUrl();?>/v1/checkout_button?publishable_key=<?=$block->getCheckoutKey();?><?=$block->getVariantForInstantButton("PPC");?>" class="bolt-product-checkout-button">
<object data="<?= /* @noEscape */ $block->getCheckoutCdnUrl();?>/v1/checkout_button?publishable_key=<?= /* @noEscape */$block->getCheckoutKey();?><?= /* @noEscape */ $block->getVariantForInstantButton("PPC");?>" class="bolt-product-checkout-button">
</object>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -383,7 +383,7 @@ foreach ($block->getAdditionalCheckoutButtonAttributes() as $attrName => $attrVa
let childProducts = new Map();
// collect child product id's and sku's
<?php foreach ($block->getGroupedProductChildren() as $childProduct):?>
childProducts.set(<?= $childProduct->getId() ?>, { sku: '<?= $childProduct->getSku() ?>'});
childProducts.set(<?= /* @noEscape */ $childProduct->getId() ?>, { sku: '<?= /* @noEscape */ $childProduct->getSku() ?>'});
<?php endforeach; ?>
childProducts.forEach((product, productId) => {
// get warranty plan configuration instance for current child product
Expand All @@ -404,13 +404,13 @@ foreach ($block->getAdditionalCheckoutButtonAttributes() as $attrName => $attrVa
<?php else: ?>
// get warranty plan configuration instance for current non-group product
// the "#warranty-offers" part is hardcoded in module
let extendWarrantyInstance = Extend.buttons.instance('#warranty-offers-<?= $block->getProduct()->getId() ?>');
let extendWarrantyInstance = Extend.buttons.instance('#warranty-offers-<?= /* @noEscape */ $block->getProduct()->getId() ?>');
if (extendWarrantyInstance) {
// get warranty plan selected
let extendWarrantyPlan = extendWarrantyInstance.getPlanSelection();
if (extendWarrantyPlan) {
// fill product sku to warranty plan, The key should be product it is module restriction
extendWarrantyPlan.product = '<?= $block->getProduct()->getSku() ?>';
extendWarrantyPlan.product = '<?= /* @noEscape */ $block->getProduct()->getSku() ?>';
extendWarrantyPlanItems.push(extendWarrantyPlan);
}
}
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/js/custom_sso_buttons.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $customSSOSelectors = $block->getCustomSSOSelectors();
var boltSSOCustomClass = 'bolt-sso-custom';
require(['Bolt_Boltpay/js/utils/when-defined'], function (whenDefined) {
whenDefined(window, 'BoltAccount', function () {
var selectors = <?php echo json_encode($customSSOSelectors); ?>;
var selectors = <?php /* @noEscape */ echo json_encode($customSSOSelectors); ?>;

/**
* Converts all present elements matching {@see loginSelectors} and {@see logoutSelectors}
Expand Down

0 comments on commit 179988e

Please sign in to comment.