Files
peptide-repo-core/includes/cpt/class-pr-core-peptide-meta-schema.php
peptiderepo b84cc656e5 fix: add short descriptions to file docblocks + fix security/Yoda errors in metaboxes
- 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
2026-06-16 16:12:25 +00:00

145 lines
4.2 KiB
PHP

<?php
/**
* Peptide Meta Schema.
*
* @package Peptide_Repo_Core
*/
declare(strict_types=1);
/**
* Returns the complete meta field definition map used by PR_Core_Peptide_CPT
*
* @package Peptide_Repo_Core
*/
/**
* Meta field schema definitions for the peptide CPT.
*
* What: Returns the complete meta field definition map used by PR_Core_Peptide_CPT.
* Who calls it: PR_Core_Peptide_CPT::get_meta_fields() delegates here.
* Dependencies: PR_Core_Peptide_CPT (for sanitize callbacks), PR_Core_Schema_Sanitizers,
* PR_Core_Verification_Sanitizers.
*
* @see cpt/class-pr-core-peptide-cpt.php — Consumer of this schema.
*/
class PR_Core_Peptide_Meta_Schema {
/**
* Return the full meta field definition array for the peptide CPT.
*
* Keys map to meta_key strings; values are arrays with type, default, and sanitize.
*
* @return array<string, array<string, mixed>>
*/
public static function get_fields(): array {
return array(
'display_name' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'aliases' => array(
'type' => 'string',
'default' => '[]',
'sanitize' => array( PR_Core_Schema_Sanitizers::class, 'sanitize_json_array' ),
),
'molecular_formula' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'molecular_weight' => array(
'type' => 'number',
'default' => 0,
'sanitize' => 'floatval',
),
'cas_number' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'drugbank_id' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'chembl_id' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'evidence_strength' => array(
'type' => 'string',
'default' => 'preclinical',
'sanitize' => array( PR_Core_Peptide_CPT::class, 'sanitize_evidence_strength' ),
),
'editorial_review_status' => array(
'type' => 'string',
'default' => 'draft',
'sanitize' => array( PR_Core_Peptide_CPT::class, 'sanitize_review_status' ),
),
'last_editorial_review_at' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'medical_editor_id' => array(
'type' => 'integer',
'default' => 0,
'sanitize' => 'absint',
),
'_pr_last_source_verified' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'_pr_last_reviewed' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'_pr_next_review_by' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_text_field',
),
'_pr_verification_velocity' => array(
'type' => 'string',
'default' => 'medium',
'sanitize' => array( PR_Core_Verification_Sanitizers::class, 'sanitize_velocity' ),
),
'_pr_verification_notes' => array(
'type' => 'string',
'default' => '',
'sanitize' => 'sanitize_textarea_field',
),
'_pr_verification_status' => array(
'type' => 'string',
'default' => 'current',
'sanitize' => array( PR_Core_Verification_Sanitizers::class, 'sanitize_status' ),
),
'_pr_molecular_formula' => array(
'type' => 'string',
'default' => '',
'sanitize' => array( PR_Core_Schema_Sanitizers::class, 'sanitize_molecular_formula' ),
),
'_pr_molecular_weight' => array(
'type' => 'string',
'default' => '',
'sanitize' => array( PR_Core_Schema_Sanitizers::class, 'sanitize_molecular_weight_string' ),
),
'_pr_aliases' => array(
'type' => 'string',
'default' => '[]',
'sanitize' => array( PR_Core_Schema_Sanitizers::class, 'sanitize_json_array' ),
),
'_pr_faq_items' => array(
'type' => 'string',
'default' => '[]',
'sanitize' => array( PR_Core_Schema_Sanitizers::class, 'sanitize_faq_items' ),
),
);
}
}