wongjn / vscode-php-sniffer

Visual Studio Code extension for PHP_Codesniffer validation and formatting.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
MIT License
46 stars 7 forks source link

Ignored bad indentations #30

Closed SharakPL closed 4 years ago

SharakPL commented 4 years ago

Describe the bug It seems indentations are ignored for most part - everything except classses and functions. Here's code example to format:

<?php

            namespace App\Http\Controllers;

                use Illuminate\Http\Request;

                class HomeController extends Controller
                {
                    /**
                                    * Create a new controller instance.
                                *
                                    * @return void
                            */
                            public function __construct()
                            {
                            $this->middleware('auth');
                        }

                    /**
                     * Show the application dashboard.
                     *
                     * @return \Illuminate\Contracts\Support\Renderable
                     */
                    public function index()
                    {
                        return view('home');
                    }
                }

To Reproduce

  1. VSCode settings:
    "[php]": {
    "editor.tabSize": 4,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "wongjn.php-sniffer"
    }
  2. Format on save results: phpsniffer

Expected behavior Extension should apply proper indentation.

Environment

Extension settings

{
    "phpSniffer.autoDetect": true,
    "phpSniffer.onTypeDelay": 500,
    "phpSniffer.run": "onType",
    "phpSniffer.standard": "PSR12",
}

Additional context

wongjn commented 4 years ago

This seems like an “issue” with PSR12 standard implementation or PHP_CodeSniffer not the extension — when I run phpcbf from the command line (./vendor/bin/phpcbf --standard=PSR12 index.php) I get the same result.

SharakPL commented 4 years ago

I'm afraid there's not much point in using PHP Sniffer as default formatter if it won't even follow proper indentation rules :(