Skip to content

Commit

Permalink
Typos and unused variables. Good job, PhpStorm!
Browse files Browse the repository at this point in the history
  • Loading branch information
ozh committed May 3, 2013
1 parent 523224a commit da12eb6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion includes/functions-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function json_encode( $array ) {
/**
* Converts an associative array of arbitrary depth and dimension into JSON representation. Used for compatibility with older PHP builds.
*
* @param $array The array to convert.
* @param array $array the array to convert.
* @return mixed The resulting JSON string, or false if the argument was not an array.
* @author Andy Rusterholz
* @link http://php.net/json_encode (see comments)
Expand Down
1 change: 0 additions & 1 deletion includes/functions-formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ function yourls_check_invalid_utf8( $string, $strip = false ) {
*
* @param string $string The text which is to be encoded.
* @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
* @param string $charset Optional. The character encoding of the string. Default is false.
* @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
* @return string The encoded text with HTML entities.
*/
Expand Down
13 changes: 3 additions & 10 deletions includes/functions-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function yourls_html_tfooter( $params = array() ) {
* @param array $options array of 'value' => 'Text displayed'
* @param string $selected optional 'value' from the $options array that will be highlighted
* @param boolean $display false (default) to return, true to echo
* @return HTML content of the select element
* @return string HTML content of the select element
*/
function yourls_html_select( $name, $options, $selected = '', $display = false ) {
$html = "<select name='$name' id='$name' size='1'>\n";
Expand Down Expand Up @@ -445,9 +445,6 @@ function yourls_die( $message = '', $title = '', $header_code = 200 ) {
* @return string HTML of the edit row
*/
function yourls_table_edit_row( $keyword ) {
global $ydb;

$table = YOURLS_DB_TABLE_URL;
$keyword = yourls_sanitize_string( $keyword );
$id = yourls_string2htmlid( $keyword ); // used as HTML #id
$url = yourls_get_keyword_longurl( $keyword );
Expand All @@ -457,10 +454,6 @@ function yourls_table_edit_row( $keyword ) {
$safe_title = yourls_esc_attr( $title );
$www = yourls_link();

$save_link = yourls_nonce_url( 'save-link_'.$id,
yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit_save', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) )
);

$nonce = yourls_create_nonce( 'edit-save_'.$id );

if( $url ) {
Expand Down Expand Up @@ -797,11 +790,11 @@ function yourls_notice_box( $message, $style = 'notice' ) {
*/
function yourls_page( $page ) {
$include = YOURLS_ABSPATH . "/pages/$page.php";
if( !file_exists($include) ) {
if( !file_exists( $include ) ) {
yourls_die( "Page '$page' not found", 'Not found', 404 );
}
yourls_do_action( 'pre_page', $page );
include($include);
include( $include );
yourls_do_action( 'post_page', $page );
die();
}
Expand Down
1 change: 0 additions & 1 deletion includes/functions-infos.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ function yourls_days_in_month( $month, $year ) {
*
*/
function yourls_stats_get_best_day( $list_of_days ) {
$max = 0; $day = 0;
$max = max( $list_of_days );
foreach( $list_of_days as $k=>$v ) {
if ( $v == $max )
Expand Down
33 changes: 25 additions & 8 deletions includes/functions-l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function yourls__( $text, $domain = 'default' ) {
* @see sprintf()
* @since 1.6
*
* @param string $text Text to translate
* @param string $pattern Text to translate
* @param string $arg1, $arg2... Optional: sprintf tokens, and translation domain
* @return string Translated text
*/
Expand Down Expand Up @@ -284,8 +284,11 @@ function yourls_ex( $text, $context, $domain = 'default' ) {
* @see yourls_x()
* @since 1.6
*
* @param string $text Text to translate
* @param string $domain Optional. Domain to retrieve the translated text
* @param string $single
* @param string $context
* @param string $domain Optional. Domain to retrieve the translated text
* @internal param string $text Text to translate
* @return string
*/
function yourls_esc_attr_x( $single, $context, $domain = 'default' ) {
return yourls_esc_attr( yourls_translate_with_context( $single, $context, $domain ) );
Expand All @@ -299,8 +302,11 @@ function yourls_esc_attr_x( $single, $context, $domain = 'default' ) {
* @see yourls_x()
* @since 1.6
*
* @param string $text Text to translate
* @param string $domain Optional. Domain to retrieve the translated text
* @param string $single
* @param string $context
* @param string $domain Optional. Domain to retrieve the translated text
* @internal param string $text Text to translate
* @return string
*/
function yourls_esc_html_x( $single, $context, $domain = 'default' ) {
return yourls_esc_html( yourls_translate_with_context( $single, $context, $domain ) );
Expand Down Expand Up @@ -406,6 +412,7 @@ function yourls_nx_noop( $singular, $plural, $context, $domain = null ) {
* @param int $count Number of objects
* @param string $domain Optional. The domain identifier the text should be retrieved in. If $nooped_plural contains
* a domain passed to yourls_n_noop() or yourls_nx_noop(), it will override this value.
* @return string
*/
function yourls_translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
if ( $nooped_plural['domain'] )
Expand Down Expand Up @@ -587,9 +594,9 @@ function yourls_number_format_i18n( $number, $decimals = 0 ) {
*
* @since 1.6
*
* @param string $dateformatstring Format to display the date.
* @param int $unixtimestamp Optional. Unix timestamp.
* @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
* @param string $dateformatstring Format to display the date.
* @param bool|int $unixtimestamp Optional. Unix timestamp.
* @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
* @return string The date, translated if locale specifies it.
*/
function yourls_date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
Expand Down Expand Up @@ -752,6 +759,15 @@ class YOURLS_Locale_Formats {
*/
var $meridiem;

/**
* Stores the translated number format
*
* @since 1.6
* @var array
* @access private
*/
var $number_format;

/**
* The text direction of the locale language.
*
Expand Down Expand Up @@ -1018,6 +1034,7 @@ function is_rtl() {
*
* @param string $domain Unique identifier (the "domain") for retrieving translated strings
* @param string $path Full path to directory containing MO files.
* @return bool
*/
function yourls_load_custom_textdomain( $domain, $path ) {
$locale = yourls_apply_filters( 'load_custom_textdomain', yourls_get_locale(), $domain );
Expand Down
11 changes: 5 additions & 6 deletions includes/functions-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @param callback $function_name the name of the function that is to be called.
* @param integer $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default=10, lower=earlier execution, and functions with the same priority are executed in the order in which they were added to the filter)
* @param int $accepted_args optional. The number of arguments the function accept (default is the number provided).
* @param string $type
*/
function yourls_add_filter( $hook, $function_name, $priority = 10, $accepted_args = NULL, $type = 'filter' ) {
global $yourls_filters;
Expand Down Expand Up @@ -72,7 +73,6 @@ function yourls_add_action( $hook, $function_name, $priority = 10, $accepted_arg
* @param string $hook hook to which the function is attached
* @param string|array $function used for creating unique id
* @param int|bool $priority used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
* @param string $type filter or action
* @return string unique ID for usage as array key
*/
function yourls_filter_unique_id( $hook, $function, $priority ) {
Expand Down Expand Up @@ -293,12 +293,10 @@ function yourls_has_active_plugins( ) {
/**
* List plugins in /user/plugins
*
* @global $ydb Storage of mostly everything YOURLS needs to know
* @global object $ydb Storage of mostly everything YOURLS needs to know
* @return array Array of [/plugindir/plugin.php]=>array('Name'=>'Ozh', 'Title'=>'Hello', )
*/
function yourls_get_plugins( ) {
global $ydb;

$plugins = (array) glob( YOURLS_PLUGINDIR .'/*/plugin.php');

if( !$plugins )
Expand All @@ -316,7 +314,7 @@ function yourls_get_plugins( ) {
/**
* Check if a plugin is active
*
* @param string $file Physical path to plugin file
* @param string $plugin Physical path to plugin file
* @return bool
*/
function yourls_is_active_plugin( $plugin ) {
Expand Down Expand Up @@ -393,6 +391,7 @@ function yourls_load_plugins() {
* Check if a file is safe for inclusion (well, "safe", no guarantee)
*
* @param string $file Full pathname to a file
* @return bool
*/
function yourls_validate_plugin_file( $file ) {
if (
Expand Down Expand Up @@ -446,7 +445,7 @@ function yourls_activate_plugin( $plugin ) {
}

/**
* Dectivate a plugin
* Deactivate a plugin
*
* @param string $plugin Plugin filename (full relative to plugins directory)
* @return mixed string if error or true if success
Expand Down
2 changes: 1 addition & 1 deletion includes/functions-xml.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*************************************************************************/
/* This class stores associative arrays in an xml formated string. */
/* This class stores associative arrays in an xml formatted string. */
/* There's also a function thar retrieves them. If you try to use */
/* xml2array with a general xml, it can fail, since there can be some */
/* repeated indexes.... */
Expand Down
14 changes: 7 additions & 7 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function yourls_keyword_is_reserved( $keyword ) {
*
*/
function yourls_get_IP() {
$ip = '';

// Precedence: if set, X-Forwarded-For > HTTP_X_FORWARDED_FOR > HTTP_CLIENT_IP > HTTP_VIA > REMOTE_ADDR
$headers = array( 'X-Forwarded-For', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_VIA', 'REMOTE_ADDR' );
foreach( $headers as $header ) {
Expand Down Expand Up @@ -181,8 +183,6 @@ function yourls_url_exists( $url ) {
*
*/
function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
global $ydb;

// Allow plugins to short-circuit the whole function
$pre = yourls_apply_filter( 'shunt_add_new_link', false, $url, $keyword, $title );
if ( false !== $pre )
Expand Down Expand Up @@ -267,7 +267,7 @@ function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
$ok = ($free && $add_url);
if ( $ok === false && $add_url === 1 ) {
// we stored something, but shouldn't have (ie reserved id)
$delete = yourls_delete_link_by_keyword( $keyword );
yourls_delete_link_by_keyword( $keyword );
$return['extra_info'] .= '(deleted '.$keyword.')';
} else {
// everything ok, populate needed vars
Expand Down Expand Up @@ -449,7 +449,7 @@ function yourls_xml_encode( $array ) {
}

/**
* Return array of all informations associated with keyword. Returns false if keyword not found. Set optional $use_cache to false to force fetching from DB
* Return array of all information associated with keyword. Returns false if keyword not found. Set optional $use_cache to false to force fetching from DB
*
*/
function yourls_get_keyword_infos( $keyword, $use_cache = true ) {
Expand Down Expand Up @@ -1068,7 +1068,7 @@ function yourls_delete_option( $name ) {
if ( is_null( $option ) || !$option->option_id )
return false;

yourls_do_action( 'delete_option', $option_name );
yourls_do_action( 'delete_option', $name );

$ydb->query( "DELETE FROM `$table` WHERE `option_name` = '$name'" );
return true;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ function yourls_rnd_string ( $length = 5, $type = 0, $charlist = '' ) {

$i = 0;
while ($i < $length) {
$str .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$str .= substr( $possible, mt_rand( 0, strlen( $possible )-1 ), 1 );
$i++;
}

Expand All @@ -1373,7 +1373,7 @@ function yourls_salt( $string ) {
* array( 'var' => 'value' ), $url
* 'var', 'value'
* 'var', 'value', $url
* If $url ommited, uses $_SERVER['REQUEST_URI']
* If $url omitted, uses $_SERVER['REQUEST_URI']
*
*/
function yourls_add_query_arg() {
Expand Down

0 comments on commit da12eb6

Please sign in to comment.