Skip to content

OOM when parsing a snippet #6896

@danog

Description

@danog

Bug report

Encountering an OOM when parsing the following snippet:

Code snippet that reproduces the problem

(phpstan.org also OOMs and the share link button won't work)

<?php declare(strict_types = 1);


use IteratorIterator;
use LimitIterator;
use Traversable;
use ArrayObject;

/**
 * @template TKey as array-key
 * @template TValue
 *
 * @implements ArrayObject<TKey, TValue>
 *
 * Basic generic iterator, with additional helper functions.
 */
abstract class XIterator extends ArrayObject {
}

final class RandHelper {

	/**
	 * @template TRandKey as array-key
	 * @template TRandVal
	 * @template TRandList as array<TRandKey, TRandVal>|XIterator<TRandKey, TRandVal>|Traversable<TRandKey, TRandVal>
	 *
	 * @param TRandList $list
	 *
	 * @return (
	 * 		TRandList is array ? array<TRandKey, TRandVal> : (
	 * 		TRandList is XIterator ?	XIterator<TRandKey, TRandVal> :
	 * 		IteratorIterator<TRandKey, TRandVal>|LimitIterator<TRandKey, TRandVal>
	 * ))
	 */
	public static function getPseudoRandomWithUrl(
		array|XIterator|Traversable $list,
	): array|XIterator|IteratorIterator|LimitIterator {
		return $list;
	}
}

Expected output

No OOM

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

Thank you for your work on phpstan <3

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