Storage/src/StorageClient.php
public function buckets(array $options = [])
    {
        if (!$this->projectId) {
            throw new GoogleException(
                'No project ID was provided, ' .
                'and we were unable to detect a default project ID.'
            );
        }

        $resultLimit = $this->pluck('resultLimit', $options, false);
        $bucketUserProject = $this->pluck('bucketUserProject', $options, false);
        $bucketUserProject = !is_null($bucketUserProject)
            ? $bucketUserProject
            : true;
        $userProject = (isset($options['userProject']) && $bucketUserProject)
            ? $options['userProject']
            : null;

        return new ItemIterator(
            new PageIterator(
                function (array $bucket) use ($userProject) {
                    return new Bucket(
                        $this->connection,
                        $bucket['name'],
                        $bucket + ['requesterProjectId' => $userProject]
                    );
                },
                [$this->connection, 'listBuckets'],
                $options + ['project' => $this->projectId],
                ['resultLimit' => $resultLimit]
            )
        );
    }
public function buckets(array $options = [])
    {
        if (!$this->projectId) {
            throw new GoogleException(
                'No project ID was provided, ' .
                'and we were unable to detect a default project ID.'
            );
        }

        $resultLimit = $this->pluck('resultLimit', $options, false);
        $bucketUserProject = $this->pluck('bucketUserProject', $options, false);
        $bucketUserProject = !is_null($bucketUserProject)
            ? $bucketUserProject
            : true;
        $userProject = (isset($options['userProject']) && $bucketUserProject)
            ? $options['userProject']
            : null;

        return new ItemIterator(
            new PageIterator(
                function (array $bucket) use ($userProject) {
                    return new Bucket(
                        $this->connection,
                        $bucket['name'],
                        $bucket + ['requesterProjectId' => $userProject]
                    );
                },
                [$this->connection, 'listBuckets'],
                $options + ['project' => $this->projectId],
                ['resultLimit' => $resultLimit]
            )
        );
    }
public function buckets ( array $ options = [ ] ) { if ( ! $ this -> projectId ) { throw new GoogleException ( 'No project ID was provided, ' . 'and we were unable to detect a default project ID.' ) ; } $ resultLimit = $ this -> pluck ( 'resultLimit' , $ options , false ) ; $ bucketUserProject = $ this -> pluck ( 'bucketUserProject' , $ options , false ) ; $ bucketUserProject = ! is_null ( $ bucketUserProject ) ? $ bucketUserProject : true ; $ userProject = ( isset ( $ options [ 'userProject' ] ) && $ bucketUserProject ) ? $ options [ 'userProject' ] : null ; return new ItemIterator ( new PageIterator ( function ( array $ bucket ) use ( $ userProject ) { return new Bucket ( $ this -> connection , $ bucket [ 'name' ] , $ bucket + [ 'requesterProjectId' => $ userProject ] ) ; } , [ $ this -> connection , 'listBuckets' ] , $ options + [ 'project' => $ this -> projectId ] , [ 'resultLimit' => $ resultLimit ] ) ) ; }
Fetches all buckets in the project.

Example:
```
$buckets = $storage->buckets();
```

```
// Get all buckets beginning with the prefix 'album'.
$buckets = $storage->buckets([
'prefix' => 'album'
]);

foreach ($buckets as $bucket) {
echo $bucket->name() . PHP_EOL;
}
```

@see https://cloud.google.com/storage/docs/json_api/v1/buckets/list Buckets list API documentation.

@param array $options [optional] {
Configuration options.

@type int $maxResults Maximum number of results to return per
requested page.
@type int $resultLimit Limit the number of results returned in total.
**Defaults to** `0` (return all results).
@type string $pageToken A previously-returned page token used to
resume the loading of results from a specific point.
@type string $prefix Filter results with this prefix.
@type string $projection Determines which properties to return. May
be either 'full' or 'noAcl'.
@type string $fields Selector which will cause the response to only
return the specified fields.
@type string $userProject If set, this is the ID of the project which
will be billed for the request.
@type bool $bucketUserProject If true, each returned instance will
have `$userProject` set to the value of `$options.userProject`.
If false, `$options.userProject` will be used ONLY for the
listBuckets operation. If `$options.userProject` is not set,
this option has no effect. **Defaults to** `true`.
}
@return ItemIterator<Bucket>
@throws GoogleException When a project ID has not been detected.
Fetches all buckets in the project .