Skip to content

Commit 5cd8c70

Browse files
chore: phpstan
1 parent 1f029e2 commit 5cd8c70

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

includes/admin/feedzy-rss-feeds-log.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ public function set_context( array $context ) {
270270
public static function log( $level, $message, array $context = array() ) {
271271
try {
272272
$instance = self::get_instance();
273-
if ( $instance ) {
274-
$instance->add_log_record( $level, $message, $context );
275-
}
273+
$instance->add_log_record( $level, $message, $context );
276274
} catch ( Throwable $e ) {
277275
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
278276
error_log( sprintf( 'Feedzy_Rss_Feeds_Log error: %s', $e->getMessage() ) );
@@ -304,9 +302,9 @@ private function add_log_record( $level, $message, array $context = array() ) {
304302
if ( ! isset( $merged_context['function'] ) || ! isset( $merged_context['line'] ) ) {
305303
$origin = $this->get_calling_origin();
306304
if ( ! isset( $merged_context['function'] ) ) {
307-
$merged_context['function'] = is_array( $origin ) && isset( $origin['function'] ) ? $origin['function'] : (string) $origin;
305+
$merged_context['function'] = $origin['function'];
308306
}
309-
if ( ! isset( $merged_context['line'] ) && is_array( $origin ) && isset( $origin['line'] ) ) {
307+
if ( ! isset( $merged_context['line'] ) ) {
310308
$merged_context['line'] = $origin['line'];
311309
}
312310
}
@@ -364,8 +362,9 @@ public function append_to_themeisle_log( $log_entry ) {
364362
$formatted_message .= ' ' . wp_json_encode( $log_entry['context'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
365363
}
366364

367-
$function_signature = isset( $log_entry['context']['function'] ) ? $log_entry['context']['function'] : 'unknown';
368-
$line_number = isset( $log_entry['context']['line'] ) ? $log_entry['context']['line'] : null;
365+
$context = isset( $log_entry['context'] ) && is_array( $log_entry['context'] ) ? $log_entry['context'] : array();
366+
$function_signature = (string) ( $context['function'] ?? 'unknown' );
367+
$line_number = $context['line'] ?? null;
369368

370369
do_action( 'themeisle_log_event', FEEDZY_NAME, $formatted_message, $log_entry['level'], $function_signature, $line_number );
371370
}
@@ -385,17 +384,17 @@ private function get_calling_origin() {
385384
if ( isset( $frame['class'] ) && __CLASS__ === $frame['class'] ) {
386385
continue;
387386
}
388-
if ( isset( $frame['function'] ) ) {
389-
$func = isset( $frame['class'] )
390-
? ( $frame['class'] . ( isset( $frame['type'] ) ? $frame['type'] : '::' ) . $frame['function'] . '()' )
391-
: ( $frame['function'] . '()' );
392-
$line = isset( $frame['line'] ) ? (int) $frame['line'] : null;
393-
394-
return array(
395-
'function' => $func,
396-
'line' => $line,
397-
);
398-
}
387+
388+
$function_name = $frame['function'];
389+
$func = isset( $frame['class'] )
390+
? ( $frame['class'] . ( isset( $frame['type'] ) ? $frame['type'] : '::' ) . $function_name . '()' )
391+
: ( $function_name . '()' );
392+
$line = isset( $frame['line'] ) ? (int) $frame['line'] : null;
393+
394+
return array(
395+
'function' => $func,
396+
'line' => $line,
397+
);
399398
}
400399
return array(
401400
'function' => 'unknown',

includes/layouts/feedzy-logs-viewer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$all_filter_url = admin_url( 'admin.php?page=feedzy-settings&tab=logs' );
88

9-
$logs_type_filter = isset( $_REQUEST['logs_type'] ) ? strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['logs_type'] ) ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification
9+
$logs_type_filter = isset( $_REQUEST['logs_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['logs_type'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification
1010

1111
$log_types = array(
1212
'debug' => __( 'Debug', 'feedzy-rss-feeds' ),

0 commit comments

Comments
 (0)