gabrieljmj / phptypehinting
Quick fix for type hinting with PHP
dev-master
2015-04-18 20:42 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2025-01-16 03:46:17 UTC
README
Quick fix for type hinting with PHP.
Install
Composer:
"gabrieljmj/phptypehinting": "dev-master"
Usage
use Gabrieljmj\PhpTypeHinting\TypeHinting; TypeHinting::init(); function hello(string $name) { echo 'Hello ' . $name; } hello('Gabriel');
will return
Hello Gabriel
but
hello(87);
will get
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Argument 1 passed to hello() must be string type, integer given' ...