public function testDefFunction() { $code = 'echo(\'test\')'; $generated = $this->generator->defLine($code)->code(); $expected = <<<PHP public function testMethod() { echo('test') } PHP; static::assertEquals($expected, $generated); }
/** * Generate scope list * * @param MethodGenerator $constructorGenerator * @param array $scopes * @throws \InvalidArgumentException */ protected function generateScopeList(MethodGenerator $constructorGenerator, array $scopes) { $constructorGenerator->defLine('$this->scopes = ['); /** * @var string $scopeName * @var array $ids */ foreach ($scopes as $scopeName => $ids) { $constructorGenerator->defLine("\t'{$scopeName}' => ["); // Iterate service ids foreach ($ids as $id) { $constructorGenerator->defLine("\t\t'{$id}',"); } $constructorGenerator->defLine("\t]"); } $constructorGenerator->defLine('];'); }