As mentioned before I’m really looking forward to Typed Properties that will land in PHP 7.4 (now in alpha!). Brent has done a full writeup on ‘m:
In this post we’ll look at the feature in-depth, but first let’s start by summarising the most important points:
- They are available as of PHP 7.4, which is scheduled to be released in November of 2019
- They are only available in classes and require an access modifier:
public
,protected
orprivate
; orvar
- All types are allowed, except
void
andcallable
💭 As also mentioned before, I’m missing one specific typehint: Foo[]
.
This typehint would tell PHP that you require a variable to be “an array of Foo
‘s”. With the current typehint system that not possible: when requiring the type array
, you cannot specify its contents.
And no, the variadic function syntax is not a closing solution workaround for this.