Is there a way to specify an object’s attribute’s type in PHP ?
for example, I’d have something like :
class foo{
public bar $megacool;//this is a 'bar' object
public bar2 $megasupercool;//this is a 'bar2' object
}
class bar{...}
class bar2{...}
If not, do you know if it will be possible in one of PHP’s future version, one day ?
In addition to the TypeHinting already mentioned, you can document the property, e.g.
The
@var annotationwould help some IDEs in providing Code Assistance.