Serializer/Adapter/PythonPickle.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Serializer  
Subpackage
Adapter  
Version
$Id$  

\Zend_Serializer_Adapter_PythonPickle

Package: Zend_Serializer\Adapter
Parent(s)
\Zend_Serializer_Adapter_AdapterAbstract
See
 
See
 
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Link
http://www.python.org  
Link
http://pickle-js.googlecode.com  

Constants

>VConstant  OP_MARK = '('
>VConstant  OP_STOP = '.'
>VConstant  OP_POP = '0'
>VConstant  OP_POP_MARK = '1'
>VConstant  OP_DUP = '2'
>VConstant  OP_FLOAT = 'F'
>VConstant  OP_INT = 'I'
>VConstant  OP_BININT = 'J'
>VConstant  OP_BININT1 = 'K'
>VConstant  OP_LONG = 'L'
>VConstant  OP_BININT2 = 'M'
>VConstant  OP_NONE = 'N'
>VConstant  OP_PERSID = 'P'
>VConstant  OP_BINPERSID = 'Q'
>VConstant  OP_REDUCE = 'R'
>VConstant  OP_STRING = 'S'
>VConstant  OP_BINSTRING = 'T'
>VConstant  OP_SHORT_BINSTRING = 'U'
>VConstant  OP_UNICODE = 'V'
>VConstant  OP_BINUNICODE = 'X'
>VConstant  OP_APPEND = 'a'
>VConstant  OP_BUILD = 'b'
>VConstant  OP_GLOBAL = 'c'
>VConstant  OP_DICT = 'd'
>VConstant  OP_EMPTY_DICT = '}'
>VConstant  OP_APPENDS = 'e'
>VConstant  OP_GET = 'g'
>VConstant  OP_BINGET = 'h'
>VConstant  OP_INST = 'i'
>VConstant  OP_LONG_BINGET = 'j'
>VConstant  OP_LIST = 'l'
>VConstant  OP_EMPTY_LIST = ']'
>VConstant  OP_OBJ = 'o'
>VConstant  OP_PUT = 'p'
>VConstant  OP_BINPUT = 'q'
>VConstant  OP_LONG_BINPUT = 'r'
>VConstant  OP_SETITEM = 's'
>VConstant  OP_TUPLE = 't'
>VConstant  OP_EMPTY_TUPLE = ')'
>VConstant  OP_SETITEMS = 'u'
>VConstant  OP_BINFLOAT = 'G'
>VConstant  OP_PROTO = "\x80"
>VConstant  OP_NEWOBJ = "\x81"
>VConstant  OP_EXT1 = "\x82"
>VConstant  OP_EXT2 = "\x83"
>VConstant  OP_EXT4 = "\x84"
>VConstant  OP_TUPLE1 = "\x85"
>VConstant  OP_TUPLE2 = "\x86"
>VConstant  OP_TUPLE3 = "\x87"
>VConstant  OP_NEWTRUE = "\x88"
>VConstant  OP_NEWFALSE = "\x89"
>VConstant  OP_LONG1 = "\x8a"
>VConstant  OP_LONG4 = "\x8b"
>VConstant  OP_BINBYTES = 'B'
>VConstant  OP_SHORT_BINBYTES = 'C'

Properties

>VPropertyprotected$_binary = false
Default valuefalseDetails
Type
n/a
>VPropertyprotectedbool $_isLittleEndian = null
static

Whether or not the system is little-endian

Default valuenullDetails
Type
bool
>VPropertyprotectedbool $_isPhp6 = null
static

Whether or not this is a PHP 6 binary

Default valuenullDetails
Type
bool
>VPropertyprotected$_marker = null
Default valuenullDetails
Type
n/a
>VPropertyprotected$_memo = array()
Default valuearray()Details
Type
n/a
>VPropertyprotectedarray $_options = array('protocol' => 0)

Default options

Default valuearray('protocol' => 0)Details
Type
array
>VPropertyprotected$_pickle = ''
Default value''Details
Type
n/a
>VPropertyprotected$_pickleLen = 0
Default value0Details
Type
n/a
>VPropertyprotected$_pos = 0
Default value0Details
Type
n/a
>VPropertyprotected$_protocol = 0
Default value0Details
Type
n/a
>VPropertyprotectedarray $_quoteString = array('\\' => '\\\\', "\x00" => '\\x00', "\x01" => '\\x01', "\x02" => '\\x02', "\x03" => '\\x03', "\x04" => '\\x04', "\x05" => '\\x05', "\x06" => '\\x06', "\x07" => '\\x07', "\x08" => '\\x08', "\x09" => '\\t', "\x0a" => '\\n', "\x0b" => '\\x0b', "\x0c" => '\\x0c', "\x0d" => '\\r', "\x0e" => '\\x0e', "\x0f" => '\\x0f', "\x10" => '\\x10', "\x11" => '\\x11', "\x12" => '\\x12', "\x13" => '\\x13', "\x14" => '\\x14', "\x15" => '\\x15', "\x16" => '\\x16', "\x17" => '\\x17', "\x18" => '\\x18', "\x19" => '\\x19', "\x1a" => '\\x1a', "\x1b" => '\\x1b', "\x1c" => '\\x1c', "\x1d" => '\\x1d', "\x1e" => '\\x1e', "\x1f" => '\\x1f', "\xff" => '\\xff')
static

Strings representing quotes

Default valuearray('\\' => '\\\\', "\x00" => '\\x00', "\x01" => '\\x01', "\x02" => '\\x02', "\x03" => '\\x03', "\x04" => '\\x04', "\x05" => '\\x05', "\x06" => '\\x06', "\x07" => '\\x07', "\x08" => '\\x08', "\x09" => '\\t', "\x0a" => '\\n', "\x0b" => '\\x0b', "\x0c" => '\\x0c', "\x0d" => '\\r', "\x0e" => '\\x0e', "\x0f" => '\\x0f', "\x10" => '\\x10', "\x11" => '\\x11', "\x12" => '\\x12', "\x13" => '\\x13', "\x14" => '\\x14', "\x15" => '\\x15', "\x16" => '\\x16', "\x17" => '\\x17', "\x18" => '\\x18', "\x19" => '\\x19', "\x1a" => '\\x1a', "\x1b" => '\\x1b', "\x1c" => '\\x1c', "\x1d" => '\\x1d', "\x1e" => '\\x1e', "\x1f" => '\\x1f', "\xff" => '\\xff')Details
Type
array
>VPropertyprotected$_stack = array()
Default valuearray()Details
Type
n/a

Methods

methodpublic__construct( $opts = array()) : void

Constructor

Parameters
NameTypeDescription
$opts
Details
Link
Zend_Serializer_Adapter_AdapterAbstract::__construct()  
methodprotected_checkProtocolNumber(int $number) : int

Check and normalize pickle protocol number

Parameters
NameTypeDescription
$numberint
Returns
TypeDescription
int
Throws
ExceptionDescription
\Zend_Serializer_Exception
methodprotected_convertMatchingUnicodeSequence2Utf8(array $match) : string

Convert a unicode sequence to UTF-8

Parameters
NameTypeDescription
$matcharray
Returns
TypeDescription
string
methodprotected_decodeBinLong(string $data) : int | float | string

Decode a binary long sequence

Parameters
NameTypeDescription
$datastring
Returns
TypeDescription
int | float | string
methodprotected_hex2Utf8( $hex) : string

Convert a hex string to a UTF-8 string

Parameters
NameTypeDescription
$hex
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Serializer_Exceptionon unmatched unicode sequence
methodprotected_isArrayAssoc(array $value) : boolean

Is an array associative?

Parameters
NameTypeDescription
$valuearray
Returns
TypeDescription
boolean
methodprotected_lastMarker() : int

Return last marker position in stack

Returns
TypeDescription
int
methodprotected_load(string $op) : void

Load a pickle opcode

Parameters
NameTypeDescription
$opstring
Throws
ExceptionDescription
\Zend_Serializer_Exceptionon invalid opcode
methodprotected_loadAppend() : void

Load an append (to list) sequence

methodprotected_loadAppends() : void

Load multiple append (to list) sequences at once

methodprotected_loadBinBytes() : void

Load arbitrary binary bytes

methodprotected_loadBinFloat() : void

Load a binary float value

methodprotected_loadBinGet() : void

Load a binary GET operation

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing GET identifier
methodprotected_loadBinInt() : void

Load a binary integer operator

methodprotected_loadBinInt1() : void

Load the first byte of a binary integer

methodprotected_loadBinInt2() : void

Load the second byte of a binary integer

methodprotected_loadBinPut() : void

Load a binary PUT

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing stack
methodprotected_loadBinString() : void

Load a binary string

methodprotected_loadBinUnicode() : void

Load binary unicode sequence

methodprotected_loadDict() : void

Load an associative array (Python dictionary)

methodprotected_loadEmptyDict() : void

Load an empty dictionary

methodprotected_loadEmptyList() : void

Load an empty list sequence

methodprotected_loadFloat() : void

Load a float value

methodprotected_loadGet() : void

Load a GET operation

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing GET identifier
methodprotected_loadInt() : void

Load an integer operator

methodprotected_loadList() : void

Load an array (list)

methodprotected_loadLong() : void

Load a long (float) operator

methodprotected_loadLong1() : void

Load a one byte long integer

methodprotected_loadLong4() : void

Load a 4 byte long integer

methodprotected_loadLongBinGet() : void

Load a long binary GET operation

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing GET identifier
methodprotected_loadLongBinPut() : void

Load a long binary PUT

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing stack
methodprotected_loadMark() : void

Load a marker sequence

methodprotected_loadNewFalse() : void

Load a boolean FALSE operator

methodprotected_loadNewTrue() : void

Load a boolean TRUE operator

methodprotected_loadNone() : void

Load a NONE operator

methodprotected_loadProto() : void

Load a proto value

Throws
ExceptionDescription
\Zend_Serializer_Exceptionif Pickle version does not support this feature
methodprotected_loadPut() : void

Load a PUT opcode

Throws
ExceptionDescription
\Zend_Serializer_Exceptionon missing stack
methodprotected_loadSetItem() : void

Load an item from a set

methodprotected_loadSetItems() : void

Load set items

methodprotected_loadShortBinBytes() : void

Load a single binary byte

methodprotected_loadShortBinString() : void

Load a short binary string

methodprotected_loadString() : void

Load a string

methodprotected_loadTuple() : void

Load a tuple

methodprotected_loadTuple1() : void

Load single item tuple

methodprotected_loadTuple2() : void

Load two item tuple

methodprotected_loadTuple3() : void

Load three item tuple

methodprotected_loadUnicode() : void

Load a unicode string

methodprotected_momorize(mixed $value) : void

Add a value to the memo and write the id

Parameters
NameTypeDescription
$valuemixed
methodprotected_quoteString(string $str) : string

Quote/Escape a string

Parameters
NameTypeDescription
$strstring
Returns
TypeDescription
stringquoted string
methodprotected_read(mixed $len) : string

Read a segment of the pickle

Parameters
NameTypeDescription
$lenmixed
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Serializer_Exceptionif position matches end of data
methodprotected_readline() : string

Read a line of the pickle at once

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Serializer_Exceptionif no EOL character found
methodprotected_searchMomo(mixed $value) : int | false

Search a value in the meno and return the id

Parameters
NameTypeDescription
$valuemixed
Returns
TypeDescription
int | falseThe id or false
methodprotected_unquoteString(string $str) : string

Unquote/Unescape a quoted string

Parameters
NameTypeDescription
$strstring

quoted string

Returns
TypeDescription
stringunquoted string
methodprotected_write(mixed $value) : void

Write a value

Parameters
NameTypeDescription
$valuemixed
Throws
ExceptionDescription
\Zend_Serializer_Exceptionon invalid or unrecognized value type
methodprotected_writeArrayDict(array $value) : void

Write an associative array value as dictionary

Parameters
NameTypeDescription
$valuearray
methodprotected_writeArrayList(array $value) : void

Write a simple array value as list

Parameters
NameTypeDescription
$valuearray
methodprotected_writeFalse() : void

Write a boolean false

methodprotected_writeFloat(float $value) : void

Write a float value

Parameters
NameTypeDescription
$valuefloat
methodprotected_writeGet(int $id) : void

Write a get

Parameters
NameTypeDescription
$idint

Id of memo

methodprotected_writeInt(int $value) : void

Write an integer value

Parameters
NameTypeDescription
$valueint
methodprotected_writeNull() : void

Write a null as None

methodprotected_writeObject(object $value) : void

Write an object as an dictionary

Parameters
NameTypeDescription
$valueobject
methodprotected_writeProto(int $protocol) : void

Write pickle protocol

Parameters
NameTypeDescription
$protocolint
methodprotected_writePut(int $id) : void

Write a put

Parameters
NameTypeDescription
$idint

Id of memo

methodprotected_writeStop() : void

Write stop

methodprotected_writeString(string $value) : void

Write a string value

Parameters
NameTypeDescription
$valuestring
methodprotected_writeTrue() : void

Write a boolean true

methodpublicserialize(mixed $value, array $opts = array()) : string

Serialize PHP to PythonPickle format

Parameters
NameTypeDescription
$valuemixed
$optsarray
Returns
TypeDescription
string
methodpublicsetOption(string $name, mixed $value) : \Zend_Serializer_Adapter_PythonPickle

Set an option

Parameters
NameTypeDescription
$namestring
$valuemixed
Returns
TypeDescription
\Zend_Serializer_Adapter_PythonPickle
Details
Link
Zend_Serializer_Adapter_AdapterAbstract::setOption()  
methodpublicunserialize(string $pickle, array $opts = array()) : mixed

Unserialize from Python Pickle format to PHP

Parameters
NameTypeDescription
$picklestring
$optsarray
Returns
TypeDescription
mixed
Throws
ExceptionDescription
\Zend_Serializer_Exceptionon invalid Pickle string
Documentation was generated by phpDocumentor 2.2.0 .