Hi.

This is one of those "out there" ideas. Not sure about the feasibility of it.

So ...

Currently, there are not a massive number of functions that can detail
what has been supplied to a function. Currently, the most useful is
func_get_args().

func_get_args() has no parameters and simply returns what has been supplied.

Would the following core amendments be possible/feasible/etc.

1 - Enhance func_get_args() to ...

array func_get_args([bool $verbose = false])

The verbose option returns an array, where each element contains ...

[supplied_value]
[supplied_type]
[received_value]
[received_type]
[clean_conversion]

2 - Introduce a new function ...

bool func_args_match_hints()

Simply a true/false if the conversion were clean.

3 - If E_STRICT is not active, then there are no
errors/warnings/notices for the consumer.

4 - If E_STRICT is active, then notices for conversions that are not 100%.

5 - Boolean castings must be treated in the same way that PHP would
handle it in an if() clause.

e.g. if (0), if ('') and if(false) are all valid boolean false.
Everything else is boolean true and essentially you cannot fail a
boolean conversion.

6 - Possibly a truebool type if a === bool test is needed ( but I
don't think so really ).



To me, it would seem that the API developer can call a single function
to determine if the parameters were cleanly converted.

The API consumer (if running E_STRICT) can take advantage of the hints
and notices.

So, even though hinting is "optional", a consumer would operate in
exactly the same way. E_STRICT provides the additional information to
the consumer.

The onus is still on the developer to deal with what has been
supplied, but core is assisting in this by casting and recording what
happens.



Regards,

Richard.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to