prettier / prettier/plugin-php

Forcing short hand arrays in PHP

Open
#2,123 5 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

It appears the PHP array short hand is being forced for version 5.4 and above?

const useShortForm =
(node.kind === "array" && isMinVersion(options.phpVersion, "5.4")) ||
(node.kind === "list" && node.shortForm

Can this be updated to have the option to override this?

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 from the useShortForm expression shown in the issue and trace how formatter options are read for PHP arrays. Define how an override should interact with the PHP version check, then verify that formatting can preserve the requested array form without changing the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.