Skip to content

Commit 39244bf

Browse files
authored
Merge pull request #6273 from magento-tsg/MC-29414
[Arrows] MC-29414: PHPStan: "Method invoked with X parameters, Y required" errors
2 parents a1e5689 + a63438d commit 39244bf

File tree

51 files changed

+160
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+160
-259
lines changed

app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected function _countExpr($expr, $collection)
117117
foreach ($parsedExpression as $operand) {
118118
if ($this->_parser->isOperation($operand)) {
119119
$this->_checkOperandsSet($firstOperand, $secondOperand, $tmpResult, $result);
120-
$result = $this->_operate($firstOperand, $secondOperand, $operand, $tmpResult, $result);
120+
$result = $this->_operate($firstOperand, $secondOperand, $operand);
121121
$firstOperand = $secondOperand = null;
122122
} else {
123123
if (null === $firstOperand) {
@@ -133,9 +133,9 @@ protected function _countExpr($expr, $collection)
133133
/**
134134
* Check if operands in not null and set operands values if they are empty
135135
*
136-
* @param float|int &$firstOperand
137-
* @param float|int &$secondOperand
138-
* @param float|int &$tmpResult
136+
* @param float|int $firstOperand
137+
* @param float|int $secondOperand
138+
* @param float|int $tmpResult
139139
* @param float|int $result
140140
* @return void
141141
*/

app/code/Magento/Backend/Test/Unit/Helper/DataTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ protected function setUp(): void
4242
$this->createMock(Auth::class),
4343
$this->_frontResolverMock,
4444
$this->createMock(Random::class),
45-
$this->getMockForAbstractClass(RequestInterface::class)
4645
);
4746
}
4847

app/code/Magento/Catalog/Block/Product/View/Details.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ class Details extends \Magento\Framework\View\Element\Template
2727
*
2828
* @return array
2929
* @since 103.0.1
30+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3031
*/
3132
public function getGroupSortedChildNames(string $groupName, string $callback): array
3233
{
33-
$groupChildNames = $this->getGroupChildNames($groupName, $callback);
34+
$groupChildNames = $this->getGroupChildNames($groupName);
3435
$layout = $this->getLayout();
3536

3637
$childNamesSortOrder = [];

app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Tree extends Dbp
2424

2525
const LEVEL_FIELD = 'level';
2626

27+
/**
28+
* @var array
29+
*/
30+
private $_inactiveItems;
31+
2732
/**
2833
* @var \Magento\Framework\Event\ManagerInterface
2934
*/
@@ -290,7 +295,7 @@ protected function _getDisabledIds($collection, $allIds)
290295
foreach ($allIds as $id) {
291296
$parents = $this->getNodeById($id)->getPath();
292297
foreach ($parents as $parent) {
293-
if (!$this->_getItemIsActive($parent->getId(), $storeId)) {
298+
if (!$this->_getItemIsActive($parent->getId())) {
294299
$disabledIds[] = $id;
295300
continue;
296301
}
@@ -680,6 +685,8 @@ public function getExistingCategoryIdsBySpecifiedIds($ids)
680685
}
681686

682687
/**
688+
* Get entity methadata pool.
689+
*
683690
* @return \Magento\Framework\EntityManager\MetadataPool
684691
*/
685692
private function getMetadataPool()

app/code/Magento/Catalog/Model/ResourceModel/Product/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected function _saveAttributeValue($object, $attribute, $value)
160160
$storeId = (int) $this->_storeManager->getStore($object->getStoreId())->getId();
161161
$table = $attribute->getBackend()->getTable();
162162

163-
$entityId = $this->resolveEntityId($object->getId(), $table);
163+
$entityId = $this->resolveEntityId($object->getId());
164164

165165
/**
166166
* If we work in single store mode all values should be saved just

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ class RepositoryTest extends TestCase
8383
*/
8484
protected $searchResultMock;
8585

86-
/**
87-
* @var AttributeOptionManagementInterface|MockObject
88-
*/
89-
private $optionManagementMock;
90-
9186
/**
9287
* @inheritdoc
9388
*/
@@ -116,8 +111,6 @@ protected function setUp(): void
116111
['getItems', 'getSearchCriteria', 'getTotalCount', 'setItems', 'setSearchCriteria', 'setTotalCount']
117112
)
118113
->getMockForAbstractClass();
119-
$this->optionManagementMock =
120-
$this->getMockForAbstractClass(ProductAttributeOptionManagementInterface::class);
121114

122115
$this->model = new Repository(
123116
$this->attributeResourceMock,
@@ -126,8 +119,7 @@ protected function setUp(): void
126119
$this->eavAttributeRepositoryMock,
127120
$this->eavConfigMock,
128121
$this->validatorFactoryMock,
129-
$this->searchCriteriaBuilderMock,
130-
$this->optionManagementMock
122+
$this->searchCriteriaBuilderMock
131123
);
132124
}
133125

@@ -291,7 +283,6 @@ public function testSaveDoesNotSaveAttributeOptionsIfOptionsAreAbsentInPayload()
291283
// Attribute code must not be changed after attribute creation
292284
$attributeMock->expects($this->once())->method('setAttributeCode')->with($attributeCode);
293285
$this->attributeResourceMock->expects($this->once())->method('save')->with($attributeMock);
294-
$this->optionManagementMock->expects($this->never())->method('add');
295286

296287
$this->model->save($attributeMock);
297288
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function setUp(): void
6666
];
6767
$configMock->expects($this->once())->method('getAll')->willReturn($config);
6868
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', 'getData'];
69-
$this->valueMock = $this->createPartialMock(Option::class, $methods, []);
69+
$this->valueMock = $this->createPartialMock(Option::class, $methods);
7070
$this->validator = new Select(
7171
$configMock,
7272
$priceConfigMock,

app/code/Magento/Catalog/Test/Unit/Model/Product/Price/PricePersistenceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function testDeleteWithException()
301301
->willReturn($idsBySku);
302302
$this->attributeRepository->expects($this->once())->method('get')->willReturn($this->productAttribute);
303303
$this->productAttribute->expects($this->once())->method('getAttributeId')->willReturn($attributeId);
304-
$this->attributeResource->expects($this->atLeastOnce(2))->method('getConnection')
304+
$this->attributeResource->expects($this->atLeastOnce())->method('getConnection')
305305
->willReturn($this->connection);
306306
$this->connection->expects($this->once())->method('beginTransaction')->willReturnSelf();
307307
$this->attributeResource

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function validate(Observer $observer)
193193
$option->setHasError(true);
194194
//Setting this to false, so no error statuses are cleared
195195
$removeError = false;
196-
$this->addErrorInfoToQuote($result, $quoteItem, $removeError);
196+
$this->addErrorInfoToQuote($result, $quoteItem);
197197
}
198198
}
199199
if ($removeError) {

app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class AfterProductLoadTest extends TestCase
3030
*/
3131
protected $productMock;
3232

33-
/**
34-
* @var ProductExtensionFactory|MockObject
35-
*/
36-
protected $productExtensionFactoryMock;
37-
3833
/**
3934
* @var ProductExtensionInterface|MockObject
4035
*/
@@ -43,16 +38,9 @@ class AfterProductLoadTest extends TestCase
4338
protected function setUp(): void
4439
{
4540
$stockRegistryMock = $this->getMockForAbstractClass(StockRegistryInterface::class);
46-
$this->productExtensionFactoryMock = $this->getMockBuilder(
47-
ProductExtensionFactory::class
48-
)
49-
->setMethods(['create'])
50-
->disableOriginalConstructor()
51-
->getMock();
5241

5342
$this->plugin = new AfterProductLoad(
54-
$stockRegistryMock,
55-
$this->productExtensionFactoryMock
43+
$stockRegistryMock
5644
);
5745

5846
$productId = 5494;
@@ -88,8 +76,6 @@ public function testAfterLoad()
8876
$this->productMock->expects($this->once())
8977
->method('getExtensionAttributes')
9078
->willReturn($this->productExtensionMock);
91-
$this->productExtensionFactoryMock->expects($this->never())
92-
->method('create');
9379

9480
$this->assertEquals(
9581
$this->productMock,

app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ public function dispatchExceptionInCallbackDataProvider()
679679

680680
/**
681681
* Test case, successfully run job
682+
*
683+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
682684
*/
683685
public function testDispatchRunJob()
684686
{
@@ -764,7 +766,7 @@ function ($callback) {
764766
->method('getCollection')->willReturn($this->scheduleCollectionMock);
765767
$scheduleMock->expects($this->any())
766768
->method('getResource')->willReturn($this->scheduleResourceMock);
767-
$this->scheduleFactoryMock->expects($this->once(2))
769+
$this->scheduleFactoryMock->expects($this->once())
768770
->method('create')->willReturn($scheduleMock);
769771

770772
$testCronJob = $this->getMockBuilder('CronJob')

app/code/Magento/Customer/Model/Address.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* Customer address model
1616
*
1717
* @api
18-
* @method int getParentId() getParentId()
19-
* @method \Magento\Customer\Model\Address setParentId() setParentId(int $parentId)
18+
* @method int getParentId()
19+
* @method \Magento\Customer\Model\Address setParentId(int $parentId)
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
* @since 100.0.2
2222
*/

app/code/Magento/Customer/Model/ResourceModel/Customer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct(
8585
$this->accountConfirmation = $accountConfirmation ?: ObjectManager::getInstance()
8686
->get(AccountConfirmation::class);
8787
$this->setType('customer');
88-
$this->setConnection('customer_read', 'customer_write');
88+
$this->setConnection('customer_read');
8989
$this->storeManager = $storeManager;
9090
}
9191

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,7 @@ public function testExecuteInvalidFile()
257257

258258
$this->urlDecoderMock->expects($this->once())->method('decode')->with($decodedFile)->willReturn($file);
259259
$fileFactoryMock = $this->createMock(
260-
FileFactory::class,
261-
[],
262-
[],
263-
'',
264-
false
260+
FileFactory::class
265261
);
266262

267263
$controller = $this->objectManager->getObject(

app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/SampleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected function setUp(): void
9696
*/
9797
public function testSave($product, array $data, array $modelData)
9898
{
99-
$link = $this->createSampleModel($product, $modelData, true);
99+
$link = $this->createSampleModel($product, $modelData);
100100
$this->metadataMock->expects($this->once())->method('getLinkField')->willReturn('id');
101101
$this->sampleFactory->expects($this->once())
102102
->method('create')

app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class AttributeLoaderTest extends TestCase
4848

4949
protected function setUp(): void
5050
{
51-
$this->configMock = $this->createMock(Config::class, [], [], '', false);
51+
$this->configMock = $this->createMock(Config::class);
5252
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
5353
->setMethods(['create'])
5454
->disableOriginalConstructor()
5555
->getMockForAbstractClass();
56-
$this->entityMock = $this->createMock(AbstractEntity::class, [], [], '', false);
57-
$this->entityTypeMock = $this->createMock(Type::class, [], [], '', false);
56+
$this->entityMock = $this->createMock(AbstractEntity::class);
57+
$this->entityTypeMock = $this->createMock(Type::class);
5858
$this->attributeLoader = new AttributeLoader(
5959
$this->configMock,
6060
$this->objectManagerMock

app/code/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Link.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public function isDisabled()
8181
}
8282

8383
/**
84-
* Return URL pattern for action associated with the link e.g. "(star)(slash)(star)(slash)activate" ->
85-
* will be translated to http://.../admin/integration/activate/id/X
84+
* Return URL pattern for action associated with the link e.g. "(star)(slash)(star)(slash)activate"
85+
*
86+
* Will be translated to http://.../admin/integration/activate/id/X
8687
*
8788
* @return string
8889
*/
@@ -164,6 +165,6 @@ protected function _getDataAttributes()
164165
*/
165166
protected function _getUrl(DataObject $row)
166167
{
167-
return $this->isDisabled($row) ? '#' : $this->getUrl($this->getUrlPattern(), ['id' => $row->getId()]);
168+
return $this->isDisabled() ? '#' : $this->getUrl($this->getUrlPattern(), ['id' => $row->getId()]);
168169
}
169170
}

app/code/Magento/Integration/Model/Oauth/Consumer.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* @api
1414
* @author Magento Core Team <[email protected]>
1515
* @method string getName()
16-
* @method Consumer setName() setName(string $name)
17-
* @method Consumer setKey() setKey(string $key)
18-
* @method Consumer setSecret() setSecret(string $secret)
19-
* @method Consumer setCallbackUrl() setCallbackUrl(string $url)
20-
* @method Consumer setCreatedAt() setCreatedAt(string $date)
16+
* @method Consumer setName(string $name)
17+
* @method Consumer setKey(string $key)
18+
* @method Consumer setSecret(string $secret)
19+
* @method Consumer setCallbackUrl(string $url)
20+
* @method Consumer setCreatedAt(string $date)
2121
* @method string getUpdatedAt()
22-
* @method Consumer setUpdatedAt() setUpdatedAt(string $date)
22+
* @method Consumer setUpdatedAt(string $date)
2323
* @method string getRejectedCallbackUrl()
24-
* @method Consumer setRejectedCallbackUrl() setRejectedCallbackUrl(string $rejectedCallbackUrl)
24+
* @method Consumer setRejectedCallbackUrl(string $rejectedCallbackUrl)
2525
* @since 100.0.2
2626
*/
2727
class Consumer extends \Magento\Framework\Model\AbstractModel implements ConsumerInterface
@@ -112,7 +112,7 @@ public function beforeSave()
112112
}
113113

114114
/**
115-
* {@inheritdoc}
115+
* @inheritDoc
116116
*/
117117
public function validate()
118118
{
@@ -158,39 +158,39 @@ public function loadByKey($key)
158158
}
159159

160160
/**
161-
* {@inheritdoc}
161+
* @inheritDoc
162162
*/
163163
public function getKey()
164164
{
165165
return $this->getData('key');
166166
}
167167

168168
/**
169-
* {@inheritdoc}
169+
* @inheritDoc
170170
*/
171171
public function getSecret()
172172
{
173173
return $this->getData('secret');
174174
}
175175

176176
/**
177-
* {@inheritdoc}
177+
* @inheritDoc
178178
*/
179179
public function getCallbackUrl()
180180
{
181181
return $this->getData('callback_url');
182182
}
183183

184184
/**
185-
* {@inheritdoc}
185+
* @inheritDoc
186186
*/
187187
public function getCreatedAt()
188188
{
189189
return $this->getData('created_at');
190190
}
191191

192192
/**
193-
* {@inheritdoc}
193+
* @inheritDoc
194194
*/
195195
public function isValidForTokenExchange()
196196
{

0 commit comments

Comments
 (0)