Skip to content

Allow formatting of nowdoc/heredoc contents (for example GraphQL or JSON contents) #6986

Closed Answered by ruudk
ruudk asked this question in Q&A
Discussion options

You must be logged in to vote

Sure, this is the solution I came up with. Works pretty well:

<?php

declare(strict_types=1);

namespace Dev\CodeStyle;

use GraphQL\Language\Parser;
use GraphQL\Language\Printer;
use PhpCsFixer\Fixer\FixerInterface;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use SplFileInfo;
use Throwable;

final class GraphQLOperationFixer implements FixerInterface
{
    public function getName() : string
    {
        return 'app/graphql_operation_fixer';
    }

    public function getDefinition() : FixerDefinition
    {
        return new FixerDefinition(
            'Formats GraphQL documents in nowdoc.',
            [],
        );…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ruudk
Comment options

Answer selected by ruudk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants