<?php
declare(strict_types=1);
namespace app\store\model\staff {
    class AthleteMaster {public static $row;public static function detail(int $id,array $with=[]){return self::$row;}}
    class Sport {public static function getAllData(array $where=[]){return [['id'=>1,'name'=>'UNIT_SPORT'],['id'=>2,'name'=>'UNIT_EVENT']];}}
    class Staff {public static function getAllData(array $where=[],string $field='*'){return [['id'=>801,'name'=>'UNIT_STAFF']];}}
}
namespace {
    $root=$argv[1]??'';if(!is_dir($root.'/vendor'))throw new \RuntimeException('Actual ai_api root required');require $root.'/vendor/autoload.php';spl_autoload_register(static function(string $class)use($root):void{foreach(['app\\'=>'app/','cores\\'=>'cores/'] as $p=>$d)if(strpos($class,$p)===0){$f=$root.'/'.$d.str_replace('\\','/',substr($class,strlen($p))).'.php';if(is_file($f))require $f;return;}},true,true);
    $same=static function($a,$b,string $why):void{if($a!==$b)throw new \RuntimeException($why);};$service=(new \ReflectionClass(\app\store\service\staff\Config::class))->newInstanceWithoutConstructor();$n=0;
    foreach([['1.25','1.50','1.75','2.00','2.25'],[1.25,1.5,1.75,2,2.25]] as $values){$pla=[];foreach($values as $i=>$pal)$pla[]=['strength'=>$i+2,'pal'=>$pal,'id'=>$i+101];$raw=['id'=>7,'sport_id'=>1,'sport_event_id'=>'2','staff_id'=>'801','start_age'=>18,'end_age'=>60,'gender'=>1,'notes'=>'UNIT_NOTE','store_id'=>2147001321,'is_delete'=>0,'create_by'=>'UNIT','create_time'=>'2030-04-02 10:00:00','update_time'=>'2030-04-02 10:00:00','pla'=>$pla];\app\store\model\staff\AthleteMaster::$row=$raw;$out=$service->detail(7);$wanted=[];foreach(['1.25','1.50','1.75','2.00','2.25'] as $i=>$pal)$wanted[]=['strength'=>$i+2,'pal'=>$pal];$same($out['pla'],$wanted,'PAL only response must preserve MySQL DEC5,2 fixed string and strength integers');$n++;
        $same($out['id'],7,'Parent ID type/value changed');$same($out['staff_id'],['801'],'Original CSV string-array changed');$same($out['sport_event_id'],['2'],'Original event CSV array changed');$same($out['notes'],'UNIT_NOTE','Unrelated text changed');$same($out['start_age'],18,'Unrelated numeric changed');$n+=5;$same(\app\store\model\staff\AthleteMaster::$row,$raw,'DTO mutated raw PAL values used by other calculations');$n++;
        $baseline=$raw;$baseline['pla']=$wanted;$baseline['sport_event_id']=['2'];$baseline['staff_id']=['801'];$baseline['sport_name']='UNIT_SPORT';$baseline['sport_event_name']='UNIT_EVENT';$baseline['staff_names']='UNIT_STAFF';$same($out,$baseline,'Complete original MySQL response changed outside PAL');$n++;
    }
    foreach([null,'','0.00',0] as $value){$raw=['id'=>7,'sport_id'=>1,'sport_event_id'=>'2','staff_id'=>'801','pla'=>[['strength'=>2,'pal'=>$value]]];\app\store\model\staff\AthleteMaster::$row=$raw;$out=$service->detail(7);$same($out['pla'],[['strength'=>2,'pal'=>$value===0?'0.00':$value]],'Null/empty/zero PAL legacy boundary changed');$same(\app\store\model\staff\AthleteMaster::$row,$raw,'Boundary mutated raw input');$n+=2;}
    echo json_encode(['assertions'=>$n,'all_passed'=>true,'database_or_network_called'=>false]),"\n";
}
