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


PHP hacklib_cast_as_boolean函数代码示例

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


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


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