Skip to content

JSON encode'ing IncomingPhoneNumber loses capabilities #886

@stevebauman

Description

@stevebauman

The IncomingPhoneNumberInstance class extends the InstanceResource which has the toArray() method defined:

public function toArray(): array {
return $this->properties;
}

But the PhoneNumberCapabilities does not include a toArray() method:

https://github.com/twilio/twilio-php/blob/main/src/Twilio/Base/PhoneNumberCapabilities.php

This results in the JSON encoded instance missing capabilities:

Notice how "capabilities" are empty:

{
   "accountSid":"...",
   "addressSid":null,
   "addressRequirements":"none",
   "apiVersion":"2010-04-01",
   "beta":false,
   "capabilities":{
      
   },
   "dateCreated":{
      "date":"2021-10-22 08:17:04.000000",
      "timezone_type":1,
      "timezone":"+00:00"
   },
   "dateUpdated":{
      "date":"2025-07-11 00:27:35.000000",
      "timezone_type":1,
      "timezone":"+00:00"
   },
   "friendlyName":"...",
   "identitySid":null,
   "phoneNumber":"...",
   "origin":"twilio",
   "sid":"...",
   "smsApplicationSid":"",
   "smsFallbackMethod":"POST",
   "smsFallbackUrl":"",
   "smsMethod":"POST",
   "smsUrl":"https:\/\/....com\/telephony\/messages\/twilio",
   "statusCallback":"",
   "statusCallbackMethod":"POST",
   "trunkSid":null,
   "uri":"\/2010-04-01\/Accounts\/...\/IncomingPhoneNumbers\/....json",
   "voiceReceiveMode":"voice",
   "voiceApplicationSid":"",
   "voiceCallerIdLookup":false,
   "voiceFallbackMethod":"POST",
   "voiceFallbackUrl":"",
   "voiceMethod":"POST",
   "voiceUrl":"http:\/\/realtime-websocket-dev.us-east-1.elasticbeanstalk.com:8081\/twiml",
   "emergencyStatus":"Active",
   "emergencyAddressSid":null,
   "emergencyAddressStatus":"unregistered",
   "bundleSid":null,
   "status":"in-use"
}

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