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.

5 comments
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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

0
Comment actions Permalink

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

1
Comment actions Permalink

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

0

Please sign in to leave a comment.