/** * @param mixed[] $valueList * @return string */ protected function _serialize(array $valueList) { $variableInspector = new CM_Debug_VariableInspector(); $valueListString = Functional\map($valueList, function ($value) use($variableInspector) { return $variableInspector->getDebugInfo($value, ['recursive' => true]); }); return serialize($valueListString); }
/** * @return string */ public function getDebugInfo() { try { $variableInspector = new CM_Debug_VariableInspector(); return $variableInspector->getDebugInfo($this->getParamsDecoded(), ['recursive' => true]); } catch (Exception $e) { return '[Cannot dump params: `' . $e->getMessage() . '`]'; } }
/** * @param array $row * @return array */ protected static function _extractTraceRow($row) { $traceEntry = array(); $code = ''; if (array_key_exists('function', $row)) { if (array_key_exists('class', $row)) { $code .= $row['class'] . '->'; } $code .= $row['function']; if (array_key_exists('args', $row)) { $arguments = array(); $variableInspector = new CM_Debug_VariableInspector(); foreach ($row['args'] as $argument) { $arguments[] = $variableInspector->getDebugInfo($argument, ['lengthMax' => 30]); } $code .= '(' . implode(', ', $arguments) . ')'; } $traceEntry['code'] = $code; } if (array_key_exists('file', $row)) { $file = $row['file']; $line = $row['line']; } else { $file = null; $line = null; $code = '[internal function]'; } return array('code' => $code, 'file' => $file, 'line' => $line); }
/** * @dataProvider debugInfoProviderRecursive * * @param string $expected * @param mixed $argument */ public function testGetDebugInfoRecursive($expected, $argument) { $variableInspector = new CM_Debug_VariableInspector(); $this->assertSame($expected, $variableInspector->getDebugInfo($argument, ['recursive' => true])); }
<?php $rowList = CM_Db_Db::select('cm_log', '*')->fetchAll(); foreach ($rowList as $row) { $metaInfo = @unserialize($row['metaInfo']); if (is_array($metaInfo)) { $variableInspector = new CM_Debug_VariableInspector(); $metaInfo = Functional\map($metaInfo, function ($value) use($variableInspector) { return $variableInspector->getDebugInfo($value, ['recursive' => true]); }); } else { $metaInfo = null; } CM_Db_Db::update('cm_log', ['metaInfo' => serialize($metaInfo)], ['id' => $row['id']]); }