Skip to content

Instantly share code, notes, and snippets.

@madebycaliper
Last active December 3, 2023 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madebycaliper/220e92b0ace86eaa5d22e0970bb07183 to your computer and use it in GitHub Desktop.
Save madebycaliper/220e92b0ace86eaa5d22e0970bb07183 to your computer and use it in GitHub Desktop.
VSCode Snippets to Convert to and from Standard Function to Arrow Function
// 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