Copy-paste PHP file with class in it only allows "Copy Class" option... can't paste file as new file with new name anymore

Before recently, I could right-click a file in Project pane, select Copy, then right-click its parent folder and select Paste to create a copy of the file with a new name that I specify. This made it easy to make a similar class file or just do A/B testing or whatever.

Now, when I select Paste, I get a "Copy Class" prompt, where I can't type in the name of the file... it makes no sense.

I don't want to copy a file and paste a class... I want to paste a file with a new name that I type in.

0
3 comments

There's no way to disable this behavior: https://youtrack.jetbrains.com/issue/WI-70061/Option-to-disable-copying-a-class-file-as-refactoring-to-paste-without-refactoring

This made it easy to make a similar class file or just do A/B testing or whatever.

It's not really clear why you would want to have a class with the same name but with a different filename in your project, though.

0

I am running into the same issue when I want to copy a existing test fixture into the same directory but with a different file name

 

example file

https://github.com/phpstan/phpstan-src/blob/3de7bbc6d1caad749873fb6b05560920fb046c36/tests/PHPStan/Analyser/data/call-user-func.php

 

my current workaround is to create a empty file and paste the contents in

0

Here's one reason you might want this. You've done a while bunch of work on a class file that didn't work out. You plan to revert the class file, but want to keep a copy of it in case some of the changes might be useful. For years, I've solved this by simply copying the file to the same directory with a .bak extension. Now I can't.

Thanks to Maggus Staab for the workaround, though it would be more convenient if I could just copy the file as I always have.

0

Please sign in to leave a comment.