Edit report at http://bugs.php.net/bug.php?id=54862&edit=1
ID: 54862 Updated by: ras...@php.net Reported by: simon at systemparadox dot co dot uk Summary: Type hinting for documentation -Status: Open +Status: Bogus Type: Feature/Change Request Package: Variables related PHP Version: 5.3.6 -Block user comment: No +Block user comment: Yes Private report: N New Comment: The issue is that scalar types are interchangeable in PHP out of necessity. The Web is not typed. Everything comes across the wire from the browser as a string. Once you start forcing string or integer in function calls you are pushing the type juggling to the caller instead of leaving it with the receiver where it belongs. Type hinting for non-scalar non-interchangeable types doesn't break thing which is why it is in. Previous Comments: ------------------------------------------------------------------------ [2011-05-19 14:17:14] simon at systemparadox dot co dot uk Description: ------------ Since the dawn of time the PHP documentation has contained function declarations like this: string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] ) But the PHP parser does not allow this syntax. Many people have been trying to get proper type hinting into PHP for some time now, and I appreciate some of the problems in doing so (although it really is needed ASAP). However, as far as I'm concerned, a good 60% of the reason for wanting type hinting is for documentation purposes, and readability. Until the type hinting is implemented fully, please can we at least allow the PHP parser to accept the type hinting keywords for documentation purposes. At the moment I'm on the verge of writing an extended PHP language with type hinting that compiles to PHP by removing the type keywords. That's completely insane, but the current situation leaves no choice. Thanks. Test script: --------------- function int foo(bool bar, string baz) { } Expected result: ---------------- The PHP parser should at least accept this syntax, even if it's not used yet. Actual result: -------------- Parse error. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54862&edit=1