A colleague of me forwarded me this super cool solution/template to remove one of the little annoying corners of the great PHPStorm IDE (beside the sad fact, that it is closed source software of course).
The template is fixing the problem with the generated setter methods and the missing type hinting.
Open PhpStorm's Preferences and "File and Code Templates" menu, under the "Code" tab there's an option called "PHP Setter Method". Modify it to look like this:
#set($typeHintText = "$TYPE_HINT ")
## First we check against a blacklist of primitive and other common types used in documentation.
#set($nonTypeHintableTypes = ["", "string", "int", "mixed", "number", "void", "object", "real", "double", "float", "resource", "null", "bool", "boolean"])
#foreach($nonTypeHintableType in $nonTypeHintableTypes)
#if ($nonTypeHintableType == $TYPE_HINT)
#set($typeHintText = "")
#end
#end
## Make sure the type hint actually looks like a legal php class name(permitting namespaces too) for future proofing reasons.
## This is important because PSR-5 is coming soon, and will allow documentation of types with syntax like SplStack
#if (!$TYPE_HINT.matches('^((\\)?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+)+$'))
#set($typeHintText = "")
#end
## Next, we check if this is using the array syntax like "MyClass[]", and type hint it as a plain array
#if ($TYPE_HINT.endsWith("[]"))
#set($typeHintText = "array ")
#end
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
public ${STATIC} function set${NAME}($typeHintText$${PARAM_NAME})
{
#if (${STATIC} == "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
#else
$this->${FIELD_NAME} = $${PARAM_NAME};
#end
}
I started getting tired of installing phpstorm by hand again and again. Did I mention that installing is the same as updating?.
Since the ide is for php, of course I wrote the installer in php.
# simple install or update
php phpstorm.php path/to/linux/php/version.tar.gz
# install or update and change group
# good if you created a "developer" group on your system
php phpstorm.php path/to/linux/php/version.tar.gz your_group_name
I had updated my arch linux as usual and got an update for openJDK.
java -version
java version "1.7.0_60"
OpenJDK Runtime Environment (IcedTea 2.5.0) (Arch Linux build 7.u60_2.5.0-2-x86_64)
OpenJDK 64-Bit Server VM (build 24.60-b09, mixed mode)
After that, I started my phpstorm (I am working with the window manager i3wm and the screen looks strange. Everything was there, except for the fonts - I could not read anything (and I am not that cool to code without seeing the code :D-).
After log of tryouts, I found a simple and suitable solution.