Skip to content

Since 1.4.9, setting class prop of type Set to the result of Set#reduce makes PHPStan think a TypeError is possible, regardless of the native types of the reducer callback. #6791

@ZebulanStanphill

Description

@ZebulanStanphill

Bug report

Starting with PHPStan 1.4.9 (it didn't happen in 1.4.8), when implicitThrows and missingCheckedExceptionInThrows are enabled, the attached code snippet reports this error:

Function setFooProp() throws checked exception TypeError but it's missing from the PHPDoc @throws tag.  
✏️  lib/Utils/Foo.php

I expect the PHPDoc above the anonymous function to be ignored, but surely the native return type should make it clear that TypeError will never be thrown here.

Code snippet that reproduces the problem

https://phpstan.org/r/9846cab9-33a1-461c-91bb-3f418bdfaf09

(Can't reproduce the error in the playground since it requires enabling stuff in the PHPStan config file.)

Expected output

No errors should be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions