Skip to content

Commit

Permalink
Merge branch '3.2'
Browse files Browse the repository at this point in the history
* 3.2:
  Emailer:  include REQUEST_METHOD
  Unit test fix
  Utility::gitBranch() issues with user/permissins... read .git/HEAD file instead
  UnitTest fix - (PHP-SOAP version not matching PHP_VERSION)
  UnitTest fix - (PHP-SOAP version not matching PHP_VERSION)
  github workflow - bump paambaati/codeclimate-action to v5.0.0 crate classDefinition (static property values may require abstraction) no longer add "overrides" classname (redundant to data-declared-prev)
  ErrorHandler\Error now contains "evalLine" (null unless error occurs within `eval`) logEntries for php errors, warn, error, clear, count (without label)  add meta "evalLine" & data-evalLine varDump not escaping special chars Utility/Php::getIniFiles  not properly handling empty return from `php_ini_scanned_files()`
  output phpDoc @throws tag info for methods
  "bump" default jQueryUrl to 3.7.1 Object abstractions now support deep inheritance change,(for now is simply the default -> class-definition -> instance values)
  New config options:  methodStaticVarCollect & methodStaticVarOutput
  fix unit test
  objectSort config is now a space separated list with default value = "inheritance visibility name" Implements now stored as a structure that conveys interface inheritance What interfaces a method implements are now collected for every implemented interface (prev a select few such as ArrayAccess) Anonymous objects now collected & stored like other objects... collecting attribues, phpdoc, & interfaces in the process html output : * added <hr /> between summary and main log * now displays an icon on methods implementing an interface * no longer add "inherited" classname to methods/properties/constants  (redundant to data-inherited-from attribute) * properties/methods now grouped by inheritance by default.  (dependant on objectSort beginning with 'inheritance') - "inherited" icon not didplayed when groupbed by inheritance) * new "interfacesCollapse" config * new objectSectionOrder config.    defaults to ['attributes', 'extends', 'implements', 'constants', 'cases', 'properties', 'methods', 'phpDoc'] HttpMessage\ServerRequest::fromGlobals() now has $parseStrOpts param HttpMessage\Uri::fromGlobals() is now a public static method
  • Loading branch information
bkdotcom committed Jan 3, 2024
2 parents 6886d5e + bd1c206 commit b144de5
Show file tree
Hide file tree
Showing 85 changed files with 1,625 additions and 826 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
}
},
"replace": {
"bdk/backtrace": "2.2",
"bdk/backtrace": "2.2.1",
"bdk/curl-http-message": "1.0",
"bdk/errorhandler": "3.3.1",
"bdk/errorhandler": "3.3.2",
"bdk/http-message": "1.1",
"bdk/promise": "1.0",
"bdk/pubsub": "3.2.1",
Expand Down
6 changes: 3 additions & 3 deletions src/Backtrace/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Normalizer

private static $frameDefault = array(
'args' => array(),
'evalLine' => null,
'file' => null,
'function' => null, // function, Class::function, or Class->function
'line' => null,
Expand All @@ -42,7 +43,6 @@ public static function normalize($backtrace)
'params' => null,
'type' => null,
);
$frameKeysKeep = \array_merge(self::$frameDefault, \array_flip(array('evalLine')));
$count = \count($backtrace);
$backtrace[] = array(); // add a frame so backtrace[$i + 1] is always a thing
for ($i = 0; $i < $count; $i++) {
Expand All @@ -59,7 +59,7 @@ public static function normalize($backtrace)
// xdebug_get_function_stack
$frame['args'] = self::normalizeXdebugParams($frame['params']);
}
$frame = \array_intersect_key($frame, $frameKeysKeep);
$frame = \array_intersect_key($frame, self::$frameDefault);
\ksort($frame);
self::$backtraceTemp[] = $frame;
}
Expand Down Expand Up @@ -89,8 +89,8 @@ private static function normalizeFrameFile(array $frame, array &$frameNext)
// reported line = line within eval
// line inside paren is the line `eval` is on
$frame['evalLine'] = $frame['line'];
$frame['line'] = (int) $matches[2];
$frame['file'] = $matches[1];
$frame['line'] = (int) $matches[2];
if (isset($frameNext['include_filename'])) {
// xdebug_get_function_stack puts the evaled code in include_filename
$frameNext['params'] = array($frameNext['include_filename']);
Expand Down
122 changes: 53 additions & 69 deletions src/Debug/Abstraction/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,52 @@
use ReflectionClass;
use ReflectionEnumUnitCase;
use RuntimeException;
use UnitEnum;

/**
* Abstracter: Methods used to abstract objects
*/
class AbstractObject extends AbstractComponent
{
// GENERAL
const PHPDOC_COLLECT = 1; // 2^0
const PHPDOC_OUTPUT = 2; // 2^1
const OBJ_ATTRIBUTE_COLLECT = 4;
const OBJ_ATTRIBUTE_OUTPUT = 8;
const TO_STRING_OUTPUT = 16; // 2^4
const BRIEF = 4194304; // 2^22

// CONSTANTS
const CONST_COLLECT = 32;
const CONST_OUTPUT = 64;
const CONST_ATTRIBUTE_COLLECT = 128;
const CONST_ATTRIBUTE_OUTPUT = 256; // 2^8

// CASE
// CASE (2^9 - 2^12)
const CASE_COLLECT = 512;
const CASE_OUTPUT = 1024;
const CASE_ATTRIBUTE_COLLECT = 2048;
const CASE_ATTRIBUTE_OUTPUT = 4096; // 2^12
const CASE_ATTRIBUTE_OUTPUT = 4096;

// PROPERTIES
const PROP_ATTRIBUTE_COLLECT = 8192;
const PROP_ATTRIBUTE_OUTPUT = 16384; // 2^14
// CONSTANTS (2^5 - 2^8)
const CONST_COLLECT = 32;
const CONST_OUTPUT = 64;
const CONST_ATTRIBUTE_COLLECT = 128;
const CONST_ATTRIBUTE_OUTPUT = 256;

// METHODS
// METHODS (2^15 - 2^21, 2^23 - 2^24)
const METHOD_COLLECT = 32768;
const METHOD_OUTPUT = 65536;
const METHOD_DESC_OUTPUT = 524288;
const METHOD_ATTRIBUTE_COLLECT = 131072;
const METHOD_ATTRIBUTE_OUTPUT = 262144;
const METHOD_DESC_OUTPUT = 524288;
const METHOD_STATIC_VAR_COLLECT = 8388608; // 2^23
const METHOD_STATIC_VAR_OUTPUT = 16777216; // 2^24

const OBJ_ATTRIBUTE_COLLECT = 4;
const OBJ_ATTRIBUTE_OUTPUT = 8;

const PARAM_ATTRIBUTE_COLLECT = 1048576;
const PARAM_ATTRIBUTE_OUTPUT = 2097152; // 2^21
const PARAM_ATTRIBUTE_OUTPUT = 2097152;

const PHPDOC_COLLECT = 1; // 2^0
const PHPDOC_OUTPUT = 2;

public static $cfgFlags = array( // @phpcs:ignore SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder
// GENERAL
// PROPERTIES (2^13 - 2^14)
const PROP_ATTRIBUTE_COLLECT = 8192; // 2^13
const PROP_ATTRIBUTE_OUTPUT = 16384; // 2^14

const TO_STRING_OUTPUT = 16; // 2^4

public static $cfgFlags = array(
'brief' => self::BRIEF,
'objAttributeCollect' => self::OBJ_ATTRIBUTE_COLLECT,
'objAttributeOutput' => self::OBJ_ATTRIBUTE_OUTPUT,
'phpDocCollect' => self::PHPDOC_COLLECT,
'phpDocOutput' => self::PHPDOC_OUTPUT,
'toStringOutput' => self::TO_STRING_OUTPUT,

// CASE
'caseAttributeCollect' => self::CASE_ATTRIBUTE_COLLECT,
Expand All @@ -93,12 +91,23 @@ class AbstractObject extends AbstractComponent
'methodCollect' => self::METHOD_COLLECT,
'methodDescOutput' => self::METHOD_DESC_OUTPUT,
'methodOutput' => self::METHOD_OUTPUT,
'methodStaticVarCollect' => self::METHOD_STATIC_VAR_COLLECT,
'methodStaticVarOutput' => self::METHOD_STATIC_VAR_OUTPUT,

'objAttributeCollect' => self::OBJ_ATTRIBUTE_COLLECT,
'objAttributeOutput' => self::OBJ_ATTRIBUTE_OUTPUT,

'paramAttributeCollect' => self::PARAM_ATTRIBUTE_COLLECT,
'paramAttributeOutput' => self::PARAM_ATTRIBUTE_OUTPUT,

'phpDocCollect' => self::PHPDOC_COLLECT,
'phpDocOutput' => self::PHPDOC_OUTPUT,

// PROPERTIES
'propAttributeCollect' => self::PROP_ATTRIBUTE_COLLECT,
'propAttributeOutput' => self::PROP_ATTRIBUTE_OUTPUT,

'toStringOutput' => self::TO_STRING_OUTPUT,
);

protected $abstracter;
Expand Down Expand Up @@ -137,32 +146,24 @@ class AbstractObject extends AbstractComponent
*
* @var array Array of key/values
*/
protected static $values = array( // phpcs:ignore SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder
'type' => Abstracter::TYPE_OBJECT,
protected static $values = array(
'cfgFlags' => 0,
'className' => '',
'debugMethod' => '',
'isAnonymous' => false,
'interfacesCollapse' => array(), // cfg.interfacesCollapse
'isExcluded' => false, // don't exclude if we're debugging directly
'isMaxDepth' => false,
'isRecursion' => false,
// methods may be populated with __toString info, or methods with staticVars
'properties' => array(),
'scopeClass' => '',
'sectionOrder' => array(), // cfg.objectSectionOrder
'sort' => '', // cfg.objectSort
'stringified' => null,
'traverseValues' => array(), // populated if method is table
'viaDebugInfo' => false,
);

protected static $keysTemp = array(
'collectPropertyValues',
'fullyQualifyPhpDocType',
'hist',
'isTraverseOnly',
'propertyOverrideValues',
'reflector',
);

/**
* Constructor
*
Expand Down Expand Up @@ -202,12 +203,12 @@ public function getAbstraction($obj, $method = null, array $hist = array())
$reflector = $reflector->getEnum();
}
$values = $this->getAbstractionValues($reflector, $obj, $method, $hist);
$valueStore = $this->definition->getValueStore($obj, $values);
$abs = new ObjectAbstraction($valueStore, $values);
$definitionValueStore = $this->definition->getAbstraction($obj, $values);
$abs = new ObjectAbstraction($definitionValueStore, $values);
$abs->setSubject($obj);
$abs['hist'][] = $obj;
$this->doAbstraction($abs);
$this->absClean($abs);
$abs->clean();
return $abs;
}

Expand All @@ -233,21 +234,6 @@ public static function buildObjValues(array $values = array())
);
}

/**
* Sort things and remove temporary values
*
* @param ObjectAbstraction $abs Abstraction instance
*
* @return void
*/
private function absClean(ObjectAbstraction $abs)
{
$values = \array_diff_key($abs->getInstanceValues(), \array_flip(self::$keysTemp));
$abs
->setSubject(null)
->setValues($values);
}

/**
* Populate rows or columns (traverseValues) if we're outputing as a table
*
Expand All @@ -268,9 +254,10 @@ private function addTraverseValues(ObjectAbstraction $abs)
}

/**
* Add attributes, constants, properties, methods, constants, etc
* Collect instance info
* Property values & static method variables
*
* @param ObjectAbstraction $abs Abstraction instance
* @param ObjectAbstraction $abs Object abstraction instance
*
* @return void
*/
Expand All @@ -280,11 +267,6 @@ private function doAbstraction(ObjectAbstraction $abs)
return;
}
if ($abs['isRecursion']) {
if ($abs->getSubject() instanceof UnitEnum) {
$abs['properties']['name'] = array(
'value' => $abs->getSubject()->name,
);
}
return;
}
$abs['isTraverseOnly'] = $this->isTraverseOnly($abs);
Expand All @@ -304,15 +286,16 @@ private function doAbstraction(ObjectAbstraction $abs)
if ($abs['isTraverseOnly']) {
$this->addTraverseValues($abs);
}
$this->properties->add($abs);
$this->methods->addInstance($abs); // method static variables
$this->properties->addInstance($abs);
/*
Debug::EVENT_OBJ_ABSTRACT_END subscriber has free reign to modify abtraction values
*/
$this->debug->publishBubbleEvent(Debug::EVENT_OBJ_ABSTRACT_END, $abs, $this->debug);
}

/**
* Returns information about an object
* Get initial "top-level" values.
*
* @param ReflectionClass $reflector Reflection instance
* @param object|string $obj Object (or classname) to inspect
Expand All @@ -330,11 +313,12 @@ protected function getAbstractionValues(ReflectionClass $reflector, $obj, $metho
'cfgFlags' => $this->getCfgFlags(),
'className' => $this->helper->getClassName($reflector),
'debugMethod' => $method,
'isAnonymous' => PHP_VERSION_ID >= 70000 && $reflector->isAnonymous(),
'interfacesCollapse' => \array_values(\array_intersect($reflector->getInterfaceNames(), $this->cfg['interfacesCollapse'])),
'isExcluded' => $hist && $this->isExcluded($obj), // don't exclude if we're debugging directly
'isMaxDepth' => $this->cfg['maxDepth'] && \count($hist) === $this->cfg['maxDepth'],
'isRecursion' => \in_array($obj, $hist, true),
'scopeClass' => $this->getScopeClass($hist),
'sectionOrder' => $this->cfg['objectSectionOrder'],
'sort' => $this->cfg['objectSort'],
'viaDebugInfo' => $this->cfg['useDebugInfo'] && $reflector->hasMethod('__debugInfo'),
),
Expand All @@ -355,7 +339,7 @@ protected function getAbstractionValues(ReflectionClass $reflector, $obj, $metho
*
* @return int bitmask
*/
private function getCfgFlags()
protected function getCfgFlags()
{
$flagVals = \array_intersect_key(self::$cfgFlags, \array_filter($this->cfg));
$bitmask = \array_reduce($flagVals, static function ($carry, $val) {
Expand Down
35 changes: 28 additions & 7 deletions src/Debug/Abstraction/Abstracter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,30 @@ class Abstracter extends AbstractComponent
protected $cfg = array(
'brief' => false, // collect & output less details
'fullyQualifyPhpDocType' => false,
'interfacesCollapse' => array(
'ArrayAccess',
'BackedEnum',
'Countable',
'Iterator',
'IteratorAggregate',
'UnitEnum',
),
'maxDepth' => 0, // value < 1 : no max-depth
'objectSectionOrder' => array(
'attributes',
'extends',
'implements',
'constants',
'cases',
'properties',
'methods',
'phpDoc',
),
'objectsExclude' => array(
// __NAMESPACE__ added in constructor
'DOMNode',
),
'objectSort' => 'visibility', // none, visibility, or name
'objectSort' => 'inheritance visibility name',
'objectsWhitelist' => null, // will be used if array
'stringMaxLen' => array(
'base64' => 156, // 2 lines of chunk_split'ed
Expand Down Expand Up @@ -470,22 +488,25 @@ protected function postSetCfg($cfg = array(), $prev = array())
$debugClass = \get_class($this->debug);
if (!\array_intersect(array('*', $debugClass), $this->cfg['objectsExclude'])) {
$this->cfg['objectsExclude'][] = $debugClass;
$cfg['objectsExclude'] = $this->cfg['objectsExclude'];
}
if (isset($cfg['stringMaxLen'])) {
if (\is_array($cfg['stringMaxLen']) === false) {
$cfg['stringMaxLen'] = array(
'other' => $cfg['stringMaxLen'],
);
}
$cfg['stringMaxLen'] = \array_merge($prev['stringMaxLen'], $cfg['stringMaxLen']);
$this->cfg['stringMaxLen'] = $cfg['stringMaxLen'];
$this->cfg['stringMaxLen'] = \array_merge($prev['stringMaxLen'], $cfg['stringMaxLen']);
}
if (isset($cfg['stringMinLen'])) {
$cfg['stringMinLen'] = \array_merge($prev['stringMinLen'], $cfg['stringMinLen']);
$this->cfg['stringMinLen'] = $cfg['stringMinLen'];
$this->cfg['stringMinLen'] = \array_merge($prev['stringMinLen'], $cfg['stringMinLen']);
}
if (isset($cfg['objectSectionOrder'])) {
$oso = \array_intersect($cfg['objectSectionOrder'], $prev['objectSectionOrder']);
$oso = \array_merge($oso, $prev['objectSectionOrder']);
$oso = \array_unique($oso);
$this->cfg['objectSectionOrder'] = $oso;
}
$this->setCfgDependencies($cfg);
$this->setCfgDependencies(\array_intersect_key($this->cfg, $cfg));
}

/**
Expand Down
Loading

0 comments on commit b144de5

Please sign in to comment.