當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xp::stringOf方法代碼示例

本文整理匯總了PHP中xp::stringOf方法的典型用法代碼示例。如果您正苦於以下問題:PHP xp::stringOf方法的具體用法?PHP xp::stringOf怎麽用?PHP xp::stringOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xp的用法示例。


在下文中一共展示了xp::stringOf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: locate

 /**
  * Locate a font
  *
  * @param   string font
  * @return  string
  */
 protected function locate($font)
 {
     $windows = strncasecmp(PHP_OS, 'Win', 3) === 0;
     // Compile extension list
     $extensions = ['.ttf', '.TTF'];
     if (strncasecmp($ext = substr($font, -4, 4), '.ttf', 4) === 0) {
         $font = substr($font, 0, -4);
         $extensions[] = $ext;
     }
     // Compose TTF search path
     if ($windows) {
         $search = ['.\\', getenv('WINDIR') . '\\fonts\\'];
     } else {
         $search = ['./', '/usr/X11R6/lib/X11/fonts/TrueType/', '/usr/X11R6/lib/X11/fonts/truetype/', '/usr/X11R6/lib/X11/fonts/TTF/', '/usr/share/fonts/TrueType/', '/usr/share/fonts/truetype/', '/usr/openwin/lib/X11/fonts/TrueType/'];
     }
     // Check for absolute filenames
     if (DIRECTORY_SEPARATOR === $font[0] || $windows && strlen($font) > 1 && (':' === $font[1] || '/' === $font[0])) {
         array_unshift($search, dirname($font) . DIRECTORY_SEPARATOR);
         $font = basename($font);
     }
     // Search
     foreach ($search as $dir) {
         foreach ($extensions as $ext) {
             if (file_exists($q = $dir . $font . $ext)) {
                 return $q;
             }
         }
     }
     throw new \lang\IllegalArgumentException('Could not locate font "' . $font . '[' . implode(', ', $extensions) . ']" in ' . \xp::stringOf($search));
 }
開發者ID:xp-framework,項目名稱:imaging,代碼行數:36,代碼來源:TrueTypeFont.class.php

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

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

示例5: verify

 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $a = \cast($node, 'xp.compiler.ast.AssignmentNode');
     if (!$this->isWriteable($a->variable)) {
         return ['A403', 'Cannot assign to ' . ($a->variable instanceof \lang\Generic ? nameof($a->variable) : \xp::stringOf($a->variable)) . 's'];
     }
 }
開發者ID:xp-lang,項目名稱:compiler,代碼行數:14,代碼來源:IsAssignable.class.php

示例6: send

 /**
  * Send a message
  *
  * @param   peer.mail.Message message the Message object to send
  * @return  bool success
  */
 public function send($message)
 {
     // Sanity check: Is this a message?
     if (!$message instanceof Message) {
         throw new TransportException('Can only send messages (given: ' . xp::typeOf($message) . ')', new IllegalArgumentException('Parameter message is not a Message object'));
     }
     // Sanity check: Do we have at least one recipient?
     $to = '';
     for ($i = 0, $s = sizeof($message->to); $i < $s; $i++) {
         if (!$message->to[$i] instanceof InternetAddress) {
             continue;
         }
         // Ignore!
         $to .= $message->to[$i]->toString($message->getCharset()) . ', ';
     }
     if (empty($to)) {
         throw new TransportException('No recipients defined (recipients[0]: ' . xp::typeOf($message->to[0]), new IllegalArgumentException('Recipient #0 is not an InternetAddress object'));
     }
     // Copy message and unset To / Subject. PHPs mail() function will add them
     // to the mail twice, otherwise
     $tmp = clone $message;
     unset($tmp->to);
     unset($tmp->subject);
     if (FALSE === mail(substr($to, 0, -2), QuotedPrintable::encode($message->getSubject(), $message->getCharset()), strtr($message->getBody(), array("\r\n" => "\n", "\r" => "\n")), rtrim($tmp->getHeaderString(), "\n"), $this->parameters)) {
         throw new TransportException('Could not send mail to ' . xp::stringOf($message->to[0]), new IOException('Call to mail() failed'));
     }
     return TRUE;
 }
開發者ID:melogamepay,項目名稱:xp-framework,代碼行數:34,代碼來源:MailTransport.class.php

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

示例8: __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

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

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

示例11: get

 public function get($key)
 {
     $offset = $key instanceof Generic ? $key->hashCode() : serialize($key);
     if (!isset($this->elements[$offset])) {
         throw new NoSuchElementException('No such key ' . xp::stringOf($key));
     }
     return $this->elements[$offset];
 }
開發者ID:Gamepay,項目名稱:xp-framework,代碼行數:8,代碼來源:Lookup.class.php

示例12: expect

 /**
  * Parser helper function
  *
  * @param  text.Tokenizer $st
  * @param  string $tokens
  * @return string
  * @throws lang.FormatException
  */
 private function expect($st, $tokens)
 {
     $parsed = $st->nextToken($tokens);
     if (false === strpos($tokens, $parsed)) {
         throw new FormatException('Expected [' . $tokens . '], have ' . \xp::stringOf($parsed));
     }
     return $parsed;
 }
開發者ID:xp-framework,項目名稱:rest,代碼行數:16,代碼來源:Links.class.php

示例13: toString

 /**
  * Creates a string representation of this node.
  *
  * @return  string
  */
 public function toString()
 {
     $s = nameof($this) . '(line ' . $this->position[0] . ', offset ' . $this->position[1] . ")@{\n";
     foreach (get_object_vars($this) as $name => $value) {
         '__id' !== $name && 'position' !== $name && 'holder' !== $name && ($s .= sprintf("  [%-20s] %s\n", $name, str_replace("\n", "\n  ", \xp::stringOf($value))));
     }
     return $s . '}';
 }
開發者ID:xp-lang,項目名稱:compiler,代碼行數:13,代碼來源:Node.class.php

示例14: stringOf

 /**
  * Returns a string representation
  *
  * @param  var $val
  * @param  string $default the value to use for NULL
  * @return string
  */
 public static function stringOf($val, $default = '')
 {
     if (null === $val) {
         return $default;
     } else {
         return \xp::stringOf($val);
     }
 }
開發者ID:johannes85,項目名稱:core,代碼行數:15,代碼來源:Objects.class.php

示例15: get

 public function get($key)
 {
     $offset = $key->literal();
     if (!isset($this->elements[$offset])) {
         throw new NoSuchElementException('No such key ' . xp::stringOf($key));
     }
     return $this->elements[$offset];
 }
開發者ID:melogamepay,項目名稱:xp-framework,代碼行數:8,代碼來源:TypeDictionary.class.php


注:本文中的xp::stringOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。