PHP Класс VersionPress\Storages\Serialization\IniSerializer

Our INI format is a bit stricter than the generic INI format. Specifically, the following rules apply: - Strings strictly use CRLF line endings (some implementations also allow LF) - Section names and keys are case sensitive (as opposed to Windows built-in implementation) - At least empty string is always serialized, e.g., key = "", never key = - The key/value separator is always = (single space followed by equals sign followed by empty space) The serializer supports two kinds of data structures: 1. Flat - simple associative arrays 2. Sectioned - associative arrays where key-value sets are grouped into sections Problematic cases: - "\" (should be invalid, see http://3v4l.org/1DJ49)
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
deserialize ( string $string ) : array Deserializes INI format into an array structure
serialize ( array $data ) : string Serializes sectioned data array into an INI string

Приватные методы

Метод Описание
eolWorkaround_addPlaceholders ( string $iniString ) : mixed PHP (Zend, not HHVM) has a bug that causes parse_ini_string() to fail when the line ends with an escaped quote, like:
eolWorkaround_removePlaceholders ( $deserializedArray ) : array
escapeString ( $str ) : mixed Called when serializing data into an INI string. The only character that needs special handling is a double quotation mark, see e.g. WP-284. All others are fine since using INI_SCANNER_RAW (WP-458).
expandArrays ( $deserialized ) : array Transforms e.g.
getReplacedEolString ( $str, $direction )
outputToString ( $output )
preserveNULLs ( $iniString )
preserveNumbers ( $iniString )
restorePhpSerializedData ( $deserialized ) : array Converts all PHP-serialized data in the INI (multiple lines, made for easy merging) to the original PHP-serialized strings.
restoreTypesOfValues ( $deserialized )
sanitizeSectionsAndKeys_addPlaceholders ( $string )
sanitizeSectionsAndKeys_removePlaceholders ( $deserialized )
serializeData ( $data )
serializeKeyValuePair ( string $key, string | integer | float $value ) : string Serializes key-value pair
serializeSection ( string $sectionName, array $data ) : array Serializes section - works recursively for subsections
unescapeString ( $str ) : mixed The opposite to escapeString(), called when INI strings are restored back to arrays. Again, the only char that needs special handling is the double quotation mark.

Описание методов

deserialize() публичный статический Метод

Deserializes INI format into an array structure
public static deserialize ( string $string ) : array
$string string INI string
Результат array Array structure corresponding to the INI format

serialize() публичный статический Метод

Serializes sectioned data array into an INI string
public static serialize ( array $data ) : string
$data array
Результат string Nested INI format