PHP 7致命错误:static :: class不能用于编译时类名解析

Vla*_*sny 9 php php-7

当前Travis-CI PHP7构建在执行以下代码时抛出以下错误:

PHP 7致命错误:static :: class不能用于编译时类名解析

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);
}
Run Code Online (Sandbox Code Playgroud)

这是一个临时错误还是我错过的未来功能?此RFC下面的注释说它应该可以工作(并且它在5.5和5.6中都有效).

bwo*_*ebi 7

修正了这个错误,来自http://git.php.net/?p=php-src.git;a=commitdiff;h=1d3f77d13d2b457bdf1bc52045da4679741e65cb

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

将其设置为零,现在它可以正常工作.只需拉最新的主人来修复.