Skip to content

Commit a4aafa2

Browse files
committed
Move Table Abstraction to Object\Subscriber
Remove last remnants of `isTraverseOnly`
1 parent 145bac7 commit a4aafa2

21 files changed

Lines changed: 209 additions & 144 deletions

src/Backtrace/Backtrace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static function getCallerInfo($offset = 0, $options = 0)
112112
we need to collect object... we'll remove object at end if undesired
113113
*/
114114
$phpOptions = static::translateOptions($options | self::INCL_OBJECT);
115-
$backtrace = \debug_backtrace($phpOptions, 40);
115+
$backtrace = \debug_backtrace($phpOptions, 50);
116116
$backtrace = self::normalize($backtrace);
117117
$index = SkipInternal::getFirstIndex($backtrace, $offset);
118118
$index = \max($index, 1); // ensure we're >= 1

src/Debug/Abstraction/AbstractObject.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use bdk\Debug;
1414
use bdk\Debug\AbstractComponent;
1515
use bdk\Debug\Abstraction\Abstracter;
16-
use bdk\Debug\Abstraction\Abstraction;
1716
use bdk\Debug\Abstraction\Object\Abstraction as ObjectAbstraction;
1817
use bdk\Debug\Abstraction\Object\Constants;
1918
use bdk\Debug\Abstraction\Object\Definition;
@@ -22,9 +21,7 @@
2221
use bdk\Debug\Abstraction\Object\Properties;
2322
use bdk\Debug\Abstraction\Object\PropertiesInstance;
2423
use bdk\Debug\Abstraction\Object\Subscriber;
25-
use bdk\Debug\Abstraction\Type;
2624
use bdk\Table\Element;
27-
use bdk\Table\Table;
2825
use ReflectionClass;
2926
use ReflectionEnumUnitCase;
3027
use RuntimeException;
@@ -208,10 +205,11 @@ public function __construct(Abstracter $abstracter)
208205
$this->propertiesInstance = new PropertiesInstance($this);
209206
$this->definition = new Definition($this);
210207

211-
if ($abstracter->debug->parentInstance === null) {
212-
// we only need to subscribe to these events from root channel
213-
$abstracter->debug->eventManager->addSubscriberInterface(new Subscriber($this));
214-
}
208+
// if we are the root instance, subscribe to events
209+
// otherwise ensure root instance is instantiated
210+
$abstracter->debug->parentInstance === null
211+
? $abstracter->debug->eventManager->addSubscriberInterface(new Subscriber($this))
212+
: $abstracter->debug->rootInstance->abstracter;
215213

216214
self::$values['sectionOrder'] = $abstracter->getCfg('objectSectionOrder');
217215
self::$values['sort'] = $abstracter->getCfg('objectSort');
@@ -233,16 +231,6 @@ public function getAbstraction($obj, $method = null, array $hist = array())
233231
if ($reflector instanceof ReflectionEnumUnitCase) {
234232
$reflector = $reflector->getEnum();
235233
}
236-
if ($obj instanceof Element) {
237-
$hist[] = $obj;
238-
$this->debug->eventManager->subscribe(Debug::EVENT_OBJ_ABSTRACT_END, [$this, 'tableCellValueAbstracter']);
239-
$values = $obj->jsonSerialize();
240-
$values = $this->abstracter->crate($values, $method, $hist);
241-
$this->debug->eventManager->unsubscribe(Debug::EVENT_OBJ_ABSTRACT_END, [$this, 'tableCellValueAbstracter']);
242-
return $obj instanceof Table
243-
? new Abstraction(Type::TYPE_TABLE, $values)
244-
: $values;
245-
}
246234
$values = $this->getAbstractionValues($reflector, $obj, $method, $hist);
247235
$definitionValueStore = $this->definition->getAbstraction($obj, $values);
248236
$abs = new ObjectAbstraction($definitionValueStore, $values);
@@ -272,22 +260,6 @@ public static function buildValues(array $values = array())
272260
return \array_merge(self::$values, $values);
273261
}
274262

275-
/**
276-
* If cell value is an object, set unstructuredValue for abstraction
277-
*
278-
* @param ObjectAbstraction $abs Object Abstraction instance
279-
*
280-
* @return void
281-
*/
282-
public function tableCellValueAbstracter($abs)
283-
{
284-
if (isset($abs['stringified'])) {
285-
$abs['unstructuredValue'] = $abs['stringified'];
286-
} elseif (isset($abs['methods']['__toString']['returnValue'])) {
287-
$abs['unstructuredValue'] = $abs['methods']['__toString']['returnValue'];
288-
}
289-
}
290-
291263
/**
292264
* Collect instance info
293265
* Property values & static method variables
@@ -301,7 +273,6 @@ private function doAbstraction(ObjectAbstraction $abs)
301273
if ($abs['isMaxDepth'] || $abs['isRecursion']) {
302274
return;
303275
}
304-
$abs['isTraverseOnly'] = $this->helper->isTraverseOnly($abs);
305276
/*
306277
Debug::EVENT_OBJ_ABSTRACT_START subscriber may
307278
set isExcluded
@@ -355,7 +326,6 @@ protected function getAbstractionValues(ReflectionClass $reflector, $obj, $metho
355326
'collectPropertyValues' => true,
356327
'fullyQualifyPhpDocType' => $this->cfg['fullyQualifyPhpDocType'],
357328
'hist' => $hist,
358-
'isTraverseOnly' => false,
359329
'propertyOverrideValues' => array(),
360330
'reflector' => $reflector,
361331
)

src/Debug/Abstraction/AbstractString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ private function getTypeMore($val)
370370
return Type::TYPE_STRING_FILEPATH;
371371
}
372372
$strLen = \strlen($val);
373-
$maxlen = $this->getMaxLen('other', $strLen);
374-
return $maxlen > -1 && $strLen > $maxlen
373+
$maxLen = $this->getMaxLen('other', $strLen);
374+
return $maxLen > -1 && $strLen > $maxLen
375375
? Type::TYPE_STRING_LONG
376376
: null;
377377
}

src/Debug/Abstraction/Abstracter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Abstracter extends AbstractComponent
6464
'brief' => false, // collect & output less details
6565
// see also AbstractObject::$cfgFlags where each key
6666
// can be set to true/false as a cfg value here
67+
'detectFiles' => false,
6768
'fullyQualifyPhpDocType' => false,
6869
'interfacesCollapse' => [
6970
'ArrayAccess',

src/Debug/Abstraction/Object/Abstraction.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class Abstraction extends BaseAbstraction
3232
'collectPropertyValues',
3333
'fullyQualifyPhpDocType',
3434
'hist',
35-
'isTraverseOnly',
3635
'propertyOverrideValues',
3736
'reflector',
3837
'unstructuredValue',

src/Debug/Abstraction/Object/Helper.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,6 @@ public function getPhpDocVar(Reflector $reflector, $fullyQualifyType = false)
166166
return $phpDoc;
167167
}
168168

169-
/**
170-
* Test if "traverseOnly" mode
171-
*
172-
* @param ObjectAbstraction $abs Abstraction instance
173-
*
174-
* @return bool
175-
*/
176-
public function isTraverseOnly(ObjectAbstraction $abs)
177-
{
178-
if ($abs['debugMethod'] === 'table' && \count($abs['hist']) < 7) {
179-
$abs['cfgFlags'] &= ~AbstractObject::CONST_COLLECT; // set collect constants to "false"
180-
$abs['cfgFlags'] &= ~AbstractObject::METHOD_COLLECT; // set collect methods to "false"
181-
return true;
182-
}
183-
return false;
184-
}
185-
186169
/**
187170
* Get Constant, Property, or Parameter's type or Method's return type
188171
* Priority given to phpDoc type, followed by reflection type (if available)

src/Debug/Abstraction/Object/PropertiesInstance.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class PropertiesInstance extends Properties
3232
*/
3333
public function add(Abstraction $abs)
3434
{
35-
if ($abs['isTraverseOnly']) {
36-
return;
37-
}
3835
$abs['isLazy']
3936
? $this->addValuesLazy($abs)
4037
: $this->addValues($abs);

0 commit comments

Comments
 (0)