potatoCode;10923744 wrote:Hello php experts!
I'm trying to get my head around php OOP and need some clarification.
My understanding is that php variables can hold any data type without
explicitly declaring its type.
Yes, the type of any variable's value is decided at run-time, either due to explicit setting via casting or [man]settype/man, or else by implicitly determined type based on context. The type can be changed at any time when a new value is assigned, and automatic "type juggling" can occur whenever a variable of one type is used in the context of another type.
Judging from this fact, am I correct in saying that
A. php supports covariant return, but does not enforce contravariance.
B. slicing still occurs in inheritance.
I'm afraid I'm not smart enough to know what you are asking, let alone the answer. 😕 I'm sure Weedpacket, Laserlight or one of the other better educated programmers here will be along soon to provide some feedback.