PHP5.3 VIM 中的闭包缩进
我尝试了几种不同的 php 缩进脚本,但它们无法处理以下代码的缩进:
myfunc(function(){
echo "hello";
if(1==2){
echo "world";
}
});
您能指出 vimrc 设置或 vim 的 php 缩进文件可以处理 PHP5.3 的新语法吗?
更新:这是我得到的:
myfunc(function(){
echo "hello";
if(1==2){
echo "world";
}
});
我使用 http://www.2072products.com/vim/indent/php.vim John Wellesz
剩余的 PHP 语法已正确缩进。
I have tried few different php indentation scripts, but they can't handle indentation of the following code:
myfunc(function(){
echo "hello";
if(1==2){
echo "world";
}
});
Can you point out vimrc settings or php indentation file for vim which would handle new syntax of PHP5.3?
Update: Here is what I get:
myfunc(function(){
echo "hello";
if(1==2){
echo "world";
}
});
I use bundled indent for 7.3 from http://www.2072productions.com/vim/indent/php.vim John Wellesz
Remaining PHP syntax is indented correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是因为你的闭包语法不正确。据我所知,闭包不应该有名称。例如,对于 preg_replace_callback 函数,您可以传递一个包含用
function($matches){/*logic */}
定义的闭包的变量或上述代码本身。您在这里尝试做的是在回调参数中定义一个函数。 BAAAAD 为你的脚本 xD
只需去掉这样的名称,看看它是否有帮助:
PHP 文档也显示了闭包的语法:
http://php.net/manual/en/functions.anonymous.php
It may be because your closure syntax is incorrect. Closures shouldn't have names as far as I know. E.g. for a preg_replace_callback function, you'd either pass a variable containing a closure defined with
function($matches){/* logic */}
or the aforementioned code itself.What you're trying to do here is define a function in a callback argument. BAAAAD for your script xD
Just get rid of the name like this and see if it helps:
PHP docs show this syntax for closures too:
http://php.net/manual/en/functions.anonymous.php