Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 212a1ab

Browse files
CS fixes
1 parent d878e1c commit 212a1ab

File tree

7 files changed

+183
-160
lines changed

7 files changed

+183
-160
lines changed

src/AsyncQueue.php

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
1-
<?php namespace Barryvdh\Queue;
1+
<?php
22

3+
namespace Barryvdh\Queue;
4+
5+
use Barryvdh\Queue\Models\Job;
36
use Illuminate\Queue\Queue;
47
use Illuminate\Queue\QueueInterface;
58
use Symfony\Component\Process\Process;
6-
use Barryvdh\Queue\Models\Job;
7-
8-
class AsyncQueue extends Queue implements QueueInterface {
99

10+
class AsyncQueue extends Queue implements QueueInterface
11+
{
1012
/**
1113
* Push a new job onto the queue.
1214
*
13-
* @param string $job
14-
* @param mixed $data
15-
* @param string $queue
16-
* @return mixed
15+
* @param string $job
16+
* @param mixed $data
17+
* @param string|null $queue
18+
*
19+
* @return int
1720
*/
1821
public function push($job, $data = '', $queue = null)
1922
{
2023
$id = $this->storeJob($job, $data);
2124
$this->startProcess($id, 0);
25+
2226
return 0;
2327
}
2428

2529
/**
26-
* Store the job in the database
27-
*
28-
* @param string $job
29-
* @param mixed $data
30-
* @param integer $delay
31-
* @return integer The id of the job
30+
* Store the job in the database.
31+
*
32+
* Returns the id of the job.
33+
*
34+
* @param string $job
35+
* @param mixed $data
36+
* @param int $delay
37+
*
38+
* @return int
3239
*/
33-
public function storeJob($job, $data, $delay = 0){
34-
40+
public function storeJob($job, $data, $delay = 0)
41+
{
3542
$payload = $this->createPayload($job, $data);
3643

37-
$job = new Job;
44+
$job = new Job();
3845
$job->status = Job::STATUS_OPEN;
3946
$job->delay = $delay;
4047
$job->payload = $payload;
@@ -44,19 +51,21 @@ public function storeJob($job, $data, $delay = 0){
4451
}
4552

4653
/**
47-
* Make a Process for the Artisan command for the job id
54+
* Make a Process for the Artisan command for the job id.
55+
*
56+
* @param int $jobId
4857
*
49-
* @param integer $jobId
58+
* @return void
5059
*/
5160
public function startProcess($jobId)
5261
{
5362
$environment = $this->container->environment();
5463
$cwd = $this->container['path.base'];
5564
$string = 'php artisan queue:async %d --env=%s ';
56-
if (defined('PHP_WINDOWS_VERSION_BUILD')){
57-
$string = 'start /B ' . $string . ' > NUL';
65+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
66+
$string = 'start /B '.$string.' > NUL';
5867
} else {
59-
$string = 'nohup ' . $string . ' > /dev/null 2>&1 &';
68+
$string = 'nohup '.$string.' > /dev/null 2>&1 &';
6069
}
6170

6271
$command = sprintf($string, $jobId, $environment);
@@ -67,39 +76,45 @@ public function startProcess($jobId)
6776
/**
6877
* Push a new job onto the queue after a delay.
6978
*
70-
* @param \DateTime|int $delay
71-
* @param string $job
72-
* @param mixed $data
73-
* @param string $queue
74-
* @return mixed
79+
* @param \DateTime|int $delay
80+
* @param string $job
81+
* @param mixed $data
82+
* @param string|null $queue
83+
*
84+
* @return int
7585
*/
7686
public function later($delay, $job, $data = '', $queue = null)
7787
{
7888
$delay = $this->getSeconds($delay);
7989
$id = $this->storeJob($job, $data, $delay);
8090
$this->startProcess($id);
91+
8192
return 0;
8293
}
8394

8495
/**
8596
* Pop the next job off of the queue.
8697
*
87-
* @param string $queue
88-
* @return \Illuminate\Queue\Jobs\Job|null
98+
* @param string|null $queue
99+
*
100+
* @return void
89101
*/
90-
public function pop($queue = null) {}
91-
102+
public function pop($queue = null)
103+
{
104+
// do nothing
105+
}
92106

93107
/**
94108
* Push a raw payload onto the queue.
95109
*
96-
* @param string $payload
97-
* @param string $queue
98-
* @param array $options
99-
* @return mixed
110+
* @param string $payload
111+
* @param string|null $queue
112+
* @param array $options
113+
*
114+
* @return void
100115
*/
101116
public function pushRaw($payload, $queue = null, array $options = array())
102117
{
103-
//
118+
// do nothing
104119
}
105120
}

src/AsyncServiceProvider.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
<?php namespace Barryvdh\Queue;
1+
<?php
2+
3+
namespace Barryvdh\Queue;
24

3-
use Illuminate\Support\ServiceProvider;
45
use Barryvdh\Queue\Connectors\AsyncConnector;
56
use Barryvdh\Queue\Console\AsyncCommand;
7+
use Illuminate\Support\ServiceProvider;
68

7-
class AsyncServiceProvider extends ServiceProvider {
8-
9+
class AsyncServiceProvider extends ServiceProvider
10+
{
911
/**
1012
* Indicates if loading of the provider is deferred.
1113
*
@@ -14,34 +16,36 @@ class AsyncServiceProvider extends ServiceProvider {
1416
protected $defer = false;
1517

1618
/**
17-
* Register the service provider.
19+
* Add the connector to the queue drivers.
1820
*
1921
* @return void
2022
*/
21-
public function register()
23+
public function boot()
2224
{
23-
$this->registerAsyncCommand();
25+
$manager = $this->app['queue'];
26+
$this->registerAsyncConnector($manager);
2427
}
2528

2629
/**
27-
* Add the connector to the queue drivers
30+
* Register the service provider.
31+
*
32+
* @return void
2833
*/
29-
public function boot(){
30-
$manager = $this->app['queue'];
31-
$this->registerAsyncConnector($manager);
34+
public function register()
35+
{
36+
$this->registerAsyncCommand($this->app);
3237
}
3338

3439
/**
3540
* Register the queue listener console command.
3641
*
42+
* @param \Illuminate\Foundation\Application $app
43+
*
3744
* @return void
3845
*/
39-
protected function registerAsyncCommand()
46+
protected function registerAsyncCommand($app)
4047
{
41-
$app = $this->app;
42-
43-
$app['command.queue.async'] = $app->share(function($app)
44-
{
48+
$app['command.queue.async'] = $app->share(function ($app) {
4549
return new AsyncCommand();
4650
});
4751

@@ -51,14 +55,14 @@ protected function registerAsyncCommand()
5155
/**
5256
* Register the Async queue connector.
5357
*
54-
* @param \Illuminate\Queue\QueueManager $manager
58+
* @param \Illuminate\Queue\QueueManager $manager
59+
*
5560
* @return void
5661
*/
5762
protected function registerAsyncConnector($manager)
5863
{
59-
$manager->addConnector('async', function()
60-
{
61-
return new AsyncConnector;
64+
$manager->addConnector('async', function () {
65+
return new AsyncConnector();
6266
});
6367
}
6468

@@ -71,5 +75,4 @@ public function provides()
7175
{
7276
return array('command.queue.async');
7377
}
74-
7578
}

src/Connectors/AsyncConnector.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
<?php namespace Barryvdh\Queue\Connectors;
1+
<?php
22

3-
use Illuminate\Queue\Connectors\ConnectorInterface;
4-
use Barryvdh\Queue\AsyncQueue;
3+
namespace Barryvdh\Queue\Connectors;
54

6-
class AsyncConnector implements ConnectorInterface {
5+
use Barryvdh\Queue\AsyncQueue;
6+
use Illuminate\Queue\Connectors\ConnectorInterface;
77

8+
class AsyncConnector implements ConnectorInterface
9+
{
810
/**
911
* Establish a queue connection.
1012
*
11-
* @param array $config
13+
* @param array $config
14+
*
1215
* @return \Illuminate\Queue\QueueInterface
1316
*/
1417
public function connect(array $config)
1518
{
16-
return new AsyncQueue;
19+
return new AsyncQueue();
1720
}
18-
19-
}
21+
}

src/Console/AsyncCommand.php

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
1-
<?php namespace Barryvdh\Queue\Console;
1+
<?php
22

3+
namespace Barryvdh\Queue\Console;
4+
5+
use Barryvdh\Queue\Jobs\AsyncJob;
36
use Barryvdh\Queue\Models\Job;
47
use Illuminate\Console\Command;
58
use Symfony\Component\Console\Input\InputArgument;
6-
use Barryvdh\Queue\Jobs\AsyncJob;
79

8-
class AsyncCommand extends Command {
9-
10-
/**
11-
* The console command name.
12-
*
13-
* @var string
14-
*/
15-
protected $name = 'queue:async';
16-
17-
/**
18-
* The console command description.
19-
*
20-
* @var string
21-
*/
22-
protected $description = 'Run a queue from the database';
23-
24-
/**
25-
* Create a new command instance.
26-
*
27-
*/
28-
public function __construct()
29-
{
30-
parent::__construct();
31-
}
32-
33-
/**
34-
* Execute the console command.
35-
*
36-
* @return void
37-
*/
38-
public function fire()
39-
{
10+
class AsyncCommand extends Command
11+
{
12+
/**
13+
* The console command name.
14+
*
15+
* @var string
16+
*/
17+
protected $name = 'queue:async';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Run a queue from the database';
25+
26+
/**
27+
* Create a new command instance.
28+
*
29+
* @return void
30+
*/
31+
public function __construct()
32+
{
33+
parent::__construct();
34+
}
35+
36+
/**
37+
* Execute the console command.
38+
*
39+
* @return void
40+
*/
41+
public function fire()
42+
{
4043
$item = Job::findOrFail($this->argument('job_id'));
4144

4245
$job = new AsyncJob($this->laravel, $item);
4346

4447
$job->fire();
45-
46-
}
47-
48-
/**
49-
* Get the console command arguments.
50-
*
51-
* @return array
52-
*/
53-
protected function getArguments()
54-
{
55-
return array(
56-
array('job_id', InputArgument::REQUIRED, 'The Job ID'),
57-
);
58-
}
59-
48+
}
49+
50+
/**
51+
* Get the console command arguments.
52+
*
53+
* @return array
54+
*/
55+
protected function getArguments()
56+
{
57+
return array(
58+
array('job_id', InputArgument::REQUIRED, 'The Job ID'),
59+
);
60+
}
6061
}

0 commit comments

Comments
 (0)