class PhpArrayDumper extends OptimizedPhpArrayDumper (View source)

PhpArrayDumper dumps a service container as a PHP array.

The format of this dumper is a human-readable serialized PHP array, which is very similar to the YAML based format, but based on PHP arrays instead of YAML strings.

It is human-readable, for a machine-optimized version based on this one see \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.

Properties

protected bool $serialize

Whether to serialize service definitions or not.

from  OptimizedPhpArrayDumper
protected array $aliases

A list of container aliases.

from  OptimizedPhpArrayDumper

Methods

dump(array $options = [])

{@inheritdoc}

array
getArray()

Gets the service container definition as a PHP array.

array
getAliases()

Gets the aliases as a PHP array.

array
getParameters()

Gets parameters of the container as a PHP array.

array
getServiceDefinitions()

Gets services of the container as a PHP array.

array
prepareParameters(array $parameters, bool $escape = TRUE)

Prepares parameters for the PHP array dumping.

array
escape(array $parameters)

Escapes parameters.

array
getServiceDefinition(Definition $definition)

Gets a service definition as PHP array.

array
dumpMethodCalls(array $calls)

Dumps method calls to a PHP array.

object|array
dumpCollection(mixed $collection, bool $resolve = FALSE)

Dumps a collection to a PHP array.

callable
dumpCallable(array|callable $callable)

Dumps callable to a PHP array.

object
getPrivateServiceCall(string $id, Definition $definition, bool $shared = FALSE)

Gets a private service definition in a suitable format.

mixed
dumpValue(mixed $value)

Dumps the value to PHP array format.

string|object
getReferenceCall(string $id, Reference $reference = NULL)

Gets a service reference for a reference in a suitable PHP array format.

string|object
getServiceCall(string $id, int $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)

Gets a service reference for an ID in a suitable PHP array format.

string|object
getParameterCall(string $name)

Gets a parameter reference in a suitable PHP array format.

bool
supportsMachineFormat()

Whether this supports the machine-optimized format or not.

Details

dump(array $options = [])

{@inheritdoc}

Parameters

array $options

array getArray()

Gets the service container definition as a PHP array.

Return Value

array

A PHP array representation of the service container.

protected array getAliases()

Gets the aliases as a PHP array.

Return Value

array

The aliases.

protected array getParameters()

Gets parameters of the container as a PHP array.

Return Value

array

The escaped and prepared parameters of the container.

protected array getServiceDefinitions()

Gets services of the container as a PHP array.

Return Value

array

The service definitions.

protected array prepareParameters(array $parameters, bool $escape = TRUE)

Prepares parameters for the PHP array dumping.

Parameters

array $parameters

An array of parameters.

bool $escape

Whether keys with '%' should be escaped or not.

Return Value

array

An array of prepared parameters.

protected array escape(array $parameters)

Escapes parameters.

Parameters

array $parameters

The parameters to escape for '%' characters.

Return Value

array

The escaped parameters.

protected array getServiceDefinition(Definition $definition)

Gets a service definition as PHP array.

Parameters

Definition $definition

The definition to process.

Return Value

array

The service definition as PHP array.

Exceptions

InvalidArgumentException

protected array dumpMethodCalls(array $calls)

Dumps method calls to a PHP array.

Parameters

array $calls

An array of method calls.

Return Value

array

The PHP array representation of the method calls.

protected object|array dumpCollection(mixed $collection, bool $resolve = FALSE)

Dumps a collection to a PHP array.

Parameters

mixed $collection

A collection to process.

bool $resolve

Used for passing the information to the caller whether the given collection needed to be resolved or not. This is used for optimizing deep arrays that don't need to be traversed.

Return Value

object|array

The collection in a suitable format.

protected callable dumpCallable(array|callable $callable)

Dumps callable to a PHP array.

Parameters

array|callable $callable

The callable to process.

Return Value

callable

The processed callable.

protected object getPrivateServiceCall(string $id, Definition $definition, bool $shared = FALSE)

Gets a private service definition in a suitable format.

Parameters

string $id

The ID of the service to get a private definition for.

Definition $definition

The definition to process.

bool $shared

(optional) Whether the service will be shared with others. By default this parameter is FALSE.

Return Value

object

A very lightweight private service value object.

protected mixed dumpValue(mixed $value)

Dumps the value to PHP array format.

Parameters

mixed $value

The value to dump.

Return Value

mixed

The dumped value in a suitable format.

Exceptions

RuntimeException

protected string|object getReferenceCall(string $id, Reference $reference = NULL)

Gets a service reference for a reference in a suitable PHP array format.

The main difference is that this function treats references to private services differently and returns a private service reference instead of a normal reference.

Parameters

string $id

The ID of the service to get a reference for.

Reference $reference

(optional) The reference object to process; needed to get the invalid behavior value.

Return Value

string|object

A suitable representation of the service reference.

protected string|object getServiceCall(string $id, int $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)

Gets a service reference for an ID in a suitable PHP array format.

Parameters

string $id

The ID of the service to get a reference for.

int $invalid_behavior

(optional) The invalid behavior of the service.

Return Value

string|object

A suitable representation of the service reference.

protected string|object getParameterCall(string $name)

Gets a parameter reference in a suitable PHP array format.

Parameters

string $name

The name of the parameter to get a reference for.

Return Value

string|object

A suitable representation of the parameter reference.

protected bool supportsMachineFormat()

Whether this supports the machine-optimized format or not.

Return Value

bool

TRUE if this supports machine-optimized format, FALSE otherwise.