PHPUnit 3.6 PHP 5.2.7 PHP解析错误:语法错误,意外的T_FUNCTION,在第16行的/usr/local/bin/phpunit中期望')' [英] PHPUnit 3.6 PHP 5.2.7 PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16

查看:95
本文介绍了PHPUnit 3.6 PHP 5.2.7 PHP解析错误:语法错误,意外的T_FUNCTION,在第16行的/usr/local/bin/phpunit中期望')'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发服务器中,我们安装了php 5.2.我被要求在上面安装phpunit.我按照phpunit网站上的说明进行操作,如下所示:
http://phpunit.de/manual/3.6/en/installation.html

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

注意

PHPUnit 3.6需要PHP 5.2.7(或更高版本),但PHP 5.3.9(或更高版本)是 强烈推荐. PHP_CodeCoverage,供以下人员使用的库 PHPUnit收集和处理代码覆盖率信息,具体取决于 Xdebug 2.0.5(或更高版本),但Xdebug 2.1.3(或更高版本) 推荐.

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.

以下两个命令(您可能必须以超级用户身份运行)都是 使用PEAR安装程序安装PHPUnit所必需的:

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 config-set auto_discover 1

梨安装pear.phpunit.de/PHPUnit

pear install pear.phpunit.de/PHPUnit

但是在安装后运行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

我也已经在全新的Centos 5安装上对其进行了测试,但是一切都没有用.我受够了phpunit.请提出建议.

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:

首先,您需要卸载PHPUnit 3.6及其所有依赖项.

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

接下来,按顺序安装每个依赖项的这些特定版本,最后安装PHPUnit-3.5.15.

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

从网站上: http://dustyreagan.com /downgrade-phpunit-3-6-to-3-5-15/

错误与

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

请提出任何解决此问题的想法.

Please suggest any ideas to solve this.

推荐答案

我已解决此问题,很高兴与大家分享答案.

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

问题原因:

问题是我正在遵循php 5.2不支持的某些过程.该文档的链接如下:

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

我用pear卸载了PHPUnit,但没有正确将其卸载,并且二进制文件留在了系统中.

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

解决方案:

对于php 5.2,我们需要从以下位置安装phpunit 3.6: http://phpunit.de/manual/3.6/en/installation.html

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

即使在执行phpunit命令时,它也会显示以下提到的结果.

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

[root @ localhost]#phpunit -bash:/usr/local/bin/phpunit:没有这样的文件或目录

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

我们需要删除/usr/local/bin/phpunit中剩余的二进制文件,因为pear在以下位置安装了二进制文件: /usr/bin/phpunit

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

解决方案是通过以下方式运行phpunit:/usr/bin/phpunit或将二进制文件复制到/usr/local/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/

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

这篇关于PHPUnit 3.6 PHP 5.2.7 PHP解析错误:语法错误,意外的T_FUNCTION,在第16行的/usr/local/bin/phpunit中期望')'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆