0

Final Class Yiisoft\Hydrator\Attribute\Parameter\ToArrayOfStrings

InheritanceYiisoft\Hydrator\Attribute\Parameter\ToArrayOfStrings
ImplementsYiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface

Casts the resolved value to array of strings.

In multibyte mode, trimming strips Unicode whitespace characters, such as U+00A0 (no-break space), as well. It requires the mb_trim() function provided by the mbstring PHP extension since PHP 8.4, or by the symfony/polyfill-mbstring package on earlier versions.

See also https://www.php.net/manual/function.mb-trim.php.

Property Details

Hide inherited properties

$encoding public property
public ?string $encoding = null
$multibyte public property
public ?bool $multibyte = null
$removeEmpty public property
public boolean $removeEmpty = false
$separator public property
public string $separator = '\\R'
$splitResolvedValue public property
$trim public property
public boolean $trim = false

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( boolean $trim = false, boolean $removeEmpty = false, boolean $splitResolvedValue = true, string $separator = '\\R', boolean|null $multibyte = null, string|null $encoding = null )
$trim boolean

Trim each string of array.

$removeEmpty boolean

Remove empty strings from array.

$splitResolvedValue boolean

Split non-array resolved value to array of strings by {@see $separator}.

$separator string

The boundary string. It is a part of regular expression so should be taken into account or properly escaped with {@see \Yiisoft\Hydrator\Attribute\Parameter\preg_quote()}.

$multibyte boolean|null

Whether to use multibyte-aware trimming when {@see $trim} is enabled. null means using the resolver default.

$encoding string|null

The encoding to use in multibyte mode. null means using the resolver default.

                public function __construct(
    public readonly bool $trim = false,
    public readonly bool $removeEmpty = false,
    public readonly bool $splitResolvedValue = true,
    public readonly string $separator = '\R',
    public readonly ?bool $multibyte = null,
    public readonly ?string $encoding = null,
) {
    TrimCharacters::checkMultibyteFunctionsExist($multibyte);
}

            
getResolver() public method

public string getResolver ( )

                public function getResolver(): string
{
    return ToArrayOfStringsResolver::class;
}