smartystreets / smartystreets-php-sdk

The official client libraries for accessing SmartyStreets APIs from the PHP Hypertext Processor.
https://smartystreets.com/docs/sdk/php
Apache License 2.0
28 stars 15 forks source link

Bug: Use of undefined constant STDERR #11

Closed 0b10011 closed 6 years ago

0b10011 commented 6 years ago

I've updated to the latest version and started receiving this notice:

Use of undefined constant STDERR - assumed 'STDERR'

  1. ~/smartystreets/phpsdk/src/NativeSender.php (line 52)

It was introduced with this commit.

However, STDERR is only available in CLI environments. Additionally, curl_setopt($ch, CURLINFO_HEADER_OUT, $value) expects $value to be boolean. It would have worked in CLI since the stream returned by STDERR would evaluate to true, but it fails in non-CLI environments.

Instead, defined("STDERR") seems to be what was intended. But it could also be skipped if $this->debugMode is not true. So, I would recommend:

if ($this->debugMode && defined("STDERR"))
        curl_setopt($ch, CURLINFO_HEADER_OUT, true);