kotfire/vscode-php-add-property

Indentation Bug in constructor

Closed this issue · 5 comments

When I try adding a property justATest to the following class, I end up with wrong indentation:

class Applicant
{
    public function __construct(
        ?string $salutation,
        string $firstName,
        string $lastName
    ) {
    }
}

Calling Add PHP Property and entering justATest results in the following:

class Applicant
{
    private $justATest;

    public function __construct(
    ?string $salutation,
    string $firstName,
    string $lastName,
    $justATest
  ) {
      $this->justATest = $justATest;
    }
}

Removing lastName in this example before adding the property works and results in the following:

class Applicant
{
    private $justATest;

    public function __construct(
        ?string $salutation,
        string $firstName,
        $justATest
    ) {
      $this->justATest = $justATest;
    }
}

Plugin Version: 1.1.0, VS Code Version: 1.48.2

My changed settings:

"phpAddProperty.constructor.breakIntoMultilineIfLengthExceeded.enabled": true,
"phpAddProperty.property.types": true

Hello, thank you for opening this issue.

I'm not able to reproduce the problem, I think it might be related to the code indentation. Could you create a repository with the failing code, so I can clone and try to reproduce it?

Thanks for the response. Sure:

https://github.com/binarious/reproduction-bug-32

Applicant.php ist the class I ran the above. The result for me is ApplicantPropertyAdded.php.

Also my list of plugins:

1dot75cm.RPMSpec
ajshort.latex-preview
alefragnani.Bookmarks
alefragnani.project-manager
Angular.ng-template
ardenivanov.svelte-intellisense
bmewburn.vscode-intelephense-client
breezelin.phpstan
Calsmurf2904.vscode-phpstan
christian-kohler.path-intellisense
dbaeumer.vscode-eslint
eamodio.gitlens
ecodes.vscode-phpmd
EditorConfig.EditorConfig
eg2.tslint
emmanuelbeziat.vscode-great-icons
fabianlauer.vs-code-xml-format
fabiospampinato.vscode-diff
felixfbecker.php-debug
fetzi.php-file-types
formulahendry.auto-close-tag
GitLab.gitlab-workflow
glen-84.sass-lint
ikappas.phpcs
infinity1207.angular2-switcher
James-Yu.latex-workshop
kotfire.php-add-property
mblode.twig-language
MehediDracula.php-constructor
MehediDracula.php-namespace-resolver
Mikael.Angular-BeastCode
mikestead.dotenv
mrmlnc.vscode-apache
ms-azuretools.vscode-docker
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-ssh-explorer
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
neilbrayfield.php-docblocker
persoderlind.vscode-phpcbf
phproberto.vscode-php-getters-setters
sapegin.Theme-SquirrelsongLight
sleistner.vscode-fileutils
stayfool.vscode-asciidoc
stylelint.vscode-stylelint
svelte.svelte-vscode
sysoev.language-stylus
teabyii.ayu
usernamehw.errorlens
vscodevim.vim
wayou.vscode-todo-highlight
whatwedo.twig
Zignd.html-css-class-completion

I cloned the repository and everything seems to be working as expected. I think the problem could be related with another extension.

indentation

Could you try disabling all other extensions? You can disable all and then enable only this one.
https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension

@kotfire I've disabled all installed extension. Still get the same result.

I'm unable to reproduce this myself anymore 🤷‍♂️.