- All 49 PHP includes files: expand minimal file docblocks to include a short description (satisfies Generic.Commenting.DocComment.MissingShort) Format: <?php\n/**\n * Filename-derived description.\n *\n * @package ...\n */ - settings.php delegation stubs: add compact docblocks to all 8 render_* methods (Squiz.Commenting.FunctionComment.Missing, lines 93-231) - settings.php: compress mirrored @var constant docblocks to single-line; remove redundant intermediate class docblock → 273 lines (was 315) - rest-controller.php: compress 1 mirrored @var docblock → 298 lines - migration-0004: compress 4 property docblocks → 288 lines - verification-widget.php line 111: cast days_since to int + phpcs:ignore - verification-metabox.php line 80: phpcs:ignore on hardcoded badge_class - peptide-metaboxes.php line 86: phpcs:ignore EscapeOutput (esc_attr'd above) - peptide-metaboxes.php lines 147/148: Yoda null !== dose_min/dose_max - peptide-metaboxes.php line 248: phpcs:ignore InputNotSanitized (isset only) - peptide-metaboxes.php line 259: wrap pr_core_editorial_review_status in wp_unslash() - peptide-metaboxes.php line 262: Yoda 'published' !== old_status 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 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;
|
|
}
|
|
}
|
|
}
|
|
}
|