export() public static method

public static export ( mixed $var, integer $maxDepth ) : mixed
$var mixed
$maxDepth integer
return mixed
コード例 #1
0
ファイル: EntityLogger.php プロジェクト: acplo/acplolog
 public static function dump($entity, $maxDepth = 1, $toHtml = true)
 {
     $output = print_r(Debug::export($entity, $maxDepth), true);
     if ($toHtml) {
         echo "<pre>{$output}</pre>";
     } else {
         echo $output;
     }
 }
コード例 #2
0
ファイル: DebugTest.php プロジェクト: sanborino/clinica
 public function testExportArrayTraversable()
 {
     $obj = new \ArrayObject(array('foobar'));
     $var = Debug::export($obj, 2);
     $this->assertContains('foobar', $var->__STORAGE__);
     $it = new \ArrayIterator(array('foobar'));
     $var = Debug::export($it, 5);
     $this->assertContains('foobar', $var->__STORAGE__);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function export($input, $name = NULL)
 {
     $name = $name ? $name . ' => ' : '';
     $variable = Debug::export($input, 6);
     ob_start();
     print_r($variable);
     $dump = ob_get_contents();
     ob_end_clean();
     $dump = '<pre>' . $name . $dump . '</pre>';
     return $this->setSafeMarkup($dump);
 }
コード例 #4
0
ファイル: WebUser.php プロジェクト: qrz-io/pim-community-dev
 /**
  * @param string $attributes
  *
  * @Then /^eligible attributes as label should be (.*)$/
  *
  * @throws ExpectationException
  */
 public function eligibleAttributesAsLabelShouldBe($attributes)
 {
     $expectedAttributes = $this->listToArray($attributes);
     $options = $this->getPage('Family edit')->getAttributeAsLabelOptions();
     if (count($expectedAttributes) !== ($actual = count($options))) {
         throw $this->createExpectationException(sprintf('Expected to see %d eligible attributes as label, actually saw %d:' . "\n%s", count($expectedAttributes), $actual, print_r(\Doctrine\Common\Util\Debug::export($options, 2), true)));
     }
     if ($expectedAttributes !== $options) {
         throw $this->createExpectationException(sprintf('Expected to see eligible attributes as label %s, actually saw %s', print_r(\Doctrine\Common\Util\Debug::export($expectedAttributes, 2), true), print_r(\Doctrine\Common\Util\Debug::export($options, 2), true)));
     }
 }
コード例 #5
0
ファイル: DBG.php プロジェクト: Niggu/cloudrexx
 private static function _escapeDoctrineDump(&$val)
 {
     if ($val instanceof \Cx\Model\Base\EntityBase) {
         $val = \Doctrine\Common\Util\Debug::export($val, 2);
     } else {
         if (is_array($val)) {
             foreach ($val as $entry) {
                 self::_escapeDoctrineDump($entry);
             }
         }
     }
 }
コード例 #6
0
 /**
  * Renders a dump of the given object
  *
  * @param object $object
  * @param integer $level
  * @param boolean $renderProperties
  * @param boolean $plaintext
  * @param boolean $ansiColors
  * @return string
  */
 protected static function renderObjectDump($object, $level, $renderProperties = TRUE, $plaintext = FALSE, $ansiColors = FALSE)
 {
     $dump = '';
     $scope = '';
     $additionalAttributes = '';
     if ($object instanceof \Doctrine\Common\Collections\Collection) {
         return self::renderArrayDump(\Doctrine\Common\Util\Debug::export($object, 3), $level, $plaintext, $ansiColors);
     }
     // Objects returned from Doctrine's Debug::export function are stdClass with special properties:
     try {
         $objectIdentifier = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', TRUE);
     } catch (\TYPO3\Flow\Reflection\Exception\PropertyNotAccessibleException $exception) {
         $objectIdentifier = spl_object_hash($object);
     }
     $className = $object instanceof \stdClass && isset($object->__CLASS__) ? $object->__CLASS__ : get_class($object);
     if (isset(self::$renderedObjects[$objectIdentifier]) || preg_match(self::getIgnoredClassesRegex(), $className) !== 0) {
         $renderProperties = FALSE;
     }
     self::$renderedObjects[$objectIdentifier] = TRUE;
     if (self::$objectManager !== NULL) {
         $objectName = self::$objectManager->getObjectNameByClassName(get_class($object));
         if ($objectName !== FALSE) {
             switch (self::$objectManager->getScope($objectName)) {
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_PROTOTYPE:
                     $scope = 'prototype';
                     break;
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON:
                     $scope = 'singleton';
                     break;
                 case \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SESSION:
                     $scope = 'session';
                     break;
             }
         } else {
             $additionalAttributes .= ' debug-unregistered';
         }
     }
     if ($renderProperties === TRUE && !$plaintext) {
         if ($scope === '') {
             $scope = 'prototype';
         }
         $scope .= '<a id="o' . $objectIdentifier . '"></a>';
     }
     if ($plaintext) {
         $dump .= $className;
         $dump .= $scope !== '' ? ' ' . self::ansiEscapeWrap($scope, '44;37', $ansiColors) : '';
     } else {
         $dump .= '<span class="debug-object' . $additionalAttributes . '" title="' . $objectIdentifier . '">' . $className . '</span>';
         $dump .= $scope !== '' ? '<span class="debug-scope">' . $scope . '</span>' : '';
     }
     if (property_exists($object, 'Persistence_Object_Identifier')) {
         $persistenceIdentifier = $objectIdentifier;
         $persistenceType = 'persistable';
     } elseif ($object instanceof \Closure) {
         $persistenceIdentifier = 'n/a';
         $persistenceType = 'closure';
     } else {
         $persistenceIdentifier = 'unknown';
         $persistenceType = 'object';
     }
     if ($plaintext) {
         $dump .= ' ' . self::ansiEscapeWrap($persistenceType, '42;37', $ansiColors);
     } else {
         $dump .= '<span class="debug-ptype" title="' . $persistenceIdentifier . '">' . $persistenceType . '</span>';
     }
     if ($object instanceof \TYPO3\Flow\Object\Proxy\ProxyInterface || property_exists($object, '__IS_PROXY__') && $object->__IS_PROXY__ === TRUE) {
         if ($plaintext) {
             $dump .= ' ' . self::ansiEscapeWrap('proxy', '41;37', $ansiColors);
         } else {
             $dump .= '<span class="debug-proxy" title="' . $className . '">proxy</span>';
         }
     }
     if ($renderProperties === TRUE) {
         if ($object instanceof \SplObjectStorage) {
             $dump .= ' (' . (count($object) ?: 'empty') . ')';
             foreach ($object as $value) {
                 $dump .= chr(10);
                 $dump .= str_repeat(' ', $level);
                 $dump .= self::renderObjectDump($value, 0, FALSE, $plaintext, $ansiColors);
             }
         } else {
             $classReflection = new \ReflectionClass($className);
             $properties = $classReflection->getProperties();
             foreach ($properties as $property) {
                 if (preg_match(self::$blacklistedPropertyNames, $property->getName())) {
                     continue;
                 }
                 $dump .= chr(10);
                 $dump .= str_repeat(' ', $level) . ($plaintext ? '' : '<span class="debug-property">') . self::ansiEscapeWrap($property->getName(), '36', $ansiColors) . ($plaintext ? '' : '</span>') . ' => ';
                 $property->setAccessible(TRUE);
                 $value = $property->getValue($object);
                 if (is_array($value)) {
                     $dump .= self::renderDump($value, $level + 1, $plaintext, $ansiColors);
                 } elseif (is_object($value)) {
                     $dump .= self::renderObjectDump($value, $level + 1, TRUE, $plaintext, $ansiColors);
                 } else {
                     $dump .= self::renderDump($value, $level, $plaintext, $ansiColors);
                 }
             }
         }
     } elseif (isset(self::$renderedObjects[$objectIdentifier])) {
         if (!$plaintext) {
             $dump = '<a href="#o' . $objectIdentifier . '" onclick="document.location.hash=\'#o' . $objectIdentifier . '\'; return false;" class="debug-seeabove" title="see above">' . $dump . '</a>';
         }
     }
     return $dump;
 }
コード例 #7
0
 /**
  * @param string $entityName
  * @param mixed  $criteria
  *
  * @throws \InvalidArgumentException If entity is not found
  *
  * @return object
  */
 public function getEntityOrException($entityName, $criteria)
 {
     $entity = $this->findEntity($entityName, $criteria);
     if (!$entity) {
         if (is_string($criteria)) {
             $criteria = ['code' => $criteria];
         }
         throw new \InvalidArgumentException(sprintf('Could not find "%s" with criteria %s', $this->getEntities()[$entityName], print_r(\Doctrine\Common\Util\Debug::export($criteria, 2), true)));
     }
     return $entity;
 }
コード例 #8
0
ファイル: Log.php プロジェクト: datravel/php-debug
 /**
  * @param mixed $value
  * @return string
  */
 private static function export($value = null)
 {
     $value = Debug::export($value, self::LEVEL_DEPTH);
     // if $context was object - he will be converted to \StdClass
     if ($value instanceof \StdClass) {
         $value = (array) $value;
     }
     return stripslashes(var_export($value, true));
 }
コード例 #9
0
ファイル: DBG.php プロジェクト: nahakiole/cloudrexx
 private static function _escapeDoctrineDump(&$val)
 {
     if ($val instanceof \Cx\Model\Base\EntityBase || $val instanceof \Doctrine\DBAL\Statement || $val instanceof \Doctrine\DBAL\Connection || $val instanceof \Cx\Core_Modules\MultiSite\Model\Entity\Domain || $val instanceof \Cx\Core\Core\Model\Entity\EntityBase || $val instanceof \Doctrine\ORM\Mapping\ClassMetadata || $val instanceof \Cx\Core\Core\Controller\Cx || $val instanceof \Cx\Core\Html\Sigma || $val instanceof \Cx\Core\Core\Model\Entity\SystemComponentController) {
         $val = \Doctrine\Common\Util\Debug::export($val, 2);
     } else {
         if (is_array($val)) {
             foreach ($val as &$entry) {
                 self::_escapeDoctrineDump($entry);
             }
         }
     }
 }
コード例 #10
0
ファイル: Logger.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Prepare data for logging
  *
  * @param mixed $data
  *
  * @return mixed
  */
 protected static function prepareData($data)
 {
     if (is_array($data)) {
         foreach ($data as $k => $v) {
             $data[$k] = static::prepareData($v);
         }
     } elseif (is_object($data)) {
         $data = \Doctrine\Common\Util\Debug::export($data, 2);
     }
     return $data;
 }
コード例 #11
0
ファイル: Helper.php プロジェクト: pscheit/psc-cms
 public static function getDump($item, $maxDepth = 3)
 {
     ini_set('html_errors', 'On');
     if (extension_loaded('xdebug')) {
         ini_set('xdebug.var_display_max_depth', $maxDepth);
     }
     $var = \Doctrine\Common\Util\Debug::export($item, $maxDepth++);
     ob_start();
     var_dump($var);
     $dump = ob_get_contents();
     ob_end_clean();
     return strip_tags(html_entity_decode($dump));
     ini_set('html_errors', 'Off');
 }
コード例 #12
0
ファイル: DebugTest.php プロジェクト: nemekzg/common
 public function testExportArrayObject()
 {
     $obj = new \ArrayObject(array('foobar'));
     $var = Debug::export($obj, 2);
     $this->assertContains('foobar', $var->__STORAGE__);
 }
コード例 #13
0
 public function testExportDateTime()
 {
     $obj = new \DateTime("2010-10-10 10:10:10");
     $var = Debug::export($obj, 2);
     $this->assertEquals("DateTime", $var->__CLASS__);
 }