PHP Classes

Type Hint Class: Implement type hinting support for base PHP types

Recommend this page to a friend!
  Info   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 776 This week: 1All time: 4,373 This week: 560Up
Version License PHP version Categories
typehintclass 1.0.0GNU Lesser Genera...5.1PHP 5, Language
Description 

Author

This package implements the support for type hinting that works with PHP base data types.

It works by replacing the current PHP error handler that performs enhanced type checking of the types of parameters when functions are called.

Several classes are provided to perform type checking of parameters of base types: boolean, float, integer, string, resource, callable.

There are additional classes for strict type checking of float and string values. These classes do not accept values of other types that could be promoted to types: integer float or string.

When the replacement error handler catches a recoverable error that corresponds to type checking mismatch, it checks the function declaration and calls the type checking class correspondent to the expected type of the parameter that triggered the error.

Innovation Award
PHP Programming Innovation award nominee
November 2007
Number 3


Prize: One copy of the Zend Studio
Type hinting is a feature introduced in PHP 5 that lets developers specify the type of the parameters expected by each function.

This way, application bugs may be detected earlier, when they pass function arguments of the wrong type.

Unfortunately, the current type hinting implementation only supports verification of parameters that are objects, and more recently arrays.

This package provides a solution to overcome this limitation by enabling also the verification of arguments of basic types like integer, string, float, etc..

This way type hinting can become more useful to detect bugs in broader range of applications with class functions that take basic type values as arguments.

Manuel Lemos
Picture of Martin Alterisio
Name: Martin Alterisio <contact>
Classes: 5 packages by
Country: Argentina Argentina
Age: 41
All time rank: 7348 in Argentina Argentina
Week rank: 411 Up3 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 5x

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file Bool.php Class Bool TypeHint
Accessible without login Plain text file Callable.php Class Callable TypeHint
Accessible without login Plain text file Float.php Class Float TypeHint
Accessible without login Plain text file Int.php Class Int TypeHint
Accessible without login Plain text file Resource.php Class Resource TypeHint
Accessible without login Plain text file StrictFloat.php Class StrictFloat TypeHint
Accessible without login Plain text file StrictInt.php Class StrictInt TypeHint
Accessible without login Plain text file StrictString.php Class StrictString TypeHint
Accessible without login Plain text file String.php Class String TypeHint
Accessible without login Plain text file TypeHint.php Class TypeHint Interface
Accessible without login Plain text file typehintclass.lib.php Aux. Library loader script.
Accessible without login Plain text file TypeHintHandler.php Class TypeHints handler.

 Version Control Reuses Unique User Downloads Download Rankings  
 0%1
Total:776
This week:1
All time:4,373
This week:560Up
 User Ratings  
 
 All time
Utility:84%StarStarStarStarStar
Consistency:78%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1585