Created
February 12, 2015 19:59
-
-
Save dg/a5a83b418d0a15438a99 to your computer and use it in GitHub Desktop.
Weak typing in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foo(int $bar) : int { | |
return $bar * 2; | |
} | |
var_dump( foo(2.5) ); // int(4) and triggers E_NOTICE - great! | |
// but without E_NOTICE it as bad as: | |
var_dump( foo((int) 2.5) ); | |
// and this nobody wants… | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment