src/PhpParser/Printer/BetterStandardPrinter.php
protected function pStmt_Class(Class_ $class): string
    {
        $shouldReindex = false;

        foreach ($class->stmts as $key => $stmt) {
            if ($stmt instanceof TraitUse) {
                // remove empty ones
                if (count($stmt->traits) === 0) {
                    unset($class->stmts[$key]);
                    $shouldReindex = true;
                }
            }
        }

        if ($shouldReindex) {
            $class->stmts = array_values($class->stmts);
        }

        return parent::pStmt_Class($class);
    }
protected function pStmt_Class(Class_ $class): string
    {
        $shouldReindex = false;

        foreach ($class->stmts as $key => $stmt) {
            if ($stmt instanceof TraitUse) {
                // remove empty ones
                if (count($stmt->traits) === 0) {
                    unset($class->stmts[$key]);
                    $shouldReindex = true;
                }
            }
        }

        if ($shouldReindex) {
            $class->stmts = array_values($class->stmts);
        }

        return parent::pStmt_Class($class);
    }
protected function pStmt_Class ( Class_ $ class ) : string { $ shouldReindex = false ; foreach ( $ class -> stmts as $ key => $ stmt ) { if ( $ stmt instanceof TraitUse ) { // remove empty ones if ( count ( $ stmt -> traits ) === 0 ) { unset ( $ class -> stmts [ $ key ] ) ; $ shouldReindex = true ; } } } if ( $ shouldReindex ) { $ class -> stmts = array_values ( $ class -> stmts ) ; } return parent :: pStmt_Class ( $ class ) ; }
Clean class and trait from empty "use x;" for traits causing invalid code
Clean class and trait from empty use x ; for traits causing invalid code