prettier / prettier/plugin-php

false, true and null case collision with phpcs

Open
#1,555 7 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

phpcs using Drupal coding standards require for FALSE, TRUE and NULL to be uppercase but prettier formats them to lowercase.
phpcs error message: TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"

prettier@2.0.5

prettier/plugin-php@0.14.3

Input:

  $vars = [
    'account' => $account,
    'manage_access' => FALSE,
  ];

Output:

  $vars = [
    'account' => $account,
    'manage_access' => false,
  ];

Expected behavior:

  $vars = [
    'account' => $account,
    'manage_access' => FALSE,
  ];

Prettier output:

["INFO" - 9:51:20 AM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 9:51:20 AM] Using config file at '.../.prettierrc'
["INFO" - 9:51:20 AM] Prettier Options:
{
  "filepath": "...",
  "parser": "php",
  "useTabs": false,
  "tabWidth": 2,
  "endOfLine": "lf",
  "braceStyle": "1tbs",
}
["INFO" - 9:51:20 AM] Formatting completed in 238.064488ms.

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

Reproduce the issue with the provided PHP input using prettier@2.0.5 and prettier/plugin-php@0.14.3, then inspect the formatter path that handles FALSE, TRUE, and NULL. Done means formatting preserves the uppercase literals required by Drupal coding standards without producing the reported phpcs error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.