PHPStorm不能从变量中分析路径吗?

时间:2022-10-15 18:25:09

PHPStorm不能从变量中分析路径吗?

As you see, the first require_once gives no weak warning. The latter one does, but I don't understand why. Is there any reason why this is happening? The file exists and contains a class. If its any useful, this is the file structure:

正如您所看到的,第一个require_once没有给出弱的警告。后者有,但我不明白为什么。为什么会发生这种情况?该文件存在并包含一个类。如果有用,这是文件结构:

-| Project
  -| Anomius
    - Anomius.php (This is the included file)
  -| Sites
    -| Foo
      - app.php (This is the file on the image)

2 个解决方案

#1


4  

Simply disable the setting in PhpStorm which produces the warning:

只需禁用PhpStorm中的设置,它会产生警告:

In Settings search for 'unresolved include' which is under Editor > Inspections; PHP > General > Unresolved include

在设置中搜索'待解决的include',这是编辑器>检查;PHP >一般>未解析包括

and uncheck the box.

取消选中对应的复选框。

#2


2  

By default, PHPStorm only remembers variable names, not values. So if you start typing $ano, it'll give you auto-completion for $anomius, but it doesn't know what $anomius actually contains.

默认情况下,PHPStorm只记住变量名,而不是值。如果你开始输入$ano,它会自动完成$anomius,但它不知道$anomius到底包含什么。

To make PHPStorm understand where your file is, try this:

要让PHPStorm了解您的文件在哪里,请尝试以下方法:

$anomius = "your_file.php";
/** @define "$anomius" "/absolute/path/to/your/php/file" */
require_once($anomius);

#1


4  

Simply disable the setting in PhpStorm which produces the warning:

只需禁用PhpStorm中的设置,它会产生警告:

In Settings search for 'unresolved include' which is under Editor > Inspections; PHP > General > Unresolved include

在设置中搜索'待解决的include',这是编辑器>检查;PHP >一般>未解析包括

and uncheck the box.

取消选中对应的复选框。

#2


2  

By default, PHPStorm only remembers variable names, not values. So if you start typing $ano, it'll give you auto-completion for $anomius, but it doesn't know what $anomius actually contains.

默认情况下,PHPStorm只记住变量名,而不是值。如果你开始输入$ano,它会自动完成$anomius,但它不知道$anomius到底包含什么。

To make PHPStorm understand where your file is, try this:

要让PHPStorm了解您的文件在哪里,请尝试以下方法:

$anomius = "your_file.php";
/** @define "$anomius" "/absolute/path/to/your/php/file" */
require_once($anomius);