-
Notifications
You must be signed in to change notification settings - Fork 10
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
Rule: MEQP2.Classes.ConstructorOperations #46
Comments
See #54 |
To do: add a simple example |
@schmengler I totally agree, but(!) what about classes, that are not necessarily instantiated via the OM? Value Objects for example should validate the input in the constructor (from what I've learned last year in amersfoort ;) ). I think there is already a very similar discussion in the "when to use new" issue #17 |
I complete agree with @davidverholen . Classes like Value Objects should impose stricter rules upon constructor arguments than the ones supplied by PHP 7 (using type hinting with Strict Types enabled). Simple types ( But perhaps, we can negotiate the meaning of dependency assignment operations as the rule definition mentions it. Assuming that the variables
|
Rule
Only dependency assignment operations are allowed in constructor. No other operations are allowed.
The rule can be included from MEQP2 with severity 5 (default), and needs to be documented with examples.
Reason
Magento instantiates all objects in the dependency graph early (if no proxy is used), so instantiation must 1. be fast and 2. not depend on any application state
The text was updated successfully, but these errors were encountered: