Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gabrieljmj/phptypehinting

Quick fix for type hinting
https://github.com/gabrieljmj/phptypehinting

Last synced: about 2 months ago
JSON representation

Quick fix for type hinting

Awesome Lists containing this project

README

        

TypeHinting
===========
Quick fix for type hinting with PHP.

## Install
Composer:
```json
"gabrieljmj/phptypehinting": "dev-master"
```

## Usage
```php
use Gabrieljmj\PhpTypeHinting\TypeHinting;

TypeHinting::init();

function hello(string $name) {
echo 'Hello ' . $name;
}

hello('Gabriel');
```

will return

```
Hello Gabriel
```
but
```php
hello(87);
```
will get
```
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Argument 1 passed to hello() must be string type, integer given' ...
```