/** * Registers a finalizer to be run on a class definition just before it is * converted to PHP source. Any class implementing a public static <tt>finalize()</tt> * method is a valid finalizer. * * @param $class_name nome of finalizer class. Should be absolute. * @param $where where to place the finalizer in the chain. Either 'start' or 'end' */ public static function register_finalizer($class_name, $where = 'end') { $class_name = absolutize_namespace($class_name); if ($where == 'start') { array_unshift(self::$finalizers, $class_name); } elseif ($where == 'end') { self::$finalizers[] = $class_name; } }
public static function get_class_definition($class_name) { $class_name = absolutize_namespace($class_name); // class_exists will consult the autoloader, which should be configured // to delegate loading to phpx if (class_exists($class_name, true)) { if (isset(self::$classes[$class_name])) { return self::$classes[$class_name]; } else { throw new ClassNotFoundException("Class {$class_name} is loaded, but not present in phpx registry"); } } else { throw new ClassNotFoundException("Class {$class_name} does not exist"); } }
function annotations_for($thing1, $thing2 = null) { if (is_object($thing1)) { $thing1 = get_class($thing1); } $thing1 = absolutize_namespace($thing1); if ($thing2 == null) { return Annotation::for_class($thing1); } else { if ($thing2[0] == '$') { return Annotation::for_variable($thing1, substr($thing2, 1)); } else { return Annotation::for_method($thing1, $thing2); } } }
public function to_php() { $out = ''; if ($this->is_array()) { $out .= 'array '; } elseif ($this->has_type()) { $out .= absolutize_namespace($this->get_type()) . ' '; } if ($this->is_reference()) { $out .= '&'; } $out .= '$' . $this->get_name(); if ($this->has_default()) { $out .= ' = ' . $this->get_default()->to_php(); } elseif ($this->has_type() && $this->is_null_allowed()) { $out .= ' = null'; } return $out; }