LoginSignup
1
2

More than 1 year has passed since last update.

PHPStanで定数のエラーが出力されるとき

Posted at

コマンド入力

composer stan

Stanチェックするためコマンド入力すると、あるエラーが出力される。

Constant DEL_FLG_OFF not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols

定数として定義したDEL_FLG_OFFが見つからないとのこと。

原因は?

定数を定義したファイルがStanチェックのときに、読み込まれていないためです。
親切にエラー文にURLが載せてあるため、参照すると下記のように書いています。

Global constants

Global constants used in the analysed code need to be defined in bootstrap files.
Create a file that looks like this:

constants.php
define('MY_CONSTANT', 1);
And add it to your configuration file:
phpstan.neon
parameters:
    bootstrapFiles:
        - constants.php

Please note that bootstrap files will actually be executed by the PHP runtime.

要約すると

グローバル定数を定義する場合は、
phpstan.neonにbootstrapFilesとして定義してくださいとのこと。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2