How to find class instantiations?
I want to find all places where a class is instantiated with the 'new' keyword. How can I do it?
I've found that when a class has a constructor I can use 'Find Usages' on it and all instantiations are found. But if a class has no constructor then there is nowhere I can invoke this search on. Trying to find usages on the class name returns all occurrences of the class in any form whereas I just want to find its instantiations. How can I do it regardless of whether the constructor exists or not? There is a hacky way of temporarily creating an empty constructor just for this but this seem absurd.
Please sign in to leave a comment.
You may use the "Structural search" feature:

https://www.jetbrains.com/help/phpstorm/structural-search-and-replace.html
There is even a built-in preset for searching instantiations (please disregard its name, it works for classes without constructors too):
You may want to add the needed class name as a "Text" modifier.