Skip to content

Commit 322ec0c

Browse files
committed
Add remaining type hints, add PHP 7.1 dependency
1 parent e05357f commit 322ec0c

8 files changed

Lines changed: 23 additions & 27 deletions

File tree

Classes/Job/JobInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* source code.
1212
*/
1313

14-
use Neos\Flow\Annotations as Flow;
1514
use Flowpack\JobQueue\Common\Queue\Message;
1615
use Flowpack\JobQueue\Common\Queue\QueueInterface;
1716

Classes/Job/JobManager.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class JobManager
6666
* @return void
6767
* @api
6868
*/
69-
public function queue($queueName, JobInterface $job, array $options = [])
69+
public function queue(string $queueName, JobInterface $job, array $options = []): void
7070
{
7171
$queue = $this->queueManager->getQueue($queueName);
7272

@@ -85,7 +85,7 @@ public function queue($queueName, JobInterface $job, array $options = [])
8585
* @throws \Exception
8686
* @api
8787
*/
88-
public function waitAndExecute($queueName, $timeout = null)
88+
public function waitAndExecute(string $queueName, $timeout = null): ?Message
8989
{
9090
$queue = $this->queueManager->getQueue($queueName);
9191
$message = $queue->waitAndReserve($timeout);
@@ -133,7 +133,7 @@ public function waitAndExecute($queueName, $timeout = null)
133133
* @throws JobQueueException
134134
* @internal This method has to be public so that it can be run from the command handler (when "executeIsolated" is set). It is not meant to be called from "user land"
135135
*/
136-
public function executeJobForMessage(QueueInterface $queue, Message $message)
136+
public function executeJobForMessage(QueueInterface $queue, Message $message): void
137137
{
138138
// TODO stabilize unserialize() call (maybe using PHPs unserialize_callback_func directive)
139139
$job = unserialize($message->getPayload());
@@ -153,7 +153,7 @@ public function executeJobForMessage(QueueInterface $queue, Message $message)
153153
* @return JobInterface[]
154154
* @api
155155
*/
156-
public function peek($queueName, $limit = 1)
156+
public function peek(string $queueName, int $limit = 1): array
157157
{
158158
$queue = $this->queueManager->getQueue($queueName);
159159
$messages = $queue->peek($limit);
@@ -174,7 +174,7 @@ public function peek($queueName, $limit = 1)
174174
* @Flow\Signal
175175
* @api
176176
*/
177-
protected function emitMessageSubmitted(QueueInterface $queue, $messageId, $payload, array $options = [])
177+
protected function emitMessageSubmitted(QueueInterface $queue, $messageId, $payload, array $options = []): void
178178
{
179179
}
180180

@@ -186,7 +186,7 @@ protected function emitMessageSubmitted(QueueInterface $queue, $messageId, $payl
186186
* @Flow\Signal
187187
* @api
188188
*/
189-
protected function emitMessageTimeout(QueueInterface $queue)
189+
protected function emitMessageTimeout(QueueInterface $queue): void
190190
{
191191
}
192192

@@ -199,7 +199,7 @@ protected function emitMessageTimeout(QueueInterface $queue)
199199
* @Flow\Signal
200200
* @api
201201
*/
202-
protected function emitMessageReserved(QueueInterface $queue, Message $message)
202+
protected function emitMessageReserved(QueueInterface $queue, Message $message): void
203203
{
204204
}
205205

@@ -212,7 +212,7 @@ protected function emitMessageReserved(QueueInterface $queue, Message $message)
212212
* @Flow\Signal
213213
* @api
214214
*/
215-
protected function emitMessageFinished(QueueInterface $queue, Message $message)
215+
protected function emitMessageFinished(QueueInterface $queue, Message $message): void
216216
{
217217
}
218218

@@ -227,7 +227,7 @@ protected function emitMessageFinished(QueueInterface $queue, Message $message)
227227
* @Flow\Signal
228228
* @api
229229
*/
230-
protected function emitMessageReleased(QueueInterface $queue, Message $message, array $releaseOptions, \Exception $jobExecutionException = null)
230+
protected function emitMessageReleased(QueueInterface $queue, Message $message, array $releaseOptions, \Exception $jobExecutionException = null): void
231231
{
232232
}
233233

@@ -241,7 +241,7 @@ protected function emitMessageReleased(QueueInterface $queue, Message $message,
241241
* @Flow\Signal
242242
* @api
243243
*/
244-
protected function emitMessageFailed(QueueInterface $queue, Message $message, \Exception $jobExecutionException = null)
244+
protected function emitMessageFailed(QueueInterface $queue, Message $message, \Exception $jobExecutionException = null): void
245245
{
246246
}
247247

Classes/Job/StaticMethodCallJob.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
1717
use Flowpack\JobQueue\Common\Queue\Message;
1818
use Flowpack\JobQueue\Common\Queue\QueueInterface;
19-
use Neos\Utility\TypeHandling;
2019

2120
/**
2221
* Static method call job
@@ -73,7 +72,7 @@ public function __construct($className, $methodName, array $arguments)
7372
* @return boolean TRUE If the execution was successful
7473
* @throws \Exception
7574
*/
76-
public function execute(QueueInterface $queue, Message $message)
75+
public function execute(QueueInterface $queue, Message $message): bool
7776
{
7877
$service = $this->objectManager->get($this->className);
7978
$this->deferMethodCallAspect->setProcessingJob(true);
@@ -91,7 +90,7 @@ public function execute(QueueInterface $queue, Message $message)
9190
/**
9291
* @return string
9392
*/
94-
public function getLabel()
93+
public function getLabel(): string
9594
{
9695
$arguments = array_map([VariableDumper::class, 'dumpValue'], $this->arguments);
9796
return sprintf('%s::%s(%s)', $this->className, $this->methodName, implode(', ', $arguments));

Classes/Queue/FakeQueue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class FakeQueue implements QueueInterface
4949
* @param string $name
5050
* @param array $options
5151
*/
52-
public function __construct($name, array $options = [])
52+
public function __construct(string $name, array $options = [])
5353
{
5454
$this->name = $name;
5555
if (isset($options['async']) && $options['async'] === true) {
@@ -133,6 +133,7 @@ public function abort(string $messageId): void
133133
public function finish(string $messageId): bool
134134
{
135135
// The FakeQueue does not support message finishing
136+
return false;
136137
}
137138

138139
/**

Classes/Queue/Message.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* source code.
1212
*/
1313

14-
use Neos\Flow\Annotations as Flow;
15-
1614
/**
1715
* A DTO that wraps arbitrary payload with an identifier and a counter for failures.
1816
*/
@@ -45,7 +43,7 @@ class Message
4543
* @param mixed $payload
4644
* @param integer $numberOfReleases
4745
*/
48-
public function __construct($identifier, $payload, $numberOfReleases = 0)
46+
public function __construct(string $identifier, $payload, int $numberOfReleases = 0)
4947
{
5048
$this->identifier = $identifier;
5149
$this->payload = $payload;
@@ -55,7 +53,7 @@ public function __construct($identifier, $payload, $numberOfReleases = 0)
5553
/**
5654
* @return string
5755
*/
58-
public function getIdentifier()
56+
public function getIdentifier(): string
5957
{
6058
return $this->identifier;
6159
}
@@ -69,10 +67,10 @@ public function getPayload()
6967
}
7068

7169
/**
72-
* @return integer
70+
* @return int
7371
*/
74-
public function getNumberOfReleases()
72+
public function getNumberOfReleases(): int
7573
{
7674
return $this->numberOfReleases;
7775
}
78-
}
76+
}

Classes/Queue/QueueInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* source code.
1212
*/
1313

14-
use Neos\Flow\Annotations as Flow;
15-
1614
/**
1715
* Message queue interface
1816
*/

Classes/Queue/QueueManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QueueManager
5353
* @throws JobQueueException
5454
* @api
5555
*/
56-
public function getQueue($queueName)
56+
public function getQueue(string $queueName): QueueInterface
5757
{
5858
if (isset($this->queues[$queueName])) {
5959
return $this->queues[$queueName];
@@ -91,7 +91,7 @@ public function getQueue($queueName)
9191
* @throws JobQueueException if no queue for the given $queueName is configured
9292
* @api
9393
*/
94-
public function getQueueSettings($queueName)
94+
public function getQueueSettings(string $queueName): array
9595
{
9696
if (isset($this->queueSettingsRuntimeCache[$queueName])) {
9797
return $this->queueSettingsRuntimeCache[$queueName];
@@ -111,4 +111,4 @@ public function getQueueSettings($queueName)
111111
return $this->queueSettingsRuntimeCache[$queueName];
112112
}
113113

114-
}
114+
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Common functionality for a JobQueue in Flow applications.",
55
"license": "MIT",
66
"require": {
7+
"php": "^7.1",
78
"neos/flow": "~4.0",
89
"neos/cache": "*"
910
},

0 commit comments

Comments
 (0)