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
Looking for PHP, Laminas or Mezzio Support?
As part of the Laminas Commercial Vendor Program, Apidemia offers expert technical support and services for:
14 Comments-

-

-

-

-

-

-

-

-

-

-

-

-

-

VireshIshwar
Brilliant, and to the point. Worked!
Komal
Genius fix! Works awesome, thanks!
OGProgrammer
For AWS ElasticBeanstalk I’ve been running into this. My one liner to replace it is:
sed -i '/$v_att_list = & func_get_args();
/c\$v_att_list = func_get_args();'
/usr/share/pear7/Archive/Tar.php
Gabi DJ
Hi OGP,
Thank you for the feedback.
That’s a great tip!
The command you provided can be tweaked and could work on a higher number of systems.
Basically if you know where …/Archive/Tar.php is you can just type in that command with the file you want to change and the job’s done.
This article purpose was not just to fix the error, but to know what caused it, understand the error and find out how to fix it yourself.
Your fix is an easier fix, but whoever tries to run that script should know what it’s doing.
In case of shell commands. For instance, I check all the commands I didn’t hear about with this free service.
sudath
Great tip., Thanks lot
Ahmad Budairi
Not Working here. I got this:
Fatal error: Cannot use result of built-in function in write
context in C:\xampp\php\pear\Archive\Tar.php on line 639
Matthias
I can approve the issue Ahmad Budairi is having. Not working for me either.
hatunga
magic !!!!. thanks so much
Michael
Almost 3 hours trying to install Prestashop on localhost… Finally I found the solution here.
You are awesome. Best Regards from Poland.
csacs
c:\xampp\php>pear install Archive_Tar
WARNING: channel “pear.php.net” has updated its protocols, use “pear channel-update pear.php.net” to update
downloading Archive_Tar-1.4.9.tgz …
Starting to download Archive_Tar-1.4.9.tgz (21,343 bytes)
……..done: 21,343 bytes
For me this errors come:
Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in PEAR\PackageFile\v2\Validator.php on line 1933
PHP Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in C:\xampp\php\pear\PEAR\PackageFile\v2\Validator.php on line 1933
Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in C:\xampp\php\pear\PEAR\PackageFile\v2\Validator.php on line 1933
ERROR: failed to mkdir C:\php\pear\docs\Archive_Tar\docs
Koushik Chatterjee
Great. Thanks a ton for this help.
shobhitjuyal
I got this after the change mentioned.
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in PEAR\PackageFile\v2\Validator.php on line 1933
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PEAR\PackageFile\v2\Validator.php on line 193
Say Hi
That worked 🙂
Dler
Sounds good for all, but how we do with cPanel, because I faced this fatal error during installing via cPanel.