fix: rename $class param to $class_name + ignore UnfinishedPrepare + ruleset cleanup

- autoloader.php load() + migration-runner.php class_to_file(): rename $class
  parameter to $class_name to satisfy
  Universal.NamingConventions.NoReservedKeywordParameterNames.classFound
- dosing-repository.php line 81: add phpcs:ignore UnfinishedPrepare on
  $wpdb->prepare() — {} is a builder-constructed safe value,
  not an unfinished placeholder
- phpcs.xml.dist: remove incorrect rule names (WordPress.WP.ReservedKeyword.class,
  WordPress.DB.PreparedSQLPlaceholders.ReplacementsFound); fix excluded names to
  match actual sniff IDs from CI logs

Agent-Session: claude-adopt-ci-20260616
This commit is contained in:
peptiderepo
2026-06-16 16:29:26 +00:00
parent cb7cd7305e
commit 1d9d9d508c
4 changed files with 10 additions and 14 deletions

View File

@@ -57,16 +57,16 @@ class PR_Core_Autoloader {
/** /**
* Autoload callback. Only handles PR_Core_ prefixed classes. * Autoload callback. Only handles PR_Core_ prefixed classes.
* *
* @param string $class Fully-qualified class name. * @param string $class_name Fully-qualified class name.
* @return void * @return void
*/ */
public static function load( string $class ): void { public static function load( string $class_name ): void {
if ( 0 !== strpos( $class, 'PR_Core_' ) ) { if ( 0 !== strpos( $class_name, 'PR_Core_' ) ) {
return; return;
} }
// PR_Core_Foo_Bar => foo-bar => class-pr-core-foo-bar.php. // PR_Core_Foo_Bar => foo-bar => class-pr-core-foo-bar.php.
$suffix = substr( $class, 8 ); // Strip 'PR_Core_'. $suffix = substr( $class_name, 8 ); // Strip 'PR_Core_'.
$filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php'; $filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php';
foreach ( self::$dirs as $dir ) { foreach ( self::$dirs as $dir ) {

View File

@@ -102,11 +102,11 @@ class PR_Core_Migration_Runner {
* *
* PR_Core_Migration_0001_Dosing_Rows => migrations/class-pr-core-migration-0001-dosing-rows.php * PR_Core_Migration_0001_Dosing_Rows => migrations/class-pr-core-migration-0001-dosing-rows.php
* *
* @param string $class Fully-qualified class name. * @param string $class_name Fully-qualified class name.
* @return string Absolute file path. * @return string Absolute file path.
*/ */
private function class_to_file( string $class ): string { private function class_to_file( string $class_name ): string {
$suffix = substr( $class, 8 ); // Strip 'PR_Core_'. $suffix = substr( $class_name, 8 ); // Strip 'PR_Core_'.
$filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php'; $filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php';
return PR_CORE_PLUGIN_DIR . 'includes/migrations/' . $filename; return PR_CORE_PLUGIN_DIR . 'includes/migrations/' . $filename;

View File

@@ -77,7 +77,7 @@ class PR_Core_Dosing_Repository {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$rows = $wpdb->get_results( $rows = $wpdb->get_results(
$wpdb->prepare( $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- dynamic {$where_sql} is builder-constructed, not a placeholder
"SELECT * FROM {$table} WHERE {$where_sql} ORDER BY evidence_strength DESC, study_year DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT * FROM {$table} WHERE {$where_sql} ORDER BY evidence_strength DESC, study_year DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
...$params ...$params
), ),

View File

@@ -31,15 +31,11 @@
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/> <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/>
<!-- Error log calls used for debug fallback in migration code; acceptable --> <!-- Error log calls used for debug fallback in migration code; acceptable -->
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_error_log"/> <exclude name="WordPress.PHP.DevelopmentFunctions.error_log_error_log"/>
<!-- file_get_contents used for local file reads, not HTTP (migration-0004) --> <!-- file_get_contents used for local file reads, not HTTP -->
<exclude name="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents"/> <exclude name="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents"/>
<!-- @ silencing used only in PubChem HTTP client for network errors --> <!-- @ silencing used only in PubChem HTTP client for network errors -->
<exclude name="WordPress.PHP.NoSilencedErrors.Discouraged"/> <exclude name="WordPress.PHP.NoSilencedErrors.Discouraged"/>
<!-- Duplicate interface name from PHPCS scanning both definition sites --> <!-- Duplicate interface name: PHPCS false-positive scanning both interface definition sites -->
<exclude name="Generic.Classes.DuplicateClassName.Found"/> <exclude name="Generic.Classes.DuplicateClassName.Found"/>
<!-- Prepared SQL placeholder warning: false positive on dynamic table names -->
<exclude name="WordPress.DB.PreparedSQLPlaceholders.ReplacementsFound"/>
<!-- Reserved keyword 'class' in string context (PHP 8.x ::class syntax) -->
<exclude name="WordPress.WP.ReservedKeyword.class"/>
</rule> </rule>
</ruleset> </ruleset>