Re: [PHP-DEV] Class cast

This is only part of a thread. view whole thread
March 25, 2020 17:36 (Benjamin Morel)
> > Currently PHP supports generic castings like (string), (int), ... maybe is > time to allow class castings like (ToClass) $fromObject?
I've proposed something similar a year ago: My intention wasn't to create an object from a scalar, nor was it to limit to a class' methods & properties (hardly possible in PHP), but to ensure that the value is an instance of the given class/interface, or throw an exception. My proposal wasn't so well received, though. — Ben