<?php
namespace think { class Model {} class Db {} }
namespace app\model {
 class BaseModel extends \think\Model {public function __call($name,$args){if($name==='select')return new ProjectionRows();$GLOBALS['query_calls'][]=[$name,$args];return $this;}}
 class ProjectionRows {public function toArray(){return $GLOBALS['native_projection_rows'];}}
}
namespace app\cores\database {class Dm {}}
namespace {
 function config($key){return $GLOBALS['driver'];}
 require $argv[1];require $argv[2];$expectedMode=$argv[3];$checks=0;$red=0;$calls=[];
 foreach(['ProteinSource','Stage_protein']as $method){foreach(['mysql','app\\cores\\database\\Dm','\\app\\cores\\database\\Dm']as $driver){foreach([0.0,100.0,.01,99999999.99,null]as $value){
  $GLOBALS['driver']=$driver;$mysql=$value===null?null:number_format($value,2,'.','');$native=$driver==='mysql'?$mysql:$value;$row=['raw_flag_weight'=>$native,'weight'=>$native,'computed'=>$native,'sum_value'=>$native,'uuid'=>'CDX-PROJECTION','nested'=>['raw_flag_weight'=>$native]];$GLOBALS['native_projection_rows']=[$row];$GLOBALS['query_calls']=[];$model=new \app\model\DateMenu();$actual=$method==='ProteinSource'?$model->$method('CDX','2026-10-08',3):$model->$method('CDX','2026-10-08','2026-10-09',[],3);$want=$row;$want['raw_flag_weight']=$mysql;
  if($expectedMode==='RED'&&$driver!=='mysql'&&$native!==$mysql){if($actual===[$want]||$actual!==[$row])throw new \RuntimeException('Original unexpectedly formatted or changed');$red++;}elseif($actual!==[$want])throw new \RuntimeException('Candidate contract mismatch '.$method.'/'.$driver);
  if($driver==='mysql'&&$actual!==[$row])throw new \RuntimeException('MySQL changed');foreach(['weight','computed','sum_value','nested']as $f)if($actual[0][$f]!==$row[$f])throw new \RuntimeException('Unowned projection changed');$checks+=6;
  if($expectedMode==='GREEN'&&empty($actual[0]['raw_flag_weight'])!==empty($mysql))throw new \RuntimeException('Original branch changed');$calls[$method]=$GLOBALS['query_calls'];
 }}}
 foreach($calls as $method=>$query){$encoded=json_encode($query);if(strpos($encoded,'b.raw_flag_weight')===false||strpos($encoded,'dishes b')===false)throw new \RuntimeException('Not actual physical projection');}
 echo json_encode(['mode'=>$expectedMode,'checks'=>$checks,'original_physical_type_RED'=>$red,'real_original_model_methods'=>array_keys($calls),'consumer_sites'=>['Stageanalyze::TeamProtein','Stageanalyze::StageTeamProtein','Ontoanalysis::Protein','Ontoanalysis::Stage_protein'],'MySQL_unchanged'=>true,'other_same_name_nested_and_computed_unchanged'=>true,'HTTP'=>0,'DML'=>0,'DB_connections'=>0]),"\n";
}
