#64896 Tighten the documented types in WP_Hook#12441
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I was looking into the other PHPStan rule level 10 issues in this file, and I found something related to the change you made here. It seems the --- a/src/wp-includes/class-wp-hook.php
+++ b/src/wp-includes/class-wp-hook.php
*
* @param mixed $offset The offset to assign the value to.
* @param mixed $value The value to set.
+ *
+ * @phpstan-param array-key|null $offset
+ * @phpstan-param array<string, Hook_Callback> $value
*/
#[ReturnTypeWillChange]
public function offsetSet( $offset, $value ) {But there are two errors remaining here: wordpress-develop/src/wp-includes/class-wp-hook.php Lines 520 to 528 in 6e10867 At:
And at:
|
… types. As an `ArrayAccess` object, the offsets of `WP_Hook` are hook priorities, which are always integers (or null when appending via `offsetSet()`), and the values are the `Hook_Callback` groups keyed by unique function ID. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Addressed in 67f3a9b. |
This adds a
Hook_CallbackPHPStan type to represent the shape of a callback used internally inWP_Hookand used in return values of array access methods.Also narrows a few other documented types.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
Trac ticket: https://core.trac.wordpress.org/ticket/64898