If I create an instance of PDO and then call PDO->Quote('test') it works no problems.
If I look at the defination of the PDO Quote method it looks like this:
/**
* Quotes a string for use in a query.
* PDO::quote() places quotes around the input string (if required) and escapes special characters within the input string, using a quoting style appropriate to the underlying driver.
*
* @param string $string The string to be quoted.
* @param int $parameter_type Provides a data type hint for drivers that have alternate quoting styles.
*
* return string
*/
function quote(string $string, int $parameter_type) {/* method implementation */}
Note the parameters actully have types defined in the method signature, string and int.
Now if I create a function like this:
function Test(string $test) {
return $test;
}
And attempt to call it like this:
echo Test('test');
It fails with the following error:
( ! ) Catchable fatal error: Argument 1 passed to Test() must be an instance of string, string given, called in [path_removed]TestTypeHinting.php on line 36 and defined in [path_removed]TestTypeHinting.php on line 2
How come PDO can do it, but I can't?
Regards,
Scott