The Problem
SimpleDTOs can contain self-references that lead to inifinite recursion. This is doubly bad with NestedDTOs, which can even contain self-references.
With the infinite recursion freeze, it gets stopped by Xdebug but in production, SimpleDTO uses up 100% of permitted RAM in php-fpm and crashes the entire server under certain situations, which is not good.
The Solution
Implement a Recursive Serialization class that detects infinite recursion. Once detected, the recursive elements should be reformatted as a string with the value of `RECURSION.
Spin this off as phpexperts/recursive-serializer. It should handle SimpleDTOs, reguarly PHP data objects, arrays, and any other class that is Traversable or Iterable.