Skip to content

Commit 84605b5

Browse files
authored
Merge pull request #561 from Automattic/fix/469-restrictedfunctions-false-positive-class-instantiation
Functions/RestrictedFunctions: fix false positive on class instantiation
2 parents 4d644cb + 35068c0 commit 84605b5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public function is_targetted_token( $stackPtr ) {
398398
\T_AS => \T_AS, // Use declaration alias.
399399
\T_DOUBLE_COLON => \T_DOUBLE_COLON,
400400
\T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR,
401+
\T_NEW => \T_NEW,
401402
];
402403
if ( isset( $skipped[ $this->tokens[ $prev ]['code'] ] ) ) {
403404
return false;

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,7 @@ wpcom_vip_get_page_by_path(); // Ok - VIP recommended version of get_page_by_pat
226226
get_page_by_path( $page_path ); // Warning.
227227

228228
$popular = stats_get_csv( 'postviews', [ 'days' => 2, 'limit' => 20 ] ); // Error.
229-
$popular = custom_stats_get_csv( 'postviews', [ 'days' => 2, 'limit' => 20 ] ); // Ok.
229+
$popular = custom_stats_get_csv( 'postviews', [ 'days' => 2, 'limit' => 20 ] ); // Ok.
230+
231+
$foo = new Link; // OK, class, not function.
232+
$foo = new Mail(); // OK, class, not function.

0 commit comments

Comments
 (0)