Ive some classes that share some attributes, and i would like to do something like:
$dog = (Dog) $cat;
is it possible or is there any gener
You may think about factories
class XyFactory {
public function createXyObject ($other) {
$new = new XyObject($other->someValue);
// Do other things, that let $new look like $other (except the used class)
return $new;
}
}
Otherwise user250120s solution is the only one, which comes close to class casting.