当前的Travis-CI PHP7版本在执行以下代码时会引发以下错误:


trait EloquentValidatingTrait
{
    // Some declarations skipped
/**
 * Eloquent will call this on model boot
 */
public static function bootEloquentValidatingTrait()
{
    // Calling Model::saving() and asking it to execute assertIsValid() before model is saved into database
    $savingCallable = [static::class, 'saving'];
    $validationCallable = [static::class, 'assertIsValid'];
    forward_static_call($savingCallable, $validationCallable);
}

那是我错过的临时错误还是将来的功能? RFC下面的注释说它应该可以工作(并且在5.5和5.6中都可以)。

最佳答案

通过http://git.php.net/?p=php-src.git;a=commitdiff;h=1d3f77d13d2b457bdf1bc52045da4679741e65cb修复了此错误

错误很简单...我在编译时进行了常量分辨率优化,将模式设置为强制成功或失败(对函数调用的简单 bool 值)。静态表达式需要该模式(例如const FOO = static::class;必须失败)。

将其设置为零,现在可以正常工作了。只需拉最新的大师进行修复。

关于PHP 7致命错误:static::class无法用于编译时类名称解析,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30629933/

10-12 00:20
查看更多