team-telnyx / telnyx-php

PHP SDK for the Telnyx API
MIT License
33 stars 26 forks source link

array offset on value of type int in php 7.4 #37

Closed may-96 closed 4 years ago

may-96 commented 4 years ago

I am getting the following exception:

Trying to access array offset on value of type int "exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type int at ..\vendor\telnyx\telnyx-php\lib\Util\Util.php:45)

It is in the function where Telnyx object is converted into array:

foreach ($values as $k => $v) { 
// FIXME: this is an encapsulation violation 
    if ($k[0] == '_') {                       // Line 45 
        continue; `
    } 
... 

To fix this error Line 45 should be converted as:

if (strpos($k, '_') === 0) {

This is an issue in PHP version 7.4 when accessing an array by key.

weroh commented 4 years ago

Hey @may-96 thanks for the info on this bug and your suggestion. Please take a look at our new branch which should address this bug. Please let us know if this fixes your issues.

Note: If you are converting a TelnyxObject to an array by using __toArray(), please rename your call to toArray(). Example:

$call->__toArray() is now $call->toArray()

Link for this branch can be found here: https://github.com/team-telnyx/telnyx-php/tree/Bug37

weroh commented 4 years ago

@may-96 The new PR has been merged with master. Please update your archive and it should fix your issues. Have a great week!

may-96 commented 4 years ago

Ok, sure. Thanks