调用app / console cache时出现Symfony2 PHP Parse错误:清除

时间:2013-11-23 04:36:33

标签: php symfony

每当我尝试清除Symfony2上的缓存时,我都会遇到以下错误:

PHP Parse error:  parse error in /Users/Adam/Sites/MyApp/src/MyApp/MainBundle/Services/TransactionManager.php on line 177
PHP Stack trace:
PHP   1. {main}() /Users/Adam/Sites/MyApp/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /Users/Adam/Sites/MyApp/app/console:32
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Users/Adam/Sites/MyApp/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\HttpKernel\Kernel->boot() /Users/Adam/Sites/MyApp/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
PHP   5. Symfony\Component\HttpKernel\Kernel->initializeContainer() /Users/Adam/Sites/MyApp/app/bootstrap.php.cache:2215
PHP   6. Symfony\Component\DependencyInjection\ContainerBuilder->compile() /Users/Adam/Sites/MyApp/app/bootstrap.php.cache:2435
PHP   7. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() /Users/Adam/Sites/MyApp/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:629
PHP   8. JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->process() /Users/Adam/Sites/MyApp/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:119
PHP   9. JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->processDefinition() /Users/Adam/Sites/MyApp/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:59
PHP  10. class_exists() /Users/Adam/Sites/MyApp/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:96
PHP  11. Composer\Autoload\ClassLoader->loadClass() /Users/Adam/Sites/MyApp/vendor/jms/aop-bundle/JMS/AopBundle/DependencyInjection/Compiler/PointcutMatchingPass.php:0

以下是第177行的内容:

/**
 * {@inheritDoc} 
 */
public function findAwaitingPaymentTransactionsByUserId( $dateRange = [] )
 {
   // ...
 }

知道为什么会这样吗?这只是在我升级我的Lion OS X之后才发生的,之后它与上面的代码完全一致。

1 个答案:

答案 0 :(得分:2)

该方法的默认参数$dateRange = []使用PHP 5.4中引入的短数组语法

您的PHP命令行界面使用无法理解此语法的PHP 5.3

因此,方法声明会产生PHP Parse error

将方法更改为...

// array() instead of []
public function findAwaitingPaymentTransactionsByUserId( $dateRange = array() )
{
    // ...
}

...解决问题。