22
33namespace {
44 if (!function_exists ('sanitize_text_field ' )) {
5- function sanitize_text_field ($ value )
5+ /** @param string $value */
6+ function sanitize_text_field ($ value ): string
67 {
78 return $ value ;
89 }
910 }
1011
1112 if (!function_exists ('esc_url_raw ' )) {
12- function esc_url_raw ($ value )
13+ /** @param string $value */
14+ function esc_url_raw ($ value ): string
1315 {
1416 return $ value ;
1517 }
1618 }
1719
1820 if (!function_exists ('wp_generate_uuid4 ' )) {
19- function wp_generate_uuid4 ()
21+ function wp_generate_uuid4 (): string
2022 {
2123 return 'uuid-1 ' ;
2224 }
2325 }
2426
2527 if (!function_exists ('wp_remote_post ' )) {
28+ /**
29+ * @param string $url
30+ * @param array<string, mixed> $args
31+ * @return array{response: array{code: int}}
32+ */
2633 function wp_remote_post ($ url , $ args )
2734 {
2835 $ GLOBALS ['remotePosts ' ][] = [$ url , $ args ];
@@ -31,13 +38,19 @@ function wp_remote_post($url, $args)
3138 }
3239
3340 if (!function_exists ('wp_json_encode ' )) {
34- function wp_json_encode ($ value )
41+ /** @param mixed $value */
42+ function wp_json_encode ($ value ): string
3543 {
3644 return json_encode ($ value );
3745 }
3846 }
3947
4048 if (!function_exists ('get_option ' )) {
49+ /**
50+ * @param string $key
51+ * @param mixed $default
52+ * @return mixed
53+ */
4154 function get_option ($ key , $ default = null )
4255 {
4356 return $ GLOBALS ['testOptions ' ][$ key ] ?? $ default ;
@@ -46,13 +59,16 @@ function get_option($key, $default = null)
4659
4760 class WP_REST_Request
4861 {
62+ /** @var array<string, mixed> */
4963 private array $ params ;
5064
65+ /** @param array<string, mixed> $params */
5166 public function __construct (array $ params )
5267 {
5368 $ this ->params = $ params ;
5469 }
5570
71+ /** @return mixed */
5672 public function get_param (string $ key )
5773 {
5874 return $ this ->params [$ key ] ?? null ;
@@ -61,9 +77,11 @@ public function get_param(string $key)
6177
6278 class WP_REST_Response
6379 {
80+ /** @var array<string, mixed> */
6481 public array $ data ;
6582 public int $ status ;
6683
84+ /** @param array<string, mixed> $data */
6785 public function __construct (array $ data , int $ status )
6886 {
6987 $ this ->data = $ data ;
@@ -112,10 +130,12 @@ public function testHandlePageViewSendsPayload(): void
112130 $ response = $ dispatcher ->handlePageView ($ request );
113131
114132 $ this ->assertSame ('sent ' , $ response ->data ['status ' ]);
115- $ this ->assertSame (1 , count ($ GLOBALS ['remotePosts ' ]));
133+ /** @var list<array{0: string, 1: mixed}> $posts */
134+ $ posts = $ GLOBALS ['remotePosts ' ];
135+ $ this ->assertSame (1 , count ($ posts ));
116136 $ this ->assertSame (
117137 'https://graph.facebook.com/v18.0/123/events?access_token=token ' ,
118- $ GLOBALS [ ' remotePosts ' ] [0 ][0 ]
138+ $ posts [0 ][0 ]
119139 );
120140 }
121141 }
0 commit comments