/** * Проверяет является ли данный класс данного объект наследником заданного класса * * @param $ancestor * @param $object * * @return boolean */ public static function is_subclass_of($ancestor, $object) { $ancestor_class = self::real_class_name_for($ancestor); if (is_object($object)) { return $object instanceof $ancestor_class; } $object_class = self::real_class_name_for($object); if (!class_exists($object_class, false)) { return false; } //return $object_class instanceof $ancestor_class; //TODO: remove: $object_reflection = new ReflectionClass($object_class); return Core::with($ancestor_reflection = new ReflectionClass($ancestor_class))->isInterface() ? $object_reflection->implementsInterface($ancestor_class) : $object_reflection->isSubclassOf($ancestor_reflection); }
/** * @param array $argv * * @return int */ public function run(array $argv) { Core::with($this->config->output ? IO_FS::File($this->config->output)->open('w+') : IO::stdout())->write(Dev_Source::Library($argv)->xml->SaveXML()); return 0; }
/** * @param array $argv */ public static function main(array $argv) { Core::with(new Dev_Source_Diagram_Application())->main($argv); }
/** * @param boolean $reload * * @return Dev_Source_Library */ public function load($reload = false) { if (!$this->xml || $reload) { $library = Core::with($this->xml = new DOMDocument())->appendChild(new DOMElement('library')); foreach ($this->modules as $module) { if ($module->xml) { $library->appendChild($this->xml->importNode($module->xml->documentElement, true)); } } } return $this->xml; }
private function next_part() { $part = $this->source->valid() ? $this->source->current() : null; return $part ? $part instanceof Iterator ? $part : ($part instanceof IteratorAggregate ? $part->getIterator() : Core::with(new ArrayObject((array) $part))->getIterator()) : null; }
/** * @param string $name * @param int $http_mask * @param string $path * @param string $formats * * @return WS_REST_DSL_Resource */ public function method($name, $http_mask = Net_HTTP::ANY, $path = null, $formats = null, $defaults = array()) { $formats = $formats === null ? isset($this->scope->formats) ? $this->scope->formats : array() : $formats; $path = $path === null ? isset($this->scope->path) ? $this->scope->path : 'index' : $path; $name = $name ? $name : $path; $http_mask = $http_mask === null ? isset($this->scope->http_methods) ? $this->scope->http_methods : Net_HTTP::ANY : $http_mask; $this->object->method(Core::with(new WS_Services_REST_Method($name))->path($path)->http($http_mask)->defaults($defaults)->produces(is_array($formats) ? $formats : Core_Strings::split_by(',', (string) $formats))); return $this; }
/** * @return Dev_Benchmark_Timer */ public static function start() { return Core::with(new Dev_Benchmark_Timer())->start(); }
/** * Фабричный метод, возвращает объект приложения * * @param array $argv */ public static function main(array $argv) { Core::with(new Dev_Cache_Dump_Application())->main($argv); }
private function get_properties() { $result = array(); foreach (Core::with(new ReflectionObject($this))->getProperties() as $v) { if (($name = $v->getName()) != '_frozen') { $result[] = $v->getName(); } } return $result; }
/** * @param Dev_Unit_TestResult $result * * @return Dev_Unit_TestResult */ public function run(Dev_Unit_TestResult $result = null) { Core::with($result = Core::if_null($result, Dev_Unit::TestResult()))->start_test($this); $is_ok = true; try { $this->before_setup(); $this->setup(); $this->after_setup(); } catch (Exception $e) { $result->add_error($this, Dev_Unit_Error::make_from($this, $e)); $is_ok = false; } if ($is_ok) { try { call_user_func(array($this, $this->method)); } catch (Dev_Unit_FailureException $e) { $result->add_failure($this, Dev_Unit_Failure::make_from($this, $e)); $is_ok = false; } catch (Exception $e) { $result->add_error($this, Dev_Unit_Error::make_from($this, $e)); $is_ok = false; } } try { $this->before_teardown(); $this->teardown(); $this->after_teardown(); } catch (Exception $e) { $result->add_error($this, Dev_Unit_Error::make_from($this, $e)); $is_ok = false; } if ($is_ok) { $result->add_success($this); } $result->finish_test($this); return $this; }
/** * @return int */ public static function main(array $argv) { return Core::with(new Service_Twitter_Application())->main($argv); }
/** */ protected function convert_element($element) { switch (true) { case $element instanceof self: return $element->__value; case method_exists($element, 'as_array'): return $element->as_array(); case is_array($element): return Core::with(new Service_Google_AdWords_Entity($element))->as_array(); default: return $element; } }
public function create_response($env) { if (!empty($this->callback_result)) { return $this->callback_result; } return Core::with($this->target_instance && $this->target_method ? ($result = $this->execute($this->target_instance, $this->target_method->name, $env, $this->match ? $this->match->parms : array(), $this->format, $this->target_method->defaults)) instanceof Net_HTTP_Response ? $result : Net_HTTP::Response($result)->content_type(!empty($this->format) ? $this->format : self::DEFAULT_CONTENT_TYPE) : Net_HTTP::Response(Net_HTTP::NOT_FOUND)); }
/** * @param array $argv * * @return int */ public static function main(array $argv) { return Core::with(new Dev_Unit_Run_Text_Application())->main($argv); }
/** * Формирует основную часть письма * */ protected function body() { $messages_path = Mail_List::option('root') . '/messages'; IO_FS::mkdir($messages_path); $path = sprintf('%s/%s.body', $messages_path, $this->id); IO_FS::rm($path); $f = IO_FS::File($path); $f->open('w')->write(Core::with(new Mail_List_Encoder())->encode($this->message))->close(); $f->chmod(0664); return $this; }
/** * @param array $tasks * * @return Service_Yandex_Direct_Manager */ private function run_tasks(array $tasks) { $this->log->debug("Running task list"); foreach ($tasks as $name) { $path = $this->config->prefix ? $this->config->prefix . $name . '.php' : $name; if (!IO_FS::exists($path)) { throw new Service_Yandex_Direct_Manager_MissingTaskFileException($path); } Core::with(new Service_Yandex_Direct_Manager_Task(IO_FS::File($path), $this))->run(); $this->processed++; } $this->log->debug("Task list complete"); return $this; }