Symfony 1.4 using deprecated functions in php 5.5

前端 未结 7 828
野趣味
野趣味 2020-12-25 14:48

I recently upgraded PHP from version 5.3.27 to 5.5.0. Everything is working fine in my Symfony 2.3.2 project, and I can enjoy the latest PHP functionalities.

Now wh

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 15:13

    Alternative FIX for pregtr method in /lib/vendor/symfony/lib/util/sfToolkit.class.php on line 360

    public static function pregtr($search, $replacePairs)
    {
      // return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search);
      foreach($replacePairs as $pattern => $replacement)
      {
        if (preg_match('/(.*)e$/', $pattern, $matches))
        {
          $pattern = $matches[1];
          $search = preg_replace_callback($pattern, function ($matches) use ($replacement) {
            preg_match("/('::'\.)?([a-z]*)\('\\\\([0-9]{1})'\)/", $replacement, $match);
            return ($match[1]==''?'':'::').call_user_func($match[2], $matches[$match[3]]);
          }, $search);
        }
        else
        {
          $search = preg_replace($pattern, $replacement, $search);
        }
      }
      return $search;
    }
    

提交回复
热议问题