Sublime Forum

PHP "Reindent Lines"

#1

I am mainly a PHP developer and I’m using Netbeans IDE.

I consider auto-formatting functionality in NetBeans very well done. It indents automatically the entire file, which is desirable all the time because it’s well done. The indentation is not only done horizontally but also vertically, meaning more than one empty lines are reduced to one etc.

After some hours struggling I found how to add the keyboard shortcut for the “Reindent Lines” command found in command palette but not in menu:


	{ "keys": "shift+alt+f"], "command": "reindent", "args": {"single_line": false}}
]

In PHP I found some problems in Reindent:

I suggest:

  • Adding vertical reindentation
  • Adding a shortcut key to “Reindent Lines”
  • Adding “Reindent Lines” to menu
  • Improving “Reindent Lines” by using NetBeans styling rules

Some bugs I found in “Reindent Lines”:

<?php

namespace ens\database;

class DbManager {

    static $connections = array(
        'master' => array(
            'username' => 'root',
            'password' => 'root',
            'dsn' => 'mysql:host=127.0.0.1;dbname=ctc',
            'prefix' => ''
            )
            );
            static $test = array(
                'lala' => 'lolo'
                );
                static function connectAll() {
                    foreach (self::$connections as &$connection)
                    $connection'connection'] = new \ens\database\DbConnection($connection'dsn'], $connection'username'], $connection'password']);
                }
                static function lala($test){

                }

            }

That should be something like:

<?php

namespace ens\database;

class DbManager {

    static $connections = array(
        'master' => array(
            'username' => 'root',
            'password' => 'root',
            'dsn' => 'mysql:host=127.0.0.1;dbname=ctc',
            'prefix' => ''
        )
    );
    static $test = array(
        'lala' => 'lolo'
    );

    static function connectAll() {
        foreach (self::$connections as &$connection)
            $connection'connection'] = new \ens\database\DbConnection($connection'dsn'], $connection'username'], $connection'password']);
    }

    static function lala($test) {
        
    }

}
0 Likes