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


PHP xp类代码示例

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


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

示例1: defineInterface

 /**
  * Helper method
  *
  * @param   string name
  * @param   lang.XPClass class
  * @throws  unittest.AssertionFailedError
  */
 protected function defineInterface($name, $parents, $bytes)
 {
     if (interface_exists(xp::reflect($name), FALSE)) {
         $this->fail('Interface "' . $name . '" may not exist!');
     }
     return ClassLoader::defineInterface($name, $parents, $bytes);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:14,代码来源:RuntimeClassDefinitionTest.class.php

示例2: gc

 public function gc()
 {
     trigger_error('Test');
     $this->assertEquals([__FILE__ => [__LINE__ - 2 => ['Test' => ['class' => NULL, 'method' => 'trigger_error', 'cnt' => 1]]]], \xp::$errors);
     \xp::gc();
     $this->assertEquals([], \xp::$errors);
 }
开发者ID:xp-framework,项目名称:core,代码行数:7,代码来源:XpTest.class.php

示例3: connect

 /**
  * Connect
  *
  * @param   bool reconnect default FALSE
  * @return  bool success
  * @throws  rdbms.SQLConnectException
  */
 public function connect($reconnect = false)
 {
     if (is_resource($this->handle)) {
         return true;
     }
     // Already connected
     if (!$reconnect && false === $this->handle) {
         return false;
     }
     // Previously failed connecting
     $this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECT, $reconnect));
     if ($this->flags & DB_PERSISTENT) {
         $this->handle = mssql_pconnect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword());
     } else {
         $this->handle = mssql_connect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword());
     }
     if (!is_resource($this->handle)) {
         $e = new \rdbms\SQLConnectException(trim(mssql_get_last_message()), $this->dsn);
         \xp::gc(__FILE__);
         throw $e;
     }
     \xp::gc(__FILE__);
     $this->_obs && $this->notifyObservers(new \rdbms\DBEvent(\rdbms\DBEvent::CONNECTED, $reconnect));
     return parent::connect();
 }
开发者ID:xp-framework,项目名称:rdbms,代码行数:32,代码来源:MsSQLConnection.class.php

示例4: __construct

 /**
  * Constructor. Accepts one of the following:
  *
  * <ul>
  *   <li>The values TRUE or FALSE</li>
  *   <li>An integer - any non-zero value will be regarded TRUE</li>
  *   <li>The strings "true" and "false", case-insensitive</li>
  *   <li>Numeric strings - any non-zero value will be regarded TRUE</li>
  * </ul>
  *
  * @param   var value
  * @throws  lang.IllegalArgumentException if value is not acceptable
  */
 public function __construct($value)
 {
     if (TRUE === $value || FALSE === $value) {
         $this->value = $value;
     } else {
         if (is_int($value)) {
             $this->value = 0 !== $value;
         } else {
             if ('0' === $value) {
                 $this->value = FALSE;
             } else {
                 if (is_string($value) && ($l = strlen($value)) && strspn($value, '1234567890') === $l) {
                     $this->value = TRUE;
                 } else {
                     if (0 === strncasecmp($value, 'true', 4)) {
                         $this->value = TRUE;
                     } else {
                         if (0 === strncasecmp($value, 'false', 5)) {
                             $this->value = FALSE;
                         } else {
                             throw new IllegalArgumentException('Not a valid boolean: ' . xp::stringOf($value));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:41,代码来源:Boolean.class.php

示例5: export

 /**
  * Export this keypair
  *
  * @param   string passphrase default NULL
  * @return  string key
  */
 public function export($passphrase = null)
 {
     if (false === openssl_pkey_export($this->_res, $out, $passphrase)) {
         throw new SecurityException('Could not export key: ' . \xp::stringOf(OpenSslUtil::getErrors()));
     }
     return $out;
 }
开发者ID:xp-framework,项目名称:security,代码行数:13,代码来源:KeyPair.class.php

示例6: process

 /**
  * Processes cell value
  *
  * @param   var in
  * @return  var
  * @throws  lang.FormatException
  */
 public function process($in)
 {
     if (!(null === $in || is_numeric($in))) {
         throw new \lang\FormatException('Cannot format non-number ' . \xp::stringOf($in));
     }
     return $this->proceed(number_format($in, $this->decimals, $this->decimalPoint, $this->thousandsSeparator));
 }
开发者ID:xp-framework,项目名称:csv,代码行数:14,代码来源:FormatNumber.class.php

示例7: 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();
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:13,代码来源:TypeMatcher.class.php

示例8: process

 /**
  * Processes cell value
  *
  * @param   var in
  * @return  var
  * @throws  lang.FormatException
  */
 public function process($in)
 {
     if (!$in->getClass()->isEnum()) {
         throw new FormatException('Cannot format non-enum ' . xp::stringOf($in));
     }
     return $this->proceed($in->name());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:FormatEnum.class.php

示例9: connect

 /**
  * Connect
  *
  * @param   bool reconnect default FALSE
  * @return  bool success
  * @throws  rdbms.SQLConnectException
  */
 public function connect($reconnect = FALSE)
 {
     if (is_resource($this->handle)) {
         return TRUE;
     }
     // Already connected
     if (!$reconnect && FALSE === $this->handle) {
         return FALSE;
     }
     // Previously failed connecting
     $this->_obs && $this->notifyObservers(new DBEvent(DBEvent::CONNECT, $reconnect));
     if ($this->flags & DB_PERSISTENT) {
         $this->handle = sybase_pconnect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword(), 'iso_1');
     } else {
         $this->handle = sybase_connect($this->dsn->getHost(), $this->dsn->getUser(), $this->dsn->getPassword(), 'iso_1');
     }
     if (!is_resource($this->handle)) {
         $e = new SQLConnectException(trim(sybase_get_last_message()), $this->dsn);
         xp::gc(__FILE__);
         throw $e;
     }
     xp::gc(__FILE__);
     $this->_obs && $this->notifyObservers(new DBEvent(DBEvent::CONNECTED, $reconnect));
     return parent::connect();
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:32,代码来源:SybaseConnection.class.php

示例10: toString

 /**
  * Creates a string representation of this object. In general, the toString 
  * method returns a string that "textually represents" this object. The result 
  * should be a concise but informative representation that is easy for a 
  * person to read. It is recommended that all subclasses override this method.
  * 
  * Per default, this method returns:
  * ```
  *   [fully-qualified-class-name] '{' [members-and-value-list] '}'
  * ```
  * 
  * Example:
  * ```
  *   lang.Object {
  *     __id => "0.43080500 1158148350"
  *   }
  * ```
  *
  * @return  string
  */
 public function toString()
 {
     if (!$this->__id) {
         $this->__id = uniqid('', true);
     }
     return \xp::stringOf($this);
 }
开发者ID:xp-framework,项目名称:core,代码行数:27,代码来源:Object.class.php

示例11: findEntry

 /**
  * Find an entry
  *
  * @param   string name
  * @return  peer.ftp.FtpEntry entry or NULL if nothing was found
  * @throws  io.IOException in case listing fails
  * @throws  peer.ProtocolException in case listing yields an unexpected result
  */
 protected function findEntry($name)
 {
     if (NULL === ($list = $this->connection->listingOf($this->name . $name, '-ald'))) {
         return NULL;
         // Not found
     }
     // If we get more than one result and the first result ends with a
     // dot, the server ignored the "-d" option and listed the directory's
     // contents instead. In this case, replace the "." by the directory
     // name. Otherwise, we don't expect more than one result!
     $entry = $list[0];
     if (($s = sizeof($list)) > 1) {
         if ('.' === $entry[strlen($entry) - 1]) {
             $entry = substr($entry, 0, -1) . basename($name);
         } else {
             throw new ProtocolException('List "' . $this->name . $name . '" yielded ' . $s . ' result(s), expected: 1 (' . xp::stringOf($list) . ')');
         }
     }
     // Calculate base
     $base = $this->name;
     if (FALSE !== ($p = strrpos(rtrim($name, '/'), '/'))) {
         $base .= substr($name, 0, $p + 1);
     }
     return $this->connection->parser->entryFrom($entry, $this->connection, $base);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:33,代码来源:FtpDir.class.php

示例12: 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

示例13: __static

 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());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:7,代码来源:RestFormat.class.php

示例14: read

 /**
  * Read a record
  *
  * @param   string[] fields if omitted, class fields are used in order of appearance
  * @return  lang.Object or NULL if end of the file is reached
  */
 public function read(array $fields = array())
 {
     if (NULL === ($values = $this->readValues())) {
         return NULL;
     }
     if (!$fields) {
         foreach ($this->class->getFields() as $f) {
             $fields[] = $f->getName();
         }
     }
     // Create an object by deserialization. This enables us to also set
     // private and protected fields as well as avoids the constructor call.
     $n = xp::reflect($this->class->getName());
     $s = 'O:' . strlen($n) . ':"' . $n . '":' . sizeof($fields) . ':{';
     foreach ($fields as $i => $name) {
         $f = $this->class->getField($name);
         switch ($f->getModifiers() & (MODIFIER_PUBLIC | MODIFIER_PROTECTED | MODIFIER_PRIVATE)) {
             case MODIFIER_PUBLIC:
                 $s .= serialize($f->getName());
                 break;
             case MODIFIER_PROTECTED:
                 $s .= serialize("*" . $f->getName());
                 break;
             case MODIFIER_PRIVATE:
                 $s .= serialize("" . $n . "" . $f->getName());
                 break;
         }
         $s .= serialize($values[$i]);
     }
     $s .= '}';
     return unserialize($s);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:38,代码来源:CsvObjectReader.class.php

示例15: __invoke

 /**
  * Invoke match. Returns the handler's result for the first condition to 
  * match the given value. If no condition matched and no default handler
  * was installed, an exception is raised.
  *
  * @param  var $value
  * @return var
  * @throws lang.IllegalArgumentException
  */
 public function __invoke($value)
 {
     if ($this->mapping) {
         $f = $this->mapping;
         $expr = $f($value);
     } else {
         $expr = $value;
     }
     if (null === $expr) {
         $type = null;
     } else {
         $type = gettype($expr);
     }
     if (isset($this->primitive[$type])) {
         return $this->primitive[$type]($value, $this);
     } else {
         foreach ($this->instance as $conditional) {
             if ($conditional->condition->matches($expr)) {
                 $f = $conditional->handle;
                 return $f($value, $this);
             }
         }
     }
     if ($this->otherwise) {
         $f = $this->otherwise;
         return $f($value, $this);
     } else {
         throw new IllegalArgumentException('Unhandled type ' . \xp::typeOf($expr));
     }
 }
开发者ID:xp-forge,项目名称:match,代码行数:39,代码来源:TypeOf.class.php


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