style: auto-fix PHPCS violations via phpcbf

This commit is contained in:
peptiderepo
2026-06-16 15:31:35 +00:00
parent 01a9356c16
commit 166c5d4caf
13 changed files with 72 additions and 72 deletions

View File

@@ -117,7 +117,7 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector {
$standings = array(); $standings = array();
foreach ( (array) $standing_rows as $row ) { foreach ( (array) $standing_rows as $row ) {
$top_domains = $this->extract_top_domains( (string) ( $row['domains_json_list'] ?? '' ) ); $top_domains = $this->extract_top_domains( (string) ( $row['domains_json_list'] ?? '' ) );
$standings[ (string) $row['peptide_slug'] ] = array( $standings[ (string) $row['peptide_slug'] ] = array(
'label' => (string) $row['peptide_label'], 'label' => (string) $row['peptide_label'],
'cited' => (bool) (int) $row['cited'], 'cited' => (bool) (int) $row['cited'],

View File

@@ -73,19 +73,19 @@ class PRV_Call_Drawer_Renderer {
* @return void * @return void
*/ */
public function render_content( array $meta, ?array $io ): void { public function render_content( array $meta, ?array $io ): void {
$id = (int) $meta['id']; $id = (int) $meta['id'];
$captured = (string) $meta['captured_at']; $captured = (string) $meta['captured_at'];
$peptide = (string) $meta['peptide_slug']; $peptide = (string) $meta['peptide_slug'];
$model = (string) $meta['model']; $model = (string) $meta['model'];
$intent = (string) $meta['intent_label']; $intent = (string) $meta['intent_label'];
$http_status = (int) ( $meta['http_status'] ?? 200 ); $http_status = (int) ( $meta['http_status'] ?? 200 );
$is_error = $http_status >= 400; $is_error = $http_status >= 400;
$cited = isset( $meta['cited'] ) ? $meta['cited'] : null; $cited = isset( $meta['cited'] ) ? $meta['cited'] : null;
$tok_in = isset( $meta['tokens_in'] ) ? (int) $meta['tokens_in'] : null; $tok_in = isset( $meta['tokens_in'] ) ? (int) $meta['tokens_in'] : null;
$tok_out = isset( $meta['tokens_out'] ) ? (int) $meta['tokens_out'] : null; $tok_out = isset( $meta['tokens_out'] ) ? (int) $meta['tokens_out'] : null;
$latency_ms = isset( $meta['latency_ms'] ) ? (int) $meta['latency_ms'] : null; $latency_ms = isset( $meta['latency_ms'] ) ? (int) $meta['latency_ms'] : null;
$cost_usd = (float) ( $meta['cost_usd'] ?? 0.0 ); $cost_usd = (float) ( $meta['cost_usd'] ?? 0.0 );
$run_id = (string) ( $meta['run_id'] ?? '' ); $run_id = (string) ( $meta['run_id'] ?? '' );
$config_ver = isset( $meta['config_version'] ) ? (int) $meta['config_version'] : null; $config_ver = isset( $meta['config_version'] ) ? (int) $meta['config_version'] : null;
$io_captured = isset( $meta['io_captured'] ) ? (int) $meta['io_captured'] : 0; $io_captured = isset( $meta['io_captured'] ) ? (int) $meta['io_captured'] : 0;
@@ -93,7 +93,7 @@ class PRV_Call_Drawer_Renderer {
// io_captured = 1 AND io row present → Normal. // io_captured = 1 AND io row present → Normal.
// io_captured = 1 AND io row absent → Pruned (aged out by retention cron). // io_captured = 1 AND io row absent → Pruned (aged out by retention cron).
// io_captured = 0 → Legacy / not captured (pre-feature row). // io_captured = 0 → Legacy / not captured (pre-feature row).
$has_io = ( null !== $io ); $has_io = ( null !== $io );
$vis_row_null = empty( $meta['visibility_row'] ); $vis_row_null = empty( $meta['visibility_row'] );
if ( ! $is_error ) { if ( ! $is_error ) {
$is_legacy = ( 0 === $io_captured ); $is_legacy = ( 0 === $io_captured );

View File

@@ -133,10 +133,10 @@ class PRV_Call_Log_Table_Renderer {
// Status filter. // Status filter.
$status_opts = array( $status_opts = array(
'' => __( 'All statuses', 'pr-vision' ), '' => __( 'All statuses', 'pr-vision' ),
'cited' => __( 'Cited', 'pr-vision' ), 'cited' => __( 'Cited', 'pr-vision' ),
'not_cited' => __( 'Not cited', 'pr-vision' ), 'not_cited' => __( 'Not cited', 'pr-vision' ),
'error' => __( 'Error', 'pr-vision' ), 'error' => __( 'Error', 'pr-vision' ),
); );
echo '<label for="prv-f-status" class="prv-sr-only">' . esc_html__( 'Status', 'pr-vision' ) . '</label>'; echo '<label for="prv-f-status" class="prv-sr-only">' . esc_html__( 'Status', 'pr-vision' ) . '</label>';
echo '<select id="prv-f-status" name="prv_filter_status" class="prv-filter-select">'; echo '<select id="prv-f-status" name="prv_filter_status" class="prv-filter-select">';
@@ -180,12 +180,12 @@ class PRV_Call_Log_Table_Renderer {
} }
foreach ( $rows as $row ) { foreach ( $rows as $row ) {
$id = (int) $row['id']; $id = (int) $row['id'];
$is_error = ( (int) $row['http_status'] >= 400 ); $is_error = ( (int) $row['http_status'] >= 400 );
$cited_null = ( null === $row['cited'] ); $cited_null = ( null === $row['cited'] );
$is_cited = ! $cited_null && (bool) $row['cited']; $is_cited = ! $cited_null && (bool) $row['cited'];
$latency_ms = isset( $row['latency_ms'] ) ? (int) $row['latency_ms'] : null; $latency_ms = isset( $row['latency_ms'] ) ? (int) $row['latency_ms'] : null;
$lat_warn = ( null !== $latency_ms && $latency_ms > 8000 ) ? ' style="color:#FFB36E"' : ''; $lat_warn = ( null !== $latency_ms && $latency_ms > 8000 ) ? ' style="color:#FFB36E"' : '';
$status_chip = $is_error ? '<span class="prv-chip prv-chip--error">&#x2715; Error</span>' : '<span class="prv-chip prv-chip--ok">OK</span>'; $status_chip = $is_error ? '<span class="prv-chip prv-chip--error">&#x2715; Error</span>' : '<span class="prv-chip prv-chip--ok">OK</span>';

View File

@@ -152,7 +152,7 @@ class PRV_Config_Version {
* @return int The new version number. * @return int The new version number.
*/ */
private static function create_version_record(): int { private static function create_version_record(): int {
$versions = get_option( self::VERSIONS_KEY, array() ); $versions = get_option( self::VERSIONS_KEY, array() );
if ( ! is_array( $versions ) ) { if ( ! is_array( $versions ) ) {
$versions = array(); $versions = array();
} }

View File

@@ -124,16 +124,16 @@ class PRV_Config {
$per_probe = 0.005; $per_probe = 0.005;
$per_run = round( $probe_count * $per_probe, 4 ); $per_run = round( $probe_count * $per_probe, 4 );
$cadence = self::get_cadence(); $cadence = self::get_cadence();
$runs_per_month = 'weekly' === $cadence ? 4 : ( 'daily' === $cadence ? 30 : 8 ); $runs_per_month = 'weekly' === $cadence ? 4 : ( 'daily' === $cadence ? 30 : 8 );
$per_month = round( $per_run * $runs_per_month, 4 ); $per_month = round( $per_run * $runs_per_month, 4 );
$cap = self::get_monthly_budget_usd(); $cap = self::get_monthly_budget_usd();
return array( return array(
'per_run_usd' => $per_run, 'per_run_usd' => $per_run,
'per_month_usd' => $per_month, 'per_month_usd' => $per_month,
'probe_count' => $probe_count, 'probe_count' => $probe_count,
'over_cap' => $per_month > $cap, 'over_cap' => $per_month > $cap,
); );
} }

View File

@@ -99,12 +99,12 @@ class PRV_Cost_Rollup_Query {
$result = array(); $result = array();
foreach ( (array) $rows as $row ) { foreach ( (array) $rows as $row ) {
$calls = (int) $row['calls']; $calls = (int) $row['calls'];
$mtd_cost = (float) $row['mtd_cost']; $mtd_cost = (float) $row['mtd_cost'];
$result[] = array( $result[] = array(
'model' => (string) $row['model'], 'model' => (string) $row['model'],
'calls' => $calls, 'calls' => $calls,
'mtd_cost' => $mtd_cost, 'mtd_cost' => $mtd_cost,
'cost_per_call' => $calls > 0 ? $mtd_cost / $calls : 0.0, 'cost_per_call' => $calls > 0 ? $mtd_cost / $calls : 0.0,
); );
} }
@@ -193,8 +193,8 @@ class PRV_Cost_Rollup_Query {
* @return float Projected full-month cost. * @return float Projected full-month cost.
*/ */
public function project_month_end( float $mtd_cost ): float { public function project_month_end( float $mtd_cost ): float {
$days_in_month = (int) gmdate( 't' ); $days_in_month = (int) gmdate( 't' );
$day_of_month = (int) gmdate( 'j' ); $day_of_month = (int) gmdate( 'j' );
if ( $day_of_month < 1 ) { if ( $day_of_month < 1 ) {
return $mtd_cost; return $mtd_cost;

View File

@@ -75,14 +75,14 @@ class PRV_Costs_Page {
// Drill-down parameters. // Drill-down parameters.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$level = isset( $_GET['prv_level'] ) ? sanitize_text_field( wp_unslash( $_GET['prv_level'] ) ) : 'run'; $level = isset( $_GET['prv_level'] ) ? sanitize_text_field( wp_unslash( $_GET['prv_level'] ) ) : 'run';
// phpcs:ignore WordPress.Security.NonceVerification.Recommended // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$offset = isset( $_GET['prv_offset'] ) ? absint( wp_unslash( $_GET['prv_offset'] ) ) : 0; $offset = isset( $_GET['prv_offset'] ) ? absint( wp_unslash( $_GET['prv_offset'] ) ) : 0;
$drill = $query->get_drill_down( $level, $offset ); $drill = $query->get_drill_down( $level, $offset );
$cap = PRV_Config::get_monthly_budget_usd(); $cap = PRV_Config::get_monthly_budget_usd();
$mtd_cost = $summary['total_cost']; $mtd_cost = $summary['total_cost'];
$projected = $query->project_month_end( $mtd_cost ); $projected = $query->project_month_end( $mtd_cost );
$renderer = new PRV_Costs_Renderer(); $renderer = new PRV_Costs_Renderer();
$renderer->render( $renderer->render(

View File

@@ -44,9 +44,9 @@ class PRV_Costs_Renderer {
$level = (string) $data['level']; $level = (string) $data['level'];
$offset = (int) $data['offset']; $offset = (int) $data['offset'];
$meter_pct = $cap > 0 ? min( 100, round( ( $mtd_cost / $cap ) * 100 ) ) : 0; $meter_pct = $cap > 0 ? min( 100, round( ( $mtd_cost / $cap ) * 100 ) ) : 0;
$meter_class = $meter_pct >= 90 ? ' prv-meter--capped' : ''; $meter_class = $meter_pct >= 90 ? ' prv-meter--capped' : '';
$projected_warn = $projected > $cap; $projected_warn = $projected > $cap;
echo '<div class="wrap prv-page-wrap">'; echo '<div class="wrap prv-page-wrap">';
$this->render_subnav( 'costs' ); $this->render_subnav( 'costs' );
@@ -139,10 +139,10 @@ class PRV_Costs_Renderer {
); );
echo '<nav class="prv-subnav" aria-label="' . esc_attr__( 'PR Vision navigation', 'pr-vision' ) . '">'; echo '<nav class="prv-subnav" aria-label="' . esc_attr__( 'PR Vision navigation', 'pr-vision' ) . '">';
foreach ( $tabs as $key => $tab ) { foreach ( $tabs as $key => $tab ) {
$is_active = ( $key === $active ); $is_active = ( $key === $active );
$aria_current = $is_active ? ' aria-current="page"' : ''; $aria_current = $is_active ? ' aria-current="page"' : '';
$tab_class = 'prv-subnav-tab' . ( $is_active ? ' prv-subnav-tab--active' : '' ); $tab_class = 'prv-subnav-tab' . ( $is_active ? ' prv-subnav-tab--active' : '' );
$url = admin_url( 'admin.php?page=' . rawurlencode( $tab['slug'] ) ); $url = admin_url( 'admin.php?page=' . rawurlencode( $tab['slug'] ) );
echo '<a href="' . esc_url( $url ) . '" class="' . esc_attr( $tab_class ) . '"' . $aria_current . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- aria-current is safe static string echo '<a href="' . esc_url( $url ) . '" class="' . esc_attr( $tab_class ) . '"' . $aria_current . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- aria-current is safe static string
echo esc_html( $tab['label'] ); echo esc_html( $tab['label'] );
echo '</a>'; echo '</a>';

View File

@@ -138,9 +138,9 @@ class PRV_Model_Manager_Table {
* @return string HTML badge (pre-escaped). * @return string HTML badge (pre-escaped).
*/ */
private function render_health_badge( array $m ): string { private function render_health_badge( array $m ): string {
$status = (string) ( $m['health_status'] ?? 'unknown' ); $status = (string) ( $m['health_status'] ?? 'unknown' );
$probed = (int) ( $m['health_probed'] ?? 0 ); $probed = (int) ( $m['health_probed'] ?? 0 );
$errors = (int) ( $m['health_errors'] ?? 0 ); $errors = (int) ( $m['health_errors'] ?? 0 );
switch ( $status ) { switch ( $status ) {
case 'healthy': case 'healthy':

View File

@@ -212,7 +212,7 @@ class PRV_Model_Registry {
if ( ! isset( $outcomes[ $slug ] ) ) { if ( ! isset( $outcomes[ $slug ] ) ) {
continue; continue;
} }
$o = $outcomes[ $slug ]; $o = $outcomes[ $slug ];
$m['health_probed'] = (int) $o['probed']; $m['health_probed'] = (int) $o['probed'];
$m['health_errors'] = (int) $o['errors']; $m['health_errors'] = (int) $o['errors'];
$m['health_run_id'] = $run_id; $m['health_run_id'] = $run_id;

View File

@@ -157,11 +157,11 @@ class PRV_Probe_Run_Executor {
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, Universal.WhiteSpace.CommaSpacing.TooMuchSpaceAfter // phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, Universal.WhiteSpace.CommaSpacing.TooMuchSpaceAfter
$cid = $this->capture->write_meta( $cid = $this->capture->write_meta(
array( array(
'visibility_row' => null, 'run_id' => $run_id, 'visibility_row' => null, 'run_id' => $run_id,
'peptide_slug' => $peptide['slug'], 'model' => $model, 'peptide_slug' => $peptide['slug'], 'model' => $model,
'intent_label' => $intent_tpl, 'tokens_in' => null, 'intent_label' => $intent_tpl, 'tokens_in' => null,
'tokens_out' => null, 'cost_usd' => 0.0, 'tokens_out' => null, 'cost_usd' => 0.0,
'latency_ms' => $latency_ms, 'cited' => null, 'latency_ms' => $latency_ms, 'cited' => null,
'http_status' => $http_status, 'config_version' => $config_ver, 'http_status' => $http_status, 'config_version' => $config_ver,
) )
); // phpcs:enable ); // phpcs:enable
@@ -184,11 +184,11 @@ class PRV_Probe_Run_Executor {
// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, Universal.WhiteSpace.CommaSpacing.TooMuchSpaceAfter // phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, Universal.WhiteSpace.CommaSpacing.TooMuchSpaceAfter
$cid = $this->capture->write_meta( $cid = $this->capture->write_meta(
array( array(
'visibility_row' => $row_id > 0 ? $row_id : null, 'run_id' => $run_id, 'visibility_row' => $row_id > 0 ? $row_id : null, 'run_id' => $run_id,
'peptide_slug' => $peptide['slug'], 'model' => $model, 'peptide_slug' => $peptide['slug'], 'model' => $model,
'intent_label' => $intent_tpl, 'tokens_in' => $result->get_tokens_in(), 'intent_label' => $intent_tpl, 'tokens_in' => $result->get_tokens_in(),
'tokens_out' => $result->get_tokens_out(), 'cost_usd' => $result->get_cost_usd(), 'tokens_out' => $result->get_tokens_out(), 'cost_usd' => $result->get_cost_usd(),
'latency_ms' => $latency_ms, 'cited' => $result->is_cited() ? 1 : 0, 'latency_ms' => $latency_ms, 'cited' => $result->is_cited() ? 1 : 0,
'http_status' => $http_status, 'config_version' => $config_ver, 'http_status' => $http_status, 'config_version' => $config_ver,
) )
); // phpcs:enable ); // phpcs:enable

View File

@@ -72,7 +72,7 @@ class PRV_Settings_Controller {
$old_cadence = PRV_Config::get_cadence(); $old_cadence = PRV_Config::get_cadence();
// phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce verified above. // phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce verified above.
$budget = isset( $_POST['prv_monthly_budget_usd'] ) $budget = isset( $_POST['prv_monthly_budget_usd'] )
? max( 0.01, (float) sanitize_text_field( wp_unslash( (string) $_POST['prv_monthly_budget_usd'] ) ) ) ? max( 0.01, (float) sanitize_text_field( wp_unslash( (string) $_POST['prv_monthly_budget_usd'] ) ) )
: PRV_DEFAULT_MONTHLY_BUDGET_USD; : PRV_DEFAULT_MONTHLY_BUDGET_USD;
update_option( 'prv_monthly_budget_usd', $budget ); update_option( 'prv_monthly_budget_usd', $budget );
@@ -85,7 +85,7 @@ class PRV_Settings_Controller {
$cadence_raw = isset( $_POST['prv_cadence'] ) $cadence_raw = isset( $_POST['prv_cadence'] )
? sanitize_text_field( wp_unslash( (string) $_POST['prv_cadence'] ) ) ? sanitize_text_field( wp_unslash( (string) $_POST['prv_cadence'] ) )
: 'weekly'; : 'weekly';
$cadence = in_array( $cadence_raw, array( 'weekly', 'daily', 'twicedaily' ), true ) ? $cadence_raw : 'weekly'; $cadence = in_array( $cadence_raw, array( 'weekly', 'daily', 'twicedaily' ), true ) ? $cadence_raw : 'weekly';
update_option( PRV_Config::CADENCE_KEY, $cadence ); update_option( PRV_Config::CADENCE_KEY, $cadence );
if ( ! empty( $_POST['prv_peptides_json'] ) ) { if ( ! empty( $_POST['prv_peptides_json'] ) ) {
@@ -153,8 +153,8 @@ class PRV_Settings_Controller {
$result_arg = 'prv_key_unchanged'; $result_arg = 'prv_key_unchanged';
if ( '' !== $raw_key ) { if ( '' !== $raw_key ) {
$stored = PRV_Key_Store::store_key( $raw_key ); $stored = PRV_Key_Store::store_key( $raw_key );
$result_arg = $stored ? 'prv_key_set' : 'prv_key_error'; $result_arg = $stored ? 'prv_key_set' : 'prv_key_error';
// Explicitly unset to prevent the plaintext lingering in memory. // Explicitly unset to prevent the plaintext lingering in memory.
unset( $raw_key ); unset( $raw_key );
} }
@@ -162,8 +162,8 @@ class PRV_Settings_Controller {
wp_safe_redirect( wp_safe_redirect(
add_query_arg( add_query_arg(
array( array(
'page' => self::MENU_SLUG, 'page' => self::MENU_SLUG,
$result_arg => 1, $result_arg => 1,
), ),
admin_url( 'admin.php' ) admin_url( 'admin.php' )
) )

View File

@@ -119,7 +119,7 @@ class PRV_Ai_Visibility_Panel implements PRV_Dashboard_Panel {
foreach ( $standings as $row ) { foreach ( $standings as $row ) {
if ( ! empty( $row['cited'] ) ) { if ( ! empty( $row['cited'] ) ) {
$cited_count++; ++$cited_count;
} }
} }
@@ -206,9 +206,9 @@ class PRV_Ai_Visibility_Panel implements PRV_Dashboard_Panel {
foreach ( $last_run_counts as $model ) { foreach ( $last_run_counts as $model ) {
$status = (string) ( $model['health_status'] ?? 'unknown' ); $status = (string) ( $model['health_status'] ?? 'unknown' );
if ( 'retired' === $status ) { if ( 'retired' === $status ) {
$retired_count++; ++$retired_count;
} elseif ( 'healthy' === $status ) { } elseif ( 'healthy' === $status ) {
$healthy_count++; ++$healthy_count;
} }
} }