dropbox-php-sdk icon indicating copy to clipboard operation
dropbox-php-sdk copied to clipboard

dropbox listfolder is giving error

Open dileep-hegde opened this issue 7 years ago • 6 comments

$listFolderContents = $dropbox->listFolder("/"); is giving error as

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in/opt/lampp/htdocs/vendor/tightenco/collect/src/Illuminate/Support/Collection.php on line 155

dileep-hegde avatar Oct 11 '17 04:10 dileep-hegde

Please share more information, preferably the code block.

kunalvarma05 avatar Oct 11 '17 06:10 kunalvarma05

here is the code

<?php
require 'app/header.php';
use Kunnu\Dropbox\DropboxFile;
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;

$db = new PDO("mysql:host=localhost;dbname=...",'...','...');
$user = $db->prepare("SELECT * FROM users WHERE id = :user_id");
$user->execute(['user_id' => $_SESSION['user_id']]);
$user = $user->fetchObject();

$app = new DropboxApp("...", "...",$user->dropbox_token);

//Configure Dropbox service
$dropbox = new Dropbox($app);

$listFolderContents = $dropbox->listFolder("/");
//Fetch Items
$items = $listFolderContents->getItems();
 ?>

error is

Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in/opt/lampp/htdocs/vendor/tightenco/collect/src/Illuminate/Support/Collection.php on line 155

dileep-hegde avatar Oct 11 '17 08:10 dileep-hegde

I'm getting this too, PHP version 5.6.31

public function median($key = null)
{
    $count = $this->count();

    if ($count == 0) {
        return;
    }

    $values = (isset($key) ? $this->pluck($key) : $this)
                ->sort()->values();

    $middle = (int) ($count / 2);

    if ($count % 2) {
        return $values->get($middle);
    }

    return (new static([
        $values->get($middle - 1), $values->get($middle),
    ]))->average();
}

Line 155 is:

$values = (isset($key) ? $this->pluck($key) : $this) ->sort()->values();

gmadd avatar Oct 12 '17 18:10 gmadd

Replacing with:

$values = (isset($key) ? $this->pluck($key) : $this); $values = $values->sort()->values();

fixes the issue, but not ideal.

gmadd avatar Oct 12 '17 20:10 gmadd

The issue is with the PHP version you're using, that is PHP 5.6.31, and the Collection package. The last version of the Collection package, compatible with your PHP version, was v5.3.20 (Here's their composer.json file).

Thus, if you're using PHP's version >=5.5.9, you'll have to stick to the Collection package's version v5.3.20 or earlier.

The Collection package has been required whilst allowing patch changes to the version: "tightenco/collect": "^5.2". The collection package had a breaking change introduced in a patch version upgrade. They went from requiring PHP >=5.5.9 in v5.3.20 to requiring PHP >=5.6.4 in v5.3.23, thus breaking SemVer and apparently, the SDK.

What can be done now is that I can lock down to the v5.3.20. Which will make the Collection package and consequently the SDK compatible with PHP >=5.5.9 (in your case PHP 5.6.31).

However, I want to maintain the SDK for "PHP version 7.0 and up". And thus, would have to make a minor version upgrade (v0.3) for the same. Version v0.2.* would support PHP 5.5.9 till 5.6.40.

For PHP 5.5.9 and above, you'll have to use and stick to the SDK's v0.2 version range.

For PHP 7.0 and above, you'll have to use the SDK's v0.3 version range.

Does this make sense? I'm open to suggestions.

kunalvarma05 avatar Oct 14 '17 07:10 kunalvarma05

Where is version 0.3?

For PHP 7.0 and above, you'll have to use the SDK's v0.3 version range.

harpreetsb avatar Aug 18 '20 08:08 harpreetsb