Skip to content

Fix problems reported by static analysis #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/css_js_min/minify/css.cls.php
Original file line number Diff line number Diff line change
@@ -230,9 +230,9 @@ protected function combineImports($source, $content, $parents)
}

/**
* Import files into the CSS, base64-ized.
* Import files into the CSS, base64 encoded.
*
* @url(image.jpg) images will be loaded and their content merged into the
* Included images @url(image.jpg) will be loaded and their content merged into the
* original file, to save HTTP requests.
*
* @param string $source The file to import files for
@@ -282,7 +282,7 @@ protected function importFiles($source, $content)
* Minify the data.
* Perform CSS optimizations.
*
* @param string[optional] $path Path to write the data to
* @param string|null $path Path to write the data to [optional]
* @param string[] $parents Parent paths, for circular reference checks
*
* @return string The minified data
2 changes: 1 addition & 1 deletion src/admin-settings.cls.php
Original file line number Diff line number Diff line change
@@ -335,7 +335,7 @@ public static function widget_save_err($location)
* @param array $instance The new settings.
* @param array $new_instance
* @param array $old_instance The original settings.
* @param WP_Widget $widget The widget
* @param \WP_Widget $widget The widget
* @return mixed Updated settings on success, false on error.
*/
public static function validate_widget_save($instance, $new_instance, $old_instance, $widget)
6 changes: 3 additions & 3 deletions src/crawler.cls.php
Original file line number Diff line number Diff line change
@@ -621,7 +621,7 @@ private function _prepare_running()
private function _take_over_lane()
{
self::debug('Take over lane as lane is free: ' . $this->json_local_path() . '.pid');
file::save($this->json_local_path() . '.pid', LITESPEED_LANE_HASH);
File::save($this->json_local_path() . '.pid', LITESPEED_LANE_HASH);
}

/**
@@ -662,7 +662,7 @@ private function _check_valid_lane($strict_mode = false)
return false;
}
}
$pid = file::read($lane_file);
$pid = File::read($lane_file);
if ($pid && LITESPEED_LANE_HASH != $pid) {
// If lane file is older than 1h, ignore
if (time() - filemtime($lane_file) > 3600) {
@@ -1420,7 +1420,7 @@ public function display_status($status_row, $reason_set)
*
* @since 1.1.0
* @access protected
* @param string $error Error info
* @param string $msg Error info
*/
protected function output($msg)
{
2 changes: 1 addition & 1 deletion src/debug2.cls.php
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ private function _maybe_init_folder()
if (file_exists(self::$log_path_prefix . 'index.php')) {
return;
}
file::save(self::$log_path_prefix . 'index.php', '<?php // Silence is golden.', true);
File::save(self::$log_path_prefix . 'index.php', '<?php // Silence is golden.', true);

$logs = array('debug', 'debug.purge', 'crawler');
foreach ($logs as $log) {
8 changes: 4 additions & 4 deletions src/esi.cls.php
Original file line number Diff line number Diff line change
@@ -458,9 +458,9 @@ private static function _build_inline($url, $inline_param)
* @param array $params The esi parameters.
* @param string $control The cache control attribute if any.
* @param bool $silence If generate wrapper comment or not
* @param bool $preserved If this ESI block is used in any filter, need to temporarily convert it to a string to avoid the HTML tag being removed/filtered.
* @param bool $svar If store the value in memory or not, in memory will be faster
* @param array $inline_val If show the current value for current request( this can avoid multiple esi requests in first time cache generating process )
* @param bool $preserved If this ESI block is used in any filter, need to temporarily convert it to a string to avoid the HTML tag being removed/filtered.
* @param bool $svar If store the value in memory or not, in memory will be faster
* @param array $inline_param If show the current value for current request (this can avoid multiple esi requests in first time cache generating process)
*/
public function sub_esi_block(
$block_id,
@@ -719,7 +719,7 @@ public static function widget_default_options($options, $widget)
* @since 1.1.3
* @access public
* @param array $instance Parameter used to build the widget.
* @param WP_Widget $widget The widget to build.
* @param \WP_Widget $widget The widget to build.
* @param array $args Parameter used to build the widget.
* @return mixed Return false if display through esi, instance otherwise.
*/
8 changes: 4 additions & 4 deletions src/file.cls.php
Original file line number Diff line number Diff line change
@@ -219,10 +219,10 @@ public static function remove_zero_space($content)
* Replaces existing marked info. Retains surrounding
* data. Creates file if none exists.
*
* @param string $filename Filename to alter.
* @param string $marker The marker to alter.
* @param array|string $insertion The new content to insert.
* @param bool $prepend Prepend insertion if not exist.
* @param string $filename Filename to alter.
* @param array|string|false $insertion The new content to insert.
* @param string|false $marker The marker to alter.
* @param bool $prepend Prepend insertion if not exist.
* @return bool True on write success, false on failure.
*/
public static function insert_with_markers($filename, $insertion = false, $marker = false, $prepend = false)
2 changes: 1 addition & 1 deletion src/gui.cls.php
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ public static function dismiss()
break;

case self::TYPE_DISMISS_PIN:
admin_display::dismiss_pin();
Admin_Display::dismiss_pin();
break;

case self::TYPE_DISMISS_PROMO:
2 changes: 1 addition & 1 deletion src/media.cls.php
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ public function info($short_file_path, $post_id)
/**
* WP Stateless compatibility #143 https://github.com/litespeedtech/lscache_wp/issues/143
* @since 2.9.8
* @return array( 'url', 'md5', 'size' )
* Should return array( 'url', 'md5', 'size' )
*/
$info = apply_filters('litespeed_media_info', array(), $short_file_path, $post_id);
if (!empty($info['url']) && !empty($info['md5']) && !empty($info['size'])) {
2 changes: 1 addition & 1 deletion src/object-cache.cls.php
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ private function debug_oc($text, $show_error = false)
return;
}

if (!$show_error && $this->_cfg_debug != BASE::VAL_ON2) {
if (!$show_error && $this->_cfg_debug != Base::VAL_ON2) {
return;
}

2 changes: 1 addition & 1 deletion src/optimize.cls.php
Original file line number Diff line number Diff line change
@@ -443,7 +443,7 @@ private function _optimize()
$this->html_head .= $this->_build_js_inline(File::read(LSCWP_DIR . self::LIB_FILE_CSS_ASYNC), true);
} else {
$css_async_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_CSS_ASYNC;
$this->html_head .= $this->_build_js_tag($css_async_lib_url, 'litespeed-css-async-lib'); // Don't exclude it from defer for now
$this->html_head .= $this->_build_js_tag($css_async_lib_url); // Don't exclude it from defer for now
}
}

2 changes: 1 addition & 1 deletion src/purge.cls.php
Original file line number Diff line number Diff line change
@@ -768,7 +768,7 @@ public function purge_tag($val)
return;
}
$term = get_term_by('slug', $val, 'post_tag');
if ($term == 0) {
if ($term === false) {
self::debug("$val tag not exist");
return;
}
4 changes: 2 additions & 2 deletions src/str.cls.php
Original file line number Diff line number Diff line change
@@ -60,8 +60,8 @@ public static function safe_html($html)
*
* @since 1.3
* @access public
* @param int $len Length of string
* @param int $type 1-Number 2-LowerChar 4-UpperChar
* @param int $len Length of string
* @param int $type 1-Number 2-LowerChar 4-UpperChar
* @return string
*/
public static function rrand($len, $type = 7)
8 changes: 4 additions & 4 deletions src/utility.cls.php
Original file line number Diff line number Diff line change
@@ -459,8 +459,8 @@ public static function url2uri($url, $keep_qs = false)
*
* @since 3.0
* @access public
* @param string `https://aa.com/bbb/wp-content/upload/2018/08/test.jpg` or `/bbb/wp-content/upload/2018/08/test.jpg`
* @return string `2018/08/test.jpg`
* @param string $url `https://aa.com/bbb/wp-content/upload/2018/08/test.jpg` or `/bbb/wp-content/upload/2018/08/test.jpg`
* @return string `2018/08/test.jpg`
*/
public static function att_short_path($url)
{
@@ -567,8 +567,8 @@ public static function domain_const()
*
* @since 1.3
* @access public
* @param string $content
* @param bool $type String handler type
* @param array|string $arr
* @param string|null $type String handler type
* @return string|array
*/
public static function sanitize_lines($arr, $type = null)
8 changes: 4 additions & 4 deletions src/vary.cls.php
Original file line number Diff line number Diff line change
@@ -766,11 +766,11 @@ private function _get_cookie_val($key)
*
* @since 1.0.4
* @access private
* @param integer $val The value to update.
* @param integer $expire Expire time.
* @param boolean $path False if use wp root path as cookie path
* @param int|false $val The value to update.
* @param int $expire Expire time.
* @param bool $path False if use wp root path as cookie path
*/
private function _cookie($val = false, $expire = false, $path = false)
private function _cookie($val = false, $expire = 0, $path = false)
{
if (!$val) {
$expire = 1;