Commit Graph

49 Commits

Author SHA1 Message Date
hellofromTonya a395d4c50e Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.

In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780


git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:03:55 +00:00
hellofromTonya 7abc752329 Code Modernization: Fix last parameter name mismatches for parent/child classes in `Walker::start_el()`.
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779


git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 12:39:59 +00:00
hellofromTonya 1105ddf965 Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::start_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.

Why? `object` is a PHP reserved keyword.

In each child class: renames the corresponding parameter to match the parent's method signature.

Why? 

PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- in cases where the original parameter name was too generic, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51739


git-svn-id: http://core.svn.wordpress.org/trunk@51347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 15:36:59 +00:00
Sergey Biryukov 68af562077 Code Modernization: Use a consistent check for parent items in `WP_Walker`.
This affects the `::walk()`, `::paged_walk()`, and `::get_number_of_root_elements()` methods.

PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison

In particular, checking if an empty string is equal to zero in PHP 8 evaluates to `false`, not `true`.

For the `WP_Walker` class, this resulted in an incorrect handling of parent items in a few methods.

By explicitly checking for an `empty()` value instead, we make sure the check works as expected in PHP 8 and earlier versions.

Follow-up to [35876], [48960], [49043], [49076].

Props sunxiyuan, aristath, SergeyBiryukov.
Fixes #53474.
Built from https://develop.svn.wordpress.org/trunk@51204


git-svn-id: http://core.svn.wordpress.org/trunk@50813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-22 19:09:00 +00:00
Sergey Biryukov 42b6ece059 Docs: Fix typo in a comment in `Walker::display_element()`.
Props david.binda, sabernhardt.
Fixes #51713.
Built from https://develop.svn.wordpress.org/trunk@49509


git-svn-id: http://core.svn.wordpress.org/trunk@49264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-05 18:46:10 +00:00
John Blackbourn 9bc7d0a776 Docs: Another pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48590


git-svn-id: http://core.svn.wordpress.org/trunk@48352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:11:05 +00:00
Sergey Biryukov 641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov 001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov 13eecfc861 Docs: Tweak the `@since` note in `Walker::walk()` and `::paged_walk()` for better readability and consistency with other notes.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46452


git-svn-id: http://core.svn.wordpress.org/trunk@46250 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-09 04:35:01 +00:00
Sergey Biryukov 8d1e51e9c7 Docs: Add a `@since` note about new parameters with the spread operator added to function signatures.
Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46451


git-svn-id: http://core.svn.wordpress.org/trunk@46249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-09 04:28:02 +00:00
Sergey Biryukov 38a8513cf2 Code Modernisation: Introduce the spread operator in `Walker::walk()` and `::paged_walk()`.
Rather than relying on `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

This re-applies [45624] and reverts [45640], with a dev note upcoming for plugin authors to maintain backward compatibility with old versions of WordPress.

Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46442


git-svn-id: http://core.svn.wordpress.org/trunk@46240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-08 17:56:02 +00:00
Sergey Biryukov 2a35b3e7df Code Modernisation: Replace `call_user_func_array()` in `wp-includes/class-wp-walker.php` with dynamic function calls.
Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46143


git-svn-id: http://core.svn.wordpress.org/trunk@45955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-15 11:50:55 +00:00
Gary Pendergast 820ce9c438 Code Modernisation: Revert [45624].
Changing the method signatures on `Walker` causes back compat issues.

See #47678.



Built from https://develop.svn.wordpress.org/trunk@45640


git-svn-id: http://core.svn.wordpress.org/trunk@45451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-15 07:04:59 +00:00
Gary Pendergast 41ea1f106d Code Modernisation: Introduce the spread operator in `Walker`.
Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Props jrf.
See #47678.

Built from https://develop.svn.wordpress.org/trunk@45624


git-svn-id: http://core.svn.wordpress.org/trunk@45435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-11 23:51:56 +00:00
Gary Pendergast aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Gary Pendergast c90cfa3b50 General: Fix some precision alignment formatting warnings.
The WPCS `WordPress.WhiteSpace.PrecisionAlignment` rule throws warnings for a bunch of code that will likely cause issues for `wpcbf`. Fixing these manually beforehand gives us better auto-fixed results later.

See #41057.


Built from https://develop.svn.wordpress.org/trunk@42228


git-svn-id: http://core.svn.wordpress.org/trunk@42057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-26 23:57:55 +00:00
John Blackbourn 4a16295dc5 Docs: Standardise the format used for documenting parameters passed by reference.
See #35974, #41017

Built from https://develop.svn.wordpress.org/trunk@41688


git-svn-id: http://core.svn.wordpress.org/trunk@41522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:14:46 +00:00
Drew Jaynes 0860bb2771 Docs: Remove `@access` notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

Built from https://develop.svn.wordpress.org/trunk@41162


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Sergey Biryukov d054731b2b Docs: Add missing `@since` entry for `Walker::unset_children()`.
Props chiragpatel.
Fixes #39506.
Built from https://develop.svn.wordpress.org/trunk@39741


git-svn-id: http://core.svn.wordpress.org/trunk@39681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-06 22:14:00 +00:00
Drew Jaynes b1804afeaf Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.

Built from https://develop.svn.wordpress.org/trunk@37431


git-svn-id: http://core.svn.wordpress.org/trunk@37397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 18:41:31 +00:00
John Blackbourn 36679a6e89 Avoid a PHP notice when trying to access the `post_parent` property of hierarchical post type nav menu items.
FIxes #34446

Built from https://develop.svn.wordpress.org/trunk@35876


git-svn-id: http://core.svn.wordpress.org/trunk@35840 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-12 01:06:29 +00:00
Drew Jaynes edd0f2b32f Docs: Add missing parameter and return descriptions for `Walker::get_number_of_root_elements()`.
Fixes #33662.

Built from https://develop.svn.wordpress.org/trunk@34121


git-svn-id: http://core.svn.wordpress.org/trunk@34089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-14 15:33:27 +00:00
Drew Jaynes ab990ac594 Docs: Add a missing summary to the DocBlock for `Walker::get_number_of_root_elements()`.
Props wen-solutions
See #33662.

Built from https://develop.svn.wordpress.org/trunk@33868


git-svn-id: http://core.svn.wordpress.org/trunk@33836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-02 19:51:21 +00:00
Scott Taylor ef87172270 `foreach` is a statement, not a function.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@33734


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Scott Taylor c8a224c48e Cleanup missing doc blocks for `class-wp-walker.php`.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32549


git-svn-id: http://core.svn.wordpress.org/trunk@32519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-22 17:59:25 +00:00
Scott Taylor af7a017f46 When calling `unset()`, it is unnecessary to immediately precede it with a call to `isset()`.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32545


git-svn-id: http://core.svn.wordpress.org/trunk@32515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-22 05:47:25 +00:00
Boone Gorges 77875a273e `Walker::$has_children` should be public for backward compatibility.
See [31137]. See #30891.
Built from https://develop.svn.wordpress.org/trunk@31141


git-svn-id: http://core.svn.wordpress.org/trunk@31122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-11 01:56:22 +00:00
Scott Taylor b962499be6 In `Walker`:
* Every subclass of `Walker` overrides `$db_fields` and makes it public
* `wp_list_comments()` accesses `->max_pages` on an instance of `Walker`, it must be public
* `$has_children` was added as `protected` in 4.0. doesn't need BC

Make `$db_fields` and `$max_pages` public and remove magic methods.

See #30891.

Built from https://develop.svn.wordpress.org/trunk@31137


git-svn-id: http://core.svn.wordpress.org/trunk@31118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-10 23:44:23 +00:00
Drew Jaynes d33c807723 Fix some documentation typos in various core files.
Props vlajos.
Fixes #29199.

Built from https://develop.svn.wordpress.org/trunk@29479


git-svn-id: http://core.svn.wordpress.org/trunk@29257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-13 03:56:17 +00:00
Drew Jaynes a8583d5f19 Fix some words that aren't words.
See #28885.

Built from https://develop.svn.wordpress.org/trunk@29454


git-svn-id: http://core.svn.wordpress.org/trunk@29232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-09 19:30:17 +00:00
Drew Jaynes 3665b5a1a1 Add periods to short descriptions for magic methods added in [28501], [28521], and [28524].
See #22234 and #28885.

Built from https://develop.svn.wordpress.org/trunk@29165


git-svn-id: http://core.svn.wordpress.org/trunk@28949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-14 01:12:14 +00:00
Drew Jaynes 1a6884d13e Fill out inline documentation for magic methods added to the `Walker` class in [28514].
See #27881, #22234 and #28885.

Built from https://develop.svn.wordpress.org/trunk@29143


git-svn-id: http://core.svn.wordpress.org/trunk@28927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-13 23:41:14 +00:00
Scott Taylor 0ba605c55c Ensure that a `has_children` parameter is given to `Walker::start_el()`.
Adds unit tests.

Props scribu, obenland.
Fixes #14041.

Built from https://develop.svn.wordpress.org/trunk@28824


git-svn-id: http://core.svn.wordpress.org/trunk@28628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-24 17:06:14 +00:00
Scott Taylor 85f73cf458 Classes that have `__set()` also need `__isset()` and `__unset()`.
See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28524


git-svn-id: http://core.svn.wordpress.org/trunk@28350 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:52:14 +00:00
Scott Taylor 821246b4ae Some classes with `__get()` method also need `__set()`.
See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28521


git-svn-id: http://core.svn.wordpress.org/trunk@28347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:31:15 +00:00
Scott Taylor dfa4de15fa Add missing access modifiers to methods/members in `Walker` and subclasses. Add a magic `__get()` method.
See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28514


git-svn-id: http://core.svn.wordpress.org/trunk@28340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:00:15 +00:00
Scott Taylor 6b80da9d96 In `Walker::walk()` and `Walker::paged_walk()`, `$id_field` is set and never used.
See #27882.


Built from https://develop.svn.wordpress.org/trunk@28322


git-svn-id: http://core.svn.wordpress.org/trunk@28150 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 21:09:19 +00:00
Andrew Nacin 70fd806759 Revert r25824:25875 from the core.svn.wordpress.org repository.
These commits were accidentally re-synced commits from develop.svn.wordpress.org due to a race condition. Thankfully, the history of this repository matters fairly little. It also happened only for trunk.


git-svn-id: http://core.svn.wordpress.org/trunk@25876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-25 02:29:52 +00:00
Andrew Nacin 8ae8e01b67 Remove the old wp_auto_updates_maybe_update cron event. Schedule the new wp_maybe_auto_update event at 7 a.m. and 7 p.m. in the site's timezone.
see #27704.

Built from https://develop.svn.wordpress.org/trunk@25825


git-svn-id: http://core.svn.wordpress.org/trunk@25825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 22:53:14 +00:00
Ryan Boren b87d4b77e5 Pinking shears
Built from https://develop.svn.wordpress.org/trunk@25880


git-svn-id: http://core.svn.wordpress.org/trunk@25792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-23 14:38:10 +00:00
Drew Jaynes 190913aaa7 Improve inline documentation for the `Walker` class.
Includes previously undocumented parameters.

See #23406.

Built from https://develop.svn.wordpress.org/trunk@25644


git-svn-id: http://core.svn.wordpress.org/trunk@25561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-28 21:29:10 +00:00
Sergey Biryukov 4b13a1ffa4 Fix E_STRICT notices in walkers. props dvarga. see #24356.
git-svn-id: http://core.svn.wordpress.org/trunk@24377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-28 03:29:15 +00:00
Andrew Nacin 92b4636e17 Required arguments can't follow optional arguments.
Make required arguments optional in confirm_blog_signup().

Mark arguments as required in _future_post_hook(), the walker method display_element(), get_author_link() (deprecated), and the WP_Widget constructor.

props rlerdorf.
see #24210.



git-svn-id: http://core.svn.wordpress.org/trunk@24126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-29 13:26:31 +00:00
Sergey Biryukov a7f7fcdb18 Make sure the array exists before adding an element to it. props rodrigosprimo. fixes #23272.
git-svn-id: http://core.svn.wordpress.org/trunk@23346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-01-25 12:24:10 +00:00
Ryan Boren 77518e9c71 Objects no longer need to be explicitly passed by ref to call_user_func*() to be callable. Props wonderboymusic. fixes #21865
git-svn-id: http://core.svn.wordpress.org/trunk@22118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-04 20:00:16 +00:00
ryan e3b46b25d3 Lose EOF ?>. Clean up EOF newlines. fixes #12307
git-svn-id: http://svn.automattic.com/wordpress/trunk@19712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-08 17:01:11 +00:00
ryan fd1393ab7a Clear strict notices for the walkers. fixes #19249
git-svn-id: http://svn.automattic.com/wordpress/trunk@19679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-04 23:03:46 +00:00
nacin 04deafb31c File-level phpdoc for new class files. fixes #10287.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16101 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-30 14:09:05 +00:00
nacin 731bf1fb06 Begin the dissolution of classes.php. see #10287.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-30 07:02:06 +00:00