Skip to content

v2.0.0

Choose a tag to compare

@GianfriAur GianfriAur released this 20 Mar 11:01
· 125 commits to master since this release

Added

  • Client::setTimeout(float $timeout) method to configure the timeout (in seconds) for TCP connection and all socket I/O operations. Default remains 5 seconds. The method is fluent and also available on OpcUaClientInterface.
  • The configured timeout is now passed to TcpTransport::connect() both for the main connection and for the server certificate discovery connection.
  • ConnectionState enum (Disconnected, Connected, Broken) to track the client's connection lifecycle.
  • Client::isConnected() method returning true only when the state is Connected.
  • Client::getConnectionState() method returning the current ConnectionState.
  • Client::reconnect() method to re-establish the connection using the last endpoint URL. Performs a full cleanup + connect cycle. Throws ConfigurationException if connect() was never called.
  • Client::setAutoRetry(int $maxRetries) and Client::getAutoRetry() methods for configurable automatic reconnect+retry on ConnectionException during operations. Default: 0 if never connected, 1 if connected at least once.
  • All operations (read, write, browse, call, subscriptions, history, getEndpoints) are wrapped with the auto-retry mechanism.
  • ensureConnected() private method with state-aware exception messages: "Not connected: call connect() first" (Disconnected) and "Connection lost: call reconnect() or connect() to re-establish" (Broken).
  • Client::setBatchSize(int $batchSize) and Client::getBatchSize(): ?int methods for configurable automatic batching of readMulti/writeMulti. When the number of items exceeds the batch size, requests are transparently split and results merged. setBatchSize(0) disables batching entirely and skips server operation limits discovery on connect().
  • Automatic discovery of server operation limits (MaxNodesPerRead, MaxNodesPerWrite) after connect(). The limits are read from the standard OPC UA nodes (ns=0, i=11705 and i=11707). A server-reported value > 0 is used as the default batch size when setBatchSize() is not explicitly called.
  • Client::getServerMaxNodesPerRead(): ?int and Client::getServerMaxNodesPerWrite(): ?int methods to inspect the discovered server limits.
  • BrowseNode type for representing recursive br owse tree nodes, wrapping ReferenceDescription with children.
  • Client::browseAll() method that browses a node and automatically follows all continuation points, returning the complete list of references.
  • Client::browseRecursive(NodeId, direction, maxDepth, ...) method for recursive address space traversal. Builds a tree of BrowseNode objects. Default maxDepth is configurable (default: 10), use -1 for unlimited (hardcoded cap at 256). Includes cycle detection via visited NodeId tracking to prevent infinite loops on circular references.
  • Client::setDefaultBrowseMaxDepth(int) and Client::getDefaultBrowseMaxDepth(): int methods to configure the default maxDepth for browseRecursive(). Default: 10. Passing maxDepth explicitly to browseRecursive() overrides the configured default.
  • BrowseDirection enum (Forward, Inverse, Both) replacing the raw int $direction parameter in all browse methods (browse, browseWithContinuation, browseAll, browseRecursive, getBinaryDecoder). Default is BrowseDirection::Forward.
  • TranslateBrowsePathService protocol service implementing the OPC UA TranslateBrowsePathsToNodeIds service (request NodeId 554).
  • Client::translateBrowsePaths(array $browsePaths) method for translating browse paths to NodeIds. Supports multiple paths in a single request with full control over reference types and direction.
  • Client::resolveNodeId(string $path, ?NodeId $startingNodeId) helper method for resolving human-readable paths like "/Objects/Server/ServerStatus" to NodeIds. Supports namespaced segments ("2:Temperature") and custom starting nodes.
  • ExtensionObjectCodec interface for implementing custom ExtensionObject decoders/encoders with decode(BinaryDecoder) and encode(BinaryEncoder, mixed) methods.
  • ExtensionObjectRepository static registry for registering codecs by type NodeId. Supports registration by class name or instance, unregister, has, get, and clear. When a codec is registered, BinaryDecoder::readExtensionObject() automatically uses it instead of returning a raw binary blob.
  • All new methods are also available on OpcUaClientInterface.

Tests

  • Unit tests for ExtensionObjectRepository: default empty, register by class/instance, unregister, clear, independent typeIds, string NodeIds.
  • Unit tests for ExtensionObject decoding: codec-based decoding, raw fallback without codec, XML encoding fallback, no-body encoding, codec round-trip.
  • Unit tests for setTimeout() and getTimeout() covering: default value, setter/getter, fluent chaining, fractional seconds, multiple updates, and OpcUaClientInterface compliance.
  • Unit tests for ConnectionState: enum cases, initial state, disconnect on never-connected client, state-specific exception messages, reconnect() without prior connect, and setAutoRetry configuration.
  • Unit tests for auto-retry: default value, fluent chaining, override, disable, multiple updates, chaining with setTimeout, interface compliance, and no retry when not connected.
  • Integration tests for timeout behavior: custom timeout with operations, short but sufficient timeout, connection failure with very short timeout on unreachable host, and timeout persistence across multiple operations.
  • Integration tests for connection state transitions: Connected after connect, Disconnected after disconnect, Broken on failed connect, state-specific messages, reconnect recovery, and operations after reconnect.
  • Integration tests for auto-retry: default values after connect/disconnect/failed connect, override persistence, operations with retry enabled/disabled, state after retry, and no retry after explicit disconnect.
  • Unit tests for batching: default null, fluent chaining, store, disable, update, chaining with other config methods, interface compliance, and server limits null before connect.
  • Integration tests for batching: readMulti/writeMulti with and without batching, batch splitting, batchSize=1, result order preservation, server limits discovery, limits reset after disconnect, and setBatchSize override.
  • Unit tests for BrowseNode: wrapping ReferenceDescription, children management, and nested tree structure.
  • Integration tests for browseAll and browseRecursive: all references, comparison with browse, tree structure, maxDepth 1/2/3, subtree browsing, default maxDepth, configurable default, explicit override, unlimited depth, cycle detection with BrowseDirection::Both.
  • Unit tests for setDefaultBrowseMaxDepth and getDefaultBrowseMaxDepth: default value, fluent chaining, store, unlimited, multiple updates, chaining with other config, and interface compliance.
  • Unit tests for BrowseDirection enum: cases, values, from(), and tryFrom().
  • Integration test for BrowseDirection::Both verifying both forward and inverse references are returned.
  • Integration tests for translateBrowsePaths: single path, multi-segment path, multiple paths, non-existent path.
  • Integration tests for resolveNodeId: simple path, without leading slash, deep path, custom starting node, resolve-then-read, non-existent path exception.

Documentation

  • Added "Connection State", "Reconnect", and "Auto-Retry" sections to doc/02-connection.md with usage examples and behavior details.
  • Added "Timeout Configuration" section to doc/02-connection.md with usage examples and tips.
  • Added "Configurable Timeout", "Connection State Management", and "Auto-Retry" to the features list in doc/01-introduction.md and README.md.
  • Added ConnectionState enum to doc/08-types.md types reference.
  • Updated doc/09-error-handling.md with state-aware ConnectionException messages, ConfigurationException for reconnect, and recommended error handling pattern with ConnectionState check and auto-retry tip.
  • Added ConnectionState.php to the project structure in doc/11-architecture.md.
  • Updated disconnection section in doc/02-connection.md to document state reset and auto-retry behavior.
  • Updated "Full Secure Connection" examples in doc/02-connection.md and README.md to show setTimeout().
  • Added "Automatic Batching" section to doc/04-reading-writing.md with server limits discovery, transparent batching, manual batch size, and behavior table.
  • Added "Auto-Batching" to the features list in doc/01-introduction.md and README.md.
  • Updated connect() step list in doc/02-connection.md to include server operation limits discovery.
  • Added "Browse All", "Recursive Browse", and BrowseNode documentation to doc/03-browsing.md with configurable default depth, parameter order (direction before maxDepth), depth limits table, disclaimer for high values, cycle detection explanation, configuration methods table, and BrowseDirection enum usage.
  • Added BrowseDirection enum to doc/08-types.md.
  • Added BrowseNode type to doc/08-types.md.
  • Added BrowseNode.php to the project structure in doc/11-architecture.md.
  • Updated browse feature description in doc/01-introduction.md and README.md to include recursive browsing and automatic continuation.
  • Added "Path Resolution" section to doc/03-browsing.md with resolveNodeId() and translateBrowsePaths() documentation, path format, namespaced segments, and advanced usage.
  • Added "Path Resolution" to the features list in doc/01-introduction.md and README.md.
  • Added TranslateBrowsePathService.php to the project structure in doc/11-architecture.md.
  • Added "ExtensionObject Codecs" section to doc/08-types.md with interface, registry API, usage example, and notes.
  • Added "ExtensionObject Codecs" to the features list in doc/01-introduction.md and README.md.
  • Added ExtensionObjectCodec.php and ExtensionObjectRepository.php to the project structure in doc/11-architecture.md.
  • Updated README.md disclaimer to recommend gianfriaur/opcua-php-client-session-manager for session persistence across PHP requests.