PHP5.3 closing indentation in VIM

I tried several different php indentation scripts, but they cannot handle indentation of the following code:

myfunc(function(){ echo "hello"; if(1==2){ echo "world"; } }); 

Can you specify vimrc options or a php indent file for vim that will handle the new PHP5.3 syntax?

Update: Here is what I get:

 myfunc(function(){ echo "hello"; if(1==2){ echo "world"; } }); 

I am using nested indentation for 7.3 from http://www.2072productions.com/vim/indent/php.vim John Welles

The remaining PHP syntax is formatted correctly.

+4
source share
1 answer

Perhaps this is because your closure syntax is incorrect. As far as I know, a closure should not have names. For instance. for the preg_replace_callback function, you will either pass a variable containing the closure defined with function($matches){/* logic */} , or the above code.

What you are trying to do here is to define a function in the callback argument. BAAAAD for your xD script

Just get rid of a name like this and see if it helps:

 myfunc(function(){ echo "hello"; if(1==2){ echo "world"; } }); 

PHP docs also show this syntax: http://php.net/manual/en/functions.anonymous.php

0
source

All Articles