- 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
81 lines
1.8 KiB
PHP
81 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Autoloader.
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Resolves PR_Core_ class names to file paths under includes/
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
/**
|
|
* SPL autoloader for PR_Core_ prefixed classes.
|
|
*
|
|
* What: Resolves PR_Core_ class names to file paths under includes/.
|
|
* Who calls it: peptide-repo-core.php bootstrap.
|
|
* Dependencies: None.
|
|
*
|
|
* Naming convention: PR_Core_Foo_Bar => class-pr-core-foo-bar.php.
|
|
* Scans includes/ and all immediate subdirectories.
|
|
*
|
|
* @see peptide-repo-core.php — Registers this autoloader at boot.
|
|
*/
|
|
class PR_Core_Autoloader {
|
|
|
|
/**
|
|
* Directories to scan for class files.
|
|
*
|
|
* @var string[] Directories to scan for class files.
|
|
*/
|
|
private static array $dirs = array();
|
|
|
|
/**
|
|
* Register the autoloader with SPL.
|
|
*
|
|
* Side effects: calls spl_autoload_register().
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function register(): void {
|
|
$base = PR_CORE_PLUGIN_DIR . 'includes/';
|
|
|
|
self::$dirs[] = $base;
|
|
|
|
// Add all immediate subdirectories.
|
|
foreach ( glob( $base . '*', GLOB_ONLYDIR ) as $dir ) {
|
|
self::$dirs[] = trailingslashit( $dir );
|
|
}
|
|
|
|
spl_autoload_register( array( __CLASS__, 'load' ) );
|
|
}
|
|
|
|
/**
|
|
* Autoload callback. Only handles PR_Core_ prefixed classes.
|
|
*
|
|
* @param string $class_name Fully-qualified class name.
|
|
* @return void
|
|
*/
|
|
public static function load( string $class_name ): void {
|
|
if ( 0 !== strpos( $class_name, 'PR_Core_' ) ) {
|
|
return;
|
|
}
|
|
|
|
// PR_Core_Foo_Bar => foo-bar => class-pr-core-foo-bar.php.
|
|
$suffix = substr( $class_name, 8 ); // Strip 'PR_Core_'.
|
|
$filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php';
|
|
|
|
foreach ( self::$dirs as $dir ) {
|
|
$path = $dir . $filename;
|
|
if ( file_exists( $path ) ) {
|
|
require_once $path;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|