Skip to content

Commit

Permalink
Remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Jun 5, 2020
1 parent 484d1ca commit 324c6c2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 188 deletions.
56 changes: 8 additions & 48 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

class Client
{
/**
* @deprecated Use {@see Configuration::NOTIFY_ENDPOINT} instead
*/
const ENDPOINT = Configuration::NOTIFY_ENDPOINT;

/**
* The config instance.
*
Expand Down Expand Up @@ -128,7 +123,7 @@ public function __construct(
$this->resolver = $resolver ?: new BasicResolver();
$this->recorder = new Recorder();
$this->pipeline = new Pipeline();
$this->http = new HttpClient($config, $guzzle ?: static::makeGuzzle());
$this->http = new HttpClient($config, $guzzle ?: self::makeGuzzle());
$this->sessionTracker = new SessionTracker($config, $this->http);

$this->registerMiddleware(new NotificationSkipper($config));
Expand All @@ -141,36 +136,17 @@ public function __construct(
}

/**
* Make a new guzzle client instance.
*
* @param string $base No longer used
* @param array $options
*
* @return ClientInterface
*
* @deprecated Will be removed in a future release
*/
public static function makeGuzzle($base = null, array $options = [])
private static function makeGuzzle()
{
if ($path = static::getCaBundlePath()) {
$options['verify'] = $path;
if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
return new GuzzleClient();
}

return new GuzzleClient($options);
}

/**
* Get the ca bundle path if one exists.
*
* @return string|false
*/
protected static function getCaBundlePath()
{
if (version_compare(PHP_VERSION, '5.6.0') >= 0 || !class_exists(CaBundle::class)) {
return false;
}

return realpath(CaBundle::getSystemCaRootBundlePath());
return new GuzzleClient([
'verify' => realpath(CaBundle::getSystemCaRootBundlePath()),
]);
}

/**
Expand Down Expand Up @@ -332,22 +308,6 @@ public function notify(Report $report, callable $callback = null)
}
}

/**
* Notify Bugsnag of a deployment.
*
* @deprecated This function is being deprecated in favour of `build`.
*
* @param string|null $repository the repository from which you are deploying the code
* @param string|null $branch the source control branch from which you are deploying
* @param string|null $revision the source control revision you are currently deploying
*
* @return void
*/
public function deploy($repository = null, $branch = null, $revision = null)
{
$this->build($repository, $revision);
}

/**
* Notify Bugsnag of a build.
*
Expand Down Expand Up @@ -849,7 +809,7 @@ public function getBuildEndpoint()
}

/**
* Set session tracking state and pass in optional guzzle.
* Set session tracking state.
*
* @param bool $track whether to track sessions
*
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ public function getBuildEndpoint()
}

/**
* Set session tracking state and pass in optional guzzle.
* Set session tracking state.
*
* @param bool $track whether to track sessions
*
Expand Down
36 changes: 2 additions & 34 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ class HttpClient
*/
const MAX_SIZE = 1048576;

/**
* @deprecated Use {@see HttpClient::NOTIFICATION_PAYLOAD_VERSION} instead
*/
const PAYLOAD_VERSION = self::NOTIFICATION_PAYLOAD_VERSION;

/**
* The payload version for the error notification API.
*/
const NOTIFICATION_PAYLOAD_VERSION = '4.0';
const NOTIFY_PAYLOAD_VERSION = '4.0';

/**
* The payload version for the session API.
Expand Down Expand Up @@ -115,33 +110,6 @@ public function sendSessions(array $payload)
);
}

/**
* Notify Bugsnag of a deployment.
*
* @deprecated This method should no longer be used in favour of sendBuildReport.
*
* @param array $data the deployment information
*
* @return void
*/
public function deploy(array $data)
{
$app = $this->config->getAppData();

$data['releaseStage'] = $app['releaseStage'];

if (isset($app['version'])) {
$data['appVersion'] = $app['version'];
}

$data['apiKey'] = $this->config->getApiKey();

$this->post(
$this->config->getNotifyEndpoint().'deploy',
['json' => $data]
);
}

/**
* Notify Bugsnag of a build.
*
Expand Down Expand Up @@ -231,7 +199,7 @@ protected function deliverEvents(array $data)
$this->config->getNotifyEndpoint(),
[
'json' => $normalized,
'headers' => $this->getHeaders(self::NOTIFICATION_PAYLOAD_VERSION),
'headers' => $this->getHeaders(self::NOTIFY_PAYLOAD_VERSION),
]
);
} catch (Exception $e) {
Expand Down
9 changes: 2 additions & 7 deletions src/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@

class Report
{
/**
* @deprecated Use {@see HttpClient::NOTIFICATION_PAYLOAD_VERSION} instead
*/
const PAYLOAD_VERSION = HttpClient::NOTIFICATION_PAYLOAD_VERSION;

/**
* The config object.
*
* @var \Bugsnag\Config
* @var Configuration
*/
protected $config;

Expand Down Expand Up @@ -650,7 +645,7 @@ public function toArray()
'device' => array_merge(['time' => $this->time], $this->config->getDeviceData()),
'user' => $this->getUser(),
'context' => $this->getContext(),
'payloadVersion' => HttpClient::NOTIFICATION_PAYLOAD_VERSION,
'payloadVersion' => HttpClient::NOTIFY_PAYLOAD_VERSION,
'severity' => $this->getSeverity(),
'exceptions' => $this->exceptionArray(),
'breadcrumbs' => $this->breadcrumbs,
Expand Down
5 changes: 0 additions & 5 deletions src/SessionTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ class SessionTracker
*/
protected static $MAX_SESSION_COUNT = 50;

/**
* @deprecated Use {@see HttpClient::NOTIFICATION_PAYLOAD_VERSION} instead
*/
protected static $SESSION_PAYLOAD_VERSION = HttpClient::SESSION_PAYLOAD_VERSION;

/**
* The key for storing session counts.
*/
Expand Down
93 changes: 0 additions & 93 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,99 +480,6 @@ public function testCanManuallyFlush()
$this->client->flush();
}

public function testDeployWorksOutOfTheBox()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['releaseStage' => 'production', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');

$this->client->deploy();
}

public function testDeployWorksWithReleaseStage()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['releaseStage' => 'staging', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');
$this->config->setReleaseStage('staging');

$this->client->deploy();
}

public function testDeployWorksWithAppVersion()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['releaseStage' => 'production', 'appVersion' => '1.1.0', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');

$this->client->deploy();
}

public function testDeployWorksWithRepository()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['sourceControl' => ['repository' => 'foo'], 'releaseStage' => 'production', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');

$this->client->deploy('foo');
}

public function testDeployWorksWithBranch()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['releaseStage' => 'production', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');

$this->client->deploy(null, 'master');
}

public function testDeployWorksWithRevision()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['sourceControl' => ['revision' => 'bar'], 'releaseStage' => 'production', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setAppVersion('1.3.1');

$this->client->deploy(null, null, 'bar');
}

public function testDeployWorksWithEverything()
{
$this->guzzlePostWith(
'https://build.bugsnag.com',
['json' => ['sourceControl' => ['repository' => 'baz', 'revision' => 'foo'], 'releaseStage' => 'development', 'appVersion' => '1.3.1', 'apiKey' => 'example-api-key', 'buildTool' => 'bugsnag-php', 'builderName' => exec('whoami'), 'appVersion' => '1.3.1']]
);

$this->client = new Client($this->config = new Configuration('example-api-key'), null, $this->guzzle);
$this->config->setReleaseStage('development');
$this->config->setAppVersion('1.3.1');

$this->client->deploy('baz', 'develop', 'foo');
}

public function testBuildWorksOutOfTheBox()
{
$this->guzzlePostWith(
Expand Down

0 comments on commit 324c6c2

Please sign in to comment.