jaggedsoft / php-binance-api

PHP Binance API is an asynchronous PHP library for the Binance API designed to be easy to use. https://github.com/binance-exchange/php-binance-api
MIT License
610 stars 496 forks source link

Fatal error: Default value for parameters with a class type hint can only be NULL #101

Closed michielkoers closed 6 years ago

michielkoers commented 6 years ago

Hello, I've been using this api wrapper for quite some time now, and it worked great. I've updated to the latest version using composer and now I get the following error:

Fatal error: Default value for parameters with a class type hint can only be NULL in /Applications/MAMP/htdocs/dagobot/vendor/jaggedsoft/php-binance-api/php-binance-api.php on line 60

Just to make sure I created a really simple script that just pulls in some data using $ticker = $api->prices(); but I still get the error.

Could you maybe try and fix this? Thanks a lot in advance! Michiel

dmzoneill commented 6 years ago

can you post the code you are using please? thanks

<?php
// code

if you look in sample get prices, it shows how to use prices() functions.

However your error on line 60 suggests something wrong with the way you are constructing the class.

jaggedsoft commented 6 years ago

This same thing happened to me when we switched the requirements to PHP 7 I'd recommend upgrading. The improvements dmzoneill has been making are worth it

Otherwise your only option is rolling back to version v0.1.8

Posting code shouldn't be needed. it errors on any code that requires php-binance-api.php if you don't have php 7. Maybe we can add a sanity check for PHP_VERSION instructing people to upgrade

composer.json is set to this:

{
    "require": {
        "php": ">=5.4"
}}
dmzoneill commented 6 years ago

i'm looking into it faily gracefully, i also added php 7.0, 7.1, 7.2, nightly to travis builds

unfortunately i just spent a chunk of time tryng to fix it for php 5.6 :( can only type hint abstract types in php , php hinting of primitives, int, float, bool ,, and string (char*) was added in 7

image

jaggedsoft commented 6 years ago

it's ok as long as we update the requirement in composer.json, the upgrade process to php 7 is very simple now. Painless

PHP 7 is capable of 112% more requests per second and can run up to 73% faster

michielkoers commented 6 years ago

Thanks for the comments and the work you've put in! I'm away for the weekend, but I assume the problem will be fixed after updating PHP. Shouldn't be a problem but I have to check with my webhost. I will try it when I get back. Thanks again!

michielkoers commented 6 years ago

Hey guys, I promised to report back after updating to PHP7. I just did, and the error disappeared and my scripts work again. Thanks again for all your hard work. You guys rule! Michiel

jaggedsoft commented 6 years ago

<3 Glad to hear it, thanks for the kind words! @dmzoneill has been doing great work 🥇 🏆