However the forbidden classes would give much more flexibility, as there may be other features one might want to disallow in a project.
I would argue against fixer sniff for DateTime -> DateTimeImmutable blind replacement, as this would just lead to errors due to the mutability behavior.
I am willing to work on this if there is consensus on the usefulness of such sniff, otherwise I will implement it only as a part of my own standard.
P.S. making the forbidden classes sniff would work nicely if one wants to use an alternative to PHP's native types, like Carbon, as by forbidding both DateTime, DateTimeImmutable and Carbon you would always be forced to use CarbonImmutable which would be the only one allowed.
We have a sniff for forbidden functions, but I would like to have a sniff for forbidden classes.
More specifically, my usecase is to disallow use of
DateTime
, and forceDateTimeImmutable
Alternatively, we can also make a sniff just for this, given that there are talks about deprecating
DateTime
altogether in the future.However the forbidden classes would give much more flexibility, as there may be other features one might want to disallow in a project.
I would argue against fixer sniff for
DateTime
->DateTimeImmutable
blind replacement, as this would just lead to errors due to the mutability behavior.I am willing to work on this if there is consensus on the usefulness of such sniff, otherwise I will implement it only as a part of my own standard.
P.S. making the forbidden classes sniff would work nicely if one wants to use an alternative to PHP's native types, like Carbon, as by forbidding both
DateTime
,DateTimeImmutable
andCarbon
you would always be forced to useCarbonImmutable
which would be the only one allowed.