NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Can't Find declaration


Joined: 13 Jan 2010
Posts: 6
Location: US
Reply with quote
HI,

I just want confirmation on why PHPEd cant find declaration and offer suggestion;


// OK, what this does is to create two classes, $Sta_Class and $Dyn_Class. Then reference a function in each.
// $Sta_Class is in a required file known at edit time
// $Dyn_Class is in a required file known only at run time (included file created at run time)

// I'll assume its because $Dyn_Class is ambiguous at edit time PHPEd can't determine declaration.
// Perhaps PHPEd could put up a tool tip saying 'ambigous declaration' instead of appearing to be broken

--------------File My_Class.php
<?php
//My_Class.php
require_once 'Sta_Class.php';
class MyClass {
private $Sta_Class;
private $Dyn_Class;

public function __construct () {
$this->Sta_Class = new Sta_Class(); // Sta_Class is declared in Sta_Class.php, which is required from this file
require_once "ClassFactory.php";
$this->Dyn_Class = ClassFactory::Create("X"); // Dyn_Class is in a file computed at run time (see below)
}
public function DoSomething () {
$this->Sta_Class->Funct(); // ctl-click on Funct(), find decl works OK
$this->Dyn_Class->Funct(); // ctl-click on Funct(), find decl does no work
}
}
?>
--------------File Sta_Class.php
<?php
//Sta_Class.php
class Sta_Class {
public function Funct() {
// code
}
}
?>
--------------File ClassFactory.php
<?php
//"ClassFactory.php";
class ClassFactory {
static function Create($name) {
if (require_once "IncludeFile_" . $name) {
$classname = __NAMESPACE__ . '\\' . 'Dyn_Class';
return new $classname;
}
else {
throw new \Exception ("IncludeFile" . $name . "not found");
}
}
}
?>
--------------File IncludeFile_X.php
<?php
//"IncludeFile_X.php";
class Dyn_Class {
public function Funct() {
// code
}
}
?>
--------------End
View user's profileFind all posts by MikeKSend private messageAIM Address
Can't Find declaration
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