WordPress / WordPress/WordPress-Coding-Standards
Last 3.x minor | Arrays/ArrayDeclarationSpacing: hard-deprecate the `allow_single_item_single_line_associative_arrays` property
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
The allow_single_item_single_line_associative_arrays property was soft-deprecated in #2696 (docblock and changelog only) in favor of the new allow_single_item_single_line_explicit_key_arrays property.
In the last WPCS 3.x release before 4.0, a runtime deprecation warning should be added to notify users still relying on the old property name.
Implementation notes
The pre-2.0 deprecation pattern (see #2691) used $phpcsFile->addWarning() at line 0 to issue a deprecation notice when the old property was changed from its default value.
However, since this is a boolean property with a default of true, checking true !== $this->old_property_name won't catch cases where the old property is explicitly set to its default value. As suggested in https://github.com/WordPress/WordPress-Coding-Standards/issues/2691#issuecomment-3848379126, it may be worth investigating whether making the old property private and using magic methods could solve this detection problem.
To gauge the impact, consider doing some code searches for XML files containing the text allow_single_item_single_line_associative_arrays and potentially submitting PRs to the few repos using the property.
Related: #2691, #2696, #2705
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 with the Arrays/ArrayDeclarationSpacing implementation and the pre-2.0 deprecation pattern referenced in #2691. Search XML files for allow_single_item_single_line_associative_arrays to gauge current use; done means the old property produces a runtime deprecation warning when reliance on it is detected, including consideration of explicit default values.
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
- Mostly clear
- Newbie friendliness
- 35/100