Phpstorm displays a message when using "include" and "require"

Asked

Viewed 200 times

3

What reason my IDE Phpstorm, this message appears with include and require:

Dynamic include Expression 'require_once $file' is not analysed.
Include Expression is not resolved.

Código PHPStorm

  • @bigown added the question.

1 answer

4


The command makes the inclusion of code based on a variable, so Phpstorm, which is an IDE that tries to analyze as much of what can happen to the code, cannot go any further in analyzing this, only during execution would it be able to know what will be included there. He gives science to this.

This code has several other problems.

It already starts with a running condition checking whether a file exists, and which may no longer exist between verification and its invocation. It may be rare, but it happens.

Then he makes a meaningless exception, no relevant information.

And it also includes code not only conditionally, which is already bad, but based on variable. It may be the right thing to do, but it’s rare. You have to know very well what you’re doing, understand all the consequences of this, you have to have a good reason. If this variable comes from an unreliable source, then it opens a huge security breach.

I will not talk about the use of SPL, because it is only my opinion :P

  • Sorry, I never took a course or anything like that. So I know very little, all I learned was researching and here. How would you do an autoload?

  • 1

    I don’t know, which I never had to do. If one day I really needed it and I had no other solution, I would have to see the requirements to identify the best way to do it. Problems are never the same. No requirements can not say anything.

  • To use namespaces in PHP you need an autoload right? My goal is just this.

  • 2

    Namespace is something I’ve never used in PHP, but I don’t see why I would need it. The autoload is a feature that can be used in various ways, is something separate. I have seen it being used in several other ways, not this.

  • 1

    It’s not a question of being pathetic, it’s just inexperience. No one was born knowing.

  • Jeez I went to print something to see and made this mistake: Fatal error: Uncaught Error: Class 'library\Skreth\Http\Teste' not found in D:\skreth\config\config.php:9 Stack trace: #0 D:\skreth\public\index.php(3): require_once() #1 {main} thrown in D:\skreth\config\config.php on line 9. Do you think I should ask a question about?

  • Thank you very much indeed. You helped me understand something I never realized... To use namespaces don’t need autoload just like you said, what I read that said to use autoload was to load the files in different folders, organizing the folders as well as the namespace and with the files called so be able to use their namespaces

  • 2

    What I think is a tremendous gambiarra. But they invented this and some people like it. I do not say that it is not useful, but I see a lot of abuse. Things can be simpler.

  • How would you fix that code?

  • 1

    I wouldn’t do this :) Tidying or making codes always depends on requirements, which I don’t know what they are.

  • Sorry I forgot

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.