https://github.com/dunglas/phpdoc-to-typehint
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations
https://github.com/dunglas/phpdoc-to-typehint
coding-standards cs php php-7 phpdoc
Last synced: 5 months ago
JSON representation
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations
- Host: GitHub
- URL: https://github.com/dunglas/phpdoc-to-typehint
- Owner: dunglas
- License: mit
- Archived: true
- Created: 2015-11-11T15:44:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-28T22:25:46.000Z (over 4 years ago)
- Last Synced: 2024-12-17T01:12:04.526Z (6 months ago)
- Topics: coding-standards, cs, php, php-7, phpdoc
- Language: PHP
- Homepage: https://dunglas.fr/2015/11/introducing-the-phpdoc-to-typehint-converter-add-scalar-type-hints-and-return-type-declarations-to-your-projects/
- Size: 58.6 KB
- Stars: 226
- Watchers: 10
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPDoc to Type Hint
**Archived!** This repository is now archived. Consider using [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (and especially the
`phpdoc_to_param_type` and `phpdoc_to_return_type` rules) or [Rector](https://tomasvotruba.com/blog/2018/11/15/how-to-get-php-74-typed-properties-to-your-code-in-few-seconds/) instead.`phpdoc-to-typehint` adds automatically scalar type hints and return types to all functions and methods of a PHP project
using existing PHPDoc annotations.[](https://travis-ci.org/dunglas/phpdoc-to-typehint)
**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.Please [report](https://github.com/dunglas/phpdoc-to-typehint/issues) any bug you find using this tool.
## Install and usage
1. [Download the latest PHAR file](https://github.com/dunglas/phpdoc-to-typehint/releases)
2. Run `php phpdoc-to-typehint.phar `Your project should have scalar type hints and return type declarations.
Before:
```php