예제 #1
0
 public function testOptionHelpers()
 {
     $this->assertInstanceOf(Option\Some::class, some($this->initialValue));
     $this->assertInstanceOf(Option\None::class, none());
     $this->assertInstanceOf(Option\Some::class, wrap($this->initialValue, $this->alternativeValue));
     $this->assertInstanceOf(Option\None::class, wrap($this->initialValue, $this->initialValue));
 }
예제 #2
0
/**
 * @param          $value
 * @param callable $callback
 *
 * @return Optional
 */
function maybe($value, callable $callback = null) : Optional
{
    $callback = $callback ?? 'Dgame\\Optional\\verify';
    if ($callback($value)) {
        return some($value);
    }
    return none();
}
예제 #3
0
파일: functions.php 프로젝트: Rayac/search
/**
 * Like some(), with 1 as count. However, if the promise fulfills, the
 * fulfillment value is not an array of 1 but the value directly.
 *
 * @param mixed $promises Promises or values.
 *
 * @return PromiseInterface
 */
function any($promises)
{
    return some(1, $promises)->then(function ($values) {
        return $values[0];
    });
}
예제 #4
0
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
if (multi(5, 2) == 5 * 2) {
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
if (divide(5, 2) == 5 / 2) {
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
if (some(5, multi(2, 3)) == 5 + 2 * 3) {
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
if (subtrair(8, some(3, 5)) == 8 - (3 + 5)) {
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
if (some(divide(9, 3), multi(4, 2)) == 9 / 3 + 4 * 2) {
    echo 'OK<br>';
} else {
    echo 'erro<br>';
}
?>
</pre>
예제 #5
0
 public function __toString()
 {
     some();
 }
예제 #6
0
function any($promisesOrValues)
{
    return some($promisesOrValues, 1)->then(function ($val) {
        return array_shift($val);
    });
}
예제 #7
0
파일: lib.php 프로젝트: blackwood/vervel
/**
 * Returns false if $callback($x) is logical true for any $x in $arr, else true.
 */
function not_any($callback, array $arr)
{
    return !some($callback, $arr);
}
예제 #8
0
 /** @test */
 public function shouldResolveToEmptyArrayWhenInputPromiseDoesNotResolveToArray()
 {
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo([]));
     some(resolve(1), 1)->then($mock);
 }
예제 #9
0
파일: search.php 프로젝트: vooratarun/bank
					<td width='25%'><b><?php 
                echo $accno;
                ?>
</b></td>
					<td width='25%'><b><?php 
                echo $gender;
                ?>
</b></td>
					<td width="15%" valign=top><center><a href="view_profile.php?accno=<?php 
                echo $accno;
                ?>
" class="btn btn-mini btn-warning"><strong>View Profile</strong></a></center></td>
			    	</tr>
				<?php 
                $m++;
                some();
            }
        }
    } else {
        if ($opt == "Accno") {
            if (strlen(trim($content)) == 0 or strlen(trim($content)) != 7) {
                echo "<script>show_info('Messg : Search Content should not be null');</script>";
                exit;
            }
            $q1 = mysql_query("SELECT * FROM b1_users WHERE accno LIKE '%{$content}%' ");
            $q0 = mysql_fetch_array($q1);
            if (empty($q0)) {
                echo "<script>show_info('Messg : No Results Found');</script>";
                exit;
            } else {
                header("Location:view_profile.php?accno={$content}");
예제 #10
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use function jubianchi\async\runtime\{await, some};
function producer($prefix, $length) : \generator
{
    $cancel = false;
    for ($i = 0; $i < $length && $cancel === false; $i++) {
        echo $prefix . '-' . $i . PHP_EOL;
        $cancel = (bool) yield;
    }
    if ($cancel === true) {
        echo $prefix . '-canceled' . PHP_EOL;
    }
    return $prefix . '-' . __LINE__;
}
var_dump(await(some(2, producer(__LINE__, 5), producer(__LINE__, 10), producer(__LINE__, 2))));
예제 #11
0
파일: Future.php 프로젝트: qieangel2013/zys
 public function some($callback)
 {
     return some($this, $callback);
 }
예제 #12
0
 /** @test */
 public function shouldCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills()
 {
     $mock = $this->createCallableMock();
     $mock->expects($this->never())->method('__invoke');
     $deferred = new Deferred($mock);
     $deferred->resolve();
     $mock2 = $this->getMock('React\\Promise\\CancellablePromiseInterface');
     $mock2->expects($this->once())->method('cancel');
     some([$deferred->promise(), $mock2], 1)->cancel();
 }