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

  Author Author  
Picture of Martin Alterisio
Name: Martin Alterisio <e-mail contact>
Packages: 5 Browse all classes by Martin Alterisio Browse all classes by
Country: Argentina Argentina - PHP jobs in Argentina
Age: 31
All time rank: 6938 in Argentina Argentina
Week rank: 543 Up8 in Argentina Argentina Equal
Innovation award
Innovation award
Nominee: 5x


  Detailed description   Download Download .zip .tar.gz  
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.

  Classes of Martin Alterisio  >  Type Hint Class  >  Download Download .zip .tar.gz  >  Support forum Support forum (1)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Type Hint Class
Base name: typehintclass
Description: Implement type hinting support for base PHP types
Version: 1.0.0
PHP version: 5.1
License: GNU Lesser General Public License (LGPL)
All time users: 754 users
All time rank: 4031
Week users: 0 users
Week rank: 1988 Equal
 
  Groups   Rate classes User ratings   Dependents  
  Trackback   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Language Constructs to assist in the language control View top rated classes


  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

  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Perfect (100.0%) Good (90.0%) - Good (90.0%) - - Sufficient (68.0%) 314
Month: Not yet rated by the users

  Packages that need this class  
Class Dependency Why it is needed
Generic Array Recommended Nice addition to create arrays of native types (eg: ArrayOfInt)

  Trackback links  
Link Description
10 Tipps für sichere Software Wie zuvor schon am letzten Tag des Monats 10 nützliche Tipps für Anfänger und Fortgeschrittene....
PHP Typehinting today (German) And all this gives not only in 3 years, but today!

  Applications that use this class  
No application links were specified for this class.
Add link image If you know an application of this package, send a message to the author to add a link here.
  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.

Download Download all files: typehintclass.tar.gz typehintclass.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.