Last active
May 14, 2020 04:31
-
-
Save mooror/e647312cff315d8d9ca66205c496c443 to your computer and use it in GitHub Desktop.
PHP Debugging REGEX Strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** ADD DEBUG LINES *** | |
+ CALL ONLY DEBUG | |
Use the following snippet to add a debug "call" line to every method in a file. | |
Search: | |
((( )*)(public|private) (static )?function (__)?([a-zA-Z0-9]*)\(.*\)\n?(\s*)\{) | |
Replace: | |
$1\n$2 print(__FUNCTION__." call (".basename(__FILE__, ".php").":".__LINE__.")\\n<br />"); | |
+ METHOD WITH PARAMS | |
Search: | |
(((?: )*)(?:public|private) (?:static )?function (?:__)?(?:[a-zA-Z0-9]*)\((?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?(?:(?:[a-z_A-Z0-9]* )?(\$[a-zA-Z0-9_]*)(?:[="\sa-zA-Z0-9]*)?,?)?\)\n?(?:\s*)\{) | |
Replace: | |
WARNING: Will not work with functions that accept objects that cannot be converted to a string | |
$1\n$2print(__FUNCTION__."($3 $4 $5 $6 $7 $8 $9 $10) call on line ".__LINE__."\\n<br />"); | |
*** REMOVE DEBUG LINES *** | |
To remove the debug line use the following search and replace | |
Search: | |
([\n\r\s])*print\(__FUNCTION__\." called on line "\.__LINE__\."\\n<br />"\); | |
Replace: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment