If the signature of a method has a Map collection as the default value of a parameter, an error is thrown when using the ReflectionClass to inspect that method.
Cannot use collection initialization in non-collection class
The class looks like:
<?hh //strict
namespace Acme;
class Foo
{
protected Map<string, string> $options;
public function __construct(Map<string, string> $options = Map{})
{
$this->options = $options;
}
}
And the reflection error happens when
$reflection = new ReflectionClass('Acme\Foo');
$reflection->getConstructor()->getParameters();
The class instantiates correctly when actually using it. I can only create the error using Reflection.
Question
Is there something I'm doing wrong, or concept I'm missing, to make this work as expected? I would expect the getProperties
to return the properties for the method, like it does with any other value/type.