Skip to content

Could not read file: xyz.php  #3066

@twisted1919

Description

@twisted1919

Bug report

We're using PHPStan 0.12.14 and this issue appeared recently, basically PHPStan errors out with hundred of errors like:

Could not read file: callout.php 

And we cannot find out what exactly is causing it, if you take a look bellow, 'callout' is just one of the array keys. Why PHPStan picks that one in particular, i have no idea.

Code snippet that reproduces the problem

public function run()
    {
        // update old layouts
        $models = ListPageType::model()->findAll();
        $searchReplace = [
            'panel panel-default'   => 'box box-primary borderless',
            'panel-heading'         => 'box-header',
            'panel-title'           => 'box-title',
            'panel-body'            => 'box-body',
            'callout'               => 'callout callout-info',
            'panel-footer'          => 'box-footer',
            'panel-'                => 'box-',
            '@import url(\'http://fonts.googleapis.com/css?family=Open+Sans\');'            => '',
            '@import url(\'http://fonts.googleapis.com/css?family=Noto+Sans:700italic\');'  => '',
            '#b94a48'               => '#367fa9',
            '\'Open Sans\','        => '',
            '\'Noto Sans\','        => '',
        ];
        foreach ($models as $model) {
            $model->content = str_replace(array_keys($searchReplace), array_values($searchReplace), $model->content);
            $model->save(false);
        }

        /** @var OptionEmailTemplate $optionEmailTemplate */
        $optionEmailTemplate = container()->get(OptionEmailTemplate::class);

        $common = str_replace('#b94a48', '#367fa9', $optionEmailTemplate->common);
        $optionEmailTemplate->saveAttributes(['common' => $common]);
        // end update
    }

Expected output

We're expecting PHPStan to show no error, at least not an error related to loading a file based on a defined array key.

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