WordPress / WordPress/WordPress-Coding-Standards

Sniff to discourage use of number_format() and date() in output

Open
#739 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Focus: DateTime Focus: I18n Type: Enhancement
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

WP has the number_format_i18n() and the date_i18n() functions which allow for localization of numbers and dates.

While the "normal" number_format(), date_format(), date(), gmdate(), gmstrftime() and strftime() all have their place in code, I believe that when used in combination with an output generating function, the WP functions should be encouraged (and the PHP ones discouraged).

Opinions ?

On that note, there is also a PHP money_format() function. I'm not aware of a WP equivalent. Anyone know of one ?

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

No file, test, or entry point is named. Start by reviewing existing sniffs and their tests to determine how output-generating calls are identified; done means the agreed sniff discourages the listed PHP formatting functions in that context while permitting valid non-output uses.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.