static function __static() { self::$UNKNOWN = new self(0, 'UNKNOWN', xp::null(), xp::null()); self::$JSON = new self(1, 'JSON', new RestJsonSerializer(), new RestJsonDeserializer()); self::$XML = new self(2, 'XML', new RestXmlSerializer(), new RestXmlDeserializer()); self::$FORM = new self(3, 'FORM', xp::null(), new RestFormDeserializer()); }
/** * Retrieve a single bean * * @param string name * @return remote.reflect.BeanDescription or NULL if nothing is found */ public function bean($name) { if (!isset($this->beans[$name])) { return xp::null(); } return $this->beans[$name]; }
/** * Returns the outcome of a specific test * * @param unittest.TestCase test * @return unittest.TestOutcome */ public function outcomeOf(TestCase $test) { $key = $test->hashCode(); foreach (array($this->succeeded, $this->failed, $this->skipped) as $lookup) { if (isset($lookup[$key])) { return $lookup[$key]; } } return xp::null(); }
/** * Helper method to delegate call * * @param string method * @param string section * @param string key * @param mixed default * @return mixed */ private function _read($method, $section, $key, $default) { foreach ($this->props as $p) { $res = call_user_func_array(array($p, $method), array($section, $key, xp::null())); if (xp::null() !== $res) { return $res; } } return $default; }
public function xpNullArgument() { $this->assertEquals('<null>', \xp::stringOf(\xp::null())); }
public function null() { $this->assertEquals('null', get_class(xp::null())); }
function cast(Generic $expression = NULL, $type) { if (NULL === $expression) { return xp::null(); } else { if (XPClass::forName($type)->isInstance($expression)) { return $expression; } } raise('lang.ClassCastException', 'Cannot cast ' . xp::typeOf($expression) . ' to ' . $type); }
/** * Get a process by process ID * * @param int pid process id * @param string exe * @return lang.Process * @throws lang.IllegalStateException */ public static function getProcessById($pid, $exe = NULL) { $self = new self(); $self->status = array('pid' => $pid, 'running' => TRUE, 'exe' => $exe, 'command' => '', 'arguments' => NULL, 'owner' => FALSE); // Determine executable and command line: // * On Windows, use Windows Management Instrumentation API - see // http://en.wikipedia.org/wiki/Windows_Management_Instrumentation // // * On systems with a /proc filesystem, use information from /proc/self // See http://en.wikipedia.org/wiki/Procfs. Before relying on it, // also check that /proc is not just an empty directory; this assumes // that process 1 always exists - which usually is `init`. // // * Fall back to use the PHP_BINARY (#54514) constant and finally the "_" // environment variable for the executable and /bin/ps to retrieve the // command line (please note unfortunately any quote signs have been // lost and it can thus be only used for display purposes) if (strncasecmp(PHP_OS, 'Win', 3) === 0) { try { $c = new com('winmgmts:'); $p = $c->get('//./root/cimv2:Win32_Process.Handle="' . $pid . '"'); $self->status['exe'] = $p->executablePath; $self->status['command'] = $p->commandLine; } catch (Exception $e) { throw new IllegalStateException('Cannot find executable: ' . $e->getMessage()); } } else { if (is_dir('/proc/1')) { if (!file_exists($proc = '/proc/' . $pid)) { throw new IllegalStateException('Cannot find executable in /proc'); } if (defined('PHP_BINARY')) { $self->status['exe'] = PHP_BINARY; } else { do { foreach (array('/exe', '/file') as $alt) { if (!file_exists($proc . $alt)) { continue; } $self->status['exe'] = readlink($proc . $alt); break 2; } throw new IllegalStateException('Cannot find executable in ' . $proc); } while (0); } $self->status['command'] = strtr(file_get_contents($proc . '/cmdline'), "", ' '); } else { try { if (defined('PHP_BINARY')) { $self->status['exe'] = PHP_BINARY; } else { if ($exe) { $self->status['exe'] = self::resolve($exe); } else { if ($_ = getenv('_')) { $self->status['exe'] = self::resolve($_); } else { throw new IllegalStateException('Cannot find executable'); } } } $self->status['command'] = exec('ps -ww -p ' . $pid . ' -ocommand 2>&1', $out, $exit); if (0 !== $exit) { throw new IllegalStateException('Cannot find executable: ' . implode('', $out)); } } catch (IOException $e) { throw new IllegalStateException($e->getMessage()); } } } $self->in = xp::null(); $self->out = xp::null(); $self->err = xp::null(); return $self; }
public function xpNullIsNotAnInstanceOfGeneric() { $this->assertInstanceOf('lang.Generic', xp::null()); }
public function thisClassCastingNull() { $this->assertEquals(xp::null(), $this->getClass()->cast(NULL)); }
/** * Creates a new StorageElement or StorageCollection (depending on * type) * * @param string clientId * @param string uri * @param int type * @return peer.ftp.server.storage.StorageEntry */ public function createEntry($clientId, $uri, $type) { $path = substr($this->realname($clientId, $uri), strlen($this->root)); switch ($type) { case ST_ELEMENT: return new FilesystemStorageElement($path, $this->root); case ST_COLLECTION: return new FilesystemStorageCollection($path, $this->root); } return xp::null(); }
public function xpnullIsnull() { $this->assertTrue(is(null, \xp::null())); }
/** * Navigate to a relative URL * * @param string relative * @param string params * @throws unittest.AssertionFailedError */ public function beginAt($relative, $params = NULL, $method = HttpConstants::GET) { $this->dom = $this->xpath = NULL; $this->conn->getUrl()->setPath($relative); try { $this->response = $this->doRequest($method, $params); // If we get a cookie, store it for this domain and reuse it in // subsequent requests. If cookies are used for sessioning, we // would be creating new sessions with every request otherwise! foreach ((array) $this->response->header('Set-Cookie') as $str) { $cookie = Cookie::parse($str); $this->cookies[$this->conn->getUrl()->getHost()][$cookie->getName()] = $cookie; } } catch (XPException $e) { $this->response = xp::null(); $this->fail($relative, $e, NULL); } }
public function xpNullIsNull() { $this->assertTrue(is(NULL, xp::null())); $this->assertFalse(is(NULL, 1)); }
/** * Find the resource by the specified name * * @param string name resource name * @return lang.IClassLoader the classloader that provides this resource */ public function findResource($name) { foreach (self::$delegates as $delegate) { if ($delegate->providesResource($name)) { return $delegate; } } return xp::null(); }
/** * Gets an entry * * @param int clientId * @param string uri * @param int type * @return peer.ftp.server.storage.StorageEntry */ public function createEntry($clientId, $uri, $type) { $qualified = $this->normalize($this->base[$clientId], $uri); switch ($type) { case ST_ELEMENT: return new TestingElement($qualified, $this); break; case ST_COLLECTION: return new TestingCollection($qualified, $this); break; } return \xp::null(); }
public function findNullClass() { $this->assertEquals(xp::null(), ClassLoader::getDefault()->findClass(NULL)); }
/** * Close this collection * */ public function close() { $this->it = xp::null(); }
public function null() { $this->assertEquals(xp::null(), cast(NULL, 'lang.Object')); }
public function cloningOfNulls() { clone \xp::null(); }
$class::__import($scope); }; } } // }}} // {{{ main error_reporting(E_ALL); set_error_handler('__error'); date_default_timezone_set(ini_get('date.timezone')) || xp::error('[xp::core] date.timezone not configured properly.'); define('MODIFIER_STATIC', 1); define('MODIFIER_ABSTRACT', 2); define('MODIFIER_FINAL', 4); define('MODIFIER_PUBLIC', 256); define('MODIFIER_PROTECTED', 512); define('MODIFIER_PRIVATE', 1024); xp::$null = new __null(); xp::$loader = new xp(); // Paths are passed via class loader API from *-main.php. Retaining BC: // Paths are constructed inside an array before including this file. if (isset($GLOBALS['paths'])) { xp::$classpath = $GLOBALS['paths']; } else { if (0 === strpos(__FILE__, 'xar://')) { xp::$classpath = [substr(__FILE__, 6, -14)]; } else { xp::$classpath = [__DIR__ . DIRECTORY_SEPARATOR]; } } set_include_path(rtrim(implode(PATH_SEPARATOR, xp::$classpath), PATH_SEPARATOR)); spl_autoload_register(function ($class) { $name = strtr($class, '\\', '.');
public function memberWriteccess() { $null = xp::null(); $null->member = 15; }
public function xpnull_representation() { $this->assertEquals('<null>', \xp::stringOf(\xp::null())); }
public function cannotFindNontExistantUri() { $this->assertEquals(\xp::null(), \lang\ClassLoader::getDefault()->findUri('non/existant/Class.class.php')); }
/** * Cast a given object to the class represented by this object * * @param lang.Generic expression * @return lang.Generic the given expression * @throws lang.ClassCastException */ public function cast(Generic $expression = NULL) { if (NULL === $expression) { return xp::null(); } else { if (is($this->name, $expression)) { return $expression; } } raise('lang.ClassCastException', 'Cannot cast ' . xp::typeOf($expression) . ' to ' . $this->name); }