This article will cover the solution to the PEAR “Cannot use result of built-in function in write context” issue.

The Issue

If installing a pear package (for instance PHP Code Sniffer), when running:

pear install PHP_CodeSniffer

This error is shown

PHP Fatal error: Cannot use result of built-in function in write context in ...\php\pear\Archive\Tar.php on line 639
Fatal error: Cannot use result of built-in function in write context in ...\pear\Archive\Tar.php on line 639

This error is shown because the function is called by reference.

More details about this issue can be found in this Pull Request.

 

The solution

You might be tempted to execute the following

pear install Archive_Tar

which will result in the same error.

 

Go to the line indicated in the error (639 in this case) and replace:

 $v_att_list = & func_get_args();

with

 $v_att_list = func_get_args();

The above means the func_get_args() isn’t called by reference anymore.

Our recommendation

The above does fix the problem, but we recommend installing the Archive_Tar again so you have the latest working version.

 

Run the following command:

pear install Archive_Tar

This will update your Archive Tar PEAR package.

 

And to install the code sniffer run:

pear install PHP_CodeSniffer

 

One Comment

  1. VireshIshwar

    Brilliant, and to the point. Worked!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.