Login   Register  
PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2007-10-24 (6 years ago) RSS 2.0 feedStarStarStarStar 68%Total: 761 All time: 4,066 This week: 1,550Up
Version License PHP version Categories  
typehintclass 1.0.0GNU Lesser General Publ...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: 31
All time rank: 6868 in Argentina Argentina
Week rank: 615 Up4 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%1Total:761All time:4,066
 This week:0This week:1,550Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:-
Examples:90%StarStarStarStarStar
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:319