Does PHP 7 support strict typing for resources? If so, how?
For example:
declare (strict_types=1);
$ch = curl_init ();
test ($ch);
function test (resource $ch)
{
}
The above will give the error:
Fatal error: Uncaught TypeError: Argument 1 passed to test() must be an instance of resource, resource given
A var_dump on $ch
reveals it to be resource(4, curl), and the manual says curl_init ()
returns a resource.
Is it at all possible to strictly type the test()
function to support the $ch variable
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…