Skip to content

PHPStan bootstrap files cannot be re-used for rector #9818

Description

@staabm

Bug Report

Subject Details
Rector version e.g. 2.5.7

Minimal PHP Code Causing Issue

In PHPStan if you use a bootstrap file in the NEON config, it will be included with a global $container variable available to it, see

https://github.com/phpstan/phpstan-src/blob/e911cc96ac19cc55b3c5a54d379fd59bc2ab0f7d/src/Command/CommandHelper.php#L643-L645

I am sharing bootstrap files in projects between phpstan and rector, as these affect type inference in my cases.
would be great rector could also hand the PHPStan $container (DI-Container) into bootstrap files

Expected Behaviour

no fatal error like

➜  kunzmann git:(dba-cache) vendor/bin/rector process app/admin/ -a app/admin/phpstan-bootstrap.php

                                                                                                                        
 [ERROR] Call to a member function getParameter() on null                                                               

for a phpstan-bootstrap.php like

<?php

/** @var \PHPStan\DependencyInjection\Container $container */
$resultCachePath = $container->getParameter('resultCachePath');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions