diff --git a/examples/bench.php b/examples/bench.php index acdf8a04..762b9490 100644 --- a/examples/bench.php +++ b/examples/bench.php @@ -179,11 +179,11 @@ function ary3($n) { /****/ -function fibo_r($n){ +function fibo_r(int $n){ return(($n < 2) ? 1 : fibo_r($n - 2) + fibo_r($n - 1)); } -function fibo($n) { +function fibo(int $n) { $r = fibo_r($n); print "$r\n"; } diff --git a/perf/issetor.php b/perf/issetor.php new file mode 100644 index 00000000..6b324814 --- /dev/null +++ b/perf/issetor.php @@ -0,0 +1,15 @@ +parseAssignArrayDim($left, $right); } + // When the RHS is untyped (TYPE_VAR) but the LHS variable already has a known + // native type, use the LHS type for the conversion so that e.g. + // php::Int i; ... i = n; (n is php::Var) + // becomes i = php::toInt(n); + if ($finalVarType === self::TYPE_VAR && $this->hasVar($var)) { + $varType = $this->getVarType($var); + if ($varType !== self::TYPE_VAR) { + $finalVarType = $varType; + } + } + $rightExpr = $this->parseAssignRightExpr($right); $leftExprType = $this->detectTypeOfExpr($left); $rightExprType = $this->detectTypeOfExpr($right);