Skip to content

Optimization: magento/module-catalog is_null change to strict comparison#13171

Merged
magento-team merged 3 commits into
magento:2.2-developfrom
coderimus:fix/catalog-optimization-change-isnull
Jan 16, 2018
Merged

Optimization: magento/module-catalog is_null change to strict comparison#13171
magento-team merged 3 commits into
magento:2.2-developfrom
coderimus:fix/catalog-optimization-change-isnull

Conversation

@coderimus

@coderimus coderimus commented Jan 14, 2018

Copy link
Copy Markdown
Contributor

Hello,
This is the one of the optimization PR linked with the is_null() change. I decided to do them per module just to avoid any mistake during delivery and review.
Best regards,
Alex

Description

Micro-optimizations for Magento\Catalog
Magento2 has next sniff MicroOptimizations It checks next: is_null must be avoided. Use strict comparison instead.
Some classes are under // @codingStandardsIgnoreFile such as Magento\Catalog module models, block and cannot be checked during static tests. In this PR I replaced is_null with strict comparison only for models and block in Magento\Catalog module.

Fixed Issues (if relevant)

N/A

Manual testing scenarios

N/A

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

{
$params = ['_current' => true, 'id' => null, 'store' => null];
if (is_null($expanded) && $this->_backendSession->getIsTreeWasExpanded() || $expanded == true) {
if (($expanded === null) && $this->_backendSession->getIsTreeWasExpanded() || $expanded == true) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to remove brackets near $expanded === null. They're not needed there

$option->getStoreTitle() === null
);
$value['scopeTitleDisabled'] = is_null($option->getStoreTitle()) ? 'disabled' : null;
$value['scopeTitleDisabled'] = ($option->getStoreTitle() === null) ? 'disabled' : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also

$option->getStorePrice() === null
);
$value['scopePriceDisabled'] = is_null($option->getStorePrice()) ? 'disabled' : null;
$value['scopePriceDisabled'] = ($option->getStorePrice() === null) ? 'disabled' : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there

{
$this->_renderFilters();
$countSelect = is_null($select) ? $this->_getClearSelect() : $this->_buildClearSelect($select);
$countSelect = ($select === null) ? $this->_getClearSelect() : $this->_buildClearSelect($select);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there

@coderimus

Copy link
Copy Markdown
Contributor Author

@ihor-sviziev thank you for your review! I made requested changes according to your review. Please, check. :)

$this->_productLimitationFilters->setUsePriceIndex(true);

if (!isset($this->_productLimitationFilters['customer_group_id']) && is_null($customerGroupId)) {
if (!isset($this->_productLimitationFilters['customer_group_id']) && ($customerGroupId === null)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary brackets.

$customerGroupId = $this->_customerSession->getCustomerGroupId();
}
if (!isset($this->_productLimitationFilters['website_id']) && is_null($websiteId)) {
if (!isset($this->_productLimitationFilters['website_id']) && ($websiteId === null)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there

@ihor-sviziev

Copy link
Copy Markdown
Contributor

@coderimus few more issues are left. Sorry for not sending it at first time

@coderimus

Copy link
Copy Markdown
Contributor Author

@ihor-sviziev thank you for your comments and detail review! I added needed changes, please, check.

@ishakhsuvarov ishakhsuvarov self-assigned this Jan 15, 2018
@ishakhsuvarov ishakhsuvarov added this to the January 2018 milestone Jan 15, 2018
@magento-team magento-team merged commit b864e49 into magento:2.2-develop Jan 16, 2018
magento-team pushed a commit that referenced this pull request Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants