2017 © Pedro Peláez
 

project phpdoc-to-typehint

Generate scalar type hints from PHPDoc annotations

image

dunglas/phpdoc-to-typehint

Generate scalar type hints from PHPDoc annotations

  • Wednesday, December 20, 2017
  • by dunglas
  • Repository
  • 14 Watchers
  • 216 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 12 Open issues
  • 4 Versions
  • 11 % Grown

The README.md

PHPDoc to Type Hint

Archived! This repository is now archived. Consider using PHP CS Fixer (and especially the phpdoc_to_param_type and phpdoc_to_return_type rules) or Rector instead., (*1)

phpdoc-to-typehint adds automatically scalar type hints and return types to all functions and methods of a PHP project using existing PHPDoc annotations., (*2)

Build Status, (*3)

Warning: this project is an early stage of development. It can damage your code. Be sure to make a backup before running this command and to run your test suite after., (*4)

Please report any bug you find using this tool., (*5)

Install and usage

  1. Download the latest PHAR file
  2. Run php phpdoc-to-typehint.phar <your-project-directory>

Your project should have scalar type hints and return type declarations., (*6)

Before:, (*7)

<?php

/**
 * @param int|null $a
 * @param string   $b
 *
 * @return float
 */
function bar($a, $b, bool $c, callable $d = null)
{
    return 0.0;
}

After:, (*8)

<?php

/**
 * @param int|null $a
 * @param string   $b
 *
 * @return float
 */
function bar(int $a = null, string $b, bool $c, callable $d = null) : float
{
    return 0.0;
}

Features

Supports:, (*9)

  • functions
  • methods of classes and traits
  • method definitions in interfaces
  • PHPDoc inheritance
  • PHP 7.1 nullable types (can be disabled with --no-nullable-types option)

Credits

Created by Kévin Dunglas. Sponsored by Les-Tilleuls.coop., (*10)

The Versions

20/12 2017
16/11 2015
12/11 2015

v0.1.0-alpha.1

0.1.0.0-alpha1

Generate scalar type hints from PHPDoc annotations

  Sources   Download

MIT

The Requires