When executing the following code in PHP v7.2,
<?php
class A { function a() {} }
$a = new A;
$rf = new \ReflectionFunction([ $a, 'a' ]);
I got an error
ReflectionFunction::__construct() expects parameter 1 to be string, array given in php shell code
Which is very strange. I passed a closure array which is valid parameter in PHP v5.3+ according to the doc.
# php -v
PHP 7.2.24-0ubuntu0.18.04.6 (cli) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.6, Copyright (c) 1999-2018, by Zend Technologies
I execute the code inside a Ubuntu 18.04 container that install PHP package from PPA ondrej/php. In other machine, this works. But in my case, it isn't.
Is there any PHP setting that control this behavior? Or is there any underlying PHP mechanism that may cause the error?
Aucun commentaire:
Enregistrer un commentaire