Code Modernization: Rename parameters that use reserved keywords in `phpunit/includes/class-wp-unittest-factory-for-attachment.php`.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit:
* Renames the `$parent` parameter to `$parent_post_id` in `WP_UnitTest_Factory_For_Attachment::create_upload_object()`.
* Amends the `$parent_post` parameter in `wp_insert_attachment()` and `WP_REST_Revisions_Controller::get_parent()` for consistency.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55021


git-svn-id: http://core.svn.wordpress.org/trunk@54554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-12-30 02:38:17 +00:00
parent 36883a9cc2
commit 835378abe1
3 changed files with 9 additions and 9 deletions

View File

@ -6327,12 +6327,12 @@ function is_local_attachment( $url ) {
*
* @param string|array $args Arguments for inserting an attachment.
* @param string|false $file Optional. Filename.
* @param int $parent_post Optional. Parent post ID.
* @param int $parent_post_id Optional. Parent post ID.
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
* @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.
* @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
*/
function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error = false, $fire_after_hooks = true ) {
function wp_insert_attachment( $args, $file = false, $parent_post_id = 0, $wp_error = false, $fire_after_hooks = true ) {
$defaults = array(
'file' => $file,
'post_parent' => 0,
@ -6340,8 +6340,8 @@ function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error
$data = wp_parse_args( $args, $defaults );
if ( ! empty( $parent_post ) ) {
$data['post_parent'] = $parent_post;
if ( ! empty( $parent_post_id ) ) {
$data['post_parent'] = $parent_post_id;
}
$data['post_type'] = 'attachment';

View File

@ -134,21 +134,21 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller {
*
* @since 4.7.2
*
* @param int $parent_post Supplied ID.
* @param int $parent_post_id Supplied ID.
* @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
*/
protected function get_parent( $parent_post ) {
protected function get_parent( $parent_post_id ) {
$error = new WP_Error(
'rest_post_invalid_parent',
__( 'Invalid post parent ID.' ),
array( 'status' => 404 )
);
if ( (int) $parent_post <= 0 ) {
if ( (int) $parent_post_id <= 0 ) {
return $error;
}
$parent_post = get_post( (int) $parent_post );
$parent_post = get_post( (int) $parent_post_id );
if ( empty( $parent_post ) || empty( $parent_post->ID )
|| $this->parent_post_type !== $parent_post->post_type

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55020';
$wp_version = '6.2-alpha-55021';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.