/** * @test */ public function it_should_return_null_if_no_header_found() { $file = '<?php $some = "PHP Code here"; // No header at all! ?> <div class="component Hello-World" <?= attrs($__attrs) ?>> <h1>Hello<br/> <small>my name is</small> </h1> <div class="content"> <?= $__content ?> </div> </div>'; $resource = fopen('php://memory', 'r+'); fputs($resource, $file); rewind($resource); $header = DocComments::getFileHeader($resource); $this->assertEquals(null, $header); @fclose($resource); }
/** * 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; }