Re: [PHP-DEV] Class cast

This is only part of a thread. view whole thread
  109304
March 25, 2020 17:36 benjamin.morel@gmail.com (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: https://externals.io/message/105332 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