You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$foo = Mockery::mock(Foo::class);<> with my cursor now at the end of the line, I have to jump back to the class name before I can import.
Alternatively I'd have to stop at $foo = Mockery::mock(Foo<> to exit insert mode, call the import, reenter insert mode and continue typing.
I don't know how practical this is to implement, but it would be nice if there were the option to have phpactor#UseAdd() or a similar function import all classes written on the current line. so it can be called at the end of the line just written.
@derekhamilton You can add let g:phpactorOmniAutoClassImport = v:true in your vimrc
This will create the use statement anytime you complete a class.
Only downside if you're using a completion manager like ncm2 or ycm this will not work.
You can work around that by using the standard completion <C-x><C-o> to complete the class instead of using the completion manager (not sure i'm clear....)
Or maybe more generally to import all unresolvable classes?
I'm not a big fan of things done without me checking them first, I always print the diff with php-cs for example... OCD ?
But identifying all classes not imported, then printed the list with fzf and letting the user choose which one to import (possibility to check all with one shortcut) that would be awesome! :)
Does anyone have a hint to figure out where to start with that?
I would like to have a service allowing to retrieve every class not starting with a \ and that is not present in the uses statments (aliases including of course).
And in the same time, to check all uses statement that don't have their classes in the rest of the file.
So how to retrieve all classes used inside a file, or more generally a source code?
Ok, I got less time currently anyway.
I gave a try to what you propose above and hit a wall because I had an exception from the Tolerant parser.
I don't remember exactly which one but you opened an issue about it to their repository already.
When I would have time I will come back to you for help on that I think, unless I find an digest doc about tolerant parser...
I'm using latest master and I have a similar issue , and it seems the linked PR does not do the trick for me , when I call
:call phpactor#ImportMissingClasses()
it list all the classes in my file , complaining they don't exists , even though there's only one class missing
it seems to be because i'm also hit by #1085
removing the autochdir and starting in the "root" directory of my project allows me to use :call phpactor#ImportMissingClasses()
Activity
dantleech commentedon Aug 27, 2019
Or maybe more generally to import all unresolvable classes?
camilledejoye commentedon Oct 13, 2019
@derekhamilton You can add
let g:phpactorOmniAutoClassImport = v:truein your vimrcThis will create the use statement anytime you complete a class.
Only downside if you're using a completion manager like ncm2 or ycm this will not work.
You can work around that by using the standard completion
<C-x><C-o>to complete the class instead of using the completion manager (not sure i'm clear....)I'm not a big fan of things done without me checking them first, I always print the diff with php-cs for example... OCD ?
But identifying all classes not imported, then printed the list with fzf and letting the user choose which one to import (possibility to check all with one shortcut) that would be awesome! :)
camilledejoye commentedon Oct 24, 2019
Does anyone have a hint to figure out where to start with that?
I would like to have a service allowing to retrieve every class not starting with a
\and that is not present in the uses statments (aliases including of course).And in the same time, to check all uses statement that don't have their classes in the rest of the file.
So how to retrieve all classes used inside a file, or more generally a source code?
dantleech commentedon Oct 24, 2019
So retrieve all the classes which are not resolvable in the file.
It would belong as a new service in code-transform
I'm not 100% sure without diving into it. I guess something like:
QualifiedNamenodesQualifiedNamecall worse reflection to reflect that offset ($reflector->reflectOffset(ByteOffset::fromInt($node->getStart()))NotFoundexception is thrown add that qualified name to a list[1]The handler can then do something like:
[1] I actually created a value object library for "names": name but it hasn't been used yet, otherwise it could just be a string for now.
camilledejoye commentedon Oct 25, 2019
Ok thanks, I will look into it.
Do you want to gave a try to phpactor/packages or not yet ?
dantleech commentedon Nov 16, 2019
I think we should switch to phpactor/phpactor-packages after the next release.
camilledejoye commentedon Nov 18, 2019
Ok, I got less time currently anyway.
I gave a try to what you propose above and hit a wall because I had an exception from the Tolerant parser.
I don't remember exactly which one but you opened an issue about it to their repository already.
When I would have time I will come back to you for help on that I think, unless I find an digest doc about tolerant parser...
dantleech commentedon Nov 18, 2019
No worries, feel free to open a PR and paste any errors you get. In theory there is nothing above which we don't do already in one place or another.
dantleech commentedon Nov 24, 2019
Fixed by #843
allan-simon commentedon Jan 11, 2022
I'm using latest master and I have a similar issue , and it seems the linked PR does not do the trick for me , when I call
it list all the classes in my file , complaining they don't exists , even though there's only one class missing
it seems to be because i'm also hit by #1085
removing the autochdir and starting in the "root" directory of my project allows me to use
:call phpactor#ImportMissingClasses()