PHP call forward frequency is inevitable?

Given the following interface:

interface ISoapInterface {
  public static function registerSoapTypes( &$wsdl );
  public static function registerSoapOperations( &$server );
}

And the following code:

$soapProvider = array( "FilePool", "UserList" );
foreach( $soapProvider as $provider ) {
  call_user_func( array( $provider, "registerSoapTypes" ), &$server->wsdl );
  call_user_func( array( $provider, "registerSoapOperations" ), &$server );
}

FilePooland UserListboth implement ISoapInterface.

PHP will complain about two calls inside foreach:

Call diverting is outdated

So, I looked through this post, and the documentation seems pretty clear how to solve this. Removing an ampersand from an actual call.
So I changed my code to look like this:

$soapProvider = array( "FilePool", "UserList" );
foreach( $soapProvider as $provider ) {
  call_user_func( array( $provider, "registerSoapTypes" ), $server->wsdl );
  call_user_func( array( $provider, "registerSoapOperations" ), $server );
}

PHP is now complaining

Parameter 1 in FilePool :: registerSoapTypes expected as a reference, the value specified
Parameter 1 in FilePool :: registerSoapOperations expected as a link, the value specified

In addition to this, the functionality is now broken. So this obviously cannot be a solution.

+3
2

call_user_func:

, call_user_func() .

, Class::method(), Class / method:

$soapProvider = array( "FilePool", "UserList" );
foreach( $soapProvider as $provider ) {
  $provider::registerSoapTypes($server->wsdl);
  $provider::registerSoapOperations($server);
}
+6

call_user_func , call_user_func_array .

$callback = array($provider, 'blahblahblah');
call_user_func_array($callback, array( &$server ));

, , call_user_func ( sprintf vsprintf)...

+3

Source: https://habr.com/ru/post/1770311/


All Articles