生成PHP接口

前端之家收集整理的这篇文章主要介绍了生成PHP接口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否有工具从现有类生成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提供这样的功能.

猜你在找的PHP相关文章