加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

生成PHP接口

发布时间:2020-12-13 22:38:23 所属栏目:PHP教程 来源:网络整理
导读:是否有工具从现有类生成php接口?有一个像Netbeans自动getter / setter创建工具但接口的工具会很好. 对于程序化用法,有 InterfaceDistiller 允许您从现有类派生接口,如下所示: $distiller = new InterfaceDistiller;$distiller -methodsWithModifiers(Refl
是否有工具从现有类生成php接口?有一个像Netbeans自动getter / setter创建工具但接口的工具会很好.
对于程序化用法,有 InterfaceDistiller允许您从现有类派生接口,如下所示:
$distiller = new InterfaceDistiller;
$distiller
    ->methodsWithModifiers(ReflectionMethod::IS_PUBLIC)
    ->extendInterfaceFrom('Iterator,SeekableIterator')
    ->excludeImplementedMethods()
    ->excludeInheritedMethods()
    ->excludeMagicMethods()
    ->excludeOldStyleConstructors()
    ->filterMethodsByPattern('(^get)')
    ->saveAs(new SplFileObject('MyInterface.php'))
    ->distill('SomeFoo','MyInterface');

它还有一个CLI界面:

Usage: phpdistill [options] <classname> <interfacename>

  --bootstrap                           Path to File containing your bootstrap and autoloader

  --methodsWithModifiers <number>       A ReflectionMethod Visibility BitMask. Defaults to Public.
  --extendInterfaceFrom  <name,...>     Comma-separated list of Interfaces to extend.
  --excludeImplementedMethods           Will exclude all implemented methods.
  --excludeInheritedMethods             Will exclude all inherited methods.
  --excludeMagicMethods                 Will exclude all magic methods.
  --excludeOldStyleConstructors         Will exclude Legacy Constructors.
  --filterMethodsByPattern <pattern>    Only include methods matching PCRE pattern.
  --saveAs                              Filename to save new Interface to. STDOUT if omitted.

我不知道有任何IDE为php提供这样的功能.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读