Repository navigation
Docs: Add PHPStan templates and generics #13895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
d66ad8e
6059544
d2e5e84
10a0f30
17eac8c
bd1142a
3a1824b
f44beb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
| * | ||
| * @since 2.8.0 | ||
| * @since 4.4.0 Moved to its own file from wp-includes/widgets.php | ||
| * | ||
| * @phpstan-template T of array = array<string, mixed> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the need for a |
||
| */ | ||
| #[AllowDynamicProperties] | ||
| class WP_Widget { | ||
|
|
@@ -109,6 +111,8 @@ class WP_Widget { | |
| * @param array $args Display arguments including 'before_title', 'after_title', | ||
| * 'before_widget', and 'after_widget'. | ||
| * @param array $instance The settings for the particular instance of the widget. | ||
| * | ||
| * @phpstan-param T $instance | ||
| */ | ||
| public function widget( $args, $instance ) { | ||
| die( 'function WP_Widget::widget() must be overridden in a subclass.' ); | ||
|
|
@@ -127,6 +131,10 @@ public function widget( $args, $instance ) { | |
| * WP_Widget::form(). | ||
| * @param array $old_instance Old settings for this instance. | ||
| * @return array Settings to save or bool false to cancel saving. | ||
| * | ||
| * @phpstan-param array<string, mixed> $new_instance | ||
| * @phpstan-param T|array{} $old_instance | ||
| * @phpstan-return array<string, mixed>|false | ||
| */ | ||
| public function update( $new_instance, $old_instance ) { | ||
| return $new_instance; | ||
|
|
@@ -140,6 +148,8 @@ public function update( $new_instance, $old_instance ) { | |
| * @param array $instance The settings for the particular instance of the widget. | ||
| * @return string|void Default return is 'noform'. A subclass which echoes its own | ||
| * form returns nothing. | ||
| * | ||
| * @phpstan-param T|array{} $instance | ||
| */ | ||
| public function form( $instance ) { | ||
| echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2940,8 +2940,12 @@ function stripslashes_from_strings_only( $value ) { | |
| * | ||
| * @since 2.2.0 | ||
| * | ||
| * @param mixed $value The array or string to be encoded. | ||
| * @return mixed The encoded value. | ||
| * @param mixed[]|object|scalar $value The array, object, or scalar to be encoded. | ||
| * @return mixed[]|object|string The encoded value. | ||
| * | ||
| * @phpstan-template T of mixed[]|object|scalar | ||
| * @phpstan-param T $value | ||
| * @phpstan-return (T is array ? array<key-of<T>, mixed> : (T is object ? T : string)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the Same goes for the following. |
||
| */ | ||
| function urlencode_deep( $value ) { | ||
| return map_deep( $value, 'urlencode' ); | ||
|
|
@@ -2952,8 +2956,12 @@ function urlencode_deep( $value ) { | |
| * | ||
| * @since 3.4.0 | ||
| * | ||
| * @param mixed $value The array or string to be encoded. | ||
| * @return mixed The encoded value. | ||
| * @param mixed[]|object|scalar $value The array, object, or scalar to be encoded. | ||
| * @return mixed[]|object|string The encoded value. | ||
| * | ||
| * @phpstan-template T of mixed[]|object|scalar | ||
| * @phpstan-param T $value | ||
| * @phpstan-return (T is array ? array<key-of<T>, mixed> : (T is object ? T : string)) | ||
| */ | ||
| function rawurlencode_deep( $value ) { | ||
| return map_deep( $value, 'rawurlencode' ); | ||
|
|
@@ -2964,8 +2972,12 @@ function rawurlencode_deep( $value ) { | |
| * | ||
| * @since 4.4.0 | ||
| * | ||
| * @param mixed $value The array or string to be decoded. | ||
| * @return mixed The decoded value. | ||
| * @param mixed[]|object|scalar $value The array, object, or scalar to be decoded. | ||
| * @return mixed[]|object|string The decoded value. | ||
| * | ||
| * @phpstan-template T of mixed[]|object|scalar | ||
| * @phpstan-param T $value | ||
| * @phpstan-return (T is array ? array<key-of<T>, mixed> : (T is object ? T : string)) | ||
| */ | ||
| function urldecode_deep( $value ) { | ||
| return map_deep( $value, 'urldecode' ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.