Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
Last active June 12, 2022 22:07
Show Gist options
  • Save frankdejonge/1cd9d38c3bd4e6548f83c5977e3b2c69 to your computer and use it in GitHub Desktop.
Save frankdejonge/1cd9d38c3bd4e6548f83c5977e3b2c69 to your computer and use it in GitHub Desktop.
PHP Wither template

You can copy the XML below and paste them into your live templates in PHPStorm to start using it :)

<template name="wither" value="public function with$WITHER_SUFFIX$($MEMBER_TYPE$ $$$WITHER_NAME$): static&#10;{&#10; $clone = clone $this;&#10; $clone-&gt;$WITHER_NAME$ = $$$WITHER_NAME$;&#10;&#10; return $clone;&#10;}" description="" toReformat="true" toShortenFQNames="true">
<variable name="MEMBER_TYPE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="WITHER_NAME" expression="" defaultValue="&quot;parameter&quot;" alwaysStopAt="true" />
<variable name="WITHER_SUFFIX" expression="capitalize(WITHER_NAME)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="PHP Class Member" value="true" />
</context>
</template>
<template name="wither" value="public function with$WITHER_SUFFIX$($MEMBER_TYPE$ $$$WITHER_NAME$): $CLASS_NAME$&#10;{&#10; $clone = clone $this;&#10; $clone-&gt;$WITHER_NAME$ = $$$WITHER_NAME$;&#10;&#10; return $clone;&#10;}" description="" toReformat="true" toShortenFQNames="true">
<variable name="MEMBER_TYPE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="WITHER_NAME" expression="" defaultValue="&quot;parameter&quot;" alwaysStopAt="true" />
<variable name="WITHER_SUFFIX" expression="capitalize(WITHER_NAME)" defaultValue="" alwaysStopAt="false" />
<variable name="CLASS_NAME" expression="phpClassName()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="PHP Class Member" value="true" />
</context>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment