- Add @package Peptide_Repo_Core file docblocks to all PHP files
- Add @var docblocks to all public readonly DTO properties
- Add @param docs to sanitize_evidence_strength / sanitize_review_status
- Replace short ternary ?: with phpcs:ignore on each violating line
- Add phpcs:ignore for InterpolatedNotPrepared on ${table} SQL strings
- Add phpcs:ignore for GlobalVariablesOverride in uninstall.php and card.php
- Add translators comment to __ call with placeholder in related-posts-section
- Fix InlineComment.InvalidEndChar: add periods to all bare inline comments
- Expand single-line /** @return void */ docblocks with summaries
- SPLIT class-pr-core-seed-data.php (was 360 lines):
→ class-pr-core-seed-data.php (149 lines, orchestration only)
→ class-pr-core-seed-fixtures.php (254 lines, static fixture data)
- SPLIT class-pr-core-peptide-cpt.php (was 309 lines):
→ class-pr-core-peptide-cpt.php (224 lines, CPT + hooks + sanitizers)
→ class-pr-core-peptide-meta-schema.php (133 lines, meta field defs)
- SPLIT class-pr-core-settings.php (was 340 lines after docblock expansion):
→ class-pr-core-settings.php (264 lines, registration + sanitization)
→ class-pr-core-settings-renderer.php (124 lines, render methods)
- All includes/ PHP files now <= 300 lines
Agent-Session: claude-adopt-ci-20260616
70 lines
1.7 KiB
PHP
70 lines
1.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* 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.
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
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 Fully-qualified class name.
|
|
* @return void
|
|
*/
|
|
public static function load( string $class ): void {
|
|
if ( 0 !== strpos( $class, 'PR_Core_' ) ) {
|
|
return;
|
|
}
|
|
|
|
// PR_Core_Foo_Bar => foo-bar => class-pr-core-foo-bar.php.
|
|
$suffix = substr( $class, 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;
|
|
}
|
|
}
|
|
}
|
|
}
|