arendjantetteroo / guzzle-toggl

A Toggl API client based on guzzle
MIT License
88 stars 42 forks source link

fixed PHP fatal error of return context #19

Closed zainengineer closed 7 years ago

zainengineer commented 8 years ago

because of empty check against function PHP throws FATAL as soon as it includes the file error message is Can’t use method return value in write context

arendjantetteroo commented 8 years ago

@zainengineer on which php version are you running? This sounds like PHP7?

zainengineer commented 8 years ago

@arendjantetteroo I am running 5.4.16 It is because empty is used for both isset and condition check. And newer PHP versions don't allow isset or empty check against a function.

arendjantetteroo commented 8 years ago

@carcus88 can you check if these changes work for you? I'm not using this code at the moment and don't want to break things for others, and as you just added a PR a few days ago I thought i'd ask you for confirmation.

carcus88 commented 8 years ago

I think the code is fine the way it is as long as the package is marked as PHP 5.5+ required. The problem is that PHP <= 5.4 do not allow function calls inside of empty. (Opposite of what you are asserting @zainengineer )

(http://www.php.net/empty

"5.5.0 empty() now supports expressions, rather than only variables."

arendjantetteroo commented 8 years ago

Thanks @carcus88. As i've not seen this error myself, i found it weird, but things change between PHP versions so it makes sense. I'll tag it as php 5.5+ required in composer.json next time.

@zainengineer if you can upgrade your PHP version i would advise that, Php 5.4 is EOL for almost a year now, so i won't be merging this. You can off course use your own branch until you can upgrade.

carcus88 commented 8 years ago

@zainengineer I actually found myself in the same situation when I deployed today and realized that I was testing on php5.6 but production is still behind on php5.4.

I created a release in my fork that supports php5.4 if you want to use that

https://github.com/carcus88/guzzle-toggl/releases/tag/v0.12

To use it just drop this in your composer.json

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/carcus88/guzzle-toggl"
    }
],
"require" : {
    "ajt/guzzle-toggl": "^0.12.0"
}
arendjantetteroo commented 7 years ago

Closing, feel free to use carcus88 solution.