WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Add a lint for strpos === 0 to use str_starts_with

Open spacedmonkey opened this issue 2 years ago • 2 comments

Is your feature request related to a problem?

Describe the solution you'd like

Add a lint for strpos === 0 to use str_starts_with and the opposite. See hhttps://core.trac.wordpress.org/changeset/55703. str_starts_with is a php 8.0 function but a polyfill was added in core in WP 5.9. https://github.com/WordPress/wordpress-develop/commit/1046682e4f2453c55f836b3fe69f529daea0babc

Additional context (optional)

spacedmonkey avatar Jun 22 '23 15:06 spacedmonkey

Related #2261 .

spacedmonkey avatar Jun 22 '23 15:06 spacedmonkey

Note: This type of sniff should be created in the Modernize standard in PHPCSExtra and then used by WPCS.

jrfnl avatar Jun 23 '23 00:06 jrfnl