WordPress / WordPress/WordPress-Coding-Standards
Enforce .php file extension if approved
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem?
(Follow-up to #2164)
There may be some assumptions in WordPress core, standards packages for WP, or elsewhere, that PHP files used for WP core, plugins and themes will always have a three-letter file extension (.php). But, it's possible for servers to treat other extensions (.php3, myphp, etc.) also as PHP. A plugin that uses, .php3 file extensions, for instance, may not work (and may render secrets in plain text) so for compatibility reasons, it should be agreed and checkable that only .php extensions are used for PHP files.
As this is not a (handbook) rule, this would need a post on Make to decide whether that rule should be added or not. But if approved, this would need a check in WPCS to enforce.
Describe the solution you'd like
Check that a filename for a PHP file has a .php extension.
Additional context (optional)
If agreed, I would also suggest adding a note to https://make.wordpress.org/hosting/handbook/server-environment/ to confirm to server hosts about which file extensions are needed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing follow-up issue #2164 and the proposed rule in the WordPress Coding Standards repository; no implementation file or test is named here. Confirm through the referenced Make discussion whether the rule is approved, then identify the relevant WPCS entry point and tests. Done means PHP files with non-.php extensions are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100