$line) { if (!preg_match('/ $v[1]) { $failures++; echo 'FAIL - line '.($n+1)." $col: varchar({$v[1]}) but maxlength ".($ml[1] ?? 'none')."\n"; } } else if ($type == 'number' and preg_match('/^(tiny|small)int\b/i', $def, $i)) { $checked++; $unsigned = stripos($def, 'unsigned') !== false; $limit = array('tiny' => $unsigned ? 255 : 127, 'small' => $unsigned ? 65535 : 32767)[strtolower($i[1])]; if (!preg_match('/\bmax="(\d+)"/', $line, $mx) or $mx[1] > $limit) { $failures++; echo 'FAIL - line '.($n+1)." $col: $def but max ".($mx[1] ?? 'none')."\n"; } } } echo "checked $checked inputs\n"; echo $failures ? "$failures failed\n" : "all passed\n"; exit($failures ? 1 : 0);