Skip to content
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

Technical guidelines > Abstract classes MUST NOT be marked as public @api #25133

Conversation

lfluvisotto
Copy link
Contributor

@lfluvisotto lfluvisotto commented Oct 18, 2019

Technical guidelines > Abstract classes MUST NOT be marked as public @api

Description (*)

According to Technical guidelines > Abstract classes MUST NOT be marked as public @api.

https://devdocs.magento.com/guides/v2.3/coding-standards/technical-guidelines.html

Having the tag @api in abstract classes generates every time warning when using php code sniffer + coding standard magento.

As discussed in the comments of this pull request with @buskamuza, we cannot simply remove the @api tag from source code for compatibility with third party modules (extension developers).

However we cannot keep this warning if we want to have all source code covered and validated with php code sniffer + magento standard coding.

The solution is to add the line "phpcs: disable Magento2.Classes.AbstractApi" to all abstract classes that have the @api tag as has already been done in some abstract classes.

The purpose of this pull request is to increase and intensify coverage and validations with php code sniffer + magento standard coding.

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 18, 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.

@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch from 779fcad to 093f256 Compare October 18, 2019 13:20
@buskamuza
Copy link
Contributor

We can't remove existing @api from abstract classes. If a class is marked with @api, it is considered necessary for extension developers. But for the new code, this should not happen.
In order to remove @api from existing classes, we should provide other ways of the same extensibility first, and allow people to migrate.

@lfluvisotto
Copy link
Contributor Author

lfluvisotto commented Oct 21, 2019

@buskamuza

So the "Technical guidelines" > "2.8. Abstract classes MUST NOT be marked as public @api" is incorrect ? Should we remove this item from devdocs ? Or the "MUST NOT" in the item 2.8 needs to be more detailed, for example, only for third party source code (third party modules) and not for magento source code ?

The php code sniffer with standard magento coding is already validating this rule and impacting us, every moment generates warning.

Do you think we'd better add "phpcs: disable Magento2.Classes.AbstractApi" in all abstract magento source code classes where there "@api" for php code sniffer to stop generating warnings?

@buskamuza
Copy link
Contributor

Yes, I'd recommend to suppress validation for specific files.

Regarding the rule itself, no, I'd not remove it. New code should comply with it. But old code needs time and effort to be refactored, so that it can comply with Tech Guidelines. Having the rule helps to evolve code in the desired direction.

@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch from 093f256 to 55cc5cd Compare October 22, 2019 03:11
@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch 2 times, most recently from 83c0bd9 to 4ca0e63 Compare November 14, 2019 21:45
@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch 2 times, most recently from 9ca7959 to 312fa0f Compare November 23, 2019 02:03
@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:17
@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch from 8b30d92 to eb32b0c Compare December 9, 2019 01:04
@lfluvisotto lfluvisotto force-pushed the 2.3-develop-abstract-class-api branch from eb32b0c to 05a397b Compare December 9, 2019 02:02
@ihor-sviziev ihor-sviziev self-assigned this Feb 17, 2020
@@ -13,6 +13,8 @@
*
* phpcs:disable Magento2.Classes.AbstractApi
* Backend grid item abstract renderer
*
* phpcs:disable Magento2.Classes.AbstractApi
Copy link
Contributor

@ihor-sviziev ihor-sviziev Feb 18, 2020

Choose a reason for hiding this comment

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

This class already contains it. this line above, please fix duplicate

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. Could you fix static test?
Also note that static test failures related to not meaningful phpdoc blocks could be just removed.
Related PR in coding standard: magento/magento-coding-standard#171

@ihor-sviziev
Copy link
Contributor

@lfluvisotto I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@m2-assistant
Copy link

m2-assistant bot commented Mar 4, 2020

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.

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.

6 participants