From 612b605c801a4bac71029f47916c962dee4967ae Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 27 Feb 2014 23:15:29 +0000 Subject: [PATCH] Avoid an undefined index notice in wp_doc_link_parse(). props pross for initial patch. fixes #27214. git-svn-id: https://develop.svn.wordpress.org/trunk@27323 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/misc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 10d72d5745..cf7dcb255f 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -314,11 +314,15 @@ function wp_doc_link_parse( $content ) { return array(); $tokens = token_get_all( $content ); + $count = count( $tokens ); $functions = array(); $ignore_functions = array(); - for ( $t = 0, $count = count( $tokens ); $t < $count; $t++ ) { - if ( !is_array( $tokens[$t] ) ) continue; - if ( T_STRING == $tokens[$t][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { + for ( $t = 0; $t < $count - 2; $t++ ) { + if ( ! is_array( $tokens[ $t ] ) ) { + continue; + } + + if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { // If it's a function or class defined locally, there's not going to be any docs available if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { $ignore_functions[] = $tokens[$t][1];