phpdoc to simulate class for variable type hinting
Sorry for the strange name;)
Let's start with some demo code, maybe it's easier to understand what i mean
class Foo extends Bar{
}
The problem is, Bar doesn't exist, because it's created on runtime as a extended class from Baz.
So, while developing, it would be great if i coould define that Foo extends Baz so i can use autocomplete feature.
ATM i'm doing it this way:
class Foo extends
#Bar
Baz
{
}
so i can use autocomplete and before i test it, i have to change it to
class Foo extends
Bar
#Baz
{
}
Is there any way i can define this, like with variables ??
/** @var $foo Ragtek_Object_Me
$foo = Ragtek::get('me');
请先登录再写评论。
Hello ragga ragtek,
AFAIK there are not syntax to define a class through phpdoc, so you can get autocompletion by providing a 'stub' of such class.
Just put a dummy definition of the class anywhere inside a project:
Thank you for feedback!
Hello ragga,
Does it help?Thank you for feedback!No, because i need this for > 100 classes;) ( i think my english is too bad to describe what exactly i need :( )
That's why i'll stay with my method:
while development:
class Foo extends
#Virtual
Original
{
}
testing/runtime:
class Foo extends
Virtual
#Original
{
}
and remove the # while developing from Original and add it to Virtual and while testing and "while runtime" i have to switch it:D (i hope you know what i mean^^)
ragga ragtek,
And what is the difference between 'Virtual' and 'Original' classes?
Thank you for feedback!
They only exist while the runtime.
It's a application plugin system, which extends the base class with the plugin classes
A small phantasy example:
class Application_Bar{
function foo(){
return true;
}
function baz(){
return do_something();
}
now i create a plugin to overwrite foo to return false=>
class Plugin_Bar extends Virtual_Application_Bar{
funcin foo(){
return false;
}
and i have an other plugin overwriting baz=>
class OtherPlugin_Bar extends Virtual_Application_Bar{
function baz(){
$prev = parent::baz();
if ($pref == 'whatever')
{ return 'new value';}
else {
return $pref;
}
on runtime, it gets to
class Other_plugin_bar extends Plugin_Bar{}
class Plugin_Bar extends Application_Bar{}
because we don't know what pluginclasses exist in the application, which should extend from the original Application_Bar
but the system needs the virtual_ prefix in the class name, to know that it needs to extend it with the pluginsystem.
I hope you know what i mean?:)
Well, actually no - I can't grasp the idea.
But now you can create stub defintions for ANY missing class(es) - such as ones that you've put in here - in usual PHP file and just put it anywhere in non-excluded project folder - they will be recogenised by editor.