symfony 1.4 - 警告:遇到非数字值

symfony 1.4 - Warning: A non-numeric value encountered

Warning: A non-numeric value encountered in C:\Program Files (x86)\Ampps\www\Symfony_project\lib\vendor\symfony1\lib\yaml\sfYamlInline.php(138) : runtime-created function on line 1

使用php7.1

if (
      (1 == count($keys) && '0' == $keys[0])
      ||
    Line 138->  (count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))

23 0.1704 3586632 __lambda_func( ) ...\sfYamlInline.php:138

如何修复?

有一些 symfony1 的分支与 PHP7.1.

兼容

在这种情况下,您可以通过将 'return (integer) $v + $w;' 更改为 'return (integer) $v + (integer) $w;' 来轻松修补此问题。

(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))      [position 138:48]    

应替换为

(count($keys) > 1 && array_reduce($keys, function($v,$w) { return ((int) $v + (int) $w);}, 0) == count($keys) * (count($keys) - 1) / 2))