-
Notifications
You must be signed in to change notification settings - Fork 160
[New Rule] Method chaining in class design MUST be avoided #25
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
Comments
@lenaorobei I do understand that such "useful" sniff is quite easy to implement but it is firstly not applicable to Magento codebase and secondly is wrong in general. For example, returning Could you please point out where its approval comes from? Like architectural meeting notes or something. |
@orlangur the fact that the rule is accepted doesn't mean that implementation is accepted. The example I provided is just the suggested direction where to start the implementation. I'll fix the issue content.
We have an agreement with core team that every rule from Magento Technical Guidelines is automatically accepted. |
@lenaorobei , why the rule is marked as MUST while applying CQRS principles is recommended (SHOULD)? Also does that mean that data storage classes and interfaces will not have setter methods anymore as currently there too many methods that are modifying state of an object? |
Hello @chaikovskyia. This rule is the paragraph 2.15 of the Technical Guidelines. In case of any concerns regarding this rule, please crate an issue in the magento/architecture repository. Looks like this rule requires additional explanation and some exceptions. |
Cannot be implemented with PHP CodeSniffer. |
@lenaorobei why we cannot have it with exceptions for particular class types (extending |
@orlangur we need to enforce this rule and can discuss use cases and appropriate tool. |
…-coding-standard-228 [Imported] Moved abstract unit test to autoload-dev
Rule
Method chaining in class design MUST be avoided.
Reason
Source: Magento Technical Guidelines.
According to technical guidelines:
Good explanation of why method chaining contradicts this principal was described by Martin Fowler in the "Domain-Specific-Languages" book:
Suggested Implementation Direction
Detect
return $this;
in methods.The text was updated successfully, but these errors were encountered: