> > I'd build this in userspace, but of course we don't have operator > overloading, so the API would be a somewhat uglier function call:
It is currently possible to get operator overloads in userspace using FFI (using my fork of lisachenko's z-engine to FFI into PHP calls). I made a quick prototype implementation: https://github.com/iggyvolz/sstream (of course any IDE or static analysis tool is going to yell at you for writing `object << string` but it works) . Whether to use << or <<= or >> or >>= is up to debate but the general concept of "$x << $y calls $x->append($y)" is there.