Nexus API Reference

ActorPath
in package
implements ActorPathContract

FinalYes
Tags
psalm-api

Immutable actor path in the hierarchy.

Represents a fully-qualified path like /user/orders/order-123. The root path is represented as /.

Table of Contents

Interfaces

ActorPathContract
Common contract for local and remote actor paths.

Methods

__serialize()  : array<string, string>
Compact serialization — stores just the path string instead of the private elements array with its full namespace-qualified field key.
__toString()  : string
__unserialize()  : void
child()  : self
Creates a child path by appending a name segment.
depth()  : int
Returns the depth of this path (0 for root, 1 for `/user`, etc.).
equals()  : bool
Value equality comparison.
fromString()  : self
Parses an actor path from a string like `/user/orders`.
isChildOf()  : bool
Returns true if this path is a direct child of the given parent (i.e., depth is exactly parent depth + 1 and shares the same prefix).
isDescendantOf()  : bool
Returns true if this path is a descendant (child, grandchild, etc.) of the given ancestor.
name()  : string
Returns the last segment of the path (`'/'` for root).
parent()  : ActorPathContract|null
Returns the parent path, or null for the root path.
root()  : self
Creates the root path `/`.

Methods

__serialize()

Compact serialization — stores just the path string instead of the private elements array with its full namespace-qualified field key.

public __serialize() : array<string, string>

Before: O:...:1:{s:50:"\0...\0elements";a:2:{i:0;s:4:"user";i:1;s:7:"shard-0";}} After: O:...:1:{s:1:"p";s:14:"/user/shard-0";}

Saves ~130 bytes per Envelope passed through Thread\Queue, improving cross-thread throughput.

Return values
array<string, string>

__toString()

public __toString() : string
Return values
string

__unserialize()

public __unserialize(array<string, string> $data) : void
Parameters
$data : array<string, string>

child()

Creates a child path by appending a name segment.

public child(string $name) : self
Parameters
$name : string
Tags
throws
InvalidActorPathException

If the name contains invalid characters

Return values
self

depth()

Returns the depth of this path (0 for root, 1 for `/user`, etc.).

public depth() : int
Return values
int

fromString()

Parses an actor path from a string like `/user/orders`.

public static fromString(string $path) : self
Parameters
$path : string
Tags
throws
InvalidActorPathException

If the path is empty or does not start with /

Return values
self

isChildOf()

Returns true if this path is a direct child of the given parent (i.e., depth is exactly parent depth + 1 and shares the same prefix).

public isChildOf(ActorPathContract $parent) : bool
Parameters
$parent : ActorPathContract
Return values
bool

isDescendantOf()

Returns true if this path is a descendant (child, grandchild, etc.) of the given ancestor.

public isDescendantOf(ActorPathContract $ancestor) : bool
Parameters
$ancestor : ActorPathContract
Return values
bool

name()

Returns the last segment of the path (`'/'` for root).

public name() : string
Return values
string

root()

Creates the root path `/`.

public static root() : self

The instance is cached per thread (PHP ZTS gives each thread its own static storage), so repeated calls pay only a null-check.

Return values
self

        
On this page

Search results