• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP hacklib_cast_as_boolean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: flush

 public function flush()
 {
     if (\hacklib_cast_as_boolean($this->randomize_)) {
         shuffle($this->servers_);
     }
     foreach ($this->servers_ as $server) {
         $this->host_ = $server[0];
         $this->port_ = $server[1];
         $j = $this->numTries_;
         while ($j > 0) {
             try {
                 parent::flush();
                 return;
             } catch (TTransportException $e) {
                 if (\hacklib_cast_as_boolean($this->debug_)) {
                     call_user_func($this->debugHandler_, $e->getMessage());
                 }
                 --$j;
             }
         }
     }
     $this->host_ = "";
     $this->port_ = 0;
     $error = "THttpClientPool: Could not connect to any of the servers " . "in the pool";
     throw new TTransportException($error, TTransportException::NOT_OPEN);
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:26,代码来源:THttpClientPool.php


示例2: __construct

 public function __construct($input, $output = null)
 {
     $this->input_ = $input;
     $this->output_ = \hacklib_cast_as_boolean($output) ?: $input;
     $this->asyncHandler_ = new TClientAsyncHandler();
     $this->eventHandler_ = new TClientEventHandler();
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:7,代码来源:ThriftClientBase.php


示例3: rewind

 public function rewind()
 {
     $this->key = !\hacklib_cast_as_boolean($this->key);
     if (!\hacklib_cast_as_boolean($this->key)) {
         $this->itr->rewind();
     }
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:7,代码来源:TSimplePHPObjectProtocolKeyedIteratorWrapper.php


示例4: test_all_expression_types

function test_all_expression_types()
{
    $v = new \HH\Vector(array());
    $f = new Foo();
    test_cast("clone", (bool) \hacklib_cast_as_boolean(clone $v));
    test_cast("obj_get", (bool) \hacklib_cast_as_boolean($f->prop));
    test_cast("array_get", (bool) \hacklib_cast_as_boolean(array($v)[0]));
    test_cast("class_get", (bool) \hacklib_cast_as_boolean(Foo::$s_prop));
    test_cast("cast", (bool) \hacklib_cast_as_boolean((object) $v));
    test_cast("cast", (bool) (array) \hacklib_cast_as_array($v));
    for ($v_in = new \HH\Vector(array(1)), $i = 1; $i > 0, \hacklib_cast_as_boolean($v_in); $i++, $v_in->pop()) {
        echo "in here at " . $i . "\n";
        if ($i > 5) {
            break;
        }
    }
    test_cast("Eif", (bool) \hacklib_cast_as_boolean(true ? $v : $f));
    test_cast("unsafe_expr", (bool) \hacklib_cast_as_boolean($v));
    test_cast("call", (bool) \hacklib_cast_as_boolean(Foo::s_func()));
    test_cast("Collection", (bool) (!\hacklib_id(new \HH\Vector(array()))->isEmpty()));
    test_cast("New", (bool) new Foo());
    test_cast("New", (bool) (!\hacklib_id(new \HH\Vector(array()))->isEmpty()));
    test_cast("Eq", (bool) ($y = false));
    test_cast("Eq", (bool) \hacklib_cast_as_boolean($z = $f->i_func()));
    echo $z . "\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:26,代码来源:boolean_cast_possible_collections.php


示例5: close

 public function close()
 {
     if (\hacklib_cast_as_boolean(isset($this->handle))) {
         fclose($this->handle);
         $this->handle = null;
     }
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:7,代码来源:TServerSocket.php


示例6: verify_set

function verify_set($s)
{
    echo \hacklib_cast_as_boolean($s->isEmpty()) ? "empty\n" : "not empty\n";
    echo $s->count() . "\n";
    echo \hacklib_cast_as_boolean($s->contains("25")) ? "contains 25\n" : "does not contain 25\n";
    echo \hacklib_cast_as_boolean($s->contains("truman")) ? "contains truman\n" : "does not contain truman\n";
    echo \hacklib_cast_as_boolean(isset($s[\hacklib_id("25")])) ? "contains 25\n" : "does not contain 25\n";
    echo gettype($s[\hacklib_id("25")]) . "\n";
    echo gettype($s[\hacklib_id('25')]) . "\n";
    echo gettype($s[25]) . "\n";
    try {
        $s[\hacklib_id("truman")];
        echo "should not see this";
    } catch (OutOfBoundsException $e) {
        echo $e->getMessage() . "\n";
    }
    foreach ($s as $i => $val) {
        $out = var_export($val, true);
        $t = gettype($i);
        echo "({$t}) {$i} : {$out}\n";
    }
    $i = $s->getIterator();
    $i->next();
    $i->next();
    $i->next();
    $i->next();
    try {
        $i->current();
        echo "should not see this";
    } catch (InvalidOperationException $e) {
        echo $e->getMessage() . "\n";
    }
}
开发者ID:barnardm,项目名称:hhvm,代码行数:33,代码来源:sets.php


示例7: boolean_statements

function boolean_statements($c)
{
    if (\hacklib_cast_as_boolean($c)) {
        echo "If Then";
    } else {
        echo "If Else";
    }
    $i = 0;
    do {
        $i++;
        if ($i > 3) {
            break;
        }
    } while (\hacklib_cast_as_boolean($c));
    echo "Do Loop Iterations : {$i}\n";
    $i = 0;
    while (\hacklib_cast_as_boolean($c)) {
        $i++;
        if ($i > 3) {
            break;
        }
    }
    echo "While loop Iterations : {$i}\n";
    $i = 0;
    for (; \hacklib_cast_as_boolean($c); $i++) {
        if ($i > 3) {
            break;
        }
    }
    echo "For Loop iterations : {$i}\n";
}
开发者ID:afaltz,项目名称:hhvm,代码行数:31,代码来源:boolean_expressions.php


示例8: process

 public function process()
 {
     $client = $this->serverTransport->accept(0);
     if (\hacklib_cast_as_boolean($client)) {
         $this->clients[$this->clientIdx++] = $client;
     }
     $this->processExistingClients();
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:8,代码来源:TNonBlockingServer.php


示例9: readContextOver

 public function readContextOver()
 {
     $pos = $this->skipWhitespace(false);
     $c = $this->bufTrans->peek(1, $pos);
     if (!\hacklib_cast_as_boolean($this->first) && $c !== "," && $c !== "]") {
         throw new TProtocolException("TSimpleJSONProtocol: Expected \",\" or \"]\", encountered 0x" . bin2hex($c));
     }
     return $c === "]";
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:9,代码来源:TSimpleJSONProtocolListContext.php


示例10: open

 public function open()
 {
     try {
         parent::open();
     } catch (Exception $e) {
         $op_in_progress = strpos($e->getMessage(), "socket_connect error") !== false && strpos($e->getMessage(), "[115]") !== false;
         if (!\hacklib_cast_as_boolean($op_in_progress)) {
             throw $e;
         }
     }
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:11,代码来源:TNonBlockingSocketNoThrow.php


示例11: foo

 public function foo()
 {
     $x = 1 + 2 * (3 - 2 / 5);
     $y = -++$x % +10;
     $x -= $y++;
     $y /= --$z;
     $b = "hi" . " hello";
     $c .= "hey there";
     $n = $x-- | $y & ($z ^ ~$x >> 2) << 3;
     $yes = ((bool) \hacklib_cast_as_boolean($x) && $x > $y || !($x >= $z)) ^ $z < $y || $z <= $x;
     $maybe = \hacklib_equals($x, $y) && $x === $y && \hacklib_not_equals($z, $x) && $z !== $y;
 }
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:12,代码来源:operations.php


示例12: deserialize

 public static function deserialize($str, $object, $disable_hphp_extension = false)
 {
     $transport = new TMemoryBuffer();
     $protocol = new TBinaryProtocolAccelerated($transport);
     if (\hacklib_cast_as_boolean(function_exists('thrift_protocol_read_binary')) && !\hacklib_cast_as_boolean($disable_hphp_extension)) {
         $protocol->writeMessageBegin('', TMessageType::REPLY, 0);
         $transport->write($str);
         $object = thrift_protocol_read_binary($protocol, get_class($object), $protocol->isStrictRead());
     } else {
         $transport->write($str);
         $object->read($protocol);
     }
     return $object;
 }
开发者ID:pandasasa,项目名称:fbthrift,代码行数:14,代码来源:TBinarySerializer.php


示例13: write

 public function write($output)
 {
     $xfer = 0;
     $xfer += $output->writeStructBegin('TApplicationException');
     if (\hacklib_cast_as_boolean($message = $this->getMessage())) {
         $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
         $xfer += $output->writeString($message);
         $xfer += $output->writeFieldEnd();
     }
     if (\hacklib_cast_as_boolean($code = $this->getCode())) {
         $xfer += $output->writeFieldBegin('type', TType::I32, 2);
         $xfer += $output->writeI32($code);
         $xfer += $output->writeFieldEnd();
     }
     $xfer += $output->writeFieldStop();
     $xfer += $output->writeStructEnd();
     return $xfer;
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:18,代码来源:TApplicationException.php


示例14: deserialize

 public static function deserialize($str, $object, $override_version = null, $disable_hphp_extension = false)
 {
     $transport = new TMemoryBuffer();
     $protocol = new TCompactProtocolAccelerated($transport);
     $use_hphp_extension = \hacklib_cast_as_boolean(function_exists('thrift_protocol_read_compact')) && !\hacklib_cast_as_boolean($disable_hphp_extension);
     if ($override_version !== null) {
         $protocol->setWriteVersion($override_version);
         if (!\hacklib_cast_as_boolean(function_exists('thrift_protocol_set_compact_version'))) {
             $use_hphp_extension = false;
         }
     }
     if (\hacklib_cast_as_boolean($use_hphp_extension)) {
         $protocol->writeMessageBegin('', TMessageType::REPLY, 0);
         $transport->write($str);
         $object = thrift_protocol_read_compact($protocol, get_class($object));
     } else {
         $transport->write($str);
         $object->read($protocol);
     }
     return $object;
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:21,代码来源:TCompactSerializer.php


示例15: verify_map

function verify_map($m)
{
    echo \hacklib_cast_as_boolean($m->isEmpty()) ? "empty\n" : "not empty\n";
    echo $m->count() . "\n";
    echo $m->at("25") . "\n";
    echo $m[\hacklib_id("25")] . "\n";
    echo $m->get("25") . "\n";
    try {
        $m->at(25);
        echo "should not see this";
    } catch (OutOfBoundsException $e) {
        echo $e->getMessage() . "\n";
    }
    try {
        $m[25];
        echo "should not see this";
    } catch (OutOfBoundsException $e) {
        echo $e->getMessage() . "\n";
    }
    echo var_export($m->get(25), true) . "\n";
    echo \hacklib_cast_as_boolean(isset($m[\hacklib_id("25")])) ? "is set\n" : "not set\n";
    echo \hacklib_cast_as_boolean($m->containsKey("25")) ? "contains Key\n" : "does not contain Key\n";
    echo \hacklib_cast_as_boolean($m->containsKey(25)) ? "contains Key\n" : "does not contain Key\n";
    foreach ($m as $i => $mal) {
        $out = var_export($mal, true);
        $t = gettype($i);
        echo "({$t}) {$i} : {$out}\n";
    }
    $i = $m->getIterator();
    $i->next();
    $i->next();
    $i->next();
    $i->next();
    try {
        $i->current();
        echo "should not see this";
    } catch (InvalidOperationException $e) {
        echo $e->getMessage() . "\n";
    }
}
开发者ID:barnardm,项目名称:hhvm,代码行数:40,代码来源:maps.php


示例16: verify_pair

function verify_pair($p)
{
    echo \hacklib_cast_as_boolean($p->isEmpty()) ? "empty\n" : "not empty\n";
    echo $p->count() . "\n";
    echo $p->at(1) . "\n";
    echo $p[1] . "\n";
    echo $p->get(1) . "\n";
    try {
        $p->at(10);
        echo "should not see this";
    } catch (OutOfBoundsException $e) {
        echo $e->getMessage() . "\n";
    }
    try {
        $p[10];
        echo "should not see this";
    } catch (OutOfBoundsException $e) {
        echo $e->getMessage() . "\n";
    }
    echo var_export($p->get(10), true) . "\n";
    echo \hacklib_cast_as_boolean(isset($p[3])) ? "is set\n" : "not set\n";
    echo \hacklib_cast_as_boolean($p->containsKey(2)) ? "contains Key\n" : "does not contain Key\n";
    echo \hacklib_cast_as_boolean($p->containsKey(20)) ? "contains Key\n" : "does not contain Key\n";
    foreach ($p as $i => $val) {
        $out = var_export($val, true);
        echo "{$i} : {$out}\n";
    }
    $i = $p->getIterator();
    $i->next();
    $i->next();
    $i->next();
    $i->next();
    try {
        $i->current();
        echo "should not see this";
    } catch (InvalidOperationException $e) {
        echo $e->getMessage() . "\n";
    }
}
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:39,代码来源:pairs.php


示例17: skipWhitespace

 protected function skipWhitespace($skip = true)
 {
     $count = 0;
     $reading = true;
     while (\hacklib_cast_as_boolean($reading)) {
         $byte = $this->bufTrans->peek(1, $count);
         switch ($byte) {
             case " ":
             case "\t":
             case "\n":
             case "\r":
                 $count++;
                 break;
             default:
                 $reading = false;
                 break;
         }
     }
     if (\hacklib_cast_as_boolean($skip)) {
         $this->trans->readAll($count);
     }
     return $count;
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:23,代码来源:TSimpleJSONProtocolContext.php


示例18: flushImpl

 private function flushImpl($oneway)
 {
     if (\hacklib_equals(strlen($this->wBuf_), 0)) {
         if (\hacklib_cast_as_boolean($oneway)) {
             $this->transport_->onewayFlush();
         } else {
             $this->transport_->flush();
         }
         return;
     }
     $out = $this->transform($this->wBuf_);
     $this->wBuf_ = '';
     if ($this->protoId_ === 1 && $this->clientType_ !== self::HTTP_CLIENT_TYPE) {
         throw new TTransportException('Trying to send JSON encoding over binary', TTransportException::INVALID_CLIENT);
     }
     $buf = '';
     if ($this->clientType_ === self::HEADER_CLIENT_TYPE) {
         $transformData = '';
         $num_headers = 0;
         foreach ($this->writeTrans_ as $trans) {
             ++$num_headers;
             $transformData .= $this->getVarint($trans);
         }
         if ($this->identity !== null) {
             $this->writeHeaders[self::ID_VERSION_HEADER] = (string) self::ID_VERSION;
             $this->writeHeaders[self::IDENTITY_HEADER] = $this->identity;
         }
         $infoData = '';
         if (\hacklib_cast_as_boolean($this->writeHeaders) || \hacklib_cast_as_boolean($this->persistentWriteHeaders)) {
             $infoData .= $this->getVarint(self::INFO_KEYVALUE);
             $infoData .= $this->getVarint(count($this->writeHeaders) + count($this->persistentWriteHeaders));
             foreach ($this->persistentWriteHeaders as $str_key => $str_value) {
                 $infoData .= $this->writeString($str_key);
                 $infoData .= $this->writeString($str_value);
             }
             foreach ($this->writeHeaders as $str_key => $str_value) {
                 $infoData .= $this->writeString($str_key);
                 $infoData .= $this->writeString($str_value);
             }
         }
         $this->writeHeaders = \HH\Map::hacklib_new(array(), array());
         $headerData = $this->getVarint($this->protoId_) . $this->getVarint($num_headers);
         $header_size = strlen($transformData) + strlen($infoData) + strlen($headerData);
         $paddingSize = 4 - $header_size % 4;
         $header_size += $paddingSize;
         $buf = (string) pack('nn', self::HEADER_MAGIC, $this->flags_);
         $buf .= (string) pack('Nn', $this->seqId_, $header_size / 4);
         $buf .= $headerData . $transformData;
         $buf .= $infoData;
         for ($i = 0; $i < $paddingSize; $i++) {
             $buf .= (string) pack('C', '\\0');
         }
         $buf .= $out;
         $buf = (string) pack('N', strlen($buf)) . $buf;
     } else {
         if ($this->clientType_ === self::FRAMED_DEPRECATED) {
             $buf = (string) pack('N', strlen($out));
             $buf .= $out;
         } else {
             if ($this->clientType_ === self::UNFRAMED_DEPRECATED) {
                 $buf = $out;
             } else {
                 if ($this->clientType_ === self::HTTP_CLIENT_TYPE) {
                     throw new TTransportException('HTTP not implemented', TTransportException::INVALID_CLIENT);
                 } else {
                     throw new TTransportException('Unknown client type', TTransportException::INVALID_CLIENT);
                 }
             }
         }
     }
     if (strlen($buf) > self::MAX_FRAME_SIZE) {
         throw new TTransportException('Attempting to send oversize frame', TTransportException::INVALID_FRAME_SIZE);
     }
     $this->transport_->write($buf);
     if (\hacklib_cast_as_boolean($oneway)) {
         $this->transport_->onewayFlush();
     } else {
         $this->transport_->flush();
     }
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:80,代码来源:THeaderTransport.php


示例19: readString

 public function readString(&$value)
 {
     $len = 0;
     $result = $this->readI32($len);
     if (\hacklib_cast_as_boolean($len)) {
         $value = $this->trans_->readAll($len);
     } else {
         $value = "";
     }
     return $result + $len;
 }
开发者ID:sanjoyghosh,项目名称:fbthrift,代码行数:11,代码来源:TBinaryProtocolBase.php


示例20: _write

 protected function _write($class, $spec, $output)
 {
     $xfer = 0;
     $xfer += $output->writeStructBegin($class);
     foreach ($spec as $fid => $fspec) {
         $var = $fspec[\hacklib_id('var')];
         if ($this->{$var} !== null) {
             $ftype = $fspec[\hacklib_id('type')];
             $xfer += $output->writeFieldBegin($var, $ftype, $fid);
             if (\hacklib_cast_as_boolean(isset(TBase::$tmethod[$ftype]))) {
                 $func = 'write' . TBase::$tmethod[$ftype];
                 $xfer += $output->{$func}($this->{$var});
             } else {
                 switch ($ftype) {
                     case TType::STRUCT:
                         $xfer += $this->{$var}->write($output);
                         break;
                     case TType::MAP:
                         $xfer += $this->_writeMap($this->{$var}, $fspec, $output);
                         break;
                     case TType::LST:
                         $xfer += $this->_writeList($this->{$var}, $fspec, $output, false);
                         break;
                     case TType::SET:
                         $xfer += $this->_writeList($this->{$var}, $fspec, $output, true);
                         break;
                 }
             }
             $xfer += $output->writeFieldEnd();
         }
     }
     $xfer += $output->writeFieldStop();
     $xfer += $output->writeStructEnd();
     return $xfer;
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:35,代码来源:TBase.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP hae_yhtion_parametrit函数代码示例发布时间:2022-05-15
下一篇:
PHP hacker_dork函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap