fix GH-207 - static variables in functions become invalid

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes 
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #207
| License       | MIT

This fixes changing of static variables inside a function, it only happens under rare conditions but none the less its a bug. A minor breakage is that `static $var;` without a visibility is no longer fixed (but this was not tested in the old version, so I'm not sure if this is a problem).