Skip to content

[BUG] Class method return types needed for >8.0 support #62

@sosherof

Description

@sosherof

In 8.1 and above, class methods based on an implemented class must have a return type. Without these, PHP will throw a return type mismatch warning or error.

The following code is from Models\BandwidthMessage class, how it is today:

class BandwidthMessage implements \JsonSerializable
{
    public function jsonSerialize()
    {
    $json = array();
    //some other code here
    return array_filter($json);
    }
}

vs. how it must be for PHP 8.1 and above:

class BandwidthMessage implements \JsonSerializable
{
    public function jsonSerialize(): array
    {
    $json = array();
    //some other code here
    return array_filter($json);
    }
}

There are multiple classes in the Bandwidth SDK that "implements" JsonSerializable. There may be other things that make the SDK not fully 8.1 and above compatible but this one stood out as I tested the Messaging SDK under PHP 8.2.5.

See https://www.php.net/manual/en/migration81.incompatible.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions