Symfony 1.4 using deprecated functions in php 5.5

前端 未结 7 912
野趣味
野趣味 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:09

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in lib/vendor/symfony/…This changelog will solve the problem for all symfony 1.4.x. Tested on Symfony 1.4.20
    ---
     lib/vendor/symfony/lib/command/sfCommandManager.class.php     |  4 +++-
     lib/vendor/symfony/lib/form/addon/sfFormObject.class.php      |  2 +-
     lib/vendor/symfony/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php  |  2 +-
     lib/vendor/symfony/plugins/sfPropelPlugin/lib/form/sfFormFilterPropel.class.php      |  2 +-
     lib/vendor/symfony/lib/response/sfWebResponse.class.php       |  2 +-
     lib/vendor/symfony/lib/util/sfInflector.class.php             |  5 +----
     lib/vendor/symfony/lib/util/sfToolkit.class.php               | 11 +++++++++++
     7 files changed, 19 insertions(+), 9 deletions(-)
    
    lib/vendor/symfony/lib/command/sfCommandManager.class.php
    @@ -108,7 +108,9 @@ class sfCommandManager
         else if (!is_array($arguments))
         {
           // hack to split arguments with spaces : --test="with some spaces"
    -      $arguments = preg_replace('/(\'|")(.+?)\\1/e', "str_replace(' ', '=PLACEHOLDER=', '\\2')", $arguments);
    +      $arguments = preg_replace_callback('/(\'|")(.+?)\\1/', function($matches) {
    +         return str_replace(' ', '=PLACEHOLDER=', $matches[2]);
    +     }, $arguments);
           $arguments = preg_split('/\s+/', $arguments);
           $arguments = str_replace('=PLACEHOLDER=', ' ', $arguments);
         }
    
    lib/vendor/symfony/lib/form/addon/sfFormObject.class.php
    @@ -278,6 +278,6 @@ abstract class sfFormObject extends BaseForm
    
       protected function camelize($text)
       {
    -    return preg_replace(array('#/(.?)#e', '/(^|_|-)+(.)/e'), array("'::'.strtoupper('\\1')", "strtoupper('\\2')"), $text);
    +    return sfToolkit::camelize($text);
       }
     }
    
    lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php
    @@ -323,7 +323,7 @@ abstract class sfFormFilterDoctrine extends sfFormFilter
    
       protected function camelize($text)
       {
    -    return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
    +    return sfToolkit::camelize($text);
       }
    
       protected function getTable()
    
    lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/form/sfFormFilterPropel.class.php
    @@ -263,6 +263,6 @@ abstract class sfFormFilterPropel extends sfFormFilter
    
       protected function camelize($text)
       {
    -    return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
    +       return sfToolkit::camelize($text);
       }
     }
    
    lib/vendor/symfony/lib/response/sfWebResponse.class.php
    @@ -406,7 +406,7 @@ class sfWebResponse extends sfResponse
        */
       protected function normalizeHeaderName($name)
       {
    -    return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst(strtolower($name)), '_', '-'));
    +    return preg_replace_callback('/\-(.)/', function ($matches) { return '-'.strtoupper($matches[1]); }, strtr(ucfirst(strtolower($name)), '_', '-'));
       }
    
       /**
    
    lib/vendor/symfony/lib/util/sfInflector.class.php
    @@ -28,10 +28,7 @@ class sfInflector
       public static function camelize($lower_case_and_underscored_word)
       {
         $tmp = $lower_case_and_underscored_word;
    -    $tmp = sfToolkit::pregtr($tmp, array('#/(.?)#e'    => "'::'.strtoupper('\\1')",
    -                                         '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
    -
    -    return $tmp;
    +    return sfToolkit::camelize($tmp);;
       }
    
       /**
    
    lib/vendor/symfony/lib/util/sfToolkit.class.php
    @@ -608,4 +608,15 @@ class sfToolkit
    
         return set_include_path(join(PATH_SEPARATOR, $paths));
       }
    +
    +   public static function camelize($text)
    +   {
    +       if (preg_match('#/(.?)#', $text, $matches)) {
    +           $text = str_replace($matches[0], '::'.strtoupper($matches[1]), $text);
    +       }
    +       if (preg_match('/(^|_|-)+(.)/', $text, $matches)) {
    +           $text = str_replace($matches[0], strtoupper($matches[2]), $text);
    +       }
    +       return $text;
    +   }
     }
    --
    

提交回复
热议问题