Optimize imports in before commit for php files only

I like to use that option to remove unused "use" statements from php files. However I lately discovered that it also removes some imports from my js files as well, which shouldn't be removed. Is there a way to define that I only want to optimize my php files?

0

I am afraid there is no option to distinguish where to use "Optimize imports" on commit and where not to.

However, for example, you may create a scope with PHP files only, do the "Optimize imports" separately and manually _before_ the commit and disable it on commit. 

0

I was also looking for such solution, but how to run "optimize imports" within that scope manually? I was able to call it only by Code -> Optimize imports, but it works only for current file and I didn't find any other place when I could specify my scope.

0

My bad, for some reason, I thought that it is possible.

As some sort of workaround, you may try selecting this scope in Project Tool window, select all PHP files that need Imports Optimization, right-click and select "Optimize Imports" in a context menu for a batch process. Does not look too comfortable but still an option though.

0

Thanks. I didn't think to use the right click there. What's more there is even an option to process only VCS changed files. So it basically is the solution I was looking for. It behaves the same as optimizing import from commit actions, but with scope. It's a lot better way than optimize files one by one :)

 

0

请先登录再写评论。