digitalkaoz / typehint-to-docblock
将类型提示转换为文档块,反之亦然
0.2.2
2015-09-23 12:18 UTC
Requires
- php: >=5.5
- gossi/docblock: ~1.5
- nikic/php-parser: ~1.4
- phpdocumentor/type-resolver: ~0.1
- pimple/pimple: ~3.0
- psr/log: ~1.0
- symfony/console: ~2.3
- symfony/filesystem: ~2.7
- symfony/finder: ~2.3
Requires (Dev)
- phpspec/phpspec: ^2
This package is not auto-updated.
Last update: 2024-09-14 17:32:07 UTC
README
这个小型项目的目的是PHP 7+上PHPSpec对类型提示协作者的支持不足
这个库可以将类型提示方法转换为文档块(并移除类型提示)以及反过来
安装
$ composer require digitalkaoz/typehint-to-docblock
用法
$ bin/typehint-to-docblock transform FOLDER
$ bin/typehint-to-docblock transform --pattern=/^foo$/ FOLDER
其中 FOLDER
是一个或多个php类的路径,如果提供了 --pattern
,则只修改与这个正则表达式模式匹配的方法
在TravisCI上使用
简单地在 before_scripts
中使用这个命令
php: - 7.0 before_script: - bash -c 'if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then wget https://github.com/digitalkaoz/typehint-to-docblock/releases/download/0.2.2/typehint-to-docblock.phar && php typehint-to-docblock.phar transform spec; fi;'
示例
这个
namespace Foo\Bar; use Lol\Cat; use Bar\Bazz; class Test { function it_can_do_something(Cat $cat, Bazz $bazz) { } }
将被转换为这个
namespace Foo\Bar; use Lol\Cat; use Bar\Bazz; class Test { /** * it_can_do_something * * @param \Lol\Cat $cat * @param \Bar\Bazz $bazz */ function it_can_do_something($cat, $bazz) { } }
测试
$ composer test
待办事项
- 使文件的重新保存不那么明显
- 编写一个从文档块到类型提示的
reverse
访问者