https://github.com/nikic/typeutil
Utility for adding PHP 7 scalar types and return types
https://github.com/nikic/typeutil
Last synced: 5 months ago
JSON representation
Utility for adding PHP 7 scalar types and return types
- Host: GitHub
- URL: https://github.com/nikic/typeutil
- Owner: nikic
- License: other
- Created: 2015-03-28T10:12:32.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-06-04T10:43:14.000Z (over 3 years ago)
- Last Synced: 2025-04-04T05:04:32.989Z (9 months ago)
- Language: PHP
- Size: 74.2 KB
- Stars: 47
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Utility for adding return types and scalar types
> **WARNING**: Utility directly modifies files under the assumption that you're using version control.
To add return types and scalar types based on doc comments, run:
php-7.1 type-util.php add dir1/ dir2/ ...
To remove all PHP 5 incompatible type information, run:
php-7.1 type-util.php remove dir1/ dir2/ ...
Notes:
* Not well tested - probably doesn't work in many cases
* Uses only doc comments, so requires good doc comment coverage
* Requires PHP 7.1 to run
* The main job of this utility is dealing with the fact that PHP return types are semi-invariant
and argument types are fully invariant
### Help Text
```
Usage: php ./type-util.php add|remove [--options] dir1 dir2 ...
Options:
--php VERSION Enable all features supported up to VERSION
E.g. --php 7.1
--[no-]object Toggle generation of object type (PHP 7.2)
--[no-]nullable-types Toggle generation of nullable types (PHP 7.1)
--[no-]iterable Toggle generation of iterable type (PHP 7.1)
--[no-]strict-types Toggle use of strict_types (PHP 7.0)
Examples:
# Add everything that's possible!
php ./type-utils.php add path/to/dir
# Only add features available in PHP 7.0
php ./type-utils.php --php 7.0
# Add everything available in PHP 7.1, apart from strict types
php ./type-utils.php --php 7.1 --no-strict-types
NOTE: Will directly modify files, assumes that you're using VCS.
```