Skip to content

Commit 60a9e4e

Browse files
committed
Tweak version checks
1 parent 2470ea7 commit 60a9e4e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/LaravelDebugBar.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public function __construct($app = null)
7272
$app = app(); //Fallback when $app is not given
7373
}
7474
$this->app = $app;
75-
76-
//Normalize Laravel version
77-
$version = $app::VERSION;
78-
list($version) = explode('-', $version);
79-
$this->version = $version;
8075
}
8176

8277
/**
@@ -133,7 +128,7 @@ function () use ($debugbar, $startTime) {
133128
);
134129

135130
//Check if App::before is already called..
136-
if ($this->checkVersion('4.1') && $this->app->isBooted()) {
131+
if ($this->checkVersion('4.1-dev', '>=') && $this->app->isBooted()) {
137132
$debugbar->startMeasure('application', 'Application');
138133
} else {
139134
$this->app['router']->before(
@@ -160,7 +155,7 @@ function () use ($debugbar) {
160155
$this->app['config']->get('laravel-debugbar::config.options.exceptions.chain', true)
161156
);
162157
$this->addCollector($exceptionCollector);
163-
if ($this->checkVersion('5.0', '<')) {
158+
if ($this->checkVersion('5.0-dev', '<')) {
164159
$this->app->error(
165160
function (Exception $exception) use ($exceptionCollector) {
166161
$exceptionCollector->addException($exception);
@@ -216,7 +211,7 @@ function ($view) use ($debugbar) {
216211

217212
if ($this->shouldCollect('route')) {
218213
try {
219-
if ($this->checkVersion('4.1')) {
214+
if ($this->checkVersion('4.1', '>=')) {
220215
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\IlluminateRouteCollector'));
221216
} else {
222217
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\SymfonyRouteCollector'));
@@ -761,6 +756,6 @@ public function addMessage($message, $label = 'info')
761756
*/
762757
protected function checkVersion($version, $operator = ">=")
763758
{
764-
return version_compare($this->version, $version, $operator);
759+
return version_compare($this->app->version(), $version, $operator);
765760
}
766761
}

src/ServiceProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ function ($request, $response) use ($app) {
7474

7575
protected function shouldUseMiddleware()
7676
{
77-
$app = $this->app;
78-
list($version) = explode('-', $app::VERSION);
79-
return !$app->runningInConsole() && version_compare($version, '4.1', '>=') && version_compare($version, '5.0', '<');
77+
$version = $this->app->version();
78+
return !$this->app->runningInConsole() && version_compare($version, '4.1-dev', '>=') && version_compare($version, '5.0-dev', '<');
8079
}
8180

8281
/**

0 commit comments

Comments
 (0)