文件
mashangyoujiu/_ai_archive/scripts/test_syntax.php

65 行
1.7 KiB
PHP

<?php
// 测试语法检查脚本
echo "开始语法检查...\n";
$controllers = [
'Application/RiderApi/Controller/OrderController.class.php',
'Application/RiderApi/Controller/LocationController.class.php',
'Application/RiderApi/Controller/IncomeController.class.php',
'Application/RiderApi/Controller/AuthController.class.php',
'Application/RiderApi/Controller/MessageController.class.php'
];
foreach ($controllers as $controller) {
echo "检查文件: $controller\n";
if (!file_exists($controller)) {
echo " 错误: 文件不存在\n";
continue;
}
$content = file_get_contents($controller);
// 检查是否还有??操作符
if (strpos($content, '??') !== false) {
echo " 错误: 仍然包含??操作符\n";
// 显示包含??的行
$lines = explode("\n", $content);
foreach ($lines as $lineNum => $line) {
if (strpos($line, '??') !== false) {
echo " 第" . ($lineNum + 1) . "行: " . trim($line) . "\n";
}
}
} else {
echo " 通过: 没有发现??操作符\n";
}
// 简单的语法检查
$tempFile = tempnam(sys_get_temp_dir(), 'syntax_check');
file_put_contents($tempFile, $content);
// 尝试包含文件来检查语法
ob_start();
$error = false;
try {
include_once $tempFile;
} catch (ParseError $e) {
$error = $e->getMessage();
} catch (Error $e) {
// 忽略其他错误,我们只关心语法错误
}
ob_end_clean();
unlink($tempFile);
if ($error) {
echo " 语法错误: $error\n";
} else {
echo " 语法检查通过\n";
}
echo "\n";
}
echo "语法检查完成。\n";
?>