1

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.

kyleferg
  • 53
  • 6
  • Interesting. What is your question? – George Brighton May 26 '15 at 16:40
  • I'm wondering if I'm missing something to make this work as expected. Any other value/type and the inspection gives me back the appropriate properties etc. I would expect the same behavior with collections. – kyleferg May 26 '15 at 16:45

1 Answers1

0

This looks like a bug. Please file it on our GitHub issue tracker.

Josh Watzman
  • 7,060
  • 1
  • 18
  • 26