Quick one; Netbeans 7.0 for PHP development:
Is there any way to inform NetBeans when class_alias
has been used to alias a class, thereby triggering code-completion for the alias?
class Foo{
public static $hello = 'world';
}
class_alias('Foo', 'Bar');
Bar::$h // triggers code completion for $hello
^
I'm still working towards becoming adept with NetBeans, and haven't really played to much with the config, so I'm hoping there's some sort of project specific config I can modify.
Thanks in a开发者_开发问答dvance folks.
Interestingly, I can can'tSee below instead use namespacing's use
(though my project is otherwise namespace free) to achieve what NetBeans will understand:
class Foo{
public static $hello = 'world';
}
use \Foo as Bar;
Bar::$h // DOES trigger code completion for $hello
^
I don't know if this is a viable solution though. My Loader
class also holds a map of alias => classname
and when a given class is auto-loaded, the load method searches the map and aliases if necessary.
This wouldn't work as hoped, as use
is completely unsuited to any sort of dynamic aliasing:
- Can't be used in any scope other than global,
use
in a function or method issues a parse error. use
has no support for dynamic naming;use \{$class} as {$alias};
is illegal.- Most importantly,
use
doesn't carry through file inclusions, thereby rendering it's usage ... well, useless. Pun-tastic.
I managed to create a bit of a workaround for this
In the bootstrap of your project you can create the aliases
class_alias('Some\Namespaced\ClassName', 'aliasName');
class_alias('Some\Namespaced\ClassName2', 'anotherAlias');
In order to get Netbeans to pick it up you can create a dummy file somewhere in your project. eg. aliases.php
class aliasName extends \Some\Namespaced\ClassName{}
class anotherAlias extends \Some\Namespaced\ClassName2{}
Extend is not directly equivalent to class_alias but for code hinting purposes it works fine.
IMPORTANT! Do not actually include this file anywhere into your project, the mere presence of this file will allow Netbeans to generate the code hints.
No, sorry, I don't think there is.
I have to say class_alias
is a new one on me!
精彩评论