mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-01 12:39:49 +09:00
Update composer dependencies
This commit is contained in:
22
vendor/knplabs/github-api/CHANGELOG.md
vendored
22
vendor/knplabs/github-api/CHANGELOG.md
vendored
@@ -2,6 +2,28 @@
|
||||
|
||||
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
|
||||
|
||||
## 2.11.0
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Miscellaneous Licenses (#744)
|
||||
- Structured Limit objects for rate limiting API (#733)
|
||||
- Support for getting star creation timestamps in activity/starring endpoint (#729)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added missing has_projects parameter to repo create (#752)
|
||||
- Proper type hinting for magic methods (#758)
|
||||
- Allow symlink to files to be downloaded (#751)
|
||||
|
||||
### Changed
|
||||
|
||||
- Fix of PHP version in readme (#747)
|
||||
- Fix documentation to get release for a tag (#755)
|
||||
- Declare all used properties in RateLimitResource class (#762)
|
||||
- Set correct property and return types (#764)
|
||||
- Fixed install docs broken after 2.0 release of httplug lib (#767)
|
||||
|
||||
## 2.10.1
|
||||
|
||||
### Fixed
|
||||
|
||||
4
vendor/knplabs/github-api/README.md
vendored
4
vendor/knplabs/github-api/README.md
vendored
@@ -8,7 +8,7 @@
|
||||
[](https://packagist.org/packages/knplabs/github-api)
|
||||
[](https://packagist.org/packages/knplabs/github-api)
|
||||
|
||||
A simple Object Oriented wrapper for GitHub API, written with PHP5.
|
||||
A simple Object Oriented wrapper for GitHub API, written with PHP.
|
||||
|
||||
Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4](http://developer.github.com/v4). The object API (v3) is very similar to the RESTful API.
|
||||
|
||||
@@ -29,7 +29,7 @@ Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4]
|
||||
Via Composer:
|
||||
|
||||
```bash
|
||||
$ composer require knplabs/github-api php-http/guzzle6-adapter
|
||||
$ composer require knplabs/github-api php-http/guzzle6-adapter "^1.1"
|
||||
```
|
||||
|
||||
Why `php-http/guzzle6-adapter`? We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io/). Read about clients in our [docs](doc/customize.md).
|
||||
|
||||
2
vendor/knplabs/github-api/composer.json
vendored
2
vendor/knplabs/github-api/composer.json
vendored
@@ -43,7 +43,7 @@
|
||||
"prefer-stable": true,
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.10.x-dev"
|
||||
"dev-master": "2.11.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ abstract class AbstractApi implements ApiInterface
|
||||
if (null !== $this->perPage && !isset($parameters['per_page'])) {
|
||||
$parameters['per_page'] = $this->perPage;
|
||||
}
|
||||
if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
|
||||
if (array_key_exists('ref', $parameters) && null === $parameters['ref']) {
|
||||
unset($parameters['ref']);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ abstract class AbstractApi implements ApiInterface
|
||||
*/
|
||||
protected function head($path, array $parameters = [], array $requestHeaders = [])
|
||||
{
|
||||
if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
|
||||
if (array_key_exists('ref', $parameters) && null === $parameters['ref']) {
|
||||
unset($parameters['ref']);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Github\Api;
|
||||
*/
|
||||
trait AcceptHeaderTrait
|
||||
{
|
||||
protected $acceptHeaderValue = null;
|
||||
protected $acceptHeaderValue;
|
||||
|
||||
protected function get($path, array $parameters = [], array $requestHeaders = [])
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Show a single authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param string $clientId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -51,8 +51,8 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Update an authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param array $params
|
||||
* @param string $clientId
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Remove an authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param string $clientId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -76,8 +76,8 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Check an authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param $token
|
||||
* @param string $clientId
|
||||
* @param string $token
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -89,8 +89,8 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Reset an authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param $token
|
||||
* @param string $clientId
|
||||
* @param string $token
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -102,8 +102,8 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Remove an authorization.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param $token
|
||||
* @param string $clientId
|
||||
* @param string $token
|
||||
*/
|
||||
public function revoke($clientId, $token)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ class Authorizations extends AbstractApi
|
||||
/**
|
||||
* Revoke all authorizations.
|
||||
*
|
||||
* @param $clientId
|
||||
* @param string $clientId
|
||||
*/
|
||||
public function revokeAll($clientId)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ class Emails extends AbstractApi
|
||||
if (is_string($emails)) {
|
||||
$emails = [$emails];
|
||||
} elseif (0 === count($emails)) {
|
||||
throw new InvalidArgumentException();
|
||||
throw new InvalidArgumentException('The user emails parameter should be a single email or an array of emails');
|
||||
}
|
||||
|
||||
return $this->post('/user/emails', $emails);
|
||||
@@ -74,7 +74,7 @@ class Emails extends AbstractApi
|
||||
if (is_string($emails)) {
|
||||
$emails = [$emails];
|
||||
} elseif (0 === count($emails)) {
|
||||
throw new InvalidArgumentException();
|
||||
throw new InvalidArgumentException('The user emails parameter should be a single email or an array of emails');
|
||||
}
|
||||
|
||||
return $this->delete('/user/emails', $emails);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Github\Api\CurrentUser;
|
||||
|
||||
use Github\Api\AbstractApi;
|
||||
use Github\Api\AcceptHeaderTrait;
|
||||
|
||||
/**
|
||||
* @link https://developer.github.com/v3/activity/starring/
|
||||
@@ -11,6 +12,26 @@ use Github\Api\AbstractApi;
|
||||
*/
|
||||
class Starring extends AbstractApi
|
||||
{
|
||||
use AcceptHeaderTrait;
|
||||
|
||||
/**
|
||||
* Configure the body type.
|
||||
*
|
||||
* @see https://developer.github.com/v3/activity/starring/#list-stargazers
|
||||
*
|
||||
* @param string $bodyType
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function configure($bodyType = null)
|
||||
{
|
||||
if ('star' === $bodyType) {
|
||||
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->client->getApiVersion());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List repositories starred by the authenticated user.
|
||||
*
|
||||
|
||||
@@ -28,7 +28,7 @@ class Gists extends AbstractApi
|
||||
*/
|
||||
public function configure($bodyType = null)
|
||||
{
|
||||
if (!in_array($bodyType, ['base64'])) {
|
||||
if ('base64' !== $bodyType) {
|
||||
$bodyType = 'raw';
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ class Events extends AbstractApi
|
||||
*
|
||||
* @link https://developer.github.com/v3/issues/events/#get-a-single-event
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $event
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $event
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -120,10 +120,10 @@ class Labels extends AbstractApi
|
||||
*
|
||||
* @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param int $issue
|
||||
* @param string $labels
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param int $issue
|
||||
* @param string|array $labels
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
@@ -134,7 +134,7 @@ class Labels extends AbstractApi
|
||||
if (is_string($labels)) {
|
||||
$labels = [$labels];
|
||||
} elseif (0 === count($labels)) {
|
||||
throw new InvalidArgumentException();
|
||||
throw new InvalidArgumentException('The labels parameter should be a single label or an array of labels');
|
||||
}
|
||||
|
||||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/labels', $labels);
|
||||
@@ -167,7 +167,7 @@ class Labels extends AbstractApi
|
||||
* @param string $issue
|
||||
* @param string $label
|
||||
*
|
||||
* @return null
|
||||
* @return array|string
|
||||
*/
|
||||
public function remove($username, $repository, $issue, $label)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ class Labels extends AbstractApi
|
||||
* @param string $repository
|
||||
* @param string $issue
|
||||
*
|
||||
* @return null
|
||||
* @return array|string
|
||||
*/
|
||||
public function clear($username, $repository, $issue)
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ class Milestones extends AbstractApi
|
||||
* @param string $repository
|
||||
* @param int $id
|
||||
*
|
||||
* @return null
|
||||
* @return array|string
|
||||
*/
|
||||
public function remove($username, $repository, $id)
|
||||
{
|
||||
|
||||
34
vendor/knplabs/github-api/lib/Github/Api/Miscellaneous/Licenses.php
vendored
Normal file
34
vendor/knplabs/github-api/lib/Github/Api/Miscellaneous/Licenses.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Github\Api\Miscellaneous;
|
||||
|
||||
use Github\Api\AbstractApi;
|
||||
|
||||
class Licenses extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Lists all the licenses available on GitHub.
|
||||
*
|
||||
* @link https://developer.github.com/v3/licenses/
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->get('/licenses');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an individual license by its license key.
|
||||
*
|
||||
* @link https://developer.github.com/v3/licenses/#get-an-individual-license
|
||||
*
|
||||
* @param string $license
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function show($license)
|
||||
{
|
||||
return $this->get('/licenses/'.rawurlencode($license));
|
||||
}
|
||||
}
|
||||
@@ -91,9 +91,9 @@ class Organization extends AbstractApi
|
||||
/**
|
||||
* @link http://developer.github.com/v3/issues/#list-issues
|
||||
*
|
||||
* @param $organization
|
||||
* @param array $params
|
||||
* @param int $page
|
||||
* @param string $organization
|
||||
* @param array $params
|
||||
* @param int $page
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -87,7 +87,7 @@ class Hooks extends AbstractApi
|
||||
* @param string $organization
|
||||
* @param int $id
|
||||
*
|
||||
* @return null
|
||||
* @return array|string
|
||||
*/
|
||||
public function ping($organization, $id)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ class Hooks extends AbstractApi
|
||||
* @param string $organization
|
||||
* @param int $id
|
||||
*
|
||||
* @return null
|
||||
* @return array|string
|
||||
*/
|
||||
public function remove($organization, $id)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ class PullRequest extends AbstractApi
|
||||
*/
|
||||
public function configure($bodyType = null, $apiVersion = null)
|
||||
{
|
||||
if (!in_array($apiVersion, [])) {
|
||||
if (null === $apiVersion) {
|
||||
$apiVersion = $this->client->getApiVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ class Comments extends AbstractApi
|
||||
* @link https://developer.github.com/v3/pulls/comments/#custom-media-types
|
||||
*
|
||||
* @param string|null $bodyType
|
||||
* @param string|null @apiVersion
|
||||
* @param string|null $apiVersion
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function configure($bodyType = null, $apiVersion = null)
|
||||
{
|
||||
if (!in_array($apiVersion, ['squirrel-girl-preview'])) {
|
||||
if ($apiVersion !== 'squirrel-girl-preview') {
|
||||
$apiVersion = $this->client->getApiVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Github\Api;
|
||||
|
||||
use Github\Api\RateLimit\RateLimitResource;
|
||||
|
||||
/**
|
||||
* Get rate limits.
|
||||
*
|
||||
@@ -12,36 +14,93 @@ namespace Github\Api;
|
||||
class RateLimit extends AbstractApi
|
||||
{
|
||||
/**
|
||||
* Get rate limits.
|
||||
* @var RateLimitResource[]
|
||||
*/
|
||||
protected $resources = [];
|
||||
|
||||
/**
|
||||
* Get rate limits data in an array.
|
||||
*
|
||||
* @deprecated since 2.11.0 Use `->getResources()` instead
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRateLimits()
|
||||
{
|
||||
return $this->get('/rate_limit');
|
||||
return $this->fetchLimits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rate limit resource objects.
|
||||
*
|
||||
* @return RateLimitResource[]
|
||||
*/
|
||||
public function getResources()
|
||||
{
|
||||
$this->fetchLimits();
|
||||
|
||||
return $this->resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rate limit resource object by the given name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return RateLimitResource|false
|
||||
*/
|
||||
public function getResource($name)
|
||||
{
|
||||
// Fetch once per instance
|
||||
if (empty($this->resources)) {
|
||||
$this->fetchLimits();
|
||||
}
|
||||
|
||||
if (!isset($this->resources[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->resources[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data directly from the GitHub API endpoint.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchLimits()
|
||||
{
|
||||
$result = $this->get('/rate_limit') ?: [];
|
||||
|
||||
// Assemble Limit instances
|
||||
foreach ($result['resources'] as $resourceName => $resource) {
|
||||
$this->resources[$resourceName] = new RateLimitResource($resourceName, $resource);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get core rate limit.
|
||||
*
|
||||
* @deprecated since 2.11.0 Use `->getResource('core')->getLimit()` instead
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCoreLimit()
|
||||
{
|
||||
$response = $this->getRateLimits();
|
||||
|
||||
return $response['resources']['core']['limit'];
|
||||
return $this->getResource('core')->getLimit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get search rate limit.
|
||||
*
|
||||
* @deprecated since 2.11.0 Use `->getResource('core')->getLimit()` instead
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSearchLimit()
|
||||
{
|
||||
$response = $this->getRateLimits();
|
||||
|
||||
return $response['resources']['search']['limit'];
|
||||
return $this->getResource('search')->getLimit();
|
||||
}
|
||||
}
|
||||
|
||||
73
vendor/knplabs/github-api/lib/Github/Api/RateLimit/RateLimitResource.php
vendored
Normal file
73
vendor/knplabs/github-api/lib/Github/Api/RateLimit/RateLimitResource.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Github\Api\RateLimit;
|
||||
|
||||
/**
|
||||
* Represents the data block for a GitHub rate limit response, grouped by a name.
|
||||
*/
|
||||
class RateLimitResource
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var int */
|
||||
private $limit;
|
||||
|
||||
/** @var int */
|
||||
private $reset;
|
||||
|
||||
/** @var int */
|
||||
private $remaining;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct($name, array $data)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->limit = $data['limit'];
|
||||
$this->remaining = $data['remaining'];
|
||||
$this->reset = $data['reset'];
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the Limit, e.g. "core", "graphql", "search".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rate limit amount.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLimit()
|
||||
{
|
||||
return $this->limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of requests remaining in time period before hitting the rate limit.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRemaining()
|
||||
{
|
||||
return $this->remaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp for when the rate limit will be reset.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getReset()
|
||||
{
|
||||
return $this->reset;
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,7 @@ class Repo extends AbstractApi
|
||||
* @param bool $hasDownloads `true` to enable downloads for this repository, `false` to disable them
|
||||
* @param int $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
|
||||
* @param bool $autoInit `true` to create an initial commit with empty README, `false` for no initial commit
|
||||
* @param bool $hasProjects `true` to enable projects for this repository or false to disable them.
|
||||
*
|
||||
* @return array returns repository data
|
||||
*/
|
||||
@@ -200,7 +201,8 @@ class Repo extends AbstractApi
|
||||
$hasWiki = false,
|
||||
$hasDownloads = false,
|
||||
$teamId = null,
|
||||
$autoInit = false
|
||||
$autoInit = false,
|
||||
$hasProjects = true
|
||||
) {
|
||||
$path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos';
|
||||
|
||||
@@ -213,6 +215,7 @@ class Repo extends AbstractApi
|
||||
'has_wiki' => $hasWiki,
|
||||
'has_downloads' => $hasDownloads,
|
||||
'auto_init' => $autoInit,
|
||||
'has_projects' => $hasProjects,
|
||||
];
|
||||
|
||||
if ($organization && $teamId) {
|
||||
|
||||
@@ -14,9 +14,9 @@ class Collaborators extends AbstractApi
|
||||
/**
|
||||
* @link https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param array $params
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param array $params
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
@@ -28,9 +28,9 @@ class Collaborators extends AbstractApi
|
||||
/**
|
||||
* @link https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $collaborator
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $collaborator
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
@@ -42,10 +42,10 @@ class Collaborators extends AbstractApi
|
||||
/**
|
||||
* @link https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $collaborator
|
||||
* @param array $params
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $collaborator
|
||||
* @param array $params
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
@@ -57,9 +57,9 @@ class Collaborators extends AbstractApi
|
||||
/**
|
||||
* @link https://developer.github.com/v3/repos/collaborators/#remove-user-as-a-collaborator
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $collaborator
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $collaborator
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
@@ -71,9 +71,9 @@ class Collaborators extends AbstractApi
|
||||
/**
|
||||
* @link https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $collaborator
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $collaborator
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
|
||||
@@ -143,7 +143,7 @@ class Contents extends AbstractApi
|
||||
'ref' => $reference,
|
||||
]);
|
||||
|
||||
if ($response->getStatusCode() != 200) {
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
return false;
|
||||
}
|
||||
} catch (TwoFactorAuthenticationRequiredException $ex) {
|
||||
@@ -276,8 +276,8 @@ class Contents extends AbstractApi
|
||||
{
|
||||
$file = $this->show($username, $repository, $path, $reference);
|
||||
|
||||
if (!isset($file['type']) || 'file' !== $file['type']) {
|
||||
throw new InvalidArgumentException(sprintf('Path "%s" is not a file.', $path));
|
||||
if (!isset($file['type']) || !in_array($file['type'], ['file', 'symlink'], true)) {
|
||||
throw new InvalidArgumentException(sprintf('Path "%s" is not a file or a symlink to a file.', $path));
|
||||
}
|
||||
|
||||
if (!isset($file['content'])) {
|
||||
|
||||
@@ -16,8 +16,8 @@ class Releases extends AbstractApi
|
||||
/**
|
||||
* Get the latest release.
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -29,9 +29,9 @@ class Releases extends AbstractApi
|
||||
/**
|
||||
* List releases for a tag.
|
||||
*
|
||||
* @param $username
|
||||
* @param $repository
|
||||
* @param $tag
|
||||
* @param string $username
|
||||
* @param string $repository
|
||||
* @param string $tag
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
13
vendor/knplabs/github-api/lib/Github/Client.php
vendored
13
vendor/knplabs/github-api/lib/Github/Client.php
vendored
@@ -25,6 +25,7 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
* @method Api\Enterprise enterprise()
|
||||
* @method Api\Miscellaneous\CodeOfConduct codeOfConduct()
|
||||
* @method Api\Miscellaneous\Emojis emojis()
|
||||
* @method Api\Miscellaneous\Licenses licenses()
|
||||
* @method Api\GitData git()
|
||||
* @method Api\GitData gitData()
|
||||
* @method Api\Gists gist()
|
||||
@@ -53,8 +54,8 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
* @method Api\Repo repository()
|
||||
* @method Api\Repo repositories()
|
||||
* @method Api\Search search()
|
||||
* @method Api\Organization team()
|
||||
* @method Api\Organization teams()
|
||||
* @method Api\Organization\Teams team()
|
||||
* @method Api\Organization\Teams teams()
|
||||
* @method Api\User user()
|
||||
* @method Api\User users()
|
||||
* @method Api\Authorizations authorization()
|
||||
@@ -221,6 +222,10 @@ class Client
|
||||
$api = new Api\Markdown($this);
|
||||
break;
|
||||
|
||||
case 'licenses':
|
||||
$api = new Api\Miscellaneous\Licenses($this);
|
||||
break;
|
||||
|
||||
case 'notification':
|
||||
case 'notifications':
|
||||
$api = new Api\Notification($this);
|
||||
@@ -317,7 +322,7 @@ class Client
|
||||
throw new InvalidArgumentException('You need to specify authentication method!');
|
||||
}
|
||||
|
||||
if (null === $authMethod && in_array($password, [self::AUTH_URL_TOKEN, self::AUTH_URL_CLIENT_ID, self::AUTH_HTTP_PASSWORD, self::AUTH_HTTP_TOKEN, self::AUTH_JWT])) {
|
||||
if (null === $authMethod && in_array($password, [self::AUTH_URL_TOKEN, self::AUTH_URL_CLIENT_ID, self::AUTH_HTTP_PASSWORD, self::AUTH_HTTP_TOKEN, self::AUTH_JWT], true)) {
|
||||
$authMethod = $password;
|
||||
$password = null;
|
||||
}
|
||||
@@ -356,7 +361,7 @@ class Client
|
||||
/**
|
||||
* Add a cache plugin to cache responses locally.
|
||||
*
|
||||
* @param CacheItemPoolInterface $cache
|
||||
* @param CacheItemPoolInterface $cachePool
|
||||
* @param array $config
|
||||
*/
|
||||
public function addCache(CacheItemPoolInterface $cachePool, array $config = [])
|
||||
|
||||
@@ -10,7 +10,6 @@ use Http\Client\HttpClient;
|
||||
use Http\Discovery\HttpClientDiscovery;
|
||||
use Http\Discovery\MessageFactoryDiscovery;
|
||||
use Http\Discovery\StreamFactoryDiscovery;
|
||||
use Http\Message\MessageFactory;
|
||||
use Http\Message\RequestFactory;
|
||||
use Http\Message\StreamFactory;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
@@ -38,7 +37,7 @@ class Builder
|
||||
private $pluginClient;
|
||||
|
||||
/**
|
||||
* @var MessageFactory
|
||||
* @var RequestFactory
|
||||
*/
|
||||
private $requestFactory;
|
||||
|
||||
@@ -62,7 +61,7 @@ class Builder
|
||||
/**
|
||||
* This plugin is special treated because it has to be the very last plugin.
|
||||
*
|
||||
* @var Plugin\CachePlugin
|
||||
* @var Plugin\CachePlugin|null
|
||||
*/
|
||||
private $cachePlugin;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ResponseMediator
|
||||
/**
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return array|null
|
||||
* @return array|void
|
||||
*/
|
||||
public static function getPagination(ResponseInterface $response)
|
||||
{
|
||||
|
||||
@@ -30,26 +30,26 @@ class GithubExceptionThrower implements Plugin
|
||||
|
||||
// If error:
|
||||
$remaining = ResponseMediator::getHeader($response, 'X-RateLimit-Remaining');
|
||||
if (null != $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) {
|
||||
if (null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) {
|
||||
$limit = ResponseMediator::getHeader($response, 'X-RateLimit-Limit');
|
||||
$reset = ResponseMediator::getHeader($response, 'X-RateLimit-Reset');
|
||||
|
||||
throw new ApiLimitExceedException($limit, $reset);
|
||||
}
|
||||
|
||||
if (401 === $response->getStatusCode()) {
|
||||
if ($response->hasHeader('X-GitHub-OTP') && 0 === strpos((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 'required;')) {
|
||||
$type = substr((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 9);
|
||||
if ((401 === $response->getStatusCode()) && $response->hasHeader('X-GitHub-OTP') && 0 === strpos((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 'required;')) {
|
||||
$type = substr((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 9);
|
||||
|
||||
throw new TwoFactorAuthenticationRequiredException($type);
|
||||
}
|
||||
throw new TwoFactorAuthenticationRequiredException($type);
|
||||
}
|
||||
|
||||
$content = ResponseMediator::getContent($response);
|
||||
if (is_array($content) && isset($content['message'])) {
|
||||
if (400 == $response->getStatusCode()) {
|
||||
if (400 === $response->getStatusCode()) {
|
||||
throw new ErrorException($content['message'], 400);
|
||||
} elseif (422 == $response->getStatusCode() && isset($content['errors'])) {
|
||||
}
|
||||
|
||||
if (422 === $response->getStatusCode() && isset($content['errors'])) {
|
||||
$errors = [];
|
||||
foreach ($content['errors'] as $error) {
|
||||
switch ($error['code']) {
|
||||
@@ -84,6 +84,17 @@ class GithubExceptionThrower implements Plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (502 == $response->getStatusCode() && isset($content['errors']) && is_array($content['errors'])) {
|
||||
$errors = [];
|
||||
foreach ($content['errors'] as $error) {
|
||||
if (isset($error['message'])) {
|
||||
$errors[] = $error['message'];
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException(implode(', ', $errors), 502);
|
||||
}
|
||||
|
||||
throw new RuntimeException(isset($content['message']) ? $content['message'] : $content, $response->getStatusCode());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user