douwei4370 2011-01-24 08:07
浏览 25
已采纳

NetBeans的插件,用于创建类模板

I am looking for plugin for NetBeans PHP (or it can be some external tool) that would do something like that:

  • When run it asks for a class name and the names of private attributes (and their types) of this class
  • Then it generates this class with:
    • all listed attributes with types in vdoc format,
    • constructor that takes all the attributes as parameters and initialize class attributes with those values,
    • default getters and setters.

I know it's not difficult to write such tool, but maybe it already exists.

  • 写回答

2条回答 默认 最新

  • doutuoben6908 2011-06-21 17:30
    关注

    Netbeans has some built-in functionality similar to this already. In any PHP project, create a new PHP Class (right click a folder in the project, New -> PHP Class). Enter your properties, such as:

    class user
    {
        private $id;
        private $username;
        private $email;
        private $firstname;
    
        | <-- position the cursor here and press Alt+Insert
    }
    

    <kbd>Alt</kbd>+<kbd>Insert</kbd> will bring up a menu that allows you to generate a constructor, getters, and setters to assign values to your properties.

    If you want to do more, you can look at this Netbeans article on code generation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!