Skip to content

Instantly share code, notes, and snippets.

@dg
Created February 12, 2015 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dg/a5a83b418d0a15438a99 to your computer and use it in GitHub Desktop.
Save dg/a5a83b418d0a15438a99 to your computer and use it in GitHub Desktop.
Weak typing in PHP
<?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