![](/img/trans.png)
[英]Symfony2 and php app/console cache:clear --env=prod --no-debug
[英]Symfony2 PHP Parse error when invoking app/console cache:clear
每當我試圖清除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之后發生的,之前它與上面的代碼完全一致。
該方法的默認參數$dateRange = []
使用PHP 5.4中引入的短數組語法 。
您的PHP
命令行界面使用無法理解此語法的PHP 5.3
。
因此,方法聲明會導致PHP Parse error
。
將方法更改為...
// array() instead of []
public function findAwaitingPaymentTransactionsByUserId( $dateRange = array() )
{
// ...
}
......解決問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.