Skip to content

Commit 9c414d1

Browse files
committed
WP/DeprecatedParameters: add tests for namespaced names
1 parent d1cde1a commit 9c414d1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

WordPress/Tests/WP/DeprecatedParametersUnitTest.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ _future_post_hook( 10, $post );
4343
_load_remote_block_patterns( $value );
4444
_wp_post_revision_fields( $foo, 'deprecated' );
4545
add_option( '', '', [] );
46-
add_option( '', '', 1.23 );
47-
add_option( '', '', 10 );
46+
\Add_Option( '', '', 1.23 );
47+
ADD_OPTION( '', '', 10 );
4848
add_option( '', '', false );
4949
add_option( '', '', 'deprecated' );
5050
comments_link( 'deprecated', 'deprecated' );
@@ -100,3 +100,12 @@ inject_ignored_hooked_blocks_metadata_attributes('', 'deprecated');
100100
// All will give an WARNING as they have been deprecated after WP 6.6.
101101
wp_render_elements_support_styles('deprecated');
102102
_wp_can_use_pcre_u('deprecated');
103+
104+
/*
105+
* Safeguard correct handling of all types of namespaced function calls.
106+
*/
107+
\add_option( '', '', [] ); // Bad.
108+
MyNamespace\get_blog_list( $foo, $bar, 'deprecated' ); // Ok.
109+
\MyNamespace\get_wp_title_rss( 'deprecated' ); // Ok.
110+
namespace\the_author( 'deprecated', 'deprecated' ); // The sniff should start flagging this once it can resolve relative namespaces.
111+
namespace\Sub\wp_title_rss( 'deprecated' ); // Ok.

WordPress/Tests/WP/DeprecatedParametersUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public function getErrorList() {
4242
$errors[50] = 2;
4343
$errors[76] = 2;
4444

45+
// Fully qualified function call.
46+
$errors[107] = 1;
47+
4548
return $errors;
4649
}
4750

0 commit comments

Comments
 (0)