Skip to content

ForeachToArrayAnyRector incorrect refactoring: array_any #9900

Description

@intco

Bug Report

Subject Details
Rector version Rector 2.6.6 (hash bff669) · from 2026-09-10

the refactored code with array_any does not preserve all matching conditions

Minimal PHP Code Causing Issue

https://getrector.com/demo/47467d38-e31b-478a-ac1e-de0ee5bda472

Expected Behaviour

expected code:

return array_any($noProxyArray, function ($area) use ($host) {
    if ($area === '*') {
        return true;
    }
    
    if (empty($area)) {
        return false;
    }
    
    if ($area === $host) {
        return true;
    }

    $area = '.' . ltrim($area, '.');
    return str_ends_with($host, $area);
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions