KnpLabs / KnpLastTweetsBundle

Symfony2 bundle to easily add a widget with the latest tweets of a Twitter user to a page.
http://knplabs.com/
MIT License
32 stars 15 forks source link

PHP5.4 - OAuthFetcher - Even if the data array is not empty, it will still return true for the empty function #16

Closed jamhall closed 12 years ago

jamhall commented 12 years ago

We have a valid response from the server and I checked that the array was not empty, however, when applying the function empty on the array, it always returns true.

       if (empty($data)) {
            throw new TwitterException('Received empty data from api.twitter.com');
        }

I've added:

        if ($data === false) {
            throw new TwitterException('Received empty data from api.twitter.com');
        }

By default, if an array is empty, it'll return false.

In the php documentation (http://fr2.php.net/empty)

It states:

5.4.0 Checking non-numeric offsets of strings returns TRUE.

5.0.0 Objects with no properties are no longer considered empty.

Perhaps this is the problem or it's a bug in php?

Let me know your thoughts.