/** * Initialize parameters array with reflection info. * Detect if there is $__content parameter -> is container * Detect if there is $__attrs parameter -> allow extra attributes */ protected function initialize() { $header = DocComments::getFileHeader($this->file); $vars = DocComments::getVars($header); $parameters = []; foreach ($vars as $name => $type) { if ($name === '__attrs') { $this->allowExtraParams = true; } elseif ($name === '__content') { $this->isContainer = true; } else { $parameters[$name] = $this->guessParameterDefinition($name, $type); } } $this->parameters = $parameters; }
/** * @test */ public function it_should_parse_vars_of_collection_type() { $comment = '/** * @var \\Namespace\\Object[] $objects * @var $__attrs string[] * @return string */'; $vars = DocComments::getVars($comment); $this->assertEquals(['objects' => '\\Namespace\\Object[]', '__attrs' => 'string[]'], $vars); }