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

Breadcrumb

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

function AbstractCloner::cloneVar

Clones a PHP variable.

Parameters

int $filter A bit field of Caster::EXCLUDE_* constants:

Overrides ClonerInterface::cloneVar

File

vendor/symfony/var-dumper/Cloner/AbstractCloner.php, line 291

Class

AbstractCloner
AbstractCloner implements a generic caster mechanism for objects and resources.

Namespace

Symfony\Component\VarDumper\Cloner

Code

public function cloneVar(mixed $var, int $filter = 0) : Data {
    $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {
        if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) {
            // Cloner never dies
            throw new \ErrorException($msg, 0, $type, $file, $line);
        }
        if ($this->prevErrorHandler) {
            return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);
        }
        return false;
    });
    $this->filter = $filter;
    if ($gc = gc_enabled()) {
        gc_disable();
    }
    try {
        return new Data($this->doClone($var));
    } finally {
        if ($gc) {
            gc_enable();
        }
        restore_error_handler();
        $this->prevErrorHandler = null;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal