Edit report at https://bugs.php.net/bug.php?id=60432&edit=1
ID: 60432
Comment by: duke at ejoom dot com
Reported by: duke at ejoom dot com
Summary: Improving typehinting in function args
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.4.0RC2
Block user comment: N
Private report: N
New Comment:
It can be possible to use the function to delete rows in DB:
function delete( array $ids ) { //some code}
delete(3); //will work correct as expected.
// Or
delete(array(3,6));// will work.
Or we would be able to use that behaviour:
$object->property1 = 1;
$object->property2 = 'value';
tipehind($object);
//where $object converting into array.
Previous Comments:
------------------------------------------------------------------------
[2011-12-02 21:12:43] duke at ejoom dot com
Description:
------------
I want to discuss an improving typehint.
I propose to do typehint behaviour as following:
On the Object instance it will behave as current (emit an error).
At the array int and float it must do equivalence:
function typehint( array $array, string $string, int $int, float $float )
{}
will be equivalent to
function typehint( $array, $string, $int, $float )
{
if (is_array($array) === false) $array = (array) $array;
$string = (string) $string;
$int = (int) $int;
$float = (float) $float;
}
It will do code more readable and compact. For Zend Framework DB it will do
easier typing query where escaping is based on type of var,
Isn't logical emit error on mismatching of type on int and string at PHP caused
by easing change type against C or C++. So we must use it feature of PHP and do
life easier ;).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60432&edit=1