prettier / prettier/plugin-php

Add option to define a minimal indentation

Open
#2,138 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.9k
Forks
139
PR merge metrics
No merged PRs in 30d

Description

Hi 👋
I don't know if many people would be interested, I think it would be nice to have an option to define a minimal indentation. like :

--minimal-tab-indent: <Number> (default = 0)

Who, according to --tab-width and --use-tabs would give :
Input:

<?php

array_map(function($arg1,$arg2) use ( $var1, $var2 ) {
    return $arg1+$arg2/($var+$var2);
}, array("complex"=>"code","with"=>
    function() {return "inconsistent";}
,"formatting"=>"is", "hard" => "to", "maintain"=>true));

Output:

// With --tab-width=4, --use-tabs=false and --minimal-tab-indent=1
<?php

    array_map(
        function ($arg1, $arg2) use ($var1, $var2) {
            return $arg1 + $arg2 / ($var + $var2);
        },
        [
            "complex" => "code",
            "with" => function () {
                return "inconsistent";
            },
            "formatting" => "is",
            "hard" => "to",
            "maintain" => true,
        ]
    );

I know it's a really marginal addition but it makes me anxious not to have this indentation that I always use in all my projects 😭

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating how plugin-php handles --tab-width and --use-tabs, then format the PHP example from the issue to understand the current indentation behavior. Done means defining and documenting a minimal indentation option whose output matches the requested example across the relevant tab-width and tab-use settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.