PHPackages                             digitalkaoz/typehint-to-docblock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. digitalkaoz/typehint-to-docblock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

digitalkaoz/typehint-to-docblock
================================

converts typehints to docblocks and vice versa

0.2.2(10y ago)7242MITPHPPHP &gt;=5.5

Since Sep 19Pushed 10y ago4 watchersCompare

[ Source](https://github.com/digitalkaoz/typehint-to-docblock)[ Packagist](https://packagist.org/packages/digitalkaoz/typehint-to-docblock)[ RSS](/packages/digitalkaoz-typehint-to-docblock/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (9)Versions (5)Used By (0)

TypeHints to DocBlock
=====================

[](#typehints-to-docblock)

the intention for this tiny Project is the lack of support for typehinted Collaborators in PHPSpec on PHP7+

[phpspec/phpspec#659](https://github.com/phpspec/phpspec/issues/659)

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

[![Build Status](https://camo.githubusercontent.com/d1615d9574adb882c0b1853a60c8c51f7bc313962204f97c10cc5291a999af89/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6469676974616c6b616f7a2f7479706568696e742d746f2d646f63626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/digitalkaoz/typehint-to-docblock)[![Dependency Status](https://camo.githubusercontent.com/b35c97388505a8750a1c188e99dfb83593f5259742f0e1cef9826b60ab2c9861/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535666338363363656466343034303030623030303530632f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/55fc863cedf404000b00050c)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/97f52602c4e00a40346dec80208e27756b6950a05686099e7ba9685e7ab3a809/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6469676974616c6b616f7a2f7479706568696e742d746f2d646f63626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/digitalkaoz/typehint-to-docblock/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cfb4b55341a2de7d81ea3be720a0ce60a1b3507b5fa817f3c5570b58d8204c93/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6469676974616c6b616f7a2f7479706568696e742d746f2d646f63626c6f636b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/digitalkaoz/typehint-to-docblock/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/7086da51ce759e9d5246c28846082a30d0f90a700ac1da771bf621689a987d00/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f32616466303764312d383161652d346337332d393634302d3734626266383431613964342e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/f7633a7e-4577-4a86-b6d9-ccaa75cb7fa0)[![Latest Stable Version](https://camo.githubusercontent.com/788def28de6e2287e29942c4714159643eeba1a764da8e1ed90bb036f15ffbda/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469676974616c6b616f7a2f7479706568696e742d746f2d646f63626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalkaoz/typehint-to-docblock)[![Total Downloads](https://camo.githubusercontent.com/8fed731e6f8bc7bf79666df2ec5b23b6ab374cbe6bb5b538abad5b8134cb8f4b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469676974616c6b616f7a2f7479706568696e742d746f2d646f63626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalkaoz/typehint-to-docblock)[![StyleCI](https://camo.githubusercontent.com/4326ab03fa33e89b3e103843a36575a3256a16a76916f0bfd777f0b631fe5871/68747470733a2f2f7374796c6563692e696f2f7265706f732f34323732303138372f736869656c64)](https://styleci.io/repos/42720187)

Installation
------------

[](#installation)

```
$ composer require digitalkaoz/typehint-to-docblock

```

Usage
-----

[](#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
---------------

[](#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
--------

[](#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
-----

[](#tests)

```
$ composer test

```

TODO
----

[](#todo)

- make the resaving of files a bit less obstrusive
- write a `reverse` Visitor which converts from DocBlock to TypeHint

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

3891d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c250d4625389526aaf66f599e8e85e684cff28788f71ea2412b2434739a3bffd?d=identicon)[digitalkaoz](/maintainers/digitalkaoz)

---

Top Contributors

[![digitalkaoz](https://avatars.githubusercontent.com/u/293591?v=4)](https://github.com/digitalkaoz "digitalkaoz (32 commits)")[![pamil](https://avatars.githubusercontent.com/u/1897953?v=4)](https://github.com/pamil "pamil (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

### Embed Badge

![Health badge](/badges/digitalkaoz-typehint-to-docblock/health.svg)

```
[![Health](https://phpackages.com/badges/digitalkaoz-typehint-to-docblock/health.svg)](https://phpackages.com/packages/digitalkaoz-typehint-to-docblock)
```

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
