digitalkaoz / typehint-to-docblock
converts typehints to docblocks and vice versa
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-12-21 19:02:19 UTC
README
the intention for this tiny Project is the lack of support for typehinted Collaborators in PHPSpec on PHP7+
this library can convert typehinted methods to docblocks (and removing the typehints) and the other way around
Installation
$ composer require digitalkaoz/typehint-to-docblock
Usage
$ bin/typehint-to-docblock transform FOLDER
$ bin/typehint-to-docblock transform --pattern=/^foo$/ FOLDER
where FOLDER
is one or more paths to php classes
if --pattern
is provided only methods which matches this regex pattern will be modified
Use on TravisCI
simple use this in your 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;'
Examples
this
namespace Foo\Bar; use Lol\Cat; use Bar\Bazz; class Test { function it_can_do_something(Cat $cat, Bazz $bazz) { } }
will be converted to this
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) { } }
Tests
$ composer test
TODO
- make the resaving of files a bit less obstrusive
- write a
reverse
Visitor which converts from DocBlock to TypeHint