Skip to content

Commit f51cb5d

Browse files
committed
WP/AlternativeFunctions: add tests for namespaced names
1 parent 5c819af commit f51cb5d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

WordPress/Tests/WP/AlternativeFunctionsUnitTest.inc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ file_get_contents( $local_file, true ); // OK.
3232
file_get_contents( $url, false ); // Warning.
3333
file_get_contents(); // OK - no params, so nothing to do.
3434
file_get_contents( 'http://remoteurl.com/file/?w=1' ); // Warning.
35-
file_get_contents( 'https://wordpress.org' ); // Warning.
35+
\file_GET_contents( 'https://wordpress.org' ); // Warning.
3636
file_get_contents(ABSPATH . 'wp-admin/css/some-file.css'); // OK.
3737
file_get_contents(MYABSPATH . 'plugin-file.json'); // Warning.
3838
file_get_contents( MUPLUGINDIR . 'some-file.xml' ); // OK.
@@ -147,3 +147,12 @@ file_get_contents(
147147
// Not using plugin_dir_path() for reasons.
148148
$url
149149
); // Warning.
150+
151+
/*
152+
* Safeguard correct handling of all types of namespaced function calls
153+
*/
154+
\curl_init();
155+
MyNamespace\parse_url( 'http://example.com/' );
156+
\MyNamespace\json_encode( $data );
157+
namespace\unlink(); // The sniff should start flagging this once it can resolve relative namespaces.
158+
namespace\Sub\strip_tags( $string );

WordPress/Tests/WP/AlternativeFunctionsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function getWarningList() {
8989
131 => 1,
9090
142 => 1,
9191
146 => 1,
92+
154 => 1,
9293
);
9394
}
9495
}

0 commit comments

Comments
 (0)