Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When calling class:move with nonexistent files, no warning or error is shown #2651

Open
Azeirah opened this issue May 6, 2024 · 2 comments

Comments

@Azeirah
Copy link

Azeirah commented May 6, 2024

Title is self-explanatory.

When you do the following: phpactor class:move thisFileDoesNotExist.php newFile.php, no warning or error is given.

This was confusing to me because my CWD was a subfolder of the project I'm working in, and I tried running phpactor class:move with the path relative to the project root.

I don't think class:move is usable at all in subdirectories. For instance, if I run the same action but on a class that does exist in the subdirectory I get the following

$ cd app/subdir
$ phpactor class:move ClassThatExists.php MyNewClass.php
In ClassMover.php line 79:
                                                                                                             
  Could not move file "/app/subdir/ClassThatExists.php" to "MyNewClass.php"                                                                                            
                                                                                                             

In ClassNameCandidates.php line 39:
                                      
  There are no class name candidates  
                                      

class:move [--type TYPE] [--related] [--filesystem FILESYSTEM] [--] <src> [<dest>]

(the extra weird thing is that ClassMover line 79 doesn't exist? The file is only about 40 lines long! Debugging the issue was difficult for this reason.

@dantleech
Copy link
Collaborator

Yeah, this always expected that Phactor CLI is run in the project root or that the working directory is passed as an option.

There are two ClassMover classes, one is in the lib/Extension/ClassMover/Application.

Probably it should throw an exception if no source file(s) can be resolved.

@przepompownia
Copy link
Contributor

Searching by the constant part of the error message can be helpful in such cases.

Without direct checking on the Phpactor side: I looked into some old project composed of two subprojects and found using composer.autoloader_path. I never used it in CLI - only for LSP usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants