本文整理汇总了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);
}
示例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();
}
示例3: rewind
public function rewind()
{
$this->key = !\hacklib_cast_as_boolean($this->key);
if (!\hacklib_cast_as_boolean($this->key)) {
$this->itr->rewind();
}
}
示例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";
}
示例5: close
public function close()
{
if (\hacklib_cast_as_boolean(isset($this->handle))) {
fclose($this->handle);
$this->handle = null;
}
}
示例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";
}
}
示例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";
}
示例8: process
public function process()
{
$client = $this->serverTransport->accept(0);
if (\hacklib_cast_as_boolean($client)) {
$this->clients[$this->clientIdx++] = $client;
}
$this->processExistingClients();
}
示例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 === "]";
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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";
}
}