Skip to content

Out of memory error when using circular class reference with intersection in property declaration #13057

@Jamie4224

Description

@Jamie4224

Bug report

Given classes ModelA and ModelB, when declaring a property on each class that references the other class and also uses an intersect, phpstan runs out of memory. The phpstan playground won't make this shareable but when you paste the following code into the playground it won't produce an output.

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

use function PHPStan\dumpType;
use function PHPStan\Testing\assertType;

/**
 * @property ModelB & object{extra: string} $modelB
 */
class ModelA
{}

/**
 * @property ModelA & object{extra: string} $modelA
 */
class ModelB
{}

Expected output

Expected to run without any errors.

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

No response

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