Drupal 7 开发内部培训资料, 分头诗人

求助:drupal8安装时提示functions.php括号不匹配

赞成!
0
否决!

求助:在安装drupal8时,php-fpm返回的日志中打印functions.php括号不匹配,具体错误日志如下:

[02-Jan-2015 21:59:37] PHP Parse error:  syntax error, unexpected '[', expecting ')' in /usr/share/nginx/html/drupal8/core/vendor/react/promise/src/functions.php on line 62
[03-Jan-2015 00:20:43] PHP Parse error:  syntax error, unexpected '[', expecting ')' in /usr/share/nginx/html/drupal8/core/vendor/react/promise/src/functions.php on line 62
[03-Jan-2015 00:21:37] PHP Parse error:  syntax error, unexpected '[', expecting ')' in /usr/share/nginx/html/drupal8/core/vendor/react/promise/src/functions.php on line 62

 

对于的function.php文件如下:

其中62行对应一个if匹配:

if (!is_array($array) || !$array || $howMany < 1) {
                return resolve([]);
}

从代码看并没有错误,而且源代码我也没修改过。

完整的函数如下:

function some($promisesOrValues, $howMany)
{
    return resolve($promisesOrValues)
        ->then(function ($array) use ($howMany) {
            if (!is_array($array) || !$array || $howMany < 1) {
                return resolve([]);
            }

            return new Promise(function ($resolve, $reject, $progress) use ($array, $howMany) {
                $len       = count($array);
                $toResolve = min($howMany, $len);
                $toReject  = ($len - $toResolve) + 1;
                $values    = [];
                $reasons   = [];

                foreach ($array as $i => $promiseOrValue) {
                    $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve) {
                        if ($toResolve < 1 || $toReject < 1) {
                            return;
                        }

                        $values[$i] = $val;

                        if (0 === --$toResolve) {
                            $resolve($values);
                        }
                    };

                    $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject) {
                        if ($toResolve < 1 || $toReject < 1) {
                            return;
                        }

                        $reasons[$i] = $reason;

                        if (0 === --$toReject) {
                            $reject($reasons);
                        }
                    };

                    resolve($promiseOrValue)
                        ->then($fulfiller, $rejecter, $progress);
                }
            });
        });
}

2 个回答

赞成!
0
否决!

好像我也遇到这个问题了,应该是PHP版本问题,你安装php 5.4以上就没了

赞成!
0
否决!

多谢,是因为版本低导致的。