2017 © Pedro PelĂĄez
 

library typehint-to-docblock

converts typehints to docblocks and vice versa

image

digitalkaoz/typehint-to-docblock

converts typehints to docblocks and vice versa

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

TypeHints to DocBlock

the intention for this tiny Project is the lack of support for typehinted Collaborators in PHPSpec on PHP7+, (*1)

https://github.com/phpspec/phpspec/issues/659, (*2)

this library can convert typehinted methods to docblocks (and removing the typehints) and the other way around, (*3)

Build Status Dependency Status Scrutinizer Code Quality Code Coverage SensioLabsInsight Latest Stable Version Total Downloads StyleCI, (*4)

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, (*5)

Use on TravisCI

simple use this in your before_scripts, (*6)

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, (*7)


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, (*8)


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

The Versions