diff --git a/src/Debug/Abstraction/AbstractArray.php b/src/Debug/Abstraction/AbstractArray.php index cd623d85..67ce8453 100644 --- a/src/Debug/Abstraction/AbstractArray.php +++ b/src/Debug/Abstraction/AbstractArray.php @@ -41,7 +41,7 @@ public function __construct(Abstracter $abstracter) * * @return array|string */ - public function crate($array, $method = null, $hist = array()) + public function crate(array $array, $method = null, array $hist = array()) { if (\in_array($array, $hist, true)) { return Abstracter::RECURSION; @@ -63,7 +63,7 @@ public function crate($array, $method = null, $hist = array()) * * @return Abstraction */ - public function getAbstraction(&$array, $method = null, $hist = array()) + public function getAbstraction(array &$array, $method = null, array $hist = array()) { return new Abstraction(Abstracter::TYPE_ARRAY, array( 'value' => $this->crate($array, $method, $hist), @@ -77,7 +77,7 @@ public function getAbstraction(&$array, $method = null, $hist = array()) * * @return Abstraction */ - public function getCallableAbstraction($array) + public function getCallableAbstraction(array $array) { $className = \is_object($array[0]) ? \get_class($array[0]) diff --git a/src/Debug/Abstraction/AbstractObject.php b/src/Debug/Abstraction/AbstractObject.php index 1d9ee471..e886a595 100644 --- a/src/Debug/Abstraction/AbstractObject.php +++ b/src/Debug/Abstraction/AbstractObject.php @@ -213,7 +213,7 @@ public function getAbstraction($obj, $method = null, $hist = array()) * * @return array */ - public static function buildObjValues($values = array()) + public static function buildObjValues(array $values = array()) { $cfgFlags = \array_reduce(self::$cfgFlags, static function ($carry, $val) { return $carry | $val; @@ -313,7 +313,7 @@ private function absClean(Abstraction $abs) * * @return void */ - private function addEnumCasePhpDoc($abs) + private function addEnumCasePhpDoc(Abstraction $abs) { if (!($abs['cfgFlags'] & self::PHPDOC_COLLECT)) { return; @@ -480,7 +480,7 @@ private function getCfgFlags() * * @return null|string */ - private function getScopeClass(&$hist) + private function getScopeClass(array &$hist) { for ($i = \count($hist) - 1; $i >= 0; $i--) { if (\is_object($hist[$i])) { @@ -544,7 +544,7 @@ private function isExcluded($obj) * * @return bool */ - private function isObjInList($obj, $list) + private function isObjInList($obj, array $list) { $classname = \get_class($obj); if (\array_intersect(array('*', $classname), $list)) { diff --git a/src/Debug/Abstraction/AbstractObjectConstants.php b/src/Debug/Abstraction/AbstractObjectConstants.php index fa37a230..b329c055 100644 --- a/src/Debug/Abstraction/AbstractObjectConstants.php +++ b/src/Debug/Abstraction/AbstractObjectConstants.php @@ -67,7 +67,7 @@ public function add(Abstraction $abs) while ($reflector) { PHP_VERSION_ID >= 70100 ? $this->addConstantsReflection($reflector) - : $this->addConstants($reflector); + : $this->addConstantsLegacy($reflector); $reflector = $reflector->getParentClass(); } foreach ($this->constants as $name => $info) { @@ -84,7 +84,7 @@ public function add(Abstraction $abs) * * @return void */ - public function addCases($abs) + public function addCases(Abstraction $abs) { $abs['cases'] = array(); if ($abs['isTraverseOnly']) { @@ -113,7 +113,7 @@ public function addCases($abs) * * @return void */ - private function addConstants(ReflectionClass $reflector) + private function addConstantsLegacy(ReflectionClass $reflector) { foreach ($reflector->getConstants() as $name => $value) { if (isset($this->constants[$name])) { diff --git a/src/Debug/Abstraction/AbstractObjectProperties.php b/src/Debug/Abstraction/AbstractObjectProperties.php index 717722c0..72bd4647 100644 --- a/src/Debug/Abstraction/AbstractObjectProperties.php +++ b/src/Debug/Abstraction/AbstractObjectProperties.php @@ -400,30 +400,32 @@ private function addViaPhpDocIter(Abstraction $abs, $inheritedFrom) */ private function addViaRef(Abstraction $abs) { - $refObject = $abs['reflector']; /* We trace our ancestory to learn where properties are inherited from */ - while ($refObject) { - $className = $refObject->getName(); - $properties = $refObject->getProperties(); - while ($properties) { - $refProperty = \array_shift($properties); + $reflector = $abs['reflector']; + $properties = $abs['properties']; + while ($reflector) { + $className = $reflector->getName(); + $refProperties = $reflector->getProperties(); + while ($refProperties) { + $refProperty = \array_shift($refProperties); $name = $refProperty->getName(); - if (isset($abs['properties'][$name])) { + if (isset($properties[$name])) { // already have info... we're in an ancestor - $abs['properties'][$name]['overrides'] = $this->propOverrides( + $properties[$name]['overrides'] = $this->propOverrides( $refProperty, - $abs['properties'][$name], + $properties[$name], $className ); - $abs['properties'][$name]['originallyDeclared'] = $className; + $properties[$name]['originallyDeclared'] = $className; continue; } - $abs['properties'][$name] = $this->buildPropViaRef($abs, $refProperty); + $properties[$name] = $this->buildPropViaRef($abs, $refProperty); } - $refObject = $refObject->getParentClass(); + $reflector = $reflector->getParentClass(); } + $abs['properties'] = $properties; } /** @@ -465,8 +467,8 @@ private function buildPropViaPhpDoc(Abstraction $abs, $phpDocProp, $inheritedFro */ private function buildPropViaRef(Abstraction $abs, ReflectionProperty $refProperty) { - $refProperty->setAccessible(true); // only accessible via reflection $phpDoc = $this->helper->getPhpDocVar($refProperty); // phpDocVar + $refProperty->setAccessible(true); // only accessible via reflection /* getDeclaringClass returns "LAST-declared/overriden" */ diff --git a/src/Debug/Abstraction/AbstractString.php b/src/Debug/Abstraction/AbstractString.php index a9005c5a..5135e246 100644 --- a/src/Debug/Abstraction/AbstractString.php +++ b/src/Debug/Abstraction/AbstractString.php @@ -63,7 +63,9 @@ public function getAbstraction($string, $typeMore = null, $crateVals = array()) $absValues = $this->getAbsValuesSerialized($absValues); break; default: - $absValues['value'] = $this->debug->utf8->strcut($string, 0, $absValues['maxlen']); + if ($absValues['maxlen'] > -1) { + $absValues['value'] = $this->debug->utf8->strcut($string, 0, $absValues['maxlen']); + } } $absValues = $this->absValuesFinish($absValues); return new Abstraction(Abstracter::TYPE_STRING, $absValues); diff --git a/src/Debug/Abstraction/Abstracter.php b/src/Debug/Abstraction/Abstracter.php index db4d4cdd..c891ba2a 100644 --- a/src/Debug/Abstraction/Abstracter.php +++ b/src/Debug/Abstraction/Abstracter.php @@ -423,7 +423,7 @@ private function getTypePhp($val) 'integer' => self::TYPE_INT, 'NULL' => self::TYPE_NULL, 'resource (closed)' => self::TYPE_RESOURCE, - 'unknown type' => self::TYPE_UNKNOWN, // closed resource < php 7.2 + 'unknown type' => self::TYPE_UNKNOWN, // closed resource (php < 7.2) ); if (isset($map[$type])) { $type = $map[$type]; diff --git a/src/Debug/Collector/StatementInfo.php b/src/Debug/Collector/StatementInfo.php index c56d70b8..939c0c52 100644 --- a/src/Debug/Collector/StatementInfo.php +++ b/src/Debug/Collector/StatementInfo.php @@ -303,7 +303,9 @@ private function getGroupLabel() } $label = \preg_replace('/[\r\n\s]+/', ' ', $label); } - return $label; + return \strlen($label) > 100 + ? \substr($label, 0, 100) . '…' + : (string) $label; } /** @@ -367,6 +369,7 @@ private function logQuery($label) if (\preg_replace('/[\r\n\s]+/', ' ', $this->sql) === $label) { return; } + $stringMaxLenWas = $this->debug->setCfg('stringMaxLen', -1); $sqlPretty = $this->debug->prettify($this->sql, 'application/sql'); if ($sqlPretty instanceof Abstraction) { $this->prettified = $sqlPretty['prettified']; @@ -380,6 +383,7 @@ private function logQuery($label) ), )) ); + $this->debug->setCfg('stringMaxLen', $stringMaxLenWas); } /** diff --git a/src/Debug/Dump/Html/ObjectConstants.php b/src/Debug/Dump/Html/ObjectConstants.php index 528f148a..800e82ac 100644 --- a/src/Debug/Dump/Html/ObjectConstants.php +++ b/src/Debug/Dump/Html/ObjectConstants.php @@ -88,16 +88,16 @@ public function dumpCases(Abstraction $abs) public function dumpConstants(Abstraction $abs) { $constants = $abs['constants']; - $cfg = array( + $opts = array( 'attributeOutput' => $abs['cfgFlags'] & AbstractObject::CONST_ATTRIBUTE_OUTPUT, 'constCollect' => $abs['cfgFlags'] & AbstractObject::CONST_COLLECT, 'constOutput' => $abs['cfgFlags'] & AbstractObject::CONST_OUTPUT, 'phpDocOutput' => $abs['cfgFlags'] & AbstractObject::PHPDOC_OUTPUT, ); - if (!$cfg['constOutput']) { + if (!$opts['constOutput']) { return ''; } - if (!$cfg['constCollect']) { + if (!$opts['constCollect']) { return '