NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
code completion problem


Joined: 26 Aug 2010
Posts: 7
Reply with quote
<?php
include("db.php");
//an object of type db
$D=db_object();
//the class below
$C = new DbCreator($D);
//passing the $D reference
$C->CreatephpDatabaseObject("blah",$D);

class DbCreator{

public $D1;

function __construct($D)
{

$this->D1=$D;
}
function CreatephpDatabaseObject($database,$D1)
{
//WHY DOESN'T CODE COMPLETION WORK HERE
$this->D1->

}

function CreateClass($database)
{
echo "Class Db_".$database."(){";


}
}
?>
View user's profileFind all posts by mike628Send private message


Joined: 26 Aug 2010
Posts: 7
Reply with quote
Ive updated the code so there are no errors but I still dont get code completion????
<?php
include("db.php");
$D = return_db_object();
$C = new DbCreator($D);
$C->CreatephpDatabaseObject("blah",$D);

class DbCreator{

public $D2;


public function CreatephpDatabaseObject($database,$D1)
{
$this->D2=$D1;

THIS CODE WORKS BU NO CODE COMPLETION!!!!
$data = $this->D2->SelectQuery("select * from urog_account");
$this->CreateClass($database);


}

public function CreateClass($database)
{
echo "Class Db_".$database."(){";


}
}
?>


Thanks
View user's profileFind all posts by mike628Send private message


Joined: 26 Aug 2010
Posts: 7
Reply with quote
Got it!!
View user's profileFind all posts by mike628Send private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
If you can't get the parser to see which type the variable has (it happens plenty since sometimes includes are dynamic etc), you can always use @var as a type indicator. It has helped me a lot in the past Smile

Code:
/** @var CDbConnection */
$oDb = DB::getConnection();


Just a fictional example. If the parser didn't know what the type was, it knows now Smile

Edit: The /** is not a typo, it needs to be 2 asterisks so that the block is interpreted as a DocBlock
View user's profileFind all posts by BlizzSend private messageVisit poster's website
code completion problem
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic