Skip to content

Casper PHP SDK – Casper v2 RPC compatibility + PHP 8.4 deprecations #32

@KunBojiMan

Description

@KunBojiMan

What happened?
When using the SDK against a Casper v2.x node (e.g. CSPR.cloud testnet /rpc) and running the functional tests, several runtime errors occur because the SDK assumes v1 response shapes. Examples seen during vendor/bin/phpunit -c phpunit.xml:

  • Undefined array key for fields that are optional or renamed in v2 (last_added_block_info, available_block_ranges, public_key, kind, etc.).
  • Serializers fail on v2 payloads (TransformSerializer, DelegatorSerializer, InitiatorAddrSerializer).
  • RpcResponse::fromArray() receives null when the HTTP response isn’t valid JSON (e.g. node returns non‑JSON or error string), causing a TypeError.
  • PHP 8.4 deprecation warnings for implicitly nullable parameters (e.g. in RpcError, SpeculativeClient, SessionTarget, Secp256K1Key, DeployParams, DeployExecutable, etc.).

These issues cause tests to error out and break SDK usage with Casper 2.0 endpoints.

What did you expect to happen?

  • The SDK should handle Casper v2 response variations gracefully (missing/renamed keys) without fatal errors.
  • Serializers should accept the v2 payload formats (e.g. transform/value vs kind, delegator key variants).
  • Invalid or non‑JSON RPC responses should be reported as a clean error, not crash on null.
  • No PHP 8.4 deprecation warnings for implicit nullable parameters.

Are you willing to submit a pull request to fix this bug?
Yes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions