示例#1
0
 public function render_class_body()
 {
     $php = "";
     $nesting = 0;
     if (isset($this->options['if'])) {
         $php .= str_repeat('    ', $nesting) . "if (" . Callback::invocation($this->options['if']) . ") {\n";
         $nesting++;
     }
     if (isset($this->options['unless'])) {
         $php .= str_repeat('    ', $nesting) . "if (!" . Callback::invocation($this->options['if']) . ") {\n";
         $nesting++;
     }
     $php .= str_repeat('    ', $nesting) . "\$value = {$this->read_property_value()};\n";
     $args = $this->args;
     array_shift($args, new Variable('value'));
     $php .= str_repeat('    ', $nesting) . '$result = ' . Callback::invocation($this->validator, null, $args) . ";\n";
     $php .= str_repeat('    ', $nesting) . "if (\$result === false) {\n";
     $php .= str_repeat('    ', $nesting) . "} elseif (is_string(\$result)) {\n";
     $php .= str_repeat('    ', $nesting) . "}\n";
     while ($nesting > 0) {
         $nesting--;
         $php .= str_repeat('    ', $nesting) . "}\n";
     }
     $php .= "\n";
     return $php;
 }