/** * @expectedException Psc\Code\Generate\SyntaxErrorException */ public function testParseError() { $function = new GFunction('erroneous', array()); $function->setSourceCode(" \$das ist natürlich quatsch "); /* okay das ist schon gemein hacky normalerweise muss die reflection ja die methode / funktion laden könne und das kann die ja auch nicht, wenn sie einen syntax error hat aber so testen wir wenigsten noch, ob wir intern was vergimbeln spätestens aber beim ClassWriter würden wir was bemerken */ $function->php(); // throws }
/** * Gibt den PHP Code für die Methode zurück * * Nach der } ist kein LF */ public function php($baseIndent = 0) { $cr = "\n"; $php = $this->phpDocBlock($baseIndent); // vor die modifier muss das indent $php .= str_repeat(' ', $baseIndent); $ms = array(self::MODIFIER_ABSTRACT => 'abstract', self::MODIFIER_PUBLIC => 'public', self::MODIFIER_PRIVATE => 'private', self::MODIFIER_PROTECTED => 'protected', self::MODIFIER_STATIC => 'static', self::MODIFIER_FINAL => 'final'); foreach ($ms as $const => $modifier) { if (($const & $this->modifiers) == $const) { $php .= $modifier . ' '; } } $php .= parent::php($baseIndent); return $php; }