Search code examples
phpeclipsecode-snippetseclipse-junophpeclipse

PHPEclipse code templates incorrect indenting


Indentation behaviour is incorrect using PHPEclipse code templates. If the code is already indented at the start of template insertion, the indent depth is ignored and tabs will be used even if you use spaces for indenting.

Example: "function" code template, inserted when indent depth was 4 spaces:

    function function_name( $param ) { // 4 spaces
    return  ;                          // a tab?
}                                      // nothing!

I specified to use spaces in

Window -> Preferences -> PHPEclipse -> PHP -> Typing tab -> checked Insert spaces for tab

and

Window -> Preferences -> PHPEclipse -> PHP -> Formatter -> Style tab -> unchecked Indentation is represented by a tab

I also tried to use tabs, but nothing:

    function function_name( $param ) { // 1 tab
    return  ;                          // 1 tab... (*sigh*)
}                                      // nothing!

I also checked the code template, it seems correct and similar to the java code templates, that do work as expected. "Use code formatter" is checked. And Google doesn't help me.

I installed Eclipse for Java Juno SR 2, 20130225-0426, and PHPEclipse 1.2.3

EDIT: I'm wondering if PDT does have working snippets.


Solution

  • Well, PDT doesn't have this bug. I said in one comment it have... I don't know if I was wrong or PDT devs fixed some bug in the meanwhile.

    Furthermore it supports the newest language syntax. For example, the Python-like array constructor

    $array = [1, 2, 3];
    

    is signalled as error by PHPEclipse, while PDT accepts it.