Make WordPress Core

Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#58063 closed defect (bug) (invalid)

Replace 'else if' with 'elseif' in wp-includes/atomlib.php

Reported by: wpfy's profile wpfy Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3
Component: General Keywords: changes-requested close
Focuses: coding-standards Cc:

Description

The WordPress coding standards recommend using 'elseif' instead of 'else if' for conditionals to ensure consistency in the code syntax. This is because 'else if' is not compatible with the colon syntax for if|elseif blocks.

However, in the WordPress core file wp-includes/atomlib.php, on lines 251, 263, 265, and 305, 'else if' is used for conditionals. To ensure consistency with the WordPress coding standards and improve the readability and maintainability of the code, I propose replacing all instances of 'else if' with 'elseif' on these lines.

This change will ensure that the code follows the recommended syntax and is consistent with the rest of the WordPress core codebase.

I will create a pull request to the WordPress core repository with this change.

Change History (10)

This ticket was mentioned in PR #4293 on WordPress/wordpress-develop by @wpfy.


19 months ago
#1

  • Keywords has-patch added; needs-patch removed

The WordPress coding standards recommend using 'elseif' instead of 'else if' for conditionals to ensure consistency in the code syntax. This is because 'else if' is not compatible with the colon syntax for if|elseif blocks.
However, in the WordPress core file wp-includes/atomlib.php, on lines 251, 263, 265, and 305, 'else if' is used for conditionals. To ensure consistency with the WordPress coding standards and improve the readability and maintainability of the code, I propose replacing all instances of 'else if' with 'elseif' on these lines.
This change will ensure that the code follows the recommended syntax and is consistent with the rest of the WordPress core codebase.
I will create a pull request to the WordPress core repository with this change.

Trac ticket: https://core.trac.wordpress.org/ticket/58063

#2 @peterwilsoncc
19 months ago

@wpfy Hello and welcome to trac!

Each WordPress release has a general ticket for coding standards fixes, for the next major release of WordPress (6.3), the ticket is #57839.

You can save a little of your time by referring to that ticket in your pull requests, there's no need to open a ticket for each coding standards fix.

Once you've put together a few pull requests, drop a comment on #57839 to bring them to someone's attention.

#3 @wpfy
19 months ago

Hi @peterwilsoncc
Thank you so much for getting back to me and providing this helpful information. I was not aware that there is a general ticket for coding standards fixes for each WordPress release, and I appreciate you letting me know about ticket #57839 for the next major release of WordPress (6.3).

I apologize for any inconvenience caused by my previous ticket submissions, and I will make sure to refer to the general ticket in my future pull requests (Though I don’t know how to do it, if can give a short overview on it, that would be great) to avoid opening unnecessary tickets.
Thank you for taking the time to provide this guidance, and I look forward to contributing to the WordPress community.

#4 follow-up: @peterwilsoncc
19 months ago

There's no need to apologize. You don't know what you don't know and no inconvenience was caused :)

To link the ticket to pull requests, you can just include a link to https://core.trac.wordpress.org/ticket/57839 in the pull requests description. Similar to what you've done in this pull request but using the generic ticket number instead.

Thanks for contributing.

#5 in reply to: ↑ 4 @wpfy
19 months ago

Got it.

Thank you so much.

#6 @mukesh27
19 months ago

  • Keywords changes-requested added

Hi there!

Thanks for ticket and PR! left feedback on PR. Thanks!

@wpfy commented on PR #4293:


19 months ago
#7

Thanks @akramulhasan, Can you search similar instance in whole folder and correct it so we don't get similar ticket for other files?

Hi, @mukeshpanchal27
Done!

#8 @azaozz
19 months ago

  • Keywords close added; has-patch removed

The files in /wp-includes/IXR/ are part of the /wp-includes/class-IXR.php external library. See the license, copyright, etc.

In that terms it seems the (visual, stylistic) WP coding standards do not apply there unless that class is officially forked by WP and moved to a wordpress.org repo. See all the "improper" (according to the coding standards) line breaks before { there. This does not apply to PHP compatibility fixes, and similar.

Last edited 19 months ago by azaozz (previous) (diff)

#9 @jrf
19 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

What @azaozz said and these files are already excluded from the WPCS checks for that exact reason.

Last edited 19 months ago by jrf (previous) (diff)

@jrf commented on PR #4293:


19 months ago
#10

These are files from external dependencies which should not be changed.

Note: See TracTickets for help on using tickets.