WordPress / WordPress/WordPress-Coding-Standards
Unsetting a global variable should report an error.
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Bug Description
Unseting a global variable should report an error.
Minimal Code Snippet
global $wp_post_types;
$wp_post_types['post'] = $a_variable // Reports an error, nice.
unset( $wp_post_types['post'] ); // Should report an error.
Environment
| Question | Answer |
|---|---|
| PHP version | 7.3 |
| PHP_CodeSniffer version | 3.5.5 |
| WPCS version | 2.3.0 |
| WPCS install type | Composer project local |
| IDE (if relevant) | VSCode |
Additional Context (optional)
I think this is because unsetting a global variable(just the global variable) should not trigger any error, but it wasn't taken into consideration that can be unset a property/key of that global variable.
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 reproducing the reported PHP_CodeSniffer behavior with the minimal global-variable example in the issue. Trace the WPCS handling for unset global variables and identify the existing regression-test location. Done means the unset array key is reported as an error without changing the behavior for unsetting the global variable itself.
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
- Mostly clear
- Newbie friendliness
- 45/100