Can not find method

Hi.

I have 3 files with correct namespaces and spl_autoload
PHP version 7

table/campaign.php

namespace table;
Class Campaign{

function getAllCampaign(){
}
}


model/modelName/Index.php
namespace model\modelName;
class Index Extends Controller{

protected $campaign;//also i tried var and public

function __construct(){

$this->campaign = new \table\Campaign;
}

function Index(){

$this->getData();
}
}


model/modelName/Controller.php

namespace model\modelName;
/**
* @property Index campaign
*/
class Controller{

function getData(){

//with property it provides campaign protected variable but no further
//if i trying to get campaign method it will not provide autocomplete
//also it says that method not found
//in website it works

$this->campaign->get
}
}

0

Hm, this looks to be working for me:

What IDE version are you running?

0
Avatar
Permanently deleted user

I use 2016.2.2.

 

Now i see, it offers second parameter to same variable and after that it provides Sql methods.

But this is not correct. It will create error: Fatal error: Uncaught Error: Call to a member function Select() on null in

 





0

I think it works just as expected.
On the first invocation, "campaign" is a property of $this, and its type is "Index", which is perfectly fine and you get the completion you want.
On the second invocation, "campaign" is a property of "Index", and we infer the type of it as "Campaign" because of the constructor.

0
Avatar
Permanently deleted user

Hi.

 

So what i do wrong ?

0

You should probably set /** @property Index $campaign */ in Index.

0
Avatar
Permanently deleted user

Not working.

 

Enough of this, I'll stick to editplus.

0

Could you please explain what doesn't work exactly?

0

请先登录再写评论。