In PHP you can do the following thing:
class Something {// bla bla}
function functionName(Something $object) {
// Do stuff here ^^^^^^^^^
}
This ensures that function received an instance of Something class.
My problem is that I want to enforce to a basic type.
function functionName(integer $someInt) {
// Do stuff here ^^^^^^^
}
functionName(5);
This says that $someInt is "not an instance of integer, integer given" (with my PHP version below 7.0). How can you enforce to a basic type?
$someInt = (int)$someInt;on the first line of your function. this way you will always get an integer argument format.