Static properties make testing hard as you probably know. Is there no way to reset all static properties of a particular class back to their initial state? Ideally this would not require custom code for each class, but could be used in a general way by inheritance, or from outside of the class completely.
Please do not reply with something like, “don’t use static properties”. Thanks.
No. PHP does not preserve that information.
I was toying around with
ReflectionClassand::getDefaultPropertiesand::getStaticProperties, but they only return the current state.You will have to create an array with the default values, then manually foreach over them and reset your class attributes.