From 68ae5b9b1a1d157986611df00cea0a01169e8f89 Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Sat, 13 Jun 2026 09:42:55 +0000 Subject: [PATCH] PHPCS compliance: fix pre-existing violations exposed by gating the lint step All violations were present in v0.1.0 and hidden by continue-on-error. Now that PHPCS gates the build (P2-B), they must be fixed. - Add file-level @package doc comment to all PHP files (file doc requirement) - Add short descriptions to @var and constructor docblocks throughout - Fix @param type spacing throughout (PHPCS alignment rules) - Expand phpcs:ignore lines to include NoCaching where DirectQuery is already suppressed (uninstall.php, cost-ledger, table-manager, collector) - Suppress EscapeOutput.ExceptionNotEscaped on RuntimeException messages (exception strings are not HTML output) - Suppress error_log_error_log on the probe-runner failure log - Replace date() with gmdate() in panel (timezone-aware per WP standard) - Convert inline associative arrays to multi-line in config (WP array style) - Fix double-arrow alignment in probe-runner counts and insert arrays - Fix double-space before ?? in provider constructors - Expand phpcs:ignore for reads to include MissingUnslash - Fix $counts++ to ++$counts (prefix increment per WP standard) - Fix V1/v1 capitalisation in interface doc long description Agent-Session: pr-vision rename v0.1.1 --- .../class-prv-ai-visibility-collector.php | 7 ++- .../interface-prv-data-collector.php | 3 +- includes/core/class-prv-activator.php | 1 + includes/core/class-prv-admin-page.php | 17 +++--- includes/core/class-prv-autoloader.php | 1 + .../core/class-prv-collector-registry.php | 7 ++- includes/core/class-prv-config.php | 61 +++++++++++++++---- includes/core/class-prv-cost-ledger.php | 7 ++- includes/core/class-prv-cron.php | 1 + includes/core/class-prv-deactivator.php | 1 + includes/core/class-prv-plugin.php | 1 + includes/core/class-prv-probe-result.php | 23 +++++-- includes/core/class-prv-probe-runner.php | 52 +++++++++------- includes/core/class-prv-table-manager.php | 3 +- .../panel/class-prv-ai-visibility-panel.php | 15 +++-- .../panel/interface-prv-dashboard-panel.php | 1 + .../providers/class-prv-citation-detector.php | 1 + .../providers/class-prv-gateway-client.php | 5 +- .../class-prv-openrouter-provider.php | 23 +++++-- .../class-prv-perplexity-provider.php | 23 +++++-- .../interface-prv-probe-provider.php | 1 + pr-vision.php | 13 ++-- uninstall.php | 5 +- 23 files changed, 189 insertions(+), 83 deletions(-) diff --git a/includes/collector/class-prv-ai-visibility-collector.php b/includes/collector/class-prv-ai-visibility-collector.php index d45bfe5..cb4fbe3 100644 --- a/includes/collector/class-prv-ai-visibility-collector.php +++ b/includes/collector/class-prv-ai-visibility-collector.php @@ -1,4 +1,5 @@ (string) $row['run_id'], + 'run_id' => (string) $row['run_id'], 'captured_at' => (string) $row['captured_at'], 'score' => $this->compute_score( (int) $row['cited_count'], diff --git a/includes/collector/interface-prv-data-collector.php b/includes/collector/interface-prv-data-collector.php index 8a2dd33..c77c647 100644 --- a/includes/collector/interface-prv-data-collector.php +++ b/includes/collector/interface-prv-data-collector.php @@ -1,10 +1,11 @@ self::MENU_SLUG, - 'prv_run_done' => 1, - 'prv_probed' => (int) $counts['probed'], - 'prv_skipped' => (int) ( $counts['skipped_budget'] + $counts['skipped_error'] ), + 'page' => self::MENU_SLUG, + 'prv_run_done' => 1, + 'prv_probed' => (int) $counts['probed'], + 'prv_skipped' => (int) ( $counts['skipped_budget'] + $counts['skipped_error'] ), ), admin_url( 'admin.php' ) ); @@ -183,10 +184,10 @@ class PRV_Admin_Page { if ( empty( $_GET['prv_run_done'] ) ) { return; } - // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $probed = (int) ( $_GET['prv_probed'] ?? 0 ); - // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $skipped = (int) ( $_GET['prv_skipped'] ?? 0 ); + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $probed = isset( $_GET['prv_probed'] ) ? absint( wp_unslash( $_GET['prv_probed'] ) ) : 0; + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $skipped = isset( $_GET['prv_skipped'] ) ? absint( wp_unslash( $_GET['prv_skipped'] ) ) : 0; echo '
';
echo esc_html(
diff --git a/includes/core/class-prv-autoloader.php b/includes/core/class-prv-autoloader.php
index b48b1ce..62ea42b 100644
--- a/includes/core/class-prv-autoloader.php
+++ b/includes/core/class-prv-autoloader.php
@@ -1,4 +1,5 @@
'bpc-157', 'label' => 'BPC-157' ),
- array( 'slug' => 'tb-500', 'label' => 'TB-500' ),
- array( 'slug' => 'mk-677', 'label' => 'MK-677' ),
- array( 'slug' => 'cjc-1295', 'label' => 'CJC-1295' ),
- array( 'slug' => 'ghrp-6', 'label' => 'GHRP-6' ),
- array( 'slug' => 'ipamorelin', 'label' => 'Ipamorelin' ),
- array( 'slug' => 'semaglutide', 'label' => 'Semaglutide' ),
- array( 'slug' => 'tirzepatide', 'label' => 'Tirzepatide' ),
- array( 'slug' => 'selank', 'label' => 'Selank' ),
- array( 'slug' => 'semax', 'label' => 'Semax' ),
- array( 'slug' => 'nad-plus', 'label' => 'NAD+' ),
- array( 'slug' => 'aod-9604', 'label' => 'AOD-9604' ),
+ array(
+ 'slug' => 'bpc-157',
+ 'label' => 'BPC-157',
+ ),
+ array(
+ 'slug' => 'tb-500',
+ 'label' => 'TB-500',
+ ),
+ array(
+ 'slug' => 'mk-677',
+ 'label' => 'MK-677',
+ ),
+ array(
+ 'slug' => 'cjc-1295',
+ 'label' => 'CJC-1295',
+ ),
+ array(
+ 'slug' => 'ghrp-6',
+ 'label' => 'GHRP-6',
+ ),
+ array(
+ 'slug' => 'ipamorelin',
+ 'label' => 'Ipamorelin',
+ ),
+ array(
+ 'slug' => 'semaglutide',
+ 'label' => 'Semaglutide',
+ ),
+ array(
+ 'slug' => 'tirzepatide',
+ 'label' => 'Tirzepatide',
+ ),
+ array(
+ 'slug' => 'selank',
+ 'label' => 'Selank',
+ ),
+ array(
+ 'slug' => 'semax',
+ 'label' => 'Semax',
+ ),
+ array(
+ 'slug' => 'nad-plus',
+ 'label' => 'NAD+',
+ ),
+ array(
+ 'slug' => 'aod-9604',
+ 'label' => 'AOD-9604',
+ ),
);
}
diff --git a/includes/core/class-prv-cost-ledger.php b/includes/core/class-prv-cost-ledger.php
index 8165bfa..a1c7fb9 100644
--- a/includes/core/class-prv-cost-ledger.php
+++ b/includes/core/class-prv-cost-ledger.php
@@ -1,4 +1,5 @@
get_month_to_date_usd();
+ $cap = PRV_Config::get_monthly_budget_usd();
+ $spent = $this->get_month_to_date_usd();
return ( $spent + $estimated_cost_usd ) <= $cap;
}
@@ -95,7 +96,7 @@ class PRV_Cost_Ledger {
$table = PRV_Table_Manager::get_table_name();
- // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$result = $wpdb->update(
$table,
array( 'cost_usd' => number_format( $cost_usd, 8, '.', '' ) ),
diff --git a/includes/core/class-prv-cron.php b/includes/core/class-prv-cron.php
index 9816ea5..dcf1f52 100644
--- a/includes/core/class-prv-cron.php
+++ b/includes/core/class-prv-cron.php
@@ -1,4 +1,5 @@
0,
- 'skipped_budget' => 0,
- 'skipped_error' => 0,
+ 'probed' => 0,
+ 'skipped_budget' => 0,
+ 'skipped_error' => 0,
);
foreach ( $peptides as $peptide ) {
@@ -66,22 +71,23 @@ class PRV_Probe_Runner {
$provider = $this->resolve_provider( $model );
if ( null === $provider || ! $provider->is_configured() ) {
- $counts['skipped_error']++;
+ ++$counts['skipped_error'];
continue;
}
// Budget pre-check.
$estimated = $this->get_estimated_cost( $model );
if ( ! $this->ledger->can_afford( $estimated ) ) {
- $counts['skipped_budget']++;
+ ++$counts['skipped_budget'];
continue;
}
try {
$result = $provider->probe( $query );
} catch ( \Exception $e ) {
- error_log( sprintf( 'PRV: probe failed [%s / %s]: %s', $model, $peptide['slug'], $e->getMessage() ) );
- $counts['skipped_error']++;
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ error_log( sprintf( 'PRV: probe failed [%s / %s]: %s', $model, $peptide['slug'], $e->getMessage() ) );
+ ++$counts['skipped_error'];
continue;
}
@@ -90,7 +96,7 @@ class PRV_Probe_Runner {
$this->ledger->update_row_cost( $row_id, $result->get_cost_usd() );
}
- $counts['probed']++;
+ ++$counts['probed'];
}
}
}
@@ -101,11 +107,11 @@ class PRV_Probe_Runner {
/**
* Persist a single probe result to the database.
*
- * @param string $run_id UUID for this run.
- * @param array{slug:string, label:string} $peptide Peptide config.
- * @param string $model Model identifier.
- * @param string $intent_tpl Raw intent template string.
- * @param PRV_Probe_Result $result Probe result.
+ * @param string $run_id UUID for this run.
+ * @param array