Skip to content

PromotedConstructorPropertyFixer suggestions #917

@zanderwar

Description

@zanderwar

If the existing class property has a doc block, then the positioning of it when it gets moved to the __constructor is a little whack

Adding the following to the bottom of updateParameterSignature resulted in perfect positioning

foreach ($tokensToInsert as $key => $token) {
    if ($token->isGivenKind(\T_DOC_COMMENT)) {
        $tokensToInsert[$key] = new Token([\T_DOC_COMMENT, PHP_EOL.'    '.preg_replace('/^/m', '    ', $token->getContent())]);
    }
}

$this->tokensToInsert[$propertyStartIndex] = $tokensToInsert;

A few additional options would be nice:

  • keep_class_property_docblocks defaults to true
  • padding defaults to 4spaces

Currently you only put 1 whitespace in front of the promoted property which doesn't follow standards I believe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions