-
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: Keyword new
should not be used
#17
Comments
I agree that there are some use cases when |
It's used heavily for exceptions:
How about for a data transport object?
|
Completely agree with @fooman. Theoretically, exceptions and |
I think the use of |
Just wanted to add the bit that: Magento architects have said Exceptions should be created with the |
@navarr thank god, there's still some sanity :D I started a neverending argument when replacing a While I don't agree with "never use A random thought: Would it make sense to "not use |
We agreed that the spirit of the rule is good, namely to encourage dependency injection, but it may be too strict. We want to try it out for a while, with a low warning level and of course document when and why this makes sense. |
Thank you @lenaorobei, I included and documented the rule in #45 |
The
new
keyword should not be used to instantiate new classes. Constructor DI needs to be used instead.The text was updated successfully, but these errors were encountered: