junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

why are indention and code styles being ignored #190

Closed snake-py closed 2 years ago

snake-py commented 2 years ago

I followed the installation instructions and I am trying to utilize this as pre-commit hook, but the output looks awful:

If I provide the command with the following php code it will not format it at all - is this intended or am I doing something wrong

    public $elasticTemplate = [
        '_id' => null,
        'id' => null,
        'type' => null,
                    '@timestamp' => null,
        'environment' => null,
                 'internal_api_log_id' => null,
        'base_url' => null,
        '       product' => null,
        'stage' => null,
        'exception'
        =>
        [
            'trace' => null,
            'place'
            => null,
            'previousThrowable' =>
            null,
            'type' => null,
                'message' => null,
            'code' => null,
        ],

The command I am using:

tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --using-cache=no --path-mode=intersection 

The config I have:

<?php

$finder = PhpCsFixer\Finder::create()
    ->exclude('tools')
    ->in(__DIR__)
;

$config = new PhpCsFixer\Config();
return $config->setRules([
        '@PSR12' => true,
        'array_syntax' => ['syntax' => 'short'],
    ])
    ->setFinder($finder)
;
snake-py commented 2 years ago

Sorry just noticed, I posted in the wrong repo, wanted to post here https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/6631