gabrieljmj/phptypehinting

Quick fix for type hinting with PHP

dev-master 2015-04-18 20:42 UTC

This package is auto-updated.

Last update: 2024-06-16 02:31:41 UTC


README

TypeHinting

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' ...