If a class has a property of type object which is declared immutable and accessible from outside (public or via getter), the object itself must be immutable as well.
Example:
/** @var immutable */
class Immutable
{
public Cat $cat;
}
class Cat {
public int $lala; // not allowed here, Cat must be immutable
}
If a class has a property of type object which is declared immutable and accessible from outside (public or via getter), the object itself must be immutable as well.
Example: