StanAngeloff/php.vim — pull request #22 by swekaj (2014-07-08 05:58:10+00:00)
Title: Fold enhancements

I've added some improvements to the folding.

For the simple folding method (folding all pairs of { }) I just added ( ) and [ ] as folded pairs so arrays can be folded.

The advanced folding (php_folding==1) got a lot more improvements:
* try/catch folding was improved to allow for individual folding for the try and catch(es) blocks, even if the catch is on the same line as the closing } for previous block. Folding for finally blocks was added.
* for, foreach, while, and do/while loops are all now folded.
* if/elseif/else blocks are now folded, with each block being folded individually much like try/catch/finally.
* switch blocks are now folded. First, the switch block as a whole folds, then each case block and the default block fold within that.
* heredocs and nowdocs now fold.

There are a couple of bugs I couldn't figure out how to fix:
1. Closing } highlighting. I could not figure out how to get the closing } in try/catch/finally and if/elseif/else to highlight as a delimiter when they were followed by the next block's keyword on the same line, e.g.
```php
if ($expr) {
// true
} else {
// false
}
```
2. I couldn't figure out how to get successive case fall-throughs to fold together, only the last case statement will be in the fold, leaving the previous ones unfolded. e.g.
```php
switch ($expr) {
case 0: // fall-through, not folded.
case 1: // fall-through, not folded.
case 2: // do something, folded.
// code
break;
}
```