PHPUnit 3.6 PHP 5.2.7 PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16

女生的网名这么多〃 提交于 2019-12-24 17:09:22

问题


In our Development server, we have php 5.2 installed. I was asked to install phpunit on it. I followed the instruction on phpunit site as below:
http://phpunit.de/manual/3.6/en/installation.html

Note

PHPUnit 3.6 requires PHP 5.2.7 (or later) but PHP 5.3.9 (or later) is highly recommended. PHP_CodeCoverage, the library that is used by PHPUnit to collect and process code coverage information, depends on Xdebug 2.0.5 (or later) but Xdebug 2.1.3 (or later) is highly recommended.

The following two commands (which you may have to run as root) are all that is required to install PHPUnit using the PEAR Installer:

pear config-set auto_discover 1

pear install pear.phpunit.de/PHPUnit

But there is error when i run phpunit command after installation:

[root@dev ~]# phpunit



PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16

I have tested it on fresh Centos 5 installation as well but all is useless. I am fed up of phpunit. Please suggest what to do.

I have manually uninstalled and installed as below:

First you need to uninstall PHPUnit 3.6 and all of it’s dependencies.

sudo pear uninstall phpunit/PHPUnit
sudo pear uninstall phpunit/DbUnit
sudo pear uninstall phpunit/PHP_CodeCoverage
sudo pear uninstall phpunit/File_Iterator
sudo pear uninstall phpunit/Text_Template
sudo pear uninstall phpunit/PHP_Timer
sudo pear uninstall phpunit/PHPUnit_MockObject
sudo pear uninstall phpunit/PHPUnit_Selenium
sudo pear uninstall pear.symfony-project.com/YAML

Next install these specific versions of each dependency, in this order, installing PHPUnit-3.5.15 last.

sudo pear install pear.symfony-project.com/YAML-1.0.2
sudo pear install phpunit/PHPUnit_Selenium-1.0.1
sudo pear install phpunit/PHPUnit_MockObject-1.0.3
sudo pear install phpunit/PHP_Timer-1.0.0
sudo pear install phpunit/File_Iterator-1.2.3
sudo pear install phpunit/PHP_CodeCoverage-1.0.2
sudo pear install phpunit/Text_Template-1.0.0
sudo pear install phpunit/DbUnit-1.0.0
sudo pear install phpunit/PHPUnit-3.5.15

From the site: http://dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15/

The error is same as

PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16

Please suggest any ideas to solve this.


回答1:


I got it fixed and glad to share the answer back.

ISSUE CAUSE:

The issue was that I was following some procedure which was not supported to php 5.2. The link of that document is as below:

http://phpunit.de/manual/3.7/en/installation.html

I used pear to uninstall PHPUnit which did not uninstall it properly and the binary was left in the system.

SOLUTION:

For php 5.2 we require to install phpunit 3.6 from: http://phpunit.de/manual/3.6/en/installation.html

Even then When phpunit command was executed, it shown the below mentioned result.

[root@localhost]# phpunit -bash: /usr/local/bin/phpunit: No such file or directory

We need to Remove the binary left at /usr/local/bin/phpunit because pear installed the binary at: /usr/bin/phpunit

The solution was to run phpunit through: /usr/bin/phpunit or copy the binary to /usr/local/bin/phpunit

cp /usr/bin/phpunit /usr/local/bin/



来源:https://stackoverflow.com/questions/25289840/phpunit-3-6-php-5-2-7-php-parse-error-syntax-error-unexpected-t-function-expe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!