有没有从现有类生成php接口的工具?如果能有一个像Netbeans这样的工具自动创建getter/setter接口,那就太好了。
发布于 2011-11-24 02:52:19
对于编程用法,有一个允许您从现有的类派生接口,如下所示:
$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提供了这样的功能。
发布于 2014-06-11 08:02:14
https://stackoverflow.com/questions/8247482
复制相似问题