Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork15
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations
License
dunglas/phpdoc-to-typehint
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Archived! This repository is now archived. Consider usingPHP CS Fixer (and especially thephpdoc_to_param_type andphpdoc_to_return_type rules) orRector instead.
phpdoc-to-typehint adds automatically scalar type hints and return types to all functions and methods of a PHP projectusing existing PHPDoc annotations.
Warning: this project is an early stage of development. Itcan damage your code.Be sure to make a backup before running this command and to run your test suite after.
Pleasereport any bug you find using this tool.
- Download the latest PHAR file
- Run
php phpdoc-to-typehint.phar <your-project-directory>
Your project should have scalar type hints and return type declarations.
Before:
<?php/** * @param int|null $a * @param string $b * * @return float */functionbar($a,$b,bool$c,callable$d =null){return0.0;}
After:
<?php/** * @param int|null $a * @param string $b * * @return float */functionbar(int$a =null,string$b,bool$c,callable$d =null) :float{return0.0;}
Supports:
- functions
- methods of classes and traits
- method definitions in interfaces
- PHPDoc inheritance
- PHP 7.1 nullable types (can be disabled with
--no-nullable-typesoption)
Created byKévin Dunglas. Sponsored byLes-Tilleuls.coop.
About
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.