gabrieljmj/phptypehinting

Quick fix for type hinting with PHP

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

pkg:composer/gabrieljmj/phptypehinting

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

This package is auto-updated.

Last update: 2025-10-16 05:21:12 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' ...