getTokens(); // Is this one of the tokens this function handles ? if ( isset( $tokens[ $stackPtr ], Collections::listOpenTokensBC()[ $tokens[ $stackPtr ]['code'] ] ) === false ) { return array(); } if ( isset( Collections::shortArrayListOpenTokensBC()[ $tokens[ $stackPtr ]['code'] ] ) && Lists::isShortList( $phpcsFile, $stackPtr ) === false ) { return array(); } try { $assignments = Lists::getAssignments( $phpcsFile, $stackPtr ); } catch ( RuntimeException $e ) { // Parse error/live coding. return array(); } $var_pointers = array(); foreach ( $assignments as $assign ) { if ( true === $assign['is_empty'] ) { continue; } if ( true === $assign['is_nested_list'] ) { /* * Recurse into the nested list and get the variables. * No need to `catch` any errors as only lists can be nested in lists. */ $var_pointers += self::get_list_variables( $phpcsFile, $assign['assignment_token'] ); continue; } /* * Ok, so this must be a "normal" assignment in the list. * Set the variable pointer both as the key as well as the value, so we can use array join * for nested lists (above). */ $var_pointers[ $assign['assignment_token'] ] = $assign['assignment_token']; } return $var_pointers; } }