Code inspection: unused element - what is an entry point?

I (finally) take care of the yellow markers :)

Most of them are easy to get rid of. But for example I’ve got a lot of unused methods that are actually used somewhere else. I read I can suppress them or add an entry point.

  • Add the element as an entry point. By default, all code in the global scope as well as tests is treated as reachable. If you know that a method or function is executed, you may add it as an entry point. The code inside the entry point is now executed and reachable, as well.
    When you add an entry point, your source code files stay unaffected, and the element’s record is stored with the project under .idea\misc.xml.

I can’t get behind what that means and if it fits to what I want/need.

2
5 comments

Hi there,

Imaging a Controller class with 2 action methods (e.g. "login" and "logout").

You do not call those methods directly (e.g. "$myController->login(...);") -- your framework will call them for you when you hit specific URL in a browser (or whatnot).

Marking those methods as "entry points" tells IDE that those methods are actually used (an entry point into your app/specific functionality).

0
Avatar
Permanently deleted user

Thanks, that was pretty easy to understand :-) And sorry for the late reply, I thought I get an email when there is an answer. 

0
Avatar
Permanently deleted user

I looked around but couldn't find how to add a method as an entry point. Where do I define entry points?

1

Try typing "entry" in a search box in the Settings/Preferences screen -- it will narrow it down.

 

Settings (Preferences on macOS) | Editor | Inspections | PHP | Unused | Unused declaration

0
Avatar
Permanently deleted user

Great! Found it. Will have a look how to use it. Many thanks!!

0

Please sign in to leave a comment.