Skip to content

Quality Assurance > The use of function sizeof() is discouraged; use count() instead #25226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lfluvisotto
Copy link
Contributor

@lfluvisotto lfluvisotto commented Oct 22, 2019

Quality Assurance > The use of function sizeof() is discouraged; use count() instead

Description (*)

According to PHP Code Sniffer + Magento Coding Standard

https://github.com/squizlabs/PHP_CodeSniffer/blob/ae3aae46a11e3978f088552160ccca13a01b28e1/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php#L30

Discourages the use of alias functions. Alias functions are kept in PHP for compatibility with older versions. Can be used to forbid the use of any function.

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

N/A

Questions or comments

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 are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 22, 2019

Hi @lfluvisotto. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Hi @lfluvisotto,
Your changes looks good, however in files that you’ve changed we have failing static tests. Could you review and fix static tests failures?

@ghost ghost assigned ihor-sviziev Oct 23, 2019
@lfluvisotto
Copy link
Contributor Author

@ihor-sviziev

This is my contribution to solving a part of this Static Tests problem.

Several pull requests from other contributors are not going through Static Tests because the legacy code is not covered by php code sniffer + magento standard coding.

I intend to fix the other violations in other pull requests with specific scopes so as not to get all mixed up and confused.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Oct 24, 2019

Hi @lfluvisotto,
Unfortunately there is too many places where static tests are failing and it’s almost impossible to fix all the issues together. Because of that we’re running them only for files that were changed in PR. So in scope of this PR please fix failing static tests.

Some pieces could be just ignored if it requires refactoring

Thank you!

@lfluvisotto lfluvisotto force-pushed the 2.3-develop-sizeof-count branch 3 times, most recently from 12a93f3 to 0ed4fcb Compare October 27, 2019 19:44
@lfluvisotto lfluvisotto force-pushed the 2.3-develop-sizeof-count branch from 0ed4fcb to 60e77f0 Compare October 28, 2019 03:17
@ihor-sviziev
Copy link
Contributor

@magento run all tests

@ghost ghost assigned VladimirZaets Nov 6, 2019
@VladimirZaets VladimirZaets added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Nov 6, 2019
@magento-engcom-team
Copy link
Contributor

Hi @VladimirZaets, thank you for the review.
ENGCOM-6246 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

@magento run all tests

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

magento-engcom-team pushed a commit that referenced this pull request Nov 18, 2019
@magento-engcom-team magento-engcom-team merged commit 6e1822d into magento:2.3-develop Nov 18, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 18, 2019

Hi @lfluvisotto, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.5 milestone Nov 18, 2019
@VladimirZaets VladimirZaets added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests labels Nov 18, 2019
Comment on lines -147 to +148
$params = array_merge($action['url']['params'], $params);
$params[] = $action['url']['params'];
Copy link
Contributor

Choose a reason for hiding this comment

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

In my opinion - this line introduces the bug, as previously you had:

$action['url']['params'] = ['a' => 'A', 'b' => 'B'];
$params = ['x' => 'X'];

$params = array_merge($action['url']['params'], $params);

resulted in having keys a, b and x.

The new approach results in:

'x' => 'X',
[
    'a' => 'A',
    'b' => 'B'
]

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Could you create Pull request for that?

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.

8 participants