Edit report at https://bugs.php.net/bug.php?id=65104&edit=1

 ID:                 65104
 Updated by:         ni...@php.net
 Reported by:        knight at kopernet dot org
 Summary:            consider loosing the imposed restriction of
                     typehints
-Status:             Open
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Class/Object related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Violating type constraints will throw a *recoverable* fatal error. You can 
register an error handler to make the code continue executing after it happened.


Previous Comments:
------------------------------------------------------------------------
[2013-06-23 09:59:26] knight at kopernet dot org

Description:
------------
Typehints are means to introduce typesafety into PHP code which should futher 
improve the code reliability and robustness.

Considering that PHP language is dynamic in nature it's difficult to fulfill 
the promise completely as there's no compilation stage that integrates calling 
code with the modules that might make extensive usage of the hint.

Failing to satisfy the expectations of typehints generates a fatal error though.
Unfortunately it can only be detected at runtime and that can be very late when 
the misfortunate code path is executed - at edge case never.

The most real usage of the typehints are made by advanced IDE like Eclipse PDT 
or PhpStorm which use it to provide advanced intellisense like code 
completition and near compile quality static code analisis. In those 
development environments similar effect can be achieved by adding a proper 
phpdoc annotation block before the method signature. It's much more verbose 
though and naturally a typehint is a very succinct replacement and it's where I 
see the most value of the typehints.

Given the above please consider replacing the current behavior of throwing a 
fatal error in case of a mismatch by just emitting a warning.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65104&edit=1

Reply via email to