Skip to content

equivalent to __PHPSTAN_RUNNING__ #3330

@staabm

Description

@staabm

phpstan defines a php constant __PHPSTAN_RUNNING__
https://github.com/phpstan/phpstan-src/blob/ccaa6bf41cb93412536b931121abffb0d38ede6f/bin/phpstan#L14

would be great to have something similar in rector

this is usefull when working in legacy app/codes which contain classes/files which get automatically executed when files are loaded for analysis.

e.g. we have files which start with code like

<?php

if (!defined('__PHPSTAN_RUNNING__')) {
    if (!defined('FILE_PATH')) {
        if (!defined('APP_ROOT')) {
            throw new Exception('Missing required constant, either FILE_PATH or APP_ROOT');
        }

        define('FILE_PATH', APP_ROOT.'/files');
    }
}

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