Vonage / vonage-laravel

Laravel Service Provider for integrating Vonage APIs
Apache License 2.0
34 stars 8 forks source link

Return type error in Vonage\\Laravel\\VonageServiceProvider->vonageConfigHas() - autoclosed #10

Closed ribicb closed 1 year ago

ribicb commented 1 year ago

I am seeing this error in logs:

[2023-02-24 14:36:39] local.ERROR: Vonage\Laravel\VonageServiceProvider::vonageConfigHas(): Return value must be of type bool, null returned

Function VonageServiceProvider::vonageConfigHas() is marked as returning bool but returns whatever is in $config array:

protected function vonageConfigHas($key): bool
{
    if (!array_key_exists($key, $this->config)) {
        return false;
    }

    return ($this->config[$key]);
}

I assume fix would be to use

return isset($this->config[$key]);

instead of just

return ($this->config[$key]);

At last line

SecondeJK commented 1 year ago

I'll have a look at this - I don't think it'll be fixed by isset from the feel of this because it indicates there's a configuration error where it's expecting to get the right API key/secret handlers/objects

ribicb commented 1 year ago

This happened during testing, so there was no configuration section for vonage and it was tryig to return null which triggered the error.

The function return type is bool, so either the return type is wrong or it should be isset() or ! empty()

And thanx for looking into this quickly

mend-for-github-com[bot] commented 1 year ago

:heavy_check_mark: This issue was automatically closed by Mend because the errors have been resolved.