Skip to content

Narrow subtype for RecursiveIteratorIterator $iterable param #3425

@simPod

Description

@simPod

https://phpstan.org/r/ec7fe70c-0127-45a4-9f83-f9d8bd63304f

<?php declare(strict_types = 1);

new RecursiveIteratorIterator((function() { yield 22; })());

This code crashes https://3v4l.org/evDe2 because RecursiveIteratorIterator's template T in stub is of \Traversable and not of \RecursiveIterator|\IteratorAggregate as specified in docs https://www.php.net/manual/en/recursiveiteratoriterator.construct.php

(crosslink phpstan/phpstan-src#228)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions