> Key is the name of the functions being targetted. * Value is an array with parameter positions as the * keys and parameter names as the values */ protected $target_functions = array( 'add_comments_page' => array( 4 => 'menu_slug', ), 'add_dashboard_page' => array( 4 => 'menu_slug', ), 'add_links_page' => array( 4 => 'menu_slug', ), 'add_management_page' => array( 4 => 'menu_slug', ), 'add_media_page' => array( 4 => 'menu_slug', ), 'add_menu_page' => array( 4 => 'menu_slug', ), 'add_object_page' => array( 4 => 'menu_slug', ), 'add_options_page' => array( 4 => 'menu_slug', ), 'add_pages_page' => array( 4 => 'menu_slug', ), 'add_plugins_page' => array( 4 => 'menu_slug', ), 'add_posts_page' => array( 4 => 'menu_slug', ), 'add_submenu_page' => array( 1 => 'parent_slug', 5 => 'menu_slug', ), 'add_theme_page' => array( 4 => 'menu_slug', ), 'add_users_page' => array( 4 => 'menu_slug', ), 'add_utility_page' => array( 4 => 'menu_slug', ), ); /** * Process the parameters of a matched function. * * @since 0.11.0 * * @param int $stackPtr The position of the current token in the stack. * @param string $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched * in lowercase. * @param array $parameters Array with information about the parameters. * * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { foreach ( $this->target_functions[ $matched_content ] as $position => $param_name ) { $found_param = PassedParameters::getParameterFromStack( $parameters, $position, $param_name ); if ( false === $found_param ) { continue; } $file_constant = $this->phpcsFile->findNext( \T_FILE, $found_param['start'], ( $found_param['end'] + 1 ) ); if ( false !== $file_constant ) { $this->phpcsFile->addWarning( 'Using __FILE__ for menu slugs risks exposing filesystem structure.', $file_constant, 'Using__FILE__' ); } } } }