当前位置: 首页>>代码示例>>PHP>>正文


PHP lang\XPClass类代码示例

本文整理汇总了PHP中lang\XPClass的典型用法代码示例。如果您正苦于以下问题:PHP XPClass类的具体用法?PHP XPClass怎么用?PHP XPClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XPClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 /**
  * Register transport implementation for a specific scheme
  *
  * @param   string scheme
  * @param   lang.XPClass<peer.http.HttpTransport> class
  */
 public static function register($scheme, XPClass $class)
 {
     if (!$class->isSubclassOf('peer.http.HttpTransport')) {
         throw new \lang\IllegalArgumentException(sprintf('Given argument must be lang.XPClass<peer.http.HttpTransport>, %s given', $class->toString()));
     }
     self::$transports[$scheme] = $class;
 }
开发者ID:xp-framework,项目名称:http,代码行数:13,代码来源:HttpTransport.class.php

示例2: setAlgorithm

 /**
  * Register an algorithm
  *
  * @param   string name
  * @param   lang.XPClass<security.password.Algorithm> impl
  * @throws  lang.IllegalArgumentException in case the given class is not an Algorithm 
  */
 public static function setAlgorithm($name, \lang\XPClass $impl)
 {
     if (!$impl->isSubclassOf('security.password.Algorithm')) {
         throw new \lang\IllegalArgumentException('Given argument is not an Algorithm class (' . \xp::stringOf($impl) . ')');
     }
     self::$algorithms[$name] = $impl;
 }
开发者ID:xp-framework,项目名称:security,代码行数:14,代码来源:PasswordStrength.class.php

示例3: qnameFor

 /**
  * Fetch a qname for a class.
  *
  * @param   lang.XPClass class
  * @return  var xml.QName or NULL if no mapping exists
  */
 public function qnameFor(\lang\XPClass $class)
 {
     if (!isset($this->_c2q[$class->getName()])) {
         return null;
     }
     return $this->_qnames[$this->_c2q[$class->getName()]];
 }
开发者ID:treuter,项目名称:webservices,代码行数:13,代码来源:XPSoapMapping.class.php

示例4: register

 /**
  * Register an implementation
  *
  * @param   string algorithm
  * @param   lang.XPClass<security.checksum.MessageDigestImpl> class
  * @throws  lang.IllegalArgumentException
  */
 public static function register($algorithm, \lang\XPClass $impl)
 {
     if (!$impl->isSubclassOf('security.checksum.MessageDigestImpl')) {
         throw new \lang\IllegalArgumentException('Implementation class must be a security.checksum.MessageDigestImpl');
     }
     self::$implementations[$algorithm] = $impl;
 }
开发者ID:xp-framework,项目名称:security,代码行数:14,代码来源:MessageDigest.class.php

示例5: lineFor

 /**
  * Tries to get method start line
  *
  * @param lang.XPClass $class
  * @param string $methodname
  * @return int
  */
 private function lineFor(XPClass $class, $methodname)
 {
     try {
         return $class->reflect()->getMethod($methodname)->getStartLine();
     } catch (\Exception $ignored) {
         return 0;
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:15,代码来源:XmlTestListener.class.php

示例6: toCollection

 /**
  * Creates a new collector gathering the elements in a collection class
  *
  * @param  lang.XPClass $class
  * @return util.data.ICollector
  */
 public static function toCollection(XPClass $class)
 {
     return new Collector(function () use($class) {
         return $class->newInstance();
     }, function ($result, $arg) {
         $result->add($arg);
     });
 }
开发者ID:xp-forge,项目名称:sequence,代码行数:14,代码来源:Collectors.class.php

示例7: interfaceNamed

 /**
  * Locate interface by a given name
  *
  * @param  lang.XPClass $class
  * @param  string $name
  * @return lang.XPClass
  * @throws lang.ElementNotFoundException
  */
 private function interfaceNamed($class, $name)
 {
     foreach ($class->getInterfaces() as $iface) {
         if (strstr($iface->getName(), $name)) {
             return $iface;
         }
     }
     throw new ElementNotFoundException('Class ' . $class->getName() . ' does not implement ' . $name);
 }
开发者ID:xp-framework,项目名称:core,代码行数:17,代码来源:ImplementationTest.class.php

示例8: methodsAnnotatedWith

 /**
  * Returns methods annotated with a given annotatoons
  *
  * @param  lang.XPClass $self
  * @param  string $annotation
  * @return lang.reflect.Method[]
  */
 public static function methodsAnnotatedWith(\lang\XPClass $self, $annotation)
 {
     $name = substr($annotation, 1);
     $r = array();
     foreach ($self->getMethods() as $method) {
         if ($method->hasAnnotation($name)) {
             $r[] = $method;
         }
     }
     return $r;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:18,代码来源:LocalExtensionMethodTest.class.php

示例9: permutationOf

 /**
  * Add a measurable class
  *
  * @param  lang.XPClass $class
  * @param  lang.reflect.Method $method
  * @param  var $source
  * @return util.data.Sequence
  */
 private function permutationOf($class, $method, $source)
 {
     if (is_array($source)) {
         $seq = Sequence::of($source);
     } else {
         $seq = Sequence::of($class->getMethod($source)->setAccessible(true)->invoke(null));
     }
     return $seq->map(function ($args) use($class, $method) {
         return $class->newInstance($method, (array) $args);
     });
 }
开发者ID:xp-forge,项目名称:measure,代码行数:19,代码来源:Measurement.class.php

示例10: __construct

 /**
  * Constructor
  *
  * @param   lang.XPClass $scriptlet
  * @param   string[] args
  * @param   [:string] env
  */
 public function __construct(XPClass $scriptlet, $args, $env = [], $filters = [])
 {
     if ($scriptlet->hasConstructor()) {
         $this->scriptlet = $scriptlet->getConstructor()->newInstance((array) $args);
     } else {
         $this->scriptlet = $scriptlet->newInstance();
     }
     foreach ($filters as $filter) {
         $this->scriptlet->filter($filter);
     }
     $this->scriptlet->init();
     $this->env = $env;
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:20,代码来源:ScriptletHandler.class.php

示例11: commandUsage

 /**
  * Show usage
  *
  * @param  lang.XPClass class
  * @return void
  */
 protected function commandUsage(XPClass $class)
 {
     // Description
     if (null !== ($comment = $class->getComment())) {
         self::$err->writeLine(self::textOf($comment));
         self::$err->writeLine(str_repeat('=', 72));
     }
     $extra = $details = $positional = [];
     foreach ($class->getMethods() as $method) {
         if (!$method->hasAnnotation('arg')) {
             continue;
         }
         $arg = $method->getAnnotation('arg');
         $name = strtolower(preg_replace('/^set/', '', $method->getName()));
         $comment = self::textOf($method->getComment());
         if (0 == $method->numParameters()) {
             $optional = true;
         } else {
             list($first, ) = $method->getParameters();
             $optional = $first->isOptional();
         }
         if (isset($arg['position'])) {
             $details['#' . ($arg['position'] + 1)] = $comment;
             $positional[$arg['position']] = $name;
         } else {
             if (isset($arg['name'])) {
                 $details['--' . $arg['name'] . ' | -' . (isset($arg['short']) ? $arg['short'] : $arg['name'][0])] = $comment;
                 $extra[$arg['name']] = $optional;
             } else {
                 $details['--' . $name . ' | -' . (isset($arg['short']) ? $arg['short'] : $name[0])] = $comment;
                 $extra[$name] = $optional;
             }
         }
     }
     // Usage
     asort($positional);
     self::$err->write('Usage: $ xpcli ', Commands::nameOf($class), ' ');
     foreach ($positional as $name) {
         self::$err->write('<', $name, '> ');
     }
     foreach ($extra as $name => $optional) {
         self::$err->write($optional ? '[' : '', '--', $name, $optional ? '] ' : ' ');
     }
     self::$err->writeLine();
     // Argument details
     self::$err->writeLine('Arguments:');
     foreach ($details as $which => $comment) {
         self::$err->writeLine('* ', $which, "\n  ", str_replace("\n", "\n  ", $comment), "\n");
     }
 }
开发者ID:xp-framework,项目名称:command,代码行数:56,代码来源:Runner.class.php

示例12: commandUsage

 /**
  * Shows usage
  *
  * @param  lang.XPClass $class
  * @return void
  */
 protected function commandUsage(XPClass $class)
 {
     $comment = $class->getComment();
     if ('' === (string) $comment) {
         $markdown = '# ' . $class->getSimpleName() . "\n\n";
         $text = '';
     } else {
         @(list($headline, $text) = explode("\n", $comment, 2));
         $markdown = '# ' . ltrim($headline, ' #') . "\n\n";
     }
     $markdown .= "- Usage\n  ```sh\n\$ xp cmd " . Commands::nameOf($class);
     $extra = $details = $positional = [];
     foreach ($class->getMethods() as $method) {
         if (!$method->hasAnnotation('arg')) {
             continue;
         }
         $arg = $method->getAnnotation('arg');
         $name = strtolower(preg_replace('/^set/', '', $method->getName()));
         $optional = 0 === $method->numParameters() || $method->getParameters()[0]->isOptional();
         $comment = $method->getComment();
         if (isset($arg['position'])) {
             $details[$name] = [$comment, null];
             $positional[$arg['position']] = $name;
         } else {
             if (isset($arg['name'])) {
                 $details['--' . $arg['name']] = [$comment, isset($arg['short']) ? $arg['short'] : $arg['name'][0]];
                 $extra[$arg['name']] = $optional;
             } else {
                 $details['--' . $name] = [$comment, isset($arg['short']) ? $arg['short'] : $name[0]];
                 $extra[$name] = $optional;
             }
         }
     }
     // Usage
     asort($positional);
     foreach ($positional as $name) {
         $markdown .= ' ' . $name;
     }
     foreach ($extra as $name => $optional) {
         $markdown .= ' ' . (($optional ? '[' : '') . '--' . $name . ($optional ? '] ' : ' '));
     }
     $markdown .= "\n  ```\n";
     // Argument details
     foreach ($details as $which => $detail) {
         $markdown .= sprintf("  **%s**: %s%s\n\n", $which, str_replace("\n", "\n  ", $detail[0]), $detail[1] ? ' *(also: -' . $detail[1] . ')*' : '');
     }
     Help::render(self::$err, substr($markdown, 0, -1) . $text, $class->getClassLoader());
 }
开发者ID:xp-framework,项目名称:command,代码行数:54,代码来源:CmdRunner.class.php

示例13: putParameters

 public function putParameters()
 {
     $params = $this->fixture->getClass()->getMethod('put')->getParameters();
     $this->assertEquals(2, sizeof($params));
     $this->assertEquals(Primitive::$STRING, $params[0]->getType());
     $this->assertEquals(XPClass::forName('unittest.TestCase'), $params[1]->getType());
 }
开发者ID:xp-framework,项目名称:core,代码行数:7,代码来源:InstanceReflectionTest.class.php

示例14: object_return_type

 public function object_return_type()
 {
     $fixture = $this->define('{
   public function fixture(): \\lang\\Object { return new \\lang\\Object(); }
 }');
     $this->assertEquals(XPClass::forName('lang.Object'), $this->newFixture($fixture)->methods()->named('fixture')->returns());
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:7,代码来源:Php7TypesTest.class.php

示例15: __construct

 /**
  * Creates a new instance
  *
  * @param  string $source
  * @param  xp.scriptlet.Config $config
  * @throws lang.IllegalArgumentException
  */
 public function __construct($source, Config $config = null)
 {
     if ('-' === $source) {
         $this->layout = new ServeDocumentRootStatically();
     } else {
         if (is_file($source)) {
             $this->layout = new WebConfiguration(new Properties($source), $config);
         } else {
             if (is_dir($source)) {
                 $this->layout = new BasedOnWebroot($source, $config);
             } else {
                 $name = ltrim($source, ':');
                 try {
                     $class = XPClass::forName($name);
                 } catch (ClassLoadingException $e) {
                     throw new IllegalArgumentException('Cannot load ' . $name, $e);
                 }
                 if ($class->isSubclassOf('xp.scriptlet.WebLayout')) {
                     if ($class->hasConstructor()) {
                         $this->layout = $class->getConstructor()->newInstance([$config]);
                     } else {
                         $this->layout = $class->newInstance();
                     }
                 } else {
                     if ($class->isSubclassOf('scriptlet.HttpScriptlet')) {
                         $this->layout = new SingleScriptlet($class->getName(), $config);
                     } else {
                         throw new IllegalArgumentException('Expecting either a scriptlet or a weblayout, ' . $class->getName() . ' given');
                     }
                 }
             }
         }
     }
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:41,代码来源:Source.class.php


注:本文中的lang\XPClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。