extension_builder icon indicating copy to clipboard operation
extension_builder copied to clipboard

🐛 [BUG] Destroyed Codeformat

Open Gernott opened this issue 3 years ago • 1 comments

Describe the bug After saving an extension with the Extensionbuilder, the codeformat of arrays is destroyed. All is on the left side.

To Reproduce Steps to reproduce the behavior:

  1. format the code of an array (see screenshot)
  2. open and save the Ext with the EB (roundtrip active)
  3. look at the codeformat of the array

TYPO3 Version 10.4.32

Extension Builder Version: Git-branch for TYPO3 10

Additional context Code example for testing:

/**
 * @param string $searchString
 * @param array $contactPersonUids
 */
public function countByFilter($searchString, $contactPersonUids)
{

    // query
    $query = $this->createQuery();
    $query->matching(
    $query->logicalOr(
    [
    $query->like('company', $searchString),
    $query->like('companyaddon', $searchString),
    $query->like('address', $searchString),
    $query->like('city', $searchString),
    $query->in('uid', $contactPersonUids)
    ]
    )
    );

    // only count
    return $query->count();
}

codeformat

Gernott avatar Oct 14 '22 07:10 Gernott

The phpparser has an option for pretty printing: https://github.com/nikic/PHP-Parser/blob/master/doc/component/Pretty_printing.markdown

Have a look at the ParserService class here. It needs to have handed over some more lexer options for the factory method. The challenge is, that you need to keep all those statements and tokens somehow, because you need them later again for printing.

nhovratov avatar Oct 14 '22 07:10 nhovratov