Skip to content

UnionTypeHelper: Allowed memory size of xxx bytes exhausted #6872

@LastDragon-ru

Description

@LastDragon-ru

Bug report

Not sure what phpstan (1.4.10) doing on level 5 but 20G is not enough to parse this file 😅

<?php declare(strict_types = 1);

namespace App\Utils\Processor;

/**
 * @template TState of object
 */
abstract class Processor {
    public function __construct() {
        // empty
    }

    /**
     * @param TState $state
     */
    protected function saveState(object $state): void {
        $this->set($state);
    }

    /**
     * @param object|array<mixed>|string|float|int|bool|null $value
     */
    public function set(object|array|string|float|int|bool|null $value): mixed {
        return $value;
    }
}
phar://vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionTypeHelper.php:104
    100▕                 }
    101▕                 return \strcasecmp($a->describe(\PHPStan\Type\VerbosityLevel::value()), $b->describe(\PHPStan\Type\VerbosityLevel::value()));
    102▕             }
    103▕             return \strcasecmp($a->describe(\PHPStan\Type\VerbosityLevel::typeOnly()), $b->describe(\PHPStan\Type\VerbosityLevel::typeOnly()));
  ➜ 104▕         });
    105▕         return $types;
    106▕     }
    107▕ }

Code snippet that reproduces the problem

https://phpstan.org/r/67f40319-d1f6-49e6-aa0a-93d53b3121f8 (set level to 5 to fail)

Expected output

no crash

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