本文整理汇总了PHP中XPClass::forName方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::forName方法的具体用法?PHP XPClass::forName怎么用?PHP XPClass::forName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPClass
的用法示例。
在下文中一共展示了XPClass::forName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param string endpoint default 'http://api.google.com/search/beta2'
*/
public function __construct($endpoint = 'http://api.google.com/search/beta2')
{
$this->client = SoapDriver::getInstance()->forEndpoint($endpoint, 'urn:GoogleSearch');
$this->client->registerMapping(new QName('urn:GoogleSearch', 'GoogleSearchResult'), XPClass::forName('com.google.soap.search.GoogleSearchResult'));
$this->client->registerMapping(new QName('urn:GoogleSearch', 'ResultElement'), XPClass::forName('com.google.soap.search.ResultElement'));
$this->client->registerMapping(new QName('urn:GoogleSearch', 'DirectoryCategory'), XPClass::forName('com.google.soap.search.DirectoryCategory'));
}
示例2: matches
/**
* Matches implementation
*
* @param var value
* @return bool
*/
public function matches($value)
{
if (NULL === $value && $this->matchNull) {
return TRUE;
}
return xp::typeof($value) == XPClass::forName($this->type)->getName();
}
示例3: __construct
/**
* Constructor
*
* @param rdbms.DSN dsn
*/
public function __construct($dsn)
{
$this->dsn = $dsn;
$this->flags = $dsn->getFlags();
$this->setTimeout($dsn->getProperty('timeout', 0));
// 0 means no timeout
// Keep this for BC reasons
$observers = $dsn->getProperty('observer', array());
if (NULL !== ($cat = $dsn->getProperty('log'))) {
$observers['util.log.LogObserver'] = $cat;
}
// Add observers
foreach ($observers as $observer => $param) {
$class = XPClass::forName($observer);
// Check if class implements BoundLogObserver: in that case use factory method to acquire instance
if (XPClass::forName('util.log.BoundLogObserver')->isAssignableFrom($class)) {
$this->addObserver($class->getMethod('instanceFor')->invoke(NULL, array($param)));
// Otherwise, just use the constructor
} else {
$this->addObserver($class->newInstance($param));
}
}
// Time zone handling
if ($tz = $dsn->getProperty('timezone', FALSE)) {
$this->tz = new TimeZone($tz);
}
}
示例4: main
/**
* Main
*
* Exitcodes used:
* <ul>
* <li>127: Archive referenced in -xar [...] does not exist</li>
* <li>126: No manifest or manifest does not have a main-class</li>
* </ul>
*
* @see http://tldp.org/LDP/abs/html/exitcodes.html
* @param string[] args
* @return int
*/
public static function main(array $args)
{
// Open archive
$f = new File(array_shift($args));
if (!$f->exists()) {
Console::$err->writeLine('*** Cannot find archive ' . $f->getURI());
return 127;
}
// Register class loader
$cl = ClassLoader::registerLoader(new ArchiveClassLoader(new Archive($f)));
if (!$cl->providesResource(self::MANIFEST)) {
Console::$err->writeLine('*** Archive ' . $f->getURI() . ' does not have a manifest');
return 126;
}
// Load manifest
$pr = Properties::fromString($cl->getResource(self::MANIFEST));
if (NULL === ($class = $pr->readString('archive', 'main-class', NULL))) {
Console::$err->writeLine('*** Archive ' . $f->getURI() . '\'s manifest does not have a main class');
return 126;
}
// Run main()
try {
return XPClass::forName($class, $cl)->getMethod('main')->invoke(NULL, array($args));
} catch (TargetInvocationException $e) {
throw $e->getCause();
}
}
示例5: forName
/**
* Get a type instance for a given name
*
* @param string name
* @return lang.ArrayType
* @throws lang.IllegalArgumentException if the given name does not correspond to a wildcard type
*/
public static function forName($name)
{
if (false === strpos($name, '?') || false === ($p = strpos($name, '<'))) {
throw new IllegalArgumentException('Not a wildcard type: ' . $name);
}
$base = substr($name, 0, $p);
$components = [];
for ($args = substr($name, $p + 1, -1) . ',', $o = 0, $brackets = 0, $i = 0, $s = strlen($args); $i < $s; $i++) {
if (',' === $args[$i] && 0 === $brackets) {
$component = ltrim(substr($args, $o, $i - $o));
if ('?' === $component) {
$components[] = Wildcard::$ANY;
} else {
if (false === strpos($component, '?')) {
$components[] = parent::forName($component);
} else {
$components[] = self::forName($component);
}
}
$o = $i + 1;
} else {
if ('<' === $args[$i]) {
$brackets++;
} else {
if ('>' === $args[$i]) {
$brackets--;
}
}
}
}
return new self(XPClass::forName($base), $components);
}
示例6: compile
/**
* Compile and then run sourcecode
*
* @param string source
* @return lang.Runnable
*/
protected function compile($source)
{
$decl = '
import integrationtests.ArrayExtensions;
class FixturePrimitiveExtensionMethodsIntegrationTest·%d implements Runnable {
public var run() {
%s
}
}';
$emitter = new V54Emitter();
$task = new CompilationTask(new StringSource(sprintf($decl, $this->counter++, $source), self::$syntax, $this->name), new NullDiagnosticListener(), newinstance(FileManager::class, [$this->getClass()->getClassLoader()], '{
protected $cl;
public function __construct($cl) {
$this->cl= $cl;
}
public function findClass($qualified) {
return new FileSource($this->cl->getResourceAsStream("net/xp_lang/tests/integration/src/".strtr($qualified, ".", "/").".xp"));
}
public function write($r, File $target) {
// DEBUG $r->writeTo(Console::$out->getStream());
$r->executeWith(array()); // Defines the class
}
}'), $emitter);
$type = $task->run();
return XPClass::forName($type->name())->newInstance();
}
示例7: addPortlet
/**
* Add Portlets
*
* @param string classname
* @param string layout
* @return xml.portlet.Portlet
*/
public function addPortlet($classname, $layout = NULL)
{
with($portlet = XPClass::forName($classname)->newInstance());
$portlet->setLayout($layout);
$this->portlets[] = $portlet;
return $portlet;
}
示例8: genericInterface
public function genericInterface()
{
$interfaces = XPClass::forName('lang.Object')->getInterfaces();
$this->assertEquals(1, sizeof($interfaces));
$this->assertInstanceOf('lang.XPClass', $interfaces[0]);
$this->assertEquals('lang.Generic', $interfaces[0]->getName());
}
示例9: forName
/**
* Returns the implementation for the given operating system.
*
* @param string os operating system name, e.g. PHP_OS
* @param string socket default NULL
* @return rdbms.mysqlx.LocalSocket
*/
public static function forName($os, $socket = NULL)
{
if (0 === strncasecmp($os, 'Win', 3)) {
return XPClass::forName('rdbms.mysqlx.NamedPipe')->newInstance($socket);
} else {
return XPClass::forName('rdbms.mysqlx.UnixSocket')->newInstance($socket);
}
}
示例10: read
/**
* Creates a segment instance
*
* @param string $marker
* @param string $bytes
* @return self
*/
public static function read($marker, $bytes)
{
if (is_array($iptc = iptcparse($bytes))) {
return XPClass::forName('img.io.IptcSegment')->newInstance($marker, $iptc);
} else {
return new self($marker, $bytes);
}
}
示例11: __static
static function __static()
{
self::$handlers[REMOTE_MSG_INIT] = XPClass::forName('remote.server.message.EascInitMessage');
self::$handlers[REMOTE_MSG_LOOKUP] = XPClass::forName('remote.server.message.EascLookupMessage');
self::$handlers[REMOTE_MSG_CALL] = XPClass::forName('remote.server.message.EascCallMessage');
self::$handlers[REMOTE_MSG_VALUE] = XPClass::forName('remote.server.message.EascValueMessage');
self::$handlers[REMOTE_MSG_EXCEPTION] = XPClass::forName('remote.server.message.EascExceptionMessage');
}
示例12: initializeClasses
public static function initializeClasses()
{
if (version_compare(PHP_VERSION, '5.3.2', 'lt')) {
throw new PrerequisitesNotMetError('Private not supported', NULL, array('PHP 5.3.2'));
}
self::$fixture = XPClass::forName('net.xp_framework.unittest.reflection.PrivateAccessibilityFixture');
self::$fixtureChild = XPClass::forName('net.xp_framework.unittest.reflection.PrivateAccessibilityFixtureChild');
self::$fixtureCtorChild = XPClass::forName('net.xp_framework.unittest.reflection.PrivateAccessibilityFixtureCtorChild');
}
示例13: addListener
/**
* Add a connection listener. Provided for BC reasons.
*
* @deprecated Use setProtocol() instead!
* @param peer.server.ConnectionListener listener
* @return peer.server.ConnectionListener the added listener
*/
public function addListener($listener)
{
if (!$this->protocol) {
$c = XPClass::forName('peer.server.protocol.ListenerWrapperProtocol');
$this->protocol = $c->newInstance();
}
$listener->server = $this;
$this->protocol->addListener($listener);
return $listener;
}
示例14: forURL
/**
* Create client by inspecting the URL
*
* @param string url The API url
* @return com.atlassian.jira.api.JiraClientProtocol
*/
public static function forURL($url)
{
$u = new URL($url);
// Check for REST API client v2
if (create(new String($u->getPath()))->contains('/rest/api/2')) {
return XPClass::forName('com.atlassian.jira.api.protocol.JiraClientRest2Protocol')->newInstance($u);
// No suitable protocol found
} else {
throw new IllegalArgumentException('No suitable client found for ' . $url);
}
}
示例15: forName
/**
* Factory method
*
* @param string name
* @return lang.XPClass
* @throws lang.IllegalArgumentException
*/
public static function forName($name)
{
switch ($name) {
case 'dialog':
return XPClass::forName('net.xp_framework.unittest.xml.DialogType');
case 'button':
return XPClass::forName('net.xp_framework.unittest.xml.ButtonType');
default:
throw new IllegalArgumentException('Unknown tag "' . $name . '"');
}
}