🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Detect of Modulo checked numeric values always end in int fails #9724

Description

@alexander-schranz

Bug report

The detection of always int does to work in all cases e.g.:

// this works
return function(?int $limit, int $offset = 0): void
{
    if ($limit && (0 === ($offset % $limit))) {
        $this->expectInt(($offset / $limit) + 1);
    }
}

// this fails
return function(?int $limit, int $offset = 0): void
{
    if ($limit && $offset && (0 === ($offset % $limit))) {
        $this->expectInt(($offset / $limit) + 1);
    }
}

Code snippet that reproduces the problem

https://phpstan.org/r/7353d939-662d-4761-beb1-4206ef6f43b8

Expected output

No (int) casting should be required in this case as it is already (int).

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions