本文整理汇总了PHP中Doctrine\Common\Util\Debug::export方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::export方法的具体用法?PHP Debug::export怎么用?PHP Debug::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Util\Debug
的用法示例。
在下文中一共展示了Debug::export方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dump
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: testExportArrayTraversable
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: export
/**
* {@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: eligibleAttributesAsLabelShouldBe
/**
* @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: _escapeDoctrineDump
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: renderObjectDump
/**
* 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);
//.........这里部分代码省略.........
示例7: getEntityOrException
/**
* @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: export
/**
* @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: _escapeDoctrineDump
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: prepareData
/**
* 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: getDump
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: testExportArrayObject
public function testExportArrayObject()
{
$obj = new \ArrayObject(array('foobar'));
$var = Debug::export($obj, 2);
$this->assertContains('foobar', $var->__STORAGE__);
}
示例13: testExportDateTime
public function testExportDateTime()
{
$obj = new \DateTime("2010-10-10 10:10:10");
$var = Debug::export($obj, 2);
$this->assertEquals("DateTime", $var->__CLASS__);
}