Skip to content

Instantly share code, notes, and snippets.

@simshaun
Created August 9, 2012 20:25
Show Gist options
  • Save simshaun/3307806 to your computer and use it in GitHub Desktop.
Save simshaun/3307806 to your computer and use it in GitHub Desktop.
A modified setter method template for PhpStorm that generates both an `add` and `set` method for arrays.
#if (${TYPE_HINT} == "array")
/**
* @param mixed $element
*/
public ${STATIC} function add${NAME}($element)
{
#if (${STATIC} == "static")
self::$${FIELD_NAME}[] = $element;
#else
$this->${FIELD_NAME}[] = $element;
#end
}
#end
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
public ${STATIC} function set${NAME}($${PARAM_NAME})
{
#if (${STATIC} == "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
#else
$this->${FIELD_NAME} = $${PARAM_NAME};
#end
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment