Skip to content

Commit 3a1bd94

Browse files
committed
Don't needlessly serialize unused classDefinitions (ie Table, TableRow, & TableCell)
LogPhp::logPhpIni... if multiple ini files present, they weren't detected as file / linked
1 parent fe80625 commit 3a1bd94

14 files changed

Lines changed: 435 additions & 275 deletions

File tree

src/Debug/Abstraction/AbstractObject.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,12 @@ public function getAbstraction($obj, $method = null, array $hist = array())
237237
$abs->setSubject($obj);
238238
$abs['hist'][] = $obj;
239239
$this->doAbstraction($abs);
240-
return $abs['unstructuredValue']
241-
? $abs['unstructuredValue']
242-
: $abs->clean();
240+
if ($abs['unstructuredValue']) {
241+
return $abs['unstructuredValue'];
242+
}
243+
// Mark definition as used
244+
$this->definition->markAsUsed($definitionValueStore);
245+
return $abs->clean();
243246
}
244247

245248
/**

src/Debug/Abstraction/Abstracter.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function crate($mixed, $method = null, array $hist = array())
174174
public function crateWithVals($mixed, array $values = array())
175175
{
176176
/*
177-
Note: this->crateValues is the raw values passed to this method
177+
Note: this->crateVals is the raw values passed to this method
178178
the values may end up being processed in Abstraction::onSet
179179
ie, converting attribs.class to an array
180180
*/
@@ -189,10 +189,18 @@ public function crateWithVals($mixed, array $values = array())
189189
? \array_values($typeInfo)
190190
: array();
191191
unset($values['type']);
192+
$cfgRestore = array();
193+
if (isset($values['detectFiles'])) {
194+
$cfgRestore['detectFiles'] = $this->abstractString->setCfg('detectFiles', $values['detectFiles']);
195+
unset($values['detectFiles']);
196+
}
192197
$abs = $this->getAbstraction($mixed, __FUNCTION__, $typeInfo);
193198
foreach ($values as $k => $v) {
194199
$abs[$k] = $v;
195200
}
201+
if ($cfgRestore) {
202+
$this->debug->setCfg($cfgRestore, Debug::CONFIG_NO_RETURN);
203+
}
196204
$this->crateVals = array();
197205
return $abs;
198206
}

src/Debug/Abstraction/Object/Abstraction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function getInheritedValues()
137137
{
138138
$values = $this->inherited->getValues();
139139
unset($values['cfgFlags']);
140+
unset($values['__isUsed']);
140141
return $values;
141142
}
142143

src/Debug/Abstraction/Object/Definition.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,29 @@ public function getValueStoreDefault()
150150
return $this->default;
151151
}
152152
$values = $this->object->buildValues(static::buildValues());
153-
$classValueStore = new ValueStore($values);
154-
$this->default = $classValueStore;
155-
$this->debug->data->set([
156-
'classDefinitions',
157-
$values['className'], // "\x00default\x00"
158-
], $classValueStore);
159-
return $classValueStore;
153+
$this->default = new ValueStore($values);
154+
$dataPath = ['classDefinitions', $values['className']];
155+
$this->debug->data->set($dataPath, $this->default);
156+
return $this->default;
157+
}
158+
159+
/**
160+
* Mark a definition as used (referenced by a logged ObjectAbstraction)
161+
*
162+
* @param ValueStore $valueStore The definition ValueStore
163+
*
164+
* @return void
165+
*/
166+
public function markAsUsed(ValueStore $valueStore)
167+
{
168+
if ($valueStore['__isUsed']) {
169+
return; // already marked
170+
}
171+
$valueStore['__isUsed'] = true;
172+
if ($valueStore['inherited']) {
173+
// also mark "parent" definition as used
174+
$this->markAsUsed($valueStore['inherited']);
175+
}
160176
}
161177

162178
/**

src/Debug/Debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Debug extends AbstractDebug
119119
const EVENT_STREAM_WRAP = 'debug.streamWrap';
120120

121121
const META = "\x00meta\x00";
122-
const VERSION = '3.5';
122+
const VERSION = '3.6';
123123

124124
/** @var array<string,mixed> */
125125
protected $cfg = array(

src/Debug/Plugin/LogFiles.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ private function logFilesAsTree($files)
257257
'expand' => true,
258258
),
259259
)
260-
),
261-
$this->debug->meta(array(
262-
'detectFiles' => true,
263-
))
260+
)
264261
);
265262
$this->debug->setCfg('maxDepth', $maxDepthBak, Debug::CONFIG_NO_PUBLISH | Debug::CONFIG_NO_RETURN);
266263
}

src/Debug/Plugin/LogPhp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ private function logPhpIni()
283283
$this->debug->abstracter->crateWithVals(
284284
$iniFiles,
285285
array(
286+
'detectFiles' => true,
286287
'options' => array(
287288
'showListKeys' => false,
288289
),
289290
)
290-
),
291-
$this->debug->meta('detectFiles')
291+
)
292292
);
293293
}
294294

0 commit comments

Comments
 (0)