test
This commit is contained in:
+16
-4
@@ -3,7 +3,6 @@
|
||||
namespace app\config;
|
||||
|
||||
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
@@ -84,9 +83,20 @@ class Config
|
||||
get => $this->blockMode;
|
||||
}
|
||||
|
||||
public function setBlockMode(bool $value)
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @return void
|
||||
* @deprecated 禁止使用,改方法仅仅用于 test 方法
|
||||
*/
|
||||
public function setBlockMode(bool $value): void
|
||||
{
|
||||
echo "\033[31m获取禁止修改热修改阻断模式,这只是用于测试方法\033[0m\n";
|
||||
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
|
||||
$isContainTests = false;
|
||||
foreach ($stack as $item) if (str_contains($item['file'] ?? '', 'tests')) {
|
||||
$isContainTests = true;
|
||||
}
|
||||
if (!$isContainTests) throw new \RuntimeException('禁止修改阻断模式');
|
||||
$this->blockMode = $value;
|
||||
}
|
||||
|
||||
@@ -146,7 +156,9 @@ class Config
|
||||
$this->enableVirtualCleanerParser = self::getBoolEnv('ENABLE_VIRTUAL_CLEANER_PARSER', false);
|
||||
}
|
||||
|
||||
private function __clone() {}
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
private function detectCircularDependency(): void
|
||||
{
|
||||
|
||||
@@ -150,6 +150,19 @@ class ProcessContextBuilder
|
||||
$builder->isOperatorCard = $context->isOperatorCard();
|
||||
$builder->stepDurations = $context->getStepDurations();
|
||||
|
||||
// 遍历当前类的属性,检查哪些未被修改(对比默认值)
|
||||
$reflection = new \ReflectionClass($builder);
|
||||
$unmodifiedProperties = [];
|
||||
foreach ($reflection->getProperties() as $property) {
|
||||
$property->setAccessible(true); // 允许访问私有/受保护属性
|
||||
$defaultValue = $reflection->getDefaultProperties()[$property->getName()] ?? null;
|
||||
if ($property->getValue($builder) === $defaultValue) {
|
||||
$unmodifiedProperties[] = $property->getName();
|
||||
}
|
||||
}
|
||||
if (empty($unmodifiedProperties)){
|
||||
Logger::warn("from ProcessContext 创建 ProcessContextBuilder 时存在未修改的属性");
|
||||
}
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user