Nelmio\Alice\Parser\Chainable\PhpParser::parse PHP Method

parse() public method

{@inheritDoc}
public parse ( string $file ) : array
$file string Local PHP file
return array
    public function parse(string $file) : array
    {
        if (false === file_exists($file)) {
            throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
        }
        $data = (include $file);
        if (false === is_array($data)) {
            throw TypeErrorFactory::createForInvalidFixtureFileReturnedData($file);
        }
        return $data;
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException \TypeError
  * @expectedExceptionMessageRegExp /^The file ".+\/wrong_return\.php" must return a PHP array\.$/
  */
 public function testThrowsAnExceptionIfWrongValueReturnedInParsedFile()
 {
     $this->parser->parse(self::$dir . '/wrong_return.php');
 }