Skip to content

Instantly share code, notes, and snippets.

@dg dg/weak-typing.php
Created Feb 12, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.