Debug output for $sHeading
\n";
}
public static function newSection($sHeading)
{
echo "
$sHeading
\n";
}
public static function printVar($sHeading, $mVar)
{
echo ''.$sHeading. ': ';
Debug::outputVar($mVar, str_repeat(' ', strlen($sHeading) + 3));
echo "
\n";
}
public static function fmtArrayVals($aArr)
{
return array('__debug_format' => 'array_vals', 'data' => $aArr);
}
public static function printDebugArray($sHeading, $oVar)
{
if ($oVar === null) {
Debug::printVar($sHeading, 'null');
} else {
Debug::printVar($sHeading, $oVar->debugInfo());
}
}
public static function printDebugTable($sHeading, $aVar)
{
echo ''.$sHeading.":\n";
echo '';
if (!empty($aVar)) {
echo '';
$aKeys = array();
$aInfo = reset($aVar);
if (!is_array($aInfo)) {
$aInfo = $aInfo->debugInfo();
}
foreach ($aInfo as $sKey => $mVal) {
echo ''.$sKey.' | ';
$aKeys[] = $sKey;
}
echo '
';
foreach ($aVar as $oRow) {
$aInfo = $oRow;
if (!is_array($oRow)) {
$aInfo = $oRow->debugInfo();
}
echo '';
foreach ($aKeys as $sKey) {
echo '';
if (isset($aInfo[$sKey])) {
Debug::outputVar($aInfo[$sKey], '');
}
echo ' | ';
}
echo '
';
}
}
echo '
';
}
public static function printGroupTable($sHeading, $aVar)
{
echo ''.$sHeading.":\n";
echo '';
if (!empty($aVar)) {
echo 'Group | ';
$aKeys = array();
$aInfo = reset(reset($aVar));
if (!is_array($aInfo)) {
$aInfo = $aInfo->debugInfo();
}
foreach ($aInfo as $sKey => $mVal) {
echo ''.$sKey.' | ';
$aKeys[] = $sKey;
}
echo '
';
foreach ($aVar as $sGrpKey => $aGroup) {
foreach ($aGroup as $oRow) {
$aInfo = $oRow;
if (!is_array($oRow)) {
$aInfo = $oRow->debugInfo();
}
echo ''.$sGrpKey.' | ';
foreach ($aKeys as $sKey) {
echo '';
if (!empty($aInfo[$sKey])) {
Debug::outputVar($aInfo[$sKey], '');
}
echo ' | ';
}
echo '
';
}
}
}
echo '
';
}
public static function printSQL($sSQL)
{
echo ''.$sSQL.'
'."\n";
}
private static function outputVar($mVar, $sPreNL)
{
if (is_array($mVar) && !isset($mVar['__debug_format'])) {
$sPre = '';
foreach ($mVar as $mKey => $aValue) {
echo $sPre;
$iKeyLen = Debug::outputSimpleVar($mKey);
echo ' => ';
Debug::outputVar(
$aValue,
$sPreNL.str_repeat(' ', $iKeyLen + 4)
);
$sPre = "\n".$sPreNL;
}
} elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
if (!empty($mVar[data])) {
$sPre = '';
foreach ($mVar[data] as $mValue) {
echo $sPre;
Debug::outputSimpleVar($mValue);
$sPre = ', ';
}
}
} else {
Debug::outputSimpleVar($mVar);
}
}
private static function outputSimpleVar($mVar)
{
if (is_bool($mVar)) {
echo ''.($mVar ? 'True' : 'False').'';
return $mVar ? 4 : 5;
}
if (is_string($mVar)) {
echo "'$mVar'";
return strlen($mVar) + 2;
}
echo (string)$mVar;
return strlen((string)$mVar);
}
}