Skip to content

Commit 1457b5d

Browse files
author
Stanislav Idolov
committed
magento-engcom/magento2ce#4251: Code style fixes
1 parent 262d669 commit 1457b5d

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class Product extends AbstractEntity
651651
private $_logger;
652652

653653
/**
654-
* {@inheritdoc}
654+
* @var string
655655
*/
656656
protected $masterAttributeCode = 'sku';
657657

@@ -692,15 +692,11 @@ class Product extends AbstractEntity
692692
protected $rowNumbers = [];
693693

694694
/**
695-
* Product entity link field
696-
*
697695
* @var string
698696
*/
699697
private $productEntityLinkField;
700698

701699
/**
702-
* Product entity identifier field
703-
*
704700
* @var string
705701
*/
706702
private $productEntityIdentifierField;
@@ -720,15 +716,11 @@ class Product extends AbstractEntity
720716
private $filesystem;
721717

722718
/**
723-
* Catalog config.
724-
*
725719
* @var CatalogConfig
726720
*/
727721
private $catalogConfig;
728722

729723
/**
730-
* Stock Item Importer
731-
*
732724
* @var StockItemImporterInterface
733725
*/
734726
private $stockItemImporter;

app/code/Magento/JwtFrameworkAdapter/Model/JwsManager.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
/**
2828
* Works with JWS.
29+
*
30+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2931
*/
3032
class JwsManager
3133
{
@@ -77,20 +79,11 @@ public function __construct(
7779
*/
7880
public function build(JwsInterface $jws, EncryptionSettingsInterface $encryptionSettings): string
7981
{
80-
if (!$encryptionSettings instanceof JwsSignatureJwks) {
81-
throw new JwtException('Can only work with JWK encryption settings for JWS tokens');
82-
}
83-
$signaturesCount = count($encryptionSettings->getJwkSet()->getKeys());
84-
if ($jws->getProtectedHeaders() && count($jws->getProtectedHeaders()) !== $signaturesCount) {
85-
throw new MalformedTokenException('Number of headers must equal to number of JWKs');
86-
}
87-
if ($jws->getUnprotectedHeaders()
88-
&& count($jws->getUnprotectedHeaders()) !== $signaturesCount
89-
) {
90-
throw new MalformedTokenException('There must be an equal number of protected and unprotected headers.');
91-
}
82+
$this->validate($jws, $encryptionSettings);
9283
$builder = $this->jwsBuilder->create();
9384
$builder = $builder->withPayload($jws->getPayload()->getContent());
85+
$signaturesCount = count($encryptionSettings->getJwkSet()->getKeys());
86+
9487
for ($i = 0; $i < $signaturesCount; $i++) {
9588
$jwk = $encryptionSettings->getJwkSet()->getKeys()[$i];
9689
$protected = [];
@@ -101,6 +94,7 @@ public function build(JwsInterface $jws, EncryptionSettingsInterface $encryption
10194
$protected['kid'] = $jwk->getKeyId();
10295
}
10396
if ($jws->getProtectedHeaders()) {
97+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
10498
$protected = array_merge($protected, $this->extractHeaderData($jws->getProtectedHeaders()[$i]));
10599
}
106100
$protected['alg'] = $protected['alg'] ?? $jwk->getAlgorithm();
@@ -124,6 +118,28 @@ public function build(JwsInterface $jws, EncryptionSettingsInterface $encryption
124118
return $this->jwsSerializer->serialize('jws_compact', $jwsCreated);
125119
}
126120

121+
/**
122+
* Validate jws and encryption settings.
123+
*
124+
* @param JwsInterface $jws
125+
* @param EncryptionSettingsInterface $encryptionSettings
126+
*/
127+
private function validate(JwsInterface $jws, EncryptionSettingsInterface $encryptionSettings): void
128+
{
129+
if (!$encryptionSettings instanceof JwsSignatureJwks) {
130+
throw new JwtException('Can only work with JWK encryption settings for JWS tokens');
131+
}
132+
$signaturesCount = count($encryptionSettings->getJwkSet()->getKeys());
133+
if ($jws->getProtectedHeaders() && count($jws->getProtectedHeaders()) !== $signaturesCount) {
134+
throw new MalformedTokenException('Number of headers must equal to number of JWKs');
135+
}
136+
if ($jws->getUnprotectedHeaders()
137+
&& count($jws->getUnprotectedHeaders()) !== $signaturesCount
138+
) {
139+
throw new MalformedTokenException('There must be an equal number of protected and unprotected headers.');
140+
}
141+
}
142+
127143
/**
128144
* Read and verify JWS token.
129145
*

lib/internal/Magento/Framework/Mail/Message.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class Message implements MailMessageInterface
2222
protected $zendMessage;
2323

2424
/**
25-
* Message type
26-
*
2725
* @var string
2826
*/
2927
private $messageType = Mime::TYPE_TEXT;

0 commit comments

Comments
 (0)