Skip to content
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

Rules are not applied when "empty" is specified for the preset #289

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

takeshiemoto
Copy link
Contributor

I discovered a bug where the rules written in the rules section are not applied when the following settings are written in pint.json:

{
    "preset": "empty",
    "rules": {
        "array_syntax": true
    }
}

I made a fix because ConfigurationFactory::preset([]) is not called unless "empty" is added to the available presets.

I tried writing the following code and compared the cases where "empty" is not present in $presets and where it is present:

$example = array();

When "empty" is not present:

❯ ./pint -v --preset=empty --test


  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Empty
    PASS   ........................................................................................................................................................................................................................................................... 0 files

When "empty" is present:

❯ ./pint -v --preset=empty --test

  .............⨯................................

  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Empty
    FAIL   ........................................................................................................................................................................................................................................... 46 files, 1 style issue
  ⨯ app/Factories/ConfigurationResolverFactory.php                                                                                                                                                                                                                array_syntax
  @@ -34,7 +34,7 @@
        */
       public static function fromIO($input, $output)
       {
  -        $example = array();
  +        $example = [];
           $path = Project::paths($input);

           $localConfiguration = resolve(ConfigurationJsonRepository::class);

It can be seen that the rules are correctly applied.

@imanghafoori1
Copy link
Contributor

Yes, we need to add it in there.

@driesvints driesvints merged commit 7726d48 into laravel:main Aug 1, 2024
8 checks passed
@driesvints
Copy link
Member

Thanks! I'll release this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants