コード例 #1
0
ファイル: shell.php プロジェクト: Jesuslagliva12/OpenAPI
function complete_expr($code)
{
    $code = trim($code);
    if (empty($code)) {
        return array(null, null);
    }
    if (in_array($code, array('quit'))) {
        return array($code, null);
    }
    $last_char = $code[strlen($code) - 1];
    if (is_expression($code)) {
        $code = '$__rs = ' . $code;
    }
    if ($last_char !== ';' && $last_char !== '}') {
        $code .= ';';
    }
    // var_dump($code);
    return array(null, $code);
}
コード例 #2
0
ファイル: grokit_typeinfo.php プロジェクト: gokulp/grokit
 protected function CheckFuzzy(array &$expected, array &$exprs, $type)
 {
     //fwrite(STDERR, "CheckFuzzy: " . print_r($exprs,true) . PHP_EOL);
     $nGiven = \count($exprs);
     $nExpected = \count($expected);
     grokit_assert($nExpected == $nGiven, 'Unable to apply ' . $this . ' to given ' . $type . 's: Expected ' . $nExpected . ' ' . $type . 's, received ' . $nGiven);
     if ($nGiven == 0) {
         return;
     }
     $expectKeys = array_keys($expected);
     reset($expected);
     reset($exprs);
     foreach (range(0, $nExpected - 1) as $i) {
         $cExpected = current($expected);
         $cGiven = current($exprs);
         $cGivenType = is_datatype($cGiven) ? $cGiven : $cGiven->type();
         grokit_assert(canConvert($cGivenType, $cExpected), 'Unable to apply ' . $this . ' to given ' . $type . 's: ' . '' . $type . ' at position ' . $i . ' of type ' . $cGiven->type() . ' not compatible with ' . 'expected type ' . $cExpected);
         if (is_expression($cGiven)) {
             $exprs[key($exprs)] = convertExpression($cGiven, $cExpected);
         }
         next($expected);
         next($exprs);
     }
 }