Viewed   231 times

Is there any way to easily fix this issue or do I really need to rewrite all the legacy code?

PHP Fatal error: Call-time pass-by-reference has been removed in ... on line 30

This happens everywhere as variables are passed into functions as references throughout the code.

 Answers

4

You should be denoting the call by reference in the function definition, not the actual call. Since PHP started showing the deprecation errors in version 5.3, I would say it would be a good idea to rewrite the code.

From the documentation:

There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);.

For example, instead of using:

// Wrong way!
myFunc(&$arg);               # Deprecated pass-by-reference argument
function myFunc($arg) { }

Use:

// Right way!
myFunc($var);                # pass-by-value argument
function myFunc(&$arg) { }
Friday, September 2, 2022
4

From the call_user_func:

Note that the parameters for call_user_func() are not passed by reference.

To invoke static methods you can use Class::method() syntax, supplying a variable for the Class and/or method parts:

$soapProvider = array( "FilePool", "UserList" );
foreach( $soapProvider as $provider ) {
  $provider::registerSoapTypes($server->wsdl);
  $provider::registerSoapOperations($server);
}
Thursday, August 4, 2022
 
5

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (pecl.php.net)

Options:
  ...
  -r, --register-only
        do not remove files, only register the packages as not installed
  ...

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022
4

settype() hasn't been deprecated. Passing by reference at call time has been deprecated. You probably just want to remove the ampersand from in front of the first parameter to your settype() call.

That would be easier to tell for sure if you actually posted your code...

See the manual for more information on references in general, and passing by reference and the deprecation of references in function calls in particular.

Tuesday, August 23, 2022
 
4

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :