Hi,
I have a question regarding code completition inside scripts that use object made by factory pattern. Here is small example to clarify question.
interface myInterface {
public function method1();
public function method2();
}
abstract class myAbstract {
protected $property;
protected function __construct($args){
// process args...
}
}
class myFactoryClass extends myAbstract {
public static function setupObject($args){
switch($args){
case 'myType1':
return new myClassType1($args);
break;
case 'myType2':
return new myClassType2($args);
break;
// Type definition continues...
}
}
}
class myClassType1 extends myAbstract implements myInterface {
// Interface, methods, etc...
}
class myClassType2 extends myAbstract implements myInterface {
// Interface, methods, etc...
}
|
So when I setup object, factory will use right class for everything else:
$object = myFactoryClass::setupObject('myType1');
|
The thing that puzzles me is when I use class in my script it is always showing methods from myClassType2 for instance, no matter which class was really used in factory for making an script object. This is not really a problem since all of them implements same interface, but it can be sometimes confusing.
Am I doing something wrong, or does PhpEd use first/last class that it can see to produce list for code completition?[/code]