Does not work for $this->var, but works $var
Probably this is not specific to CodeComplice, but to SublimeCodeIntel as well.
Let's say I have the following PHP class.
class aClass
{
private $bClass;
public function __construct(bClass $bClass)
{
$this->bClass = $bClass;
//$bClass-> works fine (pops up the method hints)
//$this->bClass-> doesn't work
}
}
How do I fix this?
<?php
class bClass
{
public function method1()
{
return true;
}
}
class aClass
{
private $bClass;
public function __construct(bClass $bClass)
{
$this->bClass = $bClass;
// $bClass->
// $this->bClass->
}
}
I put this in a new project, in an new file. Both lines are working for me.
incomplete statements, invalid syntax, etc, can disturb the parser. Can you confirm this is not working, when you prepare a test file like the one above?
<?php
class bClass
{
public function method1()
{
return true;
}
}
class aClass
{
/** @var bClass */
private $bClass;
public function __construct($bClass)
{
$this->bClass = $bClass;
$this->bClass->
}
}
This will also work. Komodo detects quite a lot of PHPDocs!
@spectacles It works if I put the classes in the same file, but no one does that anymore.
The following code does not work.
use namespace\bClass;
class aClass
{
private $bClass;
public function __construct(bClass $bClass)
{
$this->bClass = $bClass;
}
}
/** @var fully qualified namespace **works, but that's just too much copy and paste.
Is there a way to make it work without @var?
@spectacles It works if I put the classes in the same file, but no one does that anymore.
@moon0326 true that, but now we are getting somewhere ;)
The evaluation of PHP namespaces in the Komodo codebase is seriously messy, and a lot of times not working correctly. I will fix this, if I can find the time "... find the time :notes:, la la lala..."
greetings!
@moon0326 actually the case you provided, is working for me. Have you made sure that the file where namespace\bClass is defined, gets scanned?
@spectacles Yes, I believe so.
This is my actual code.
use Modules\Entry\Services\CreateEntryService;
use Illuminate\Http\Request;
use Modules\Core\ClientIdFinder;
use SDK\Frameworks\Laravel\Authenticatable;
public function __construct(
CreateEntryService $createEntryService,
Request $request,
ClientIdFinder $clientIdFinder,
Authenticatable $auth
) {
$this->clientId = $clientIdFinder->findOrFail();
$this->auth = $auth;
$this->createEntryService = $createEntryService;
$this->id = $request->input('id');
$this->language = $request->input('language', 'default');
$this->collectionRequest = $request->input('collection', null);
$this->userId = $request->input('userId');
$this->formValues = $request->all();
// $this->createEntryService-> does not work here or in any other methods.
}
I'm sure the variable is being scanned as I see it varname{variable} as I type the name of it.
It might be my settings if it works for you. Is there a configuration value I should check?
the current file always gets scanned, that's not the question.
You have to find out if the file, in which Modules\Entry\Services\CreateEntryService gets defined, gets scanned.
To do that you can go to Sublime Command Palette, type "Dump" and select "CodeComplice: Dump import Directories".
On execution it will raise a message dialog with the current database directory. In this directory (or one directory level UP from there) you will find a directory import_dir_stats. The Command has written all scanned directories per language into text files.
Is the procedure clear? Otherwise ask!
@spectacles Thank you!
I see the all the directories in the index file. I'm not exactly sure how the extension works internally, but I think the file has been scanned. As I wrote in my first post, " //$bClass-> works fine (pops up the method hints)" works just fine.
Maybe this is related: https://github.com/Komodo/KomodoEdit/issues/123
could you test with unique names for classes/variables?
Just renamed a variable and tested it out.
I'm still getting the same error message.
I'm still getting the same error message.
You didn't mention an error message before. What is it sayin?
It's
"evaluating 'this.myvar' at myfil.ephp#49: could not resolve first part of 'myvar', info: processing 'PHP': please wait..."