Stellar PHP SDK API Documentation

XdrBuffer
in package

Enables easy iteration through a blob of XDR data.

Provides an optional recursion-depth guard for XDR types that decode themselves recursively (e.g. XdrSorobanDelegateSignature). Call enterRecursion() at the start of each recursive call and leaveRecursion() on return. The guard throws InvalidArgumentException when the depth exceeds RECURSION_LIMIT (128), preventing stack exhaustion from hostile deep-nesting in data received from the network.

The guard counts true nesting depth, not array width or sequential fields, so wide transactions and large maps are unaffected.

Table of Contents

Constants

RECURSION_LIMIT  : mixed = 128
Maximum allowed decode recursion depth (prevents stack exhaustion from hostile data).

Properties

$position  : int
$size  : int
$xdrBytes  : string

Methods

__construct()  : mixed
enterRecursion()  : void
Signals entry into one level of recursive XDR decoding.
getRecursionDepth()  : int
Returns the current recursion depth.
leaveRecursion()  : void
Signals exit from one level of recursive XDR decoding.
readBigInteger64()  : BigInteger
readBoolean()  : bool
readInteger32()  : int
readInteger64()  : int
readOpaqueFixed()  : string
readOpaqueFixedString()  : string
readOpaqueVariable()  : string
readString()  : string
readUnsignedInteger256()  : string
readUnsignedInteger32()  : int
readUnsignedInteger64()  : int
assertBytesRemaining()  : mixed
roundTo4()  : int
rounds $number up to the nearest value that's a multiple of 4

Constants

RECURSION_LIMIT

Maximum allowed decode recursion depth (prevents stack exhaustion from hostile data).

public mixed RECURSION_LIMIT = 128

Properties

Methods

__construct()

public __construct(string $xdrBytes) : mixed
Parameters
$xdrBytes : string

enterRecursion()

Signals entry into one level of recursive XDR decoding.

public enterRecursion() : void

Increments the depth counter and throws InvalidArgumentException when the limit is exceeded. Pair every call with a corresponding leaveRecursion() call.

Tags
throws
InvalidArgumentException

when depth exceeds RECURSION_LIMIT

getRecursionDepth()

Returns the current recursion depth.

public getRecursionDepth() : int
Return values
int

current depth (0 at top level)

leaveRecursion()

Signals exit from one level of recursive XDR decoding.

public leaveRecursion() : void

Decrements the depth counter. Must be called once for every successful enterRecursion() call, including on exception paths (use try/finally).

readBigInteger64()

public readBigInteger64() : BigInteger
Return values
BigInteger

readBoolean()

public readBoolean() : bool
Return values
bool

readInteger32()

public readInteger32() : int
Return values
int

readInteger64()

public readInteger64() : int
Return values
int

readOpaqueFixed()

public readOpaqueFixed(mixed $length) : string
Parameters
$length : mixed
Return values
string

readOpaqueFixedString()

public readOpaqueFixedString(mixed $length) : string
Parameters
$length : mixed
Return values
string

readOpaqueVariable()

public readOpaqueVariable([null $maxLength = null ]) : string
Parameters
$maxLength : null = null
Return values
string

readString()

public readString([null $maxLength = null ]) : string
Parameters
$maxLength : null = null
Return values
string

readUnsignedInteger256()

public readUnsignedInteger256() : string
Return values
string

readUnsignedInteger32()

public readUnsignedInteger32() : int
Return values
int

readUnsignedInteger64()

public readUnsignedInteger64() : int
Return values
int

assertBytesRemaining()

protected assertBytesRemaining(mixed $numBytes) : mixed
Parameters
$numBytes : mixed

roundTo4()

rounds $number up to the nearest value that's a multiple of 4

protected roundTo4(mixed $number) : int
Parameters
$number : mixed
Return values
int
On this page

Search results