Last active
December 3, 2023 17:27
-
-
Save madebycaliper/220e92b0ace86eaa5d22e0970bb07183 to your computer and use it in GitHub Desktop.
VSCode Snippets to Convert to and from Standard Function to Arrow Function
This file contains hidden or 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
// Place this snippet in php.json to allow it only in PHP files | |
{ | |
// Other Snippets Here | |
"Convert PHP function to arrow function": { | |
"prefix": "convertToArrow", | |
"body": [ | |
"${TM_SELECTED_TEXT/function\\s*\\(([^)]*)\\)\\s*\\{\\s*return\\s+([^;]+);\\s*\\}/fn($1) => $2/}" | |
], | |
"description": "Convert a PHP function with parameters to an arrow function" | |
}, | |
"Convert arrow function to standard PHP function": { | |
"prefix": "convertFromArrow", | |
"body": [ | |
"${TM_SELECTED_TEXT/fn\\s*\\(([^)]*)\\)\\s*=>\\s*([^;]+)/function ($1) { return $2; }/}" | |
], | |
"description": "Convert an arrow function to a standard PHP function" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment