2072 / PHP-Indenting-for-VIm

The official VIm indent script for PHP
http://www.2072productions.com/to/phpindent.txt
128 stars 29 forks source link

Indentation of method call is broken when some characters are part of arguments #77

Closed DanielSiepmann closed 3 years ago

DanielSiepmann commented 4 years ago

Given the following file content:

<?php

class Example {
    private function setConfig(array $config)
    {
        $config = GeneralUtility::intExplode(
            ',',
            $config['userGroups'] ?? '',
            true
        );

        $this->config = $config;
    }
}

The indentation is broken. I get the following result when formatting the content:

<?php

class Example {
    private function setConfig(array $config)
    {
        $config = GeneralUtility::intExplode(
',',
$config['userGroups'] ?? '',
true
        );

$this->config = $config;
    }
}

I figured out, that , as argument breaks, as well as true does.

The following example works:

<?php

class Example {
    private function setConfig(array $config)
    {
        $config = GeneralUtility::intExplode(
            '',
            $config['userGroups'] ?? '',
            'true'
        );

        $this->config = $config;
    }
}

Issue exists for 1.70 and 1.72 at least.

I didn't notice the issue with https://github.com/neovim/neovim/blob/v0.3.8/runtime/indent/php.vim. Which doesn't mean it wasn't there. At least I can reproduce the issue with that version. At least

2072 commented 3 years ago

Ok fixed, better late than never! I curse the day when I accepted to implement support for multi line strings. I knew this was a bad idea...

DanielSiepmann commented 3 years ago

Thank you very much :)

I've tried to install via pathogen, but it seems not to work. I guess I need to wait until neovim updates its version?

2072 commented 3 years ago

I don't know about that, I don't use Pathogen nor Neovim... Maybe the Pathogen instructions in README.md are no longer accurate, if you find a solution don't hesitate to share or even make a pull request to update the installation instructions.