Allow offset in fori loop #23700
Annotations
1 error and 2 warnings
|
Run infection
Process completed with exit code 1.
|
|
Run infection:
src/Analyser/NodeScopeResolver.php#L7327
Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator":
@@ @@
{
// infer $items[$i] type from for ($i = 0; $i < count($items); $i++) {...}
$positiveInt = IntegerRangeType::fromInterval(0, null);
- if (count($stmt->init) === 1 && $stmt->init[0] instanceof Assign && $stmt->init[0]->var instanceof Variable && $positiveInt->isSuperTypeOf($initScope->getType($stmt->init[0]->expr))->yes() && count($stmt->loop) === 1 && ($stmt->loop[0] instanceof Expr\PreInc || $stmt->loop[0] instanceof Expr\PostInc) && $stmt->loop[0]->var instanceof Variable) {
+ if (count($stmt->init) === 1 && $stmt->init[0] instanceof Assign && $stmt->init[0]->var instanceof Variable && !$positiveInt->isSuperTypeOf($initScope->getType($stmt->init[0]->expr))->no() && count($stmt->loop) === 1 && ($stmt->loop[0] instanceof Expr\PreInc || $stmt->loop[0] instanceof Expr\PostInc) && $stmt->loop[0]->var instanceof Variable) {
// $i < count($items)
if ($lastCondExpr instanceof BinaryOp\Smaller && $lastCondExpr->left instanceof Variable && $lastCondExpr->right instanceof FuncCall && $lastCondExpr->right->name instanceof Name && $lastCondExpr->right->name->toLowerString() === 'count' && count($lastCondExpr->right->getArgs()) > 0 && $lastCondExpr->right->getArgs()[0]->value instanceof Variable && is_string($stmt->init[0]->var->name) && $stmt->init[0]->var->name === $stmt->loop[0]->var->name && $stmt->init[0]->var->name === $lastCondExpr->left->name) {
$arrayArg = $lastCondExpr->right->getArgs()[0]->value;
|
|
Run /./build-infection/.github/actions/setup-php
Unexpected input(s) 'extensions', valid inputs are ['php-version', 'php-extensions', 'build-infection-path']
|
Loading