Adopt reusable CI standard + 300-line splits (#167)

ci: adopt estate reusable CI + split 300-line violations (v0.22.0)

Squash merge of PR #167 (claude/adopt-ci-20260616)
Head: dc5145cd92

Agent-Session: deploy-operator-2026-06-16
This commit is contained in:
peptiderepo
2026-06-16 22:01:45 +07:00
committed by GitHub
parent d770e8a86a
commit 110c681c57
25 changed files with 1059 additions and 1026 deletions

View File

@@ -35,18 +35,18 @@ const CONSTANTS_GUARD_WINDOW = 4; // 4 covers if/elseif blocks and multi-line &&
const CONSTANTS_BOOTSTRAP_FILE = 'prautoblogger.php';
// Directories skipped when walking the shipped tree for references.
const CONSTANTS_EXCLUDE_DIRS = ['tests', 'vendor', '.github', '.git', 'node_modules'];
const CONSTANTS_EXCLUDE_DIRS = array( 'tests', 'vendor', '.github', '.git', 'node_modules' );
// Entry points for the reference scan (files and dirs relative to repo root).
const CONSTANTS_SCAN_ROOTS = [
const CONSTANTS_SCAN_ROOTS = array(
'prautoblogger.php',
'uninstall.php',
'includes',
'templates',
];
);
$verbose = in_array( '--verbose', $argv ?? [], true );
$self_test = in_array( '--self-test', $argv ?? [], true );
$verbose = in_array( '--verbose', $argv ?? array(), true );
$self_test = in_array( '--self-test', $argv ?? array(), true );
// -------------------------------------------------------------------------
// 1. Build the defined set from prautoblogger.php only.
@@ -67,7 +67,7 @@ preg_match_all(
);
/** @var array<string, int> $defined_set constant name => 1 */
$defined_set = array_flip( $def_matches[1] ?? [] );
$defined_set = array_flip( $def_matches[1] ?? array() );
if ( $verbose ) {
echo 'Defined in ' . CONSTANTS_BOOTSTRAP_FILE . ' (' . count( $defined_set ) . "):\n";
@@ -108,7 +108,7 @@ function constants_collect_php_files( string $dir, array &$files ): void {
}
/** @var string[] $php_files */
$php_files = [];
$php_files = array();
foreach ( CONSTANTS_SCAN_ROOTS as $root ) {
if ( ! file_exists( $root ) ) {
@@ -133,11 +133,11 @@ if ( $verbose ) {
// -------------------------------------------------------------------------
/** @var array<int, array{string, int, string, string}> $errors */
$errors = [];
$errors = array();
foreach ( $php_files as $php_path ) {
$raw = file_get_contents( $php_path );
if ( $raw === false ) {
if ( false === $raw ) {
fwrite( STDERR, "WARNING: cannot read {$php_path} -- skipping\n" );
continue;
}
@@ -188,7 +188,7 @@ foreach ( $php_files as $php_path ) {
}
if ( ! $guarded ) {
$errors[] = [ $php_path, $idx + 1, $name, $raw_line ];
$errors[] = array( $php_path, $idx + 1, $name, $raw_line );
}
}
}
@@ -198,7 +198,7 @@ foreach ( $php_files as $php_path ) {
// 4. Report results.
// -------------------------------------------------------------------------
if ( $errors !== [] ) {
if ( array() !== $errors ) {
fwrite( STDERR, "\nFAIL -- Unguarded undefined PRAUTOBLOGGER_* constants:\n\n" );
foreach ( $errors as [ $php_path, $lineno, $name, $line_text ] ) {
fwrite( STDERR, " {$php_path}:{$lineno}: {$name}\n" );
@@ -228,7 +228,7 @@ if ( $self_test ) {
// Now simulate an unguarded reference by re-running the scan on a temp file.
$tmp_file = tempnam( sys_get_temp_dir(), 'prab_selftest_' ) . '.php';
file_put_contents( $tmp_file, "<?php\necho {$sentinel};\n" );
$tmp_errors = [];
$tmp_errors = array();
$tmp_lines = explode( "\n", (string) file_get_contents( $tmp_file ) );
foreach ( $tmp_lines as $idx => $raw_line ) {
if ( preg_match_all( '/PRAUTOBLOGGER_[A-Z0-9_]+/', $raw_line, $m ) ) {