Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[THEME-3651] Update the PHPCS rules #2

Merged
merged 1,138 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1138 commits
Select commit Hold shift + click to select a range
e38b250
Arrays/ArrayDeclarationSpacing::process_multi_line_array(): remove re…
jrfnl Jul 10, 2023
7c87f4f
Arrays/ArrayDeclarationSpacing::process_single_line_array(): lower ne…
jrfnl Jul 10, 2023
c7eae91
Arrays/ArrayDeclarationSpacing: minor test tweaks
jrfnl Jul 10, 2023
ceff5f5
Merge pull request #2300 from WordPress/feature/validvariablename-bri…
dingo-d Jul 11, 2023
0734364
Merge pull request #2301 from WordPress/feature/arraydeclarationspaci…
dingo-d Jul 11, 2023
5c04d9d
Core: add section about trait use statement rules with select new sniffs
jrfnl Oct 28, 2022
a510c20
Merge pull request #2303 from WordPress/feature/core-add-trait-use-rules
GaryJones Jul 19, 2023
0ed93af
Composer: update PHPCSUtils + PHPCSExtra
jrfnl Jul 19, 2023
1767f3a
Merge pull request #2307 from WordPress/feature/composer-update-phpcs…
dingo-d Jul 20, 2023
33f0361
Core: add some more sniffs for import `use` statements
jrfnl Jun 18, 2023
098012a
Extra: add sniff to detect inefficient "echo sprintf(...)"
jrfnl Jun 18, 2023
20029ed
Replace the WordPress.Array.CommaAfterArrayItem sniff
jrfnl Jul 17, 2023
2277863
Merge pull request #2310 from WordPress/feature/core-replace-arrays-c…
GaryJones Jul 20, 2023
0fe8f4f
Merge pull request #2309 from WordPress/feature/extra-ruleset-add-noe…
GaryJones Jul 20, 2023
61217ff
Merge pull request #2308 from WordPress/feature/core-ruleset-add-more…
GaryJones Jul 20, 2023
6e3f97e
Rulesets: various minor tweaks
jrfnl Jun 12, 2023
e6b50e6
Merge pull request #2312 from WordPress/feature/ruleset-tweaks-tidy-up
dingo-d Jul 21, 2023
7fd57b7
DB/PreparedSQLPlaceholders: final fixes for %i support
jrfnl Jul 21, 2023
f59e3d5
Merge pull request #2072 from craigfrancis/patch-1
jrfnl Jul 21, 2023
fcea43c
DB/PreparedSQLPlaceholders: add extra tests
jrfnl Jan 11, 2023
671289d
DB/PreparedSQLPlaceholders: make variables used explicit
jrfnl Jul 22, 2023
27ca935
DB/PreparedSQLPlaceholders: implement PHPCSUtils
jrfnl Jan 11, 2023
0f7b3ad
DB/PreparedSQLPlaceholders: minor simplification
jrfnl Jul 22, 2023
7004173
DB/PreparedSQLPlaceholders: prevent false positive due to comments in…
jrfnl Jul 22, 2023
abcba3d
DB/PreparedSQLPlaceholders: prevent false negative due to comments in…
jrfnl Jul 22, 2023
4fc71c3
DB/PreparedSQLPlaceholders: prevent false positive due to comments in…
jrfnl Jul 22, 2023
eee85c0
DB/PreparedSQLPlaceholders: bug fix - allow for FQN function calls
jrfnl Jul 22, 2023
7a4259f
DB/PreparedSQLPlaceholders: bug fix - sniff could skip too much
jrfnl Jul 22, 2023
7d06fbb
DB/PreparedSQLPlaceholders: improve error message precision for Ident…
jrfnl Jul 22, 2023
bc75ffe
DB/PreparedSQLPlaceholders: improve error message precision for Quote…
jrfnl Jul 22, 2023
01c5bf4
DB/PreparedSQLPlaceholders: prevent token walking too far
jrfnl Jul 22, 2023
e2f237f
DB/PreparedSQLPlaceholders: add tests with PHP 7.3+ trailing commas i…
jrfnl Jul 22, 2023
d61a616
DB/PreparedSQLPlaceholders: add tests with PHP 8.0+ nullsafe object o…
jrfnl Jul 22, 2023
b1c9095
DB/PreparedSQLPlaceholders: add tests with PHP 8.0+ nullsafe object o…
jrfnl Jul 22, 2023
8f745ff
DB/PreparedSQLPlaceholders: add support for PHP 8.0+ named parameters…
jrfnl Jan 11, 2023
7e13937
DB/PreparedSQLPlaceholders: add support for PHP 8.0+ named parameters…
jrfnl Jan 11, 2023
995ff43
DB/PreparedSQLPlaceholders: add support for PHP 8.0+ named parameters…
jrfnl Apr 8, 2023
6063a6a
DB/PreparedSQLPlaceholders: add support for PHP 8.0+ named parameters…
jrfnl Jul 22, 2023
57df20c
DB/PreparedSQLPlaceholders: add tests with PHP 8.1+ first class callable
jrfnl Jul 22, 2023
9045552
DB/PreparedSQLPlaceholders: minor documentation fix
jrfnl Apr 12, 2023
7112225
Docs: various minor tweaks
jrfnl Jul 4, 2023
690f93e
Merge pull request #2313 from WordPress/feature/various-minor-doc-tweaks
dingo-d Jul 23, 2023
824ba43
NamingConventions/PrefixAllGlobals: order constants list alphabetically
jrfnl Jul 2, 2023
3fe65af
NamingConventions/PrefixAllGlobals: update the constants list based o…
jrfnl Jul 2, 2023
aeacb6c
NamingConventions/ValidPostTypeSlug: order reserved names alphabetically
jrfnl Jul 2, 2023
af770df
NamingConventions/ValidPostTypeSlug: update the reserved post types l…
jrfnl Jul 2, 2023
72fd88b
WP/ClassNameCase: update the class lists based on WP 6.3-RC1
jrfnl Jul 1, 2023
f71b5ce
WP/ClassNameCase: add list of `Twenty*` themes classes
jrfnl Jul 1, 2023
3cae0a4
WP/DeprecatedClasses: update the class list based on WP 6.3-RC1
jrfnl Jul 1, 2023
090aa17
WP/DeprecatedFunctions: update the functions list based on WP 6.3-RC1
jrfnl Jul 1, 2023
57bea4d
WP/DeprecatedParameters: update the list based on WP 6.3-RC1
jrfnl Jul 1, 2023
b71cf17
Merge pull request #2320 from WordPress/feature/deprecatedparameters-…
dingo-d Jul 23, 2023
946ee44
Merge pull request #2319 from WordPress/feature/deprecatedfunctions-u…
dingo-d Jul 23, 2023
894a372
Merge pull request #2318 from WordPress/feature/deprecatedclasses-upd…
dingo-d Jul 23, 2023
d65600c
Merge pull request #2317 from WordPress/feature/classnamecase-update-…
dingo-d Jul 23, 2023
0a5905e
Merge pull request #2316 from WordPress/feature/validposttypeslug-upd…
dingo-d Jul 23, 2023
cfe143d
Merge pull request #2315 from WordPress/feature/prefixallglobals-upda…
dingo-d Jul 23, 2023
bf9d82a
Merge pull request #2314 from WordPress/feature/db-preparedsqlplaceho…
dingo-d Jul 23, 2023
230535a
Update the `minimum_wp_version` to WP 6.0
jrfnl Jun 26, 2023
f04d9d6
.gitattributes: minor update
jrfnl Jun 25, 2023
67d98d2
PHPUnit config: remove file which no longer exists
jrfnl Jul 1, 2023
942e786
Merge pull request #2321 from WordPress/feature/minimumwpversion-up-t…
dingo-d Jul 24, 2023
e14fd95
Merge pull request #2322 from WordPress/feature/gitattributes-sync
dingo-d Jul 24, 2023
2c593e4
Merge pull request #2323 from WordPress/feature/phpunit-update-file-list
dingo-d Jul 24, 2023
01d23a6
Core/Extra: tweak the inclusion of the `Modernize.FunctionCalls.Dirna…
jrfnl Jul 26, 2023
ca2da67
Merge pull request #2324 from WordPress/feature/core-update-dirname-s…
GaryJones Jul 26, 2023
208516e
EscapingFunctionsTrait: add esc_xml() to the list of escaping functions
jrfnl Jul 27, 2023
ed8c30d
EscapingFunctionsTrait: add wp_timezone_choice() to the list of auto-…
jrfnl Jul 27, 2023
38d3d6e
EscapingFunctionsTrait: add wp_readonly() to the list of auto-escaped…
jrfnl Jul 27, 2023
73be58a
SanitizingFunctionsTrait: add sanitize_url() to the list of sanitizat…
jrfnl Jul 27, 2023
b1ae705
[SanitizingFunctions|EscapingFunctions]Trait: add wp_kses_one_attr() …
jrfnl Jul 27, 2023
7cb6224
Merge pull request #2325 from WordPress/feature/update-various-functi…
GaryJones Jul 27, 2023
5794920
Security/EscapeOutput: rename test case file
jrfnl Jul 23, 2023
7d39aad
Security/EscapeOutput: move parse error related test to separate file
jrfnl Jul 26, 2023
2b5fa26
Security/EscapeOutput: use Tokens::$magicConstants
jrfnl Jun 30, 2020
93033c6
Security/EscapeOutput: use PHPCSUtils
jrfnl Jul 26, 2023
9af97f4
Security/EscapeOutput: normalize the `$safe_components` array
jrfnl Jul 26, 2023
26095ef
Security/EscapeOutput: bug fix - expand the "safe components" list
jrfnl Jul 27, 2023
268d415
Security/EscapeOutput: split `process_token()` method [1]
jrfnl Jul 23, 2023
4221832
Security/EscapeOutput: split `process_token()` method [2]
jrfnl Jul 24, 2023
51dd364
Security/EscapeOutput: bug fix - false positives on non-function calls
jrfnl Jul 24, 2023
8d1fffb
Helpers/PrintingFunctionsTrait: add `get_printing_functions()` method
jrfnl Jul 23, 2023
4f57d4c
Security/EscapeOutput: bug fix - false positives on non-global functi…
jrfnl Jul 24, 2023
ecbc52f
Security/EscapeOutput: bug fix - function names are case-insensitive
jrfnl Jul 24, 2023
530de77
Security/EscapeOutput: prevent false positive due to comments in param
jrfnl Jul 26, 2023
616c2c9
Security/EscapeOutput: code readability improvements [1]
jrfnl Jul 24, 2023
511787d
Security/EscapeOutput: bug fix - only examine exit/die with parentheses
jrfnl Jul 24, 2023
793fc7e
Security/EscapeOutput: bug fix - improve start/end determination for …
jrfnl Jul 25, 2023
f882b53
Security/EscapeOutput: efficiency tweak for parse errors in echo stat…
jrfnl Jul 25, 2023
2d76c1d
Security/EscapeOutput: fix up after refactor
jrfnl Jul 25, 2023
0167eb7
Security/EscapeOutput: bug fix - allow for nested statements with ter…
jrfnl Jul 25, 2023
6bcb6b0
Security/EscapeOutput: bug fix - [improved] allow for nested statemen…
jrfnl Jul 26, 2023
a59a60f
Security/EscapeOutput: bug fix - allow non-matching parentheses
jrfnl Jul 26, 2023
fd3101a
Security/EscapeOutput: bug fix - fix ternary finding within the loop
jrfnl Jul 26, 2023
e15a50e
Security/EscapeOutput: bug fix - false negatives for short ternary
jrfnl Jul 26, 2023
05df272
Security/EscapeOutput: code readability improvements [2]
jrfnl Jul 25, 2023
d49715f
Security/EscapeOutput: efficiency tweak [1]
jrfnl Jul 25, 2023
f3bd49b
Security/EscapeOutput: efficiency tweak [2]
jrfnl Jul 25, 2023
b6ec4a2
Security/EscapeOutput: bug fix - sniff would skip too much
jrfnl Jul 25, 2023
2dcd742
Security/EscapeOutput: bug fix - sniff did not handle function call p…
jrfnl Jul 26, 2023
05de946
Security/EscapeOutput: add tests for PHP 7.4 numeric literals + PHP 8…
jrfnl Jul 25, 2023
f108735
Security/EscapeOutput: add support for PHP 8.0+ named parameters [1]
jrfnl Jul 25, 2023
4a4858c
Security/EscapeOutput: add support for PHP 8.0+ named parameters [2]
jrfnl Jul 25, 2023
eab1f2b
Security/EscapeOutput: add support for PHP 8.0+ match expressions [1]
jrfnl Jul 26, 2023
3987f6d
Security/EscapeOutput: add support for PHP 8.0+ match expressions [2]
jrfnl Jul 26, 2023
4ee9469
Security/EscapeOutput: add support for *::class and PHP 8.0+ $obj::class
jrfnl Jul 26, 2023
90f291c
Security/EscapeOutput: add support for examining throw statements and…
jrfnl Jul 27, 2023
b501cd9
Security/EscapeOutput: improve handling of inline expressions
jrfnl Jul 27, 2023
ad2b2a1
Security/EscapeOutput: improve handling of params in unsafe printing …
jrfnl Jul 27, 2023
8e7b9a4
Security/EscapeOutput: very minor code readability improvements [3]
jrfnl Jul 27, 2023
2f40190
Security/EscapeOutput: bug fix - sniff did not handle arrays correctly
jrfnl Jul 27, 2023
3ccc769
Security/EscapeOutput: group common token check together
jrfnl Jul 27, 2023
1689ea5
Security/EscapeOutput: improve handling of heredocs, include PHP 7.3+…
jrfnl Jul 27, 2023
2db499f
Security/EscapeOutput: improve handling of params in formatting funct…
jrfnl Jul 27, 2023
f165714
Security/EscapeOutput: special case get_search_query( false )
jrfnl Jul 28, 2023
bb0b7d6
Security/EscapeOutput: various minor docs fixes
jrfnl Jul 27, 2023
efbaa1d
Merge pull request #2326 from WordPress/feature/escapeoutput-review-p…
dingo-d Jul 28, 2023
72be374
Core: properly check formatting of function declaration statements
jrfnl Aug 10, 2023
dfc72e4
CS: fix up closure spacing to comply with new rules
jrfnl Aug 10, 2023
602d9ef
GlobalVariablesOverride: move parse error test to separate file
jrfnl Aug 11, 2023
a025c6d
Composer: make PHP extension dependencies explicit
jrfnl Jun 25, 2023
9cf9f24
Merge pull request #2330 from WordPress/feature/composer-make-extensi…
dingo-d Aug 11, 2023
306542c
Merge pull request #2328 from WordPress/feature/core-check-function-d…
GaryJones Aug 11, 2023
38c950e
Docs: remove redundant `@package` tags
jrfnl Aug 11, 2023
e17e05c
Merge pull request #2331 from WordPress/feature/docs-remove-redundant…
dingo-d Aug 12, 2023
3c04dc7
Add release checklist
jrfnl Jun 30, 2023
71d8fed
Release checklist: update for review comments
jrfnl Aug 11, 2023
e1b4418
Merge pull request #2329 from WordPress/feature/add-release-checklist
dingo-d Aug 12, 2023
f6adf52
Whitespace/ControlStructureSpacing: sync with upstream [1]
jrfnl May 31, 2022
e1ae45b
Whitespace/ControlStructureSpacing: sync with upstream [2]
jrfnl Aug 13, 2023
2b1ba78
Whitespace/ControlStructureSpacing: sync with upstream [3]
jrfnl Aug 14, 2023
c355ab9
Whitespace/ControlStructureSpacing: sync with upstream [4]
jrfnl Aug 14, 2023
e5d967e
WhiteSpace/ControlStructureSpacing: implement PHPCSUtils
jrfnl Jun 30, 2020
612b555
WhiteSpace/ControlStructureSpacing: fix/update class docblock
jrfnl May 31, 2022
2d7f396
Merge pull request #2333 from WordPress/feature/controlstructurespaci…
dingo-d Aug 14, 2023
b42e428
Docs: remove orphaned CommaAfterArrayItem docs
jrfnl Aug 15, 2023
7e9185f
Docs: remove orphaned ClassInstantiation docs
jrfnl Aug 15, 2023
09c629f
WhiteSpace/ControlStructureSpacing: add documentation
jrfnl Aug 15, 2023
9c23de6
Docs: update the sample ruleset
jrfnl Nov 26, 2022
46810c6
Merge pull request #2335 from WordPress/feature/removed-orphaned-docs
dingo-d Aug 15, 2023
9518e8e
Merge pull request #2334 from WordPress/docs/WordPress.WhiteSpace.Con…
dingo-d Aug 15, 2023
3bca142
Merge pull request #2336 from WordPress/feature/example-ruleset-update
GaryJones Aug 16, 2023
77cbc30
Code coverage: initial setup for CodeCov
jrfnl Apr 9, 2020
d3b0a0c
Utils/I18nTextDomainFixer: use PHPCSUtils in one more place
jrfnl Aug 17, 2023
248485a
WP/Capabilities: minor clean up
jrfnl Aug 17, 2023
3a398c4
DB/DirectDatabaseQuery: minor defensive coding tweak
jrfnl Aug 17, 2023
480b1af
Files/FileName: minor defensive coding tweak in test code
jrfnl Aug 17, 2023
782f8fe
DateTime/CurrentTimeTimestamp: rename some local variables
jrfnl Aug 16, 2023
29670d7
WhiteSpace/ControlStructureSpacing: minor defensive coding tweak
jrfnl Aug 17, 2023
f119d86
Docs: array properties expect arrays
jrfnl Aug 17, 2023
ba92929
Merge pull request #2338 from WordPress/feature/add-code-coverage-rec…
dingo-d Aug 17, 2023
eb8fe7e
Merge pull request #2345 from WordPress/feature/docs-public-array-pro…
GaryJones Aug 17, 2023
c3b5b2b
Merge pull request #2344 from WordPress/feature/controlstructurespaci…
GaryJones Aug 17, 2023
f401dac
Merge pull request #2343 from WordPress/feature/filename-defensive-co…
GaryJones Aug 17, 2023
23bfa84
Merge pull request #2342 from WordPress/feature/directdbquery-minor-d…
GaryJones Aug 17, 2023
4ac8ad7
Merge pull request #2341 from WordPress/feature/currenttimetimestamp-…
GaryJones Aug 17, 2023
0957f5a
Merge pull request #2340 from WordPress/feature/capabilities-minor-cl…
GaryJones Aug 17, 2023
04dba47
Merge pull request #2339 from WordPress/feature/i18ntextdomainfixer-u…
GaryJones Aug 17, 2023
fa06a59
Sniff: move "missing unslashing" handling to callback function
jrfnl Aug 17, 2023
754dfd2
README: fix codecov badge
jrfnl Aug 17, 2023
31cef73
Merge pull request #2348 from WordPress/feature/readme-fix-codecov-badge
GaryJones Aug 17, 2023
e31c0cb
Merge pull request #2347 from WordPress/feature/move-unslash-handling…
GaryJones Aug 17, 2023
315d4e0
QA/CS: various minor tweaks
jrfnl Mar 19, 2023
dcdd602
QA/CS: alphabetize import use statements
jrfnl Mar 19, 2023
1bed57e
GH Actions: fix quicktest for `develop`
jrfnl Aug 17, 2023
d180742
Issue template: minor tweaks
jrfnl Aug 17, 2023
15a790b
Changelog: update references to the Composer PHPCS plugin
jrfnl Aug 17, 2023
84cb209
Codecov config: tweak patch config
jrfnl Aug 17, 2023
21d8cae
Rename `SanitizingFunctionsTrait` to `SanitizationHelperTrait`
jrfnl Aug 18, 2023
50e1fe9
Move sanitization methods to `SanitizationHelperTrait`
jrfnl Jul 6, 2023
e72ca2c
SanitizationHelperTrait::is_sanitized(): add some defensive coding
jrfnl Aug 18, 2023
b217ebc
SanitizationHelperTrait::is_sanitized(): implement PHPCSUtils
jrfnl Jul 6, 2023
0834f59
SanitizationHelperTrait::is_sanitized(): efficiency tweak - move unse…
jrfnl Aug 18, 2023
1bf115b
SanitizationHelperTrait::is_sanitized(): efficiency fix/improve perfo…
jrfnl Aug 18, 2023
6440bed
SanitizationHelperTrait::is_sanitized(): minor code tweaks
jrfnl Aug 18, 2023
2d019df
SanitizationHelperTrait::is_sanitized(): minor doc tweaks
jrfnl Aug 18, 2023
8da663b
Merge pull request #2356 from WordPress/feature/sniff-move-is_sanitiz…
dingo-d Aug 18, 2023
f9a73b4
Merge pull request #2350 from WordPress/feature/ghactions-fix-quick-test
dingo-d Aug 18, 2023
b4975aa
Merge pull request #2351 from WordPress/feature/issue-templates-tweaks
dingo-d Aug 18, 2023
59984c3
Merge pull request #2352 from WordPress/feature/changelog-update-comp…
dingo-d Aug 18, 2023
25d2e7e
Merge pull request #2353 from WordPress/feature/codecov-tweak-config
dingo-d Aug 18, 2023
659e3d3
Various minor doc fixes
jrfnl Aug 7, 2023
2e73eba
Docs: improve test `@return` tags
jrfnl Aug 16, 2023
b0fc0c0
Docs: more `@var`/`@param`/`@return` tag improvements
jrfnl Aug 16, 2023
6a9da70
Docs: add missing `@return` tags
jrfnl Aug 17, 2023
cfecf3f
Merge pull request #2349 from WordPress/feature/various-minor-docs-fixes
dingo-d Aug 18, 2023
c24b906
Merge pull request #2354 from WordPress/feature/various-cs-fixes
dingo-d Aug 18, 2023
d6e47ab
Add PHPStan to QA checks
jrfnl Aug 17, 2023
75a78cf
Merge pull request #2355 from WordPress/feature/ghactions-add-phpstan
dingo-d Aug 18, 2023
36c2df6
Updates related to branch rename from `master` to `main`
jrfnl Nov 26, 2022
ea871fb
Make methods in traits `final`
jrfnl Jun 14, 2023
5f565a1
Merge pull request #2360 from WordPress/feature/update-references-aft…
GaryJones Aug 18, 2023
d199361
Merge pull request #2361 from WordPress/feature/helpers-final-trait-m…
GaryJones Aug 18, 2023
bd66ced
ValidationHelper: bug fix - unsetting is not validation
jrfnl Aug 18, 2023
0883596
ValidationHelper: bug fix - validation done in another scope
jrfnl Aug 18, 2023
087249d
Security/ValidatedSanitizedInput: make sure all superglobals being ex…
jrfnl Aug 18, 2023
a594136
Security/ValidatedSanitizedInput: use PHPCSUtils for superglobal dete…
jrfnl Jun 27, 2022
d2a52ce
Security/ValidatedSanitizedInput: use PHPCSUtils for superglobal dete…
jrfnl Aug 18, 2023
57db689
Security/ValidatedSanitizedInput: add extra test for PHP 7.4+ null co…
jrfnl Aug 18, 2023
6e0a6c9
Security/ValidatedSanitizedInput: add test with PHP 8.0+ match [1]
jrfnl Aug 18, 2023
be30b5e
Security/ValidatedSanitizedInput: add tests with PHP 8.0+ match [2]
jrfnl Aug 18, 2023
f69e595
Security/ValidatedSanitizedInput: make `MissingUnslash` message more …
jrfnl Aug 18, 2023
5f8fe49
Security/ValidatedSanitizedInput: make closures static
jrfnl Aug 18, 2023
8c81cc6
CS: closures not using `$this` should be static
jrfnl Aug 18, 2023
4e8f340
Merge pull request #2363 from WordPress/feature/cs-closures-should-be…
GaryJones Aug 19, 2023
1eb217b
Merge pull request #2362 from WordPress/feature/validatedsanitizedinp…
GaryJones Aug 19, 2023
0b548b9
Helpers: add type declarations whenever possible
jrfnl Apr 17, 2023
977e3f2
Sniff: remove `init()` method
jrfnl Aug 20, 2023
afbd469
Merge pull request #2365 from WordPress/feature/helpers-use-type-decl…
dingo-d Aug 20, 2023
185308a
Merge pull request #2364 from WordPress/feature/sniff-remove-init-method
dingo-d Aug 20, 2023
d3a58e9
Tests: Remove redundant placeholder function
GaryJones Aug 20, 2023
d847317
README: updates for WordPressCS 3.0.0
jrfnl Aug 20, 2023
4a33d46
CONTRIBUTING: updates for WordPressCS 3.0.0
jrfnl Aug 20, 2023
71dc238
Docs: miscellaneous changes
jrfnl Aug 17, 2023
1413982
Merge pull request #2367 from WordPress/feature/docs-update-readme-co…
dingo-d Aug 20, 2023
c2d244c
Merge pull request #2366 from WordPress/replace-non-inclsuive-test-fu…
jrfnl Aug 21, 2023
e36e0ea
Changelog for WordPressCS 3.0.0 (#2368)
jrfnl Aug 21, 2023
bb792cb
Merge pull request #2369 from WordPress/develop
jrfnl Aug 21, 2023
387784c
Docs: Use WordPress.Files.FileName rule instead of WordPress.Files.Fi…
dawidurbanski Sep 3, 2023
c961efc
Merge pull request #2376 from dawidurbanski/docs/fix-case-sensitive-r…
dingo-d Sep 3, 2023
d7d4de3
GH Actions: add task to test example ruleset
jrfnl Sep 3, 2023
20c8503
Security/EscapeOutputSniff: More modular error codes
anomiex Sep 3, 2023
0cda979
Merge pull request #2377 from WordPress/feature/2375-ghactions-test-s…
GaryJones Sep 3, 2023
9385487
Keep the old code for `trigger_error`
anomiex Sep 4, 2023
f5590ce
Default `$code` per request
anomiex Sep 5, 2023
fe4fa45
Update readme of the project
dingo-d Aug 28, 2023
45cff8d
Update README.md
dingo-d Sep 10, 2023
4367be3
Merge pull request #2372 from WordPress/feature/update-funding-page
GaryJones Sep 10, 2023
d3c67d8
Funding: fix format
jrfnl Sep 10, 2023
caa0a8b
Merge pull request #2382 from WordPress/feature/fix-funding
GaryJones Sep 11, 2023
401e4ec
Release checklist: add link to monthly dev blog
jrfnl Sep 11, 2023
81f40bc
Merge pull request #2383 from WordPress/feature/update-release-checklist
dingo-d Sep 11, 2023
d0e0fd3
Merge pull request #2378 from anomiex/add/escapeoutput-error-codes-fo…
dingo-d Sep 13, 2023
dd9b567
Add dependabot configuration file
jrfnl Sep 12, 2023
9f57f6b
Add changelog for v3.0.1
dingo-d Sep 13, 2023
289cf43
Merge pull request #2385 from WordPress/feature/changelog-for-wpcs-3.…
dingo-d Sep 14, 2023
b4caf96
Merge pull request #2386 from WordPress/develop
dingo-d Sep 14, 2023
991cf21
Fix the release date in the changelog
dingo-d Sep 14, 2023
e02529f
Merge pull request #2384 from WordPress/feature/add-dependabot-config…
GaryJones Sep 14, 2023
82d5c91
GH Actions: Bump actions/checkout from 3 to 4
dependabot[bot] Sep 14, 2023
1a8bdf2
Merge pull request #2388 from WordPress/hofix/changelog-date-update
jrfnl Sep 14, 2023
e6b3033
Merge pull request #2389 from WordPress/dependabot/github_actions/act…
GaryJones Sep 14, 2023
25033a6
Add defensive coding to posts per page sniff and add tests
dingo-d Sep 18, 2023
54ad2d7
Merge pull request #2392 from WordPress/hotfix/2390-internal-error
jrfnl Sep 18, 2023
1d95bda
README: minor tweak
jrfnl Sep 20, 2023
7722c0b
Merge pull request #2393 from WordPress/feature/readme-minor-tweak
GaryJones Sep 20, 2023
f4df8e7
Merge with develop (THEME-3651)
KamilBaczkowski Oct 17, 2023
061a839
Add a sniff that checks if double arrows use only 1 space THEME-3651
KamilBaczkowski Oct 17, 2023
5055cf1
Add a sniff that checks if equal signs only have one space before the…
KamilBaczkowski Oct 18, 2023
5146982
Rebuild
KamilBaczkowski Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
codecov:
notify:
after_n_builds: 4

coverage:
round: nearest
# Status will be green when coverage is between 90 and 100%.
range: "90...100"
status:
project:
default:
target: auto
threshold: 1%
paths:
- "WordPress"
patch: off

ignore:
- "WordPress/Tests"

comment: false
20 changes: 12 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#
# Exclude these files from release archives.
# This will also make them unavailable when using Composer with `--prefer-dist`.
# If you develop for WPCS using Composer, use `--prefer-source`.
# If you develop for WordPressCS using Composer, use `--prefer-source`.
# https://blog.madewithlove.be/post/gitattributes/
#
/.travis.yml export-ignore
/.phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/bin export-ignore
/WordPress/Tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.codecov.yml export-ignore
/.phpcs.xml.dist export-ignore
/CODE_OF_CONDUCT.md export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/Tests export-ignore
/WordPress/Tests export-ignore

#
# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
# https://pablorsk.medium.com/be-a-git-ninja-the-gitattributes-file-e58c07c9e915
#
* text=auto

Expand Down
150 changes: 68 additions & 82 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ Bug reports containing a minimal code sample which can be used to reproduce the

## Upstream Issues

Since WPCS employs many sniffs that are part of PHPCS, sometimes an issue will be caused by a bug in PHPCS and not in WPCS itself. If the error message in question doesn't come from a sniff whose name starts with `WordPress`, the issue is probably a bug in PHPCS itself, and should be [reported there](https://github.com/squizlabs/PHP_CodeSniffer/issues).
Since WordPressCS employs many sniffs that are part of PHP_CodeSniffer itself or PHPCSExtra, sometimes an issue will be caused by a bug in PHPCS or PHPCSExtra and not in WordPressCS itself.
If the error message in question doesn't come from a sniff whose name starts with `WordPress`, the issue is probably a bug in PHPCS or PHPCSExtra.

* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/squizlabs/PHP_CodeSniffer/issues).
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).

# Contributing patches and new features

## Branches

Ongoing development will be done in the `develop` branch with merges done into `master` once considered stable.

To contribute an improvement to this project, fork the repo and open a pull request to the `develop` branch. Alternatively, if you have push access to this repo, create a feature branch prefixed by `feature/` and then open an intra-repo PR from that branch to `develop`.
Ongoing development will be done in the `develop` branch with merges to `main` once considered stable.

Once a commit is made to `develop`, a PR should be opened from `develop` into `master` and named "Next release". This PR will provide collaborators with a forum to discuss the upcoming stable release.
To contribute an improvement to this project, fork the repo, run `composer install`, make your changes to the code, run the unit tests and code style checks by running `composer check-all`, and if all is good, open a pull request to the `develop` branch.
Alternatively, if you have push access to this repo, create a feature branch prefixed by `feature/` and then open an intra-repo PR from that branch to `develop`.

# Considerations when writing sniffs

Expand All @@ -32,105 +35,87 @@ Only make a property `public` if that is the intended behaviour.

When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.

## Whitelist comments

> **Important**:
> PHPCS 3.2.0 introduced new selective ignore annotations, which can be considered an improved version of the whitelist mechanism which WPCS contains.
>
> Support for the WPCS native whitelist comments has been deprecated in WPCS 2.0.0 and will be removed in WPCS 3.0.0.
>
> With that in mind, (new) sniffs should not introduce new WPCS native whitelist comments.


# Unit Testing

## Pre-requisites
* WordPress-Coding-Standards
* PHP_CodeSniffer 3.3.1 or higher
* PHP_CodeSniffer 3.7.2 or higher
* PHPCSUtils 1.0.8 or higher
* PHPCSExtra 1.1.0 or higher
* PHPUnit 4.x, 5.x, 6.x or 7.x

The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test suite for unit testing the sniffs.

Presuming you have installed `PHP_CodeSniffer` and the WordPress-Coding-Standards as [noted in the README](https://github.com/WordPress/WordPress-Coding-Standards#how-to-use-this), all you need now is `PHPUnit`.

> N.B.: If you installed WPCS using Composer, make sure you used `--prefer-source` or run `composer install --prefer-source` now to make sure the unit tests are available.
> Other than that, you're all set already as Composer will have installed PHPUnit for you.
The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test framework for unit testing the sniffs.

If you already have PHPUnit installed on your system: Congrats, you're all set.
## Getting ready to test

## Installing PHPUnit
Presuming you have cloned WordPressCS for development, to run the unit tests you need to make sure you have run `composer install` from the root directory of your WordPressCS git clone.

N.B.: _If you used Composer to install the WordPress Coding Standards, you can skip this step._
## Custom develop setups

You can either navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies or you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.4/installation.html) as a PHAR file.

You may want to add the directory where PHPUnit is installed to a `PATH` environment variable for your operating system to make the command available everywhere on your system.

## Before running the unit tests

N.B.: _If you used Composer to install the WordPress Coding Standards, you can skip this step._

For the unit tests to work, you need to make sure PHPUnit can find your `PHP_CodeSniffer` install.

The easiest way to do this is to add a `phpunit.xml` file to the root of your WPCS installation and set a `PHPCS_DIR` environment variable from within this file.
Copy the existing `phpunit.xml.dist` file and add the below `<env>` directive within the `<php>` section. Make sure to adjust the path to reflect your local setup.
```xml
<php>
<env name="PHPCS_DIR" value="/path/to/PHP_CodeSniffer/"/>
</php>
```
If you are developing with a stand-alone PHP_CodeSniffer (git clone) installation and want to use that git clone to test WordPressCS, there are three extra things you need to do:
1. Install [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils).
If you are using a git clone of PHPCS, you may want to `git clone` PHPCSUtils as well.
2. Register PHPCSUtils with your stand-alone PHP_CodeSniffer installation by running the following commands:
```bash
phpcs --config-show
```
Copy the value from "installed_paths" and add the path to your local install of PHPCSUtils to it (and the path to WordPressCS if it's not registered with PHPCS yet).
Now use the adjusted value to run:
```bash
phpcs --config-set installed_paths /path/1,/path/2,/path/3
```
3. Make sure PHPUnit can find your `PHP_CodeSniffer` install.
The most straight-forward way to do this is to add a `phpunit.xml` file to the root of your WordPressCS installation and set a `PHPCS_DIR` environment variable from within this file.
Copy the existing `phpunit.xml.dist` file and add the below `<env>` directive within the `<php>` section. Make sure to adjust the path to reflect your local setup.
```xml
<php>
<env name="PHPCS_DIR" value="/path/to/PHP_CodeSniffer/"/>
</php>
```

## Running the unit tests

* If you didn't install WPCS using Composer, make sure you have registered the directory in which you installed WPCS with PHPCS using:
```sh
phpcs --config-set installed_paths path/to/WPCS
```
* Navigate to the directory in which you installed WPCS.
* To run the unit tests:
```sh
phpunit --filter WordPress --bootstrap="/path/to/PHP_CodeSniffer/tests/bootstrap.php" /path/to/PHP_CodeSniffer/tests/AllTests.php
From the root of your WordPressCS install, run the unit tests like so:
```bash
composer run-tests

# Or if you've installed WPCS with Composer:
composer run-tests
```
# Or if you want to use a globally installed version of PHPUnit:
phpunit --filter WordPress /path/to/PHP_CodeSniffer/tests/AllTests.php
```

Expected output:
```
PHPUnit 7.5.0 by Sebastian Bergmann and contributors.
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

Runtime: PHP 7.2.13
Configuration: /WordPressCS/phpunit.xml
Runtime: PHP 7.4.33
Configuration: /WordPressCS/phpunit.xml.dist

........................................................ 56 / 56 (100%)
......................................................... 57 / 57 (100%)

152 sniff test files generated 487 unique error codes; 52 were fixable (10.68%)
201 sniff test files generated 744 unique error codes; 50 were fixable (6%)

Time: 21.36 seconds, Memory: 22.00MB
Time: 10.19 seconds, Memory: 40.00 MB

OK (56 tests, 0 assertions)
OK (57 tests, 0 assertions)
```

[![asciicast](https://asciinema.org/a/98078.png)](https://asciinema.org/a/98078)

## Unit Testing conventions

If you look inside the `WordPress/Tests` subdirectory, you'll see the structure mimics the `WordPress/Sniffs` subdirectory structure. For example, the `WordPress/Sniffs/PHP/POSIXFunctionsSniff.php` sniff has its unit test class defined in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.php` which checks the `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc` test case file. See the file naming convention?

Lets take a look at what's inside `POSIXFunctionsUnitTest.php`:

```php
...
namespace WordPressCS\WordPress\Tests\PHP;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
*
* @return array <int line number> => <int number of errors>
* @return array<int, int> Key is the line number, value is the number of expected errors.
*/
public function getErrorList() {
return array(
Expand All @@ -142,17 +127,18 @@ class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
24 => 1,
26 => 1,
);

}
...

...
}
```

Also note the class name convention. The method `getErrorList()` MUST return an array of line numbers indicating errors (when running `phpcs`) found in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc`.
If you run:
Also note the class name convention. The method `getErrorList()` MUST return an array of line numbers indicating errors (when running `phpcs`) found in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc`. Similarly, the `getWarningList()` method must return an array of line numbers with the number of expected warnings.

If you run the following from the root directory of your WordPressCS clone:

```sh
$ cd /path-to-cloned/phpcs
$ ./bin/phpcs --standard=Wordpress -s /path/to/WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
$ "vendor/bin/phpcs" --standard=Wordpress -s ./Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
...
--------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
Expand All @@ -163,28 +149,28 @@ FOUND 7 ERRORS AFFECTING 7 LINES
16 | ERROR | eregi() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use preg_match() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_eregi)
18 | ERROR | ereg_replace() has been deprecated since PHP 5.3 and removed in PHP
| | 7.0, please use preg_replace() instead.
18 | ERROR | ereg_replace() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_replace() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_replace_ereg_replace)
20 | ERROR | eregi_replace() has been deprecated since PHP 5.3 and removed in PHP
| | 7.0, please use preg_replace() instead.
20 | ERROR | eregi_replace() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_replace() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_replace_eregi_replace)
22 | ERROR | split() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use explode(), str_split() or preg_split() instead.
| | (WordPress.PHP.POSIXFunctions.split_split)
24 | ERROR | spliti() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use explode(), str_split() or preg_split() instead.
| | (WordPress.PHP.POSIXFunctions.split_spliti)
26 | ERROR | sql_regcase() has been deprecated since PHP 5.3 and removed in PHP
| | 7.0, please use preg_match() instead.
24 | ERROR | spliti() has been deprecated since PHP 5.3 and removed in PHP
| | 7.0, please use explode(), str_split() or preg_split()
| | instead. (WordPress.PHP.POSIXFunctions.split_spliti)
26 | ERROR | sql_regcase() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_match() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_sql_regcase)
--------------------------------------------------------------------------------
....
...
```
You'll see the line number and number of ERRORs we need to return in the `getErrorList()` method.

The `--sniffs=...` directive limits the output to the sniff you are testing.

## Code Standards for this project

The sniffs and test files - not test _case_ files! - for WPCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/.phpcs.xml.dist`.
The sniffs and test files - not test _case_ files! - for WordPressCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/.phpcs.xml.dist`.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: "https://opencollective.com/thewpcc/contribute/wp-php-63406"
67 changes: 56 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ about: Create a report to help us improve

---

<!--
PLEASE FILL OUT THE TEMPLATE COMPLETELY.
BUG REPORTS WHICH CANNOT BE REPRODUCED BASED ON THE INFORMATION PROVIDED WILL BE CLOSED.
-->

## Bug Description
<!--
Please provide a clear and concise description of what the bug is.
Expand All @@ -12,36 +17,76 @@ What did you expect to happen? What actually happened?
-->

## Minimal Code Snippet
<!-- Please provide example code that demonstrates the issue. Do NOT paste screenshots of code! -->
<!-- Please provide example code that allows us to reproduce the issue. Do NOT paste screenshots of code! -->

The issue happens when running this command:
```bash
phpcs ...
```

... over a file containing this code:
```php
// Place your code sample here.
```

For bugs with fixers: How was the code fixed? How did you expect the code to be fixed?
<!-- For bugs with fixers: How was the code fixed? How did you expect the code to be fixed? -->

The file was auto-fixed via `phpcbf` to:
```php
// Place your code sample here.
```

... while I expected the code to be fixed to:
```php
// Place your code sample here.
```

## Error Code
<!--
The error code for the sniff that is (or should be) being triggered (you
can see the sniff error codes by running `phpcs` with the `-s` flag).
e.g. `WordPress.PHP.NoSilencedErrors.Discouraged`

Note: only report issues for error codes starting with `WordPress` to this repo!
If the error code starts with `Universal`, `NormalizedArrays` or `Modernize` report the issue to PHPCSExtra.
If the error code starts with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` report the issue to PHP_CodeSniffer itself.

You can leave this section empty if you are reporting a false negative.
-->

## Custom Ruleset
<!--
If the issue cannot be reproduced when using `--standard=WordPress` on the command line,
please post the relevant part of your custom ruleset here.
-->

```xml
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
...
</ruleset>
```

## Environment
<!--
To find out the versions used:
* PHP: run `php -v`.
* Packages: run `composer info` or run `composer [global] info` to see the installed versions.
-->

| Question | Answer
| ------------------------| -------
| PHP version | x.y.z
| PHP_CodeSniffer version | x.y.z
| WPCS version | x.y.z
| WPCS install type | e.g. Composer global, Composer project local, git clone, other (please expand)
| IDE (if relevant) | Name and version e.g. PhpStorm 2018.2.2
| Question | Answer
| ------------------------ | -------
| PHP version | x.y.z
| PHP_CodeSniffer version | x.y.z
| WordPressCS version | x.y.z
| PHPCSUtils version | x.y.z
| PHPCSExtra version | x.y.z
| WordPressCS install type | e.g. Composer global, Composer project local, other (please expand)
| IDE (if relevant) | Name and version e.g. PhpStorm 2018.2.2


## Additional Context (optional)
<!-- Add any other context about the problem here. -->

## Tested Against `develop` branch?
- [ ] I have verified the issue still exists in the `develop` branch of WPCS.
## Tested Against `develop` Branch?
- [ ] I have verified the issue still exists in the `develop` branch of WordPressCS.
Loading
Loading