8000 [make:form] fix generated field options_code indentation by IndraGunawan · Pull Request #1469 · symfony/maker-bundle · GitHub
[go: up one dir, main page]

Skip to content

[make:form] fix generated field options_code indentation #1469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

IndraGunawan
Copy link
Contributor
@IndraGunawan IndraGunawan commented Feb 29, 2024

when generating form with EntityType, the indentation of options_code looks wrong

below example is Foo <-- ManyToMany --> Bar
Before

<?php

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('Foo', EntityType::class, [
                'class' => Foo::class,
'choice_label' => 'id',
'multiple' => true,
            ])
        ;
    }

    // ....
}

After

<?php

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('Foo', EntityType::class, [
                'class' => Foo::class,
                'choice_label' => 'id',
                'multiple' => true,
            ])
        ;
    }

    // ....
}

@jrushlow jrushlow added Bug Bug Fix Unconfirmed Status: Needs Review Needs to be reviewed labels Mar 1, 2024
@IndraGunawan IndraGunawan force-pushed the fix-form-options-indent branch from fd7a6fc to 460b499 Compare March 2, 2024 15:48
@IndraGunawan IndraGunawan force-pushed the fix-form-options-indent branch from 460b499 to f58b535 Compare March 2, 2024 15:52
@@ -59,7 +59,7 @@ public function lintPhpTemplate(string|array $templateFilePath): void
$templateFilePath = [$templateFilePath];
}

$ignoreEnv = str_contains(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1&' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
$ignoreEnv = str_starts_with(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
Copy link
Contributor Author
@IndraGunawan IndraGunawan Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrushlow i also made changes on this as these changes didn't seem right https://github.com/symfony/maker-bundle/pull/1435/files#diff-63196606ee883ed9470b1dfceed2cc28540986c0180afdb82e274812fa4690daR59

using str_contains, it was affect Darwin as well

Copy link
Collaborator
@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, Thank you @IndraGunawan

@jrushlow jrushlow added Status: Reviewed Has been reviewed by a maintainer and removed Unconfirmed Status: Needs Review Needs to be reviewed labels Mar 4, 2024
@jrushlow jrushlow merged commit 7706a2f into symfony:main Mar 4, 2024
@jrushlow jrushlow mentioned this pull request Mar 4, 2024
@IndraGunawan IndraGunawan deleted the fix-form-options-indent branch March 4, 2024 06:49
kbond added a commit that referenced this pull request Mar 26, 2025
This PR was merged into the 1.x-dev branch.

Discussion
----------

Fix indentation of options_code

Similar to #1469 but doesn't rely on any CS fixer.

Note that using PHP_EOL was wrong: this constant is meant to be used ONLY when outputting something on a terminal. NOT when dealing with new lines in files.

Commits
-------

91b7ce0 Fix indentation of options_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0