Is it possible to remove NoClassInstantiationSniff?
Closed this issue · 2 comments
I would send a pull request, but just removing this sniff doesn't help.
I think that this sniff is against OOP.
My use case - I have a domain class Cart
, I want to create an internal domain object Item
. The Item
is part of the internal structure and will never be propagated out of the aggregate Cart
. This is the implementation. I know I use Cart
and in this class, there will be always Item
, if I ever decide to change this, I will write another implementation.
It there was a factory passed to the Cart
, everything will be overcomplicated and this factory will never be changed. It would be just nonsense. And what more - it will be against domain design, because there is nothing like a factory in the domain.
The problematic class (and will be more): https://github.com/simara-svatopluk/cart/blob/domain-logic/src/Domain/Cart.php
@TomasVotruba Could You please help me?
tl;dr; Sure 👍
I realize this rule valid only in DI-ready-packages, not community websites with posts.
Feel free to add it to excluded_checkers
in easy-coding-standard.neon
Thanks for a quick response. I'll do it in a separated commit with next article.