rfc:second_arg_to_preg_callback

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:second_arg_to_preg_callback [2013/05/04 13:44] – created laruencerfc:second_arg_to_preg_callback [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
  
-====== PHP RFC: Your Title Here ======+====== PHP RFC: Add an Second argument to callback of preg_replace_callback ======
   * Version: 1.0   * Version: 1.0
   * Date: 2013-05-04   * Date: 2013-05-04
Line 24: Line 24:
     )     )
     ..);     ..);
 +?>
 </code> </code>
-   can not be easier convert to the "callback" style. 
  
-   then I have to change it to something very ugly like(a real use case see: https://github.com/php/php-src/blob/PHP-5.5/Zend/zend_vm_gen.php#L390):+can not be easier convert to the "callback" style. 
 + 
 +then I have to change it to something very ugly like(a real use case see: https://github.com/php/php-src/blob/PHP-5.5/Zend/zend_vm_gen.php#L390):
    
 <code php> <code php>
Line 81: Line 83:
 </code> </code>
  
- for this idea, there some problems:+for this idea, there some problems:
    
-   1. you have to define various functions for different regex +1. you have to define various functions for different regex 
-   2. it's inefficient, since there need multiple function call, multiple argument processing etc.+    
 +2. it's inefficient, since there need multiple function call, multiple argument processing etc.
  
 ===== Other Ideas ===== ===== Other Ideas =====
Line 90: Line 93:
 1. the reporter(#64730) suggest "I think it would be better if prey_replace_callback function will accept array of callbacks as a 2nd argument." 1. the reporter(#64730) suggest "I think it would be better if prey_replace_callback function will accept array of callbacks as a 2nd argument."
        
-   but it's can not be achieved, because(by ww dot galen at gmail dot com): +but it's can not be achieved, because(by ww dot galen at gmail dot com): 
-   "Accepting an array of callbacks can lead to unreconcilable ambiguities. For example:+ 
 +"Accepting an array of callbacks can lead to unreconcilable ambiguities. For example:
  
     class A {     class A {
Line 109: Line 113:
      3. `$a->foo(...)` "       3. `$a->foo(...)` " 
            
-   2. Nikic suggest the first argument of preg_replace_callback accept array("regex" => "callback");+2. Nikic suggest the first argument of preg_replace_callback accept array("regex" => "callback");
          
-    but it can not be achieved either , because, thinking of: +but it can not be achieved either , because, thinking of: 
-    $regex = array("regex"); and there by accident is a function called regex, then the key "0" can be considered as a "regex" too.+$regex = array("regex"); and there by accident is a function called regex, then the key "0" can be considered as a "regex" too. 
 + 
 + 
 +===== Patch ====== 
 +The patch for this change is here: https://bugs.php.net/patch-display.php?bug_id=64730&patch=second_arg_rege_key.patch&revision=latest 
          
      
          
rfc/second_arg_to_preg_callback.1367675052.txt.gz · Last modified: 2017/09/22 13:28 (external edit)