Skip to content

howto - add type hinting to phpstorms generated setter method

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 (!$TYPEHINT.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 ${TYPEHINT} $${PARAMNAME} */ public ${STATIC} function set${NAME}($typeHintText$${PARAM_NAME}) {

if (${STATIC} == "static")

self::$${FIELD_NAME} = $${PARAM_NAME};

else

$this->${FIELD_NAME} = $${PARAM_NAME};

end

}


source
File Template Variables

Translate to de es fr it pt ja

Version 1.0.0 of Jetbrains PhpStorm Installer for (Debian) Linux released

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 yourgroupname

I hope you are going to enjoy it.

Translate to de es fr it pt ja

Arch Linux PHPStorm (JetBrains) OpenJDK Update and No Font

I had updated my arch linux as usual and got an update for openJDK.

java -version
java version "1.7.060"
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.
sudo echo "-Dawt.useSystemAAFontSettings=gasp" > /usr/share/phpstorm/bin/phpstorm64.vmoptions

This has resolved the issue on my machine. There are some hints available, but I needed only one line, hope it suits your needs too.

Translate to de es fr it pt ja

extended support for InteiilJ IDEA (means also phpstorm) for notion window manager

Just found the following block in the /etc/notion/cfgkludges.lua file (arch linux).

-- InteiilJ IDEA - I wonder whether we should do this for all sun-awt-X11-XWindowPeer windows
defwinprop {
    class = "jetbrains-idea-ce",
    instance = "sun-awt-X11-XWindowPeer",
    transientmode = "current",
}
defwinprop {
    class = "jetbrains-idea-ce",
    instance = "sun-awt-X11-XDialogPeer",
    transientmode = "current",
}
defwinprop {
    class = "jetbrains-idea",
    instance = "sun-awt-X11-XWindowPeer",
    transientmode = "current",
}
defwinprop {
    class = "jetbrains-idea",
    instance = "sun-awt-X11-XDialogPeer",
    transient_mode = "current",
}

Looks like they found a reason why working with phpstorm in notion was not that easy.

Translate to de es fr it pt ja

enable multiple search results in phpstorm

Because it is somekind of a hidden feature, you can have multiple search results in your phpstorm. Hit "Ctrl+Shift+F" and search for "open in new tab". Check the checkbox and their you go.
But be aware of the psychological side effects. It is good to only have one search result, this keeps you away from mentally switching between different tasks.
Thanks to my colleague for this hint.

Translate to de es fr it pt ja

Fackbook Tries to Solve PHP's Issues With Their New Language Called "Hack"

I just had finished an article about facebooks new programming language. I am compiling it right now (thats there is a aur package available for hhvm).
In general, it looks like hack is friendship php with benefits. Can be run as script language, can be used as dynamically typed. Yes you are right, both times a "can be", indicating "can run as compiled code" and "can be statically typed" (or how they called it gradual typing.

So what hack is hack?

Hack is a programming language for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.

Hack provides instantaneous type checking via a local server that watches the filesystem. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.

source

Good articles are starting to spreading around, first i found was on sitepoint.com.

I was searching for a support announcement of hack for phpstorm and yes, there is a feature request for hack support as well as a feature request for hvvm debugger out there. Crossing fingers to get it in asap :-D.

Translate to de es fr it pt ja

phpstorm linux - java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-7-openjdk/jre/lib/amd64/libsplashscreen.so: libgif.so.6: cannot open shared object file: No such file or directory

Just got the following exception thrown while i updated/installed phpstorm on a fresh installed arch linux.

java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-7-openjdk/jre/lib/amd64/libsplashscreen.so: libgif.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1872)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:121)
at com.intellij.idea.IdeaApplication$IdeStarter.a(IdeaApplication.java:218)
at com.intellij.idea.IdeaApplication$IdeStarter.a(IdeaApplication.java:195)
at com.intellij.idea.IdeaApplication$IdeStarter.access$000(IdeaApplication.java:178)
at com.intellij.idea.IdeaApplication.(IdeaApplication.java:97)
at com.intellij.idea.IdeaUltimateApplication.(IdeaUltimateApplication.java:16)
at com.intellij.idea.MainImpl$1$1.proceed(MainImpl.java:53)
at com.intellij.ide.a.f.ab$3.run(ab$3.java:372)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

First idea, "well something went wrong" (because i simple rsynced my settings from another pc). Later it turned out something else was missing. A simple "pacman -S giflib" and everything was running fine afterwards.
so giflib was missing.
What is "giflib"?
giflib is a library for rendering and generating GIF image files.

source

Translate to de es fr it pt ja

web - PhpStorm EAP 7 released

PhpStorm has jumped to the major version of 7.

From the PHP side we are glad to announce:

PHP 5.5 support: generators, coroutines, finally keyword, list in foreach, using empty() on the result of function calls and other expressions, class name resolution as scalar via class keyword, constant array/string dereferencing

Drupal Plugin: integration for modules, themes and core development. Hooks (completion for hook declaration, quick documentation, navigation to hook invocations), automatic assistance in development environment configuration, command line tool integration for Drush, Search in Drupal API. Please read full tutorial

Smart Step Into (PHP Debug)

Extract Interface refactoring for PHP

Built-in SSH terminal

Automatic alignment of PhpDoc comments at edit time

Smart line split on Ctrl+Enter (Cmd-Enter)

INI plugin is bundled

source

I've switched one machine so far, lets see if i can feel a major improvement in the next week. By the way, have i mention that i love the plugins?

Translate to de es fr it pt ja

zenburn for vim and phpstorm

Zenburn, a colorschema you are adding and thinking "wow, how could i code without".

I used it at home but never wrote any words about them. So here are the first to links to available zenburn application colorschemas :-).

zenburn for vim. You have to add the following lines to your .vimrc.

syntax on set t_Co=256 colorscheme zenburn

zenburn for phpstorm.

Translate to de es fr it pt ja