Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Exporter.php

class Exporter

Same name in this branch
  1. 11.1.x vendor/sebastian/exporter/src/Exporter.php \SebastianBergmann\Exporter\Exporter
  2. 11.1.x vendor/symfony/var-exporter/Internal/Exporter.php \Symfony\Component\VarExporter\Internal\Exporter

@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

@internal This class is not covered by the backward compatibility promise for PHPUnit

Hierarchy

  • class \PHPUnit\Util\Exporter

Expanded class hierarchy of Exporter

16 files declare their use of Exporter
ArrayHasKey.php in vendor/phpunit/phpunit/src/Framework/Constraint/Traversable/ArrayHasKey.php
Constraint.php in vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php
DispatchingEmitter.php in vendor/phpunit/phpunit/src/Event/Emitter/DispatchingEmitter.php
ExceptionCode.php in vendor/phpunit/phpunit/src/Framework/Constraint/Exception/ExceptionCode.php
ExceptionMessageIsOrContains.php in vendor/phpunit/phpunit/src/Framework/Constraint/Exception/ExceptionMessageIsOrContains.php

... See full list

File

vendor/phpunit/phpunit/src/Util/Exporter.php, line 23

Namespace

PHPUnit\Util
View source
final class Exporter {
    public static function export(mixed $value, bool $exportObjects = false) : string {
        if (self::isExportable($value) || $exportObjects) {
            return (new \SebastianBergmann\Exporter\Exporter())->export($value);
        }
        return '{enable export of objects to see this value}';
    }
    private static function isExportable(mixed &$value, ?Context $context = null) : bool {
        if (is_scalar($value) || $value === null) {
            return true;
        }
        if (!is_array($value)) {
            return false;
        }
        if (!$context) {
            $context = new Context();
        }
        if ($context->contains($value) !== false) {
            return true;
        }
        $array = $value;
        $context->add($value);
        foreach ($array as &$_value) {
            if (!self::isExportable($_value, $context)) {
                return false;
            }
        }
        return true;
    }

}

Members

Title Sort descending Modifiers Object type Summary
Exporter::export public static function
Exporter::isExportable private static function
RSS feed
Powered by Drupal