phpstan: Segmentation Fault (core dumped)

Bug report

When analysing a file with the following contents, I get a Segmentation Fault (using PHPStan 1.4.4, which didn’t appear on 1.4.3).

Code snippet that reproduces the problem

The demo isn’t able to give me a shareable link as it errors. I tried to reduce the amount of code from this class to isolate the exact issue but removing various methods appears to make the fault go away, so here is the code:

<?php

declare(strict_types=1);

namespace App\Hydrator;

use App\Entity\AttributeOption;
use App\Entity\ProductOption;
use App\Entity\EntityInterface;
use Doctrine\ORM\ORMException;

use function call_user_func;

/**
 * @template T of EntityInterface
 * @template R of AttributeOption|ProductOption
 */
abstract class AbstractWithOptionsHydrator
{
    /** @var string */
    protected const OPTION_OWNER_PROPERTY = '';

    /**
     * @param array<string, mixed> $data
     * @param T $entity
     *
     * @return R
     */
    protected function hydrateOption(array $data, EntityInterface $entity): EntityInterface
    {
        /** @var R $option */
        $option   = $this->optionHydrator->hydrate($data);
        $callable = [$option, 'set' . static::OPTION_OWNER_PROPERTY];
        call_user_func($callable, $entity);

        return $option;
    }
}

Expected output

Show analysis output.

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

PHPStan making the world a brighter place one error at a time.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

@staabm It’s gonna be a bug in PHPStan coming from infinite recursion…

@staabm It occurs on the PHPStan playground, so same as that one (PHP 8.1.2).