Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F5661146
D784.id1983.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
69 KB
Referenced Files
None
Subscribers
None
D784.id1983.diff
View Options
diff --git a/app/Actions/AMQPAction.php b/app/Actions/AMQPAction.php
--- a/app/Actions/AMQPAction.php
+++ b/app/Actions/AMQPAction.php
@@ -26,8 +26,12 @@
/**
* Initializes a new instance of a AMQP action to report
+ *
+ * @param string $method The action done on the broker (e.g. 'publish')
+ * @param string $target The queue or exchange target on the broker
+ * @param string $routingKey The routing key for this exchange or queue
*/
- public function __construct ($method, $target, $routingKey = '') {
+ public function __construct (string $method, string $target, string $routingKey = '') {
parent::__construct();
$this->method = $method;
diff --git a/app/Actions/Action.php b/app/Actions/Action.php
--- a/app/Actions/Action.php
+++ b/app/Actions/Action.php
@@ -30,7 +30,7 @@
*
* @param ActionError $error The error to attach
*/
- public function attachError (ActionError $error) {
+ public function attachError (ActionError $error) : void {
$this->error = $error;
}
}
diff --git a/app/Actions/ActionsReport.php b/app/Actions/ActionsReport.php
--- a/app/Actions/ActionsReport.php
+++ b/app/Actions/ActionsReport.php
@@ -48,7 +48,7 @@
* @param string $gate The gate
* @param string $door The door
*/
- public function attachToGate ($gate, $door) {
+ public function attachToGate (string $gate, string $door) : void {
$this->gate = $gate;
$this->door = $door;
}
@@ -58,7 +58,7 @@
*
* @param Action $action The action to add
*/
- public function addAction (Action $action) {
+ public function addAction (Action $action) : void {
$this->actions[] = $action;
}
@@ -67,7 +67,7 @@
*
* @return bool
*/
- public function containsError () {
+ public function containsError () : bool {
foreach ($this->actions as $action) {
if ($action->error !== null) {
return true;
@@ -84,7 +84,7 @@
/**
* Gets a JSON string representation of the current instance
*/
- public function __toString () {
+ public function __toString () : string {
return json_encode($this, JSON_PRETTY_PRINT);
}
}
diff --git a/app/Actions/NotifyNewCommitsAction.php b/app/Actions/NotifyNewCommitsAction.php
--- a/app/Actions/NotifyNewCommitsAction.php
+++ b/app/Actions/NotifyNewCommitsAction.php
@@ -11,9 +11,11 @@
public $callSign;
/**
- * Initializes a new instance of a AMQP action to report
+ * Initializes a new instance of a AMQP action to report.
+ *
+ * @param string $callSign The Phabricator repository call sign
*/
- public function __construct ($callSign) {
+ public function __construct (string $callSign) {
parent::__construct();
$this->callSign = $callSign;
diff --git a/app/Actions/TriggerDockerHubBuildAction.php b/app/Actions/TriggerDockerHubBuildAction.php
--- a/app/Actions/TriggerDockerHubBuildAction.php
+++ b/app/Actions/TriggerDockerHubBuildAction.php
@@ -12,8 +12,10 @@
/**
* Initializes a new instance of a DockerHub build trigger action to report
+ *
+ * @param string $image The Docker Hub image to trigger
*/
- public function __construct ($image) {
+ public function __construct (string $image) {
parent::__construct();
$this->image = $image;
diff --git a/app/Analyzers/BasePayloadAnalyzer.php b/app/Analyzers/BasePayloadAnalyzer.php
--- a/app/Analyzers/BasePayloadAnalyzer.php
+++ b/app/Analyzers/BasePayloadAnalyzer.php
@@ -51,11 +51,7 @@
* @param string $project
* @param \stdClass $payload
*/
- public function __construct($project, $payload) {
- if (!is_object($payload)) {
- throw new InvalidArgumentException("Payload must be an object.");
- }
-
+ public function __construct(string $project, \stdClass $payload) {
$this->project = $project;
$this->payload = $payload;
@@ -76,7 +72,7 @@
*
* @return string
*/
- public function getConfigurationFileName () {
+ public function getConfigurationFileName () : string {
$dir = Config::get('services.' . strtolower(static::SERVICE_NAME) . '.analyzer.configDir');
$filename = $dir . '/' . $this->project . '.json';
@@ -93,7 +89,7 @@
*
* @return string
*/
- private function getCandidateConfigurationClassName() {
+ private function getCandidateConfigurationClassName() : string {
$namespace = 'Nasqueron\Notifications\Analyzers\\' . static::SERVICE_NAME;
return $namespace . "\\" . static::SERVICE_NAME . 'PayloadAnalyzerConfiguration';
}
@@ -104,7 +100,7 @@
*
* @return string The configuration class to use
*/
- private function getConfigurationClassName () {
+ private function getConfigurationClassName () : string {
$class = $this->getCandidateConfigurationClassName();
if (class_exists($class)) {
@@ -117,7 +113,7 @@
/**
* Loads configuration for the analyzer
*/
- public function loadConfiguration () {
+ public function loadConfiguration () : void {
$fileName = $this->getConfigurationFileName();
$class = $this->getConfigurationClassName();
@@ -137,7 +133,7 @@
*
* @var string
*/
- public function getItemName () {
+ public function getItemName () : string {
throw new BadMethodCallException("The getItemName method must be implemented in the analyzer class if used.");
}
@@ -147,7 +143,7 @@
*
* @return bool
*/
- public function isAdministrativeEvent () {
+ public function isAdministrativeEvent () : bool {
return false;
}
@@ -156,7 +152,7 @@
*
* @return string The group, central part of the routing key
*/
- public function getGroup () {
+ public function getGroup () : string {
// Some events are organization-level only and can't be mapped
// to projects.
if ($this->isAdministrativeEvent()) {
diff --git a/app/Analyzers/GitHub/Events/CommitCommentEvent.php b/app/Analyzers/GitHub/Events/CommitCommentEvent.php
--- a/app/Analyzers/GitHub/Events/CommitCommentEvent.php
+++ b/app/Analyzers/GitHub/Events/CommitCommentEvent.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$comment = $this->payload->comment;
return trans(
@@ -32,7 +32,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->comment->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/CreateEvent.php b/app/Analyzers/GitHub/Events/CreateEvent.php
--- a/app/Analyzers/GitHub/Events/CreateEvent.php
+++ b/app/Analyzers/GitHub/Events/CreateEvent.php
@@ -22,7 +22,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$repository = $this->payload->repository->full_name;
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
@@ -50,10 +50,10 @@
/**
* Gets link segments for the type
*
- * @return Array
+ * @return array
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
- private function getLinkRefSegments () {
+ private function getLinkRefSegments () : array {
return [
'tag' => '/releases/tag/',
'branch' => '/tree/',
@@ -65,7 +65,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
diff --git a/app/Analyzers/GitHub/Events/DeleteEvent.php b/app/Analyzers/GitHub/Events/DeleteEvent.php
--- a/app/Analyzers/GitHub/Events/DeleteEvent.php
+++ b/app/Analyzers/GitHub/Events/DeleteEvent.php
@@ -19,7 +19,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$repository = $this->payload->repository->full_name;
$type = $this->payload->ref_type;
$ref = $this->payload->ref;
@@ -62,7 +62,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
$type = $this->payload->ref_type;
$url = $this->payload->repository->html_url;
diff --git a/app/Analyzers/GitHub/Events/ForkEvent.php b/app/Analyzers/GitHub/Events/ForkEvent.php
--- a/app/Analyzers/GitHub/Events/ForkEvent.php
+++ b/app/Analyzers/GitHub/Events/ForkEvent.php
@@ -16,7 +16,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return trans(
'GitHub.EventsDescriptions.ForkEvent',
[
@@ -31,7 +31,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->forkee->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/IssueCommentEvent.php b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
--- a/app/Analyzers/GitHub/Events/IssueCommentEvent.php
+++ b/app/Analyzers/GitHub/Events/IssueCommentEvent.php
@@ -25,7 +25,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$action = $this->payload->action;
if (!static::isValidAction($action)) {
@@ -57,7 +57,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->comment->html_url;
}
diff --git a/app/Analyzers/GitHub/Events/PingEvent.php b/app/Analyzers/GitHub/Events/PingEvent.php
--- a/app/Analyzers/GitHub/Events/PingEvent.php
+++ b/app/Analyzers/GitHub/Events/PingEvent.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return trans(
'GitHub.EventsDescriptions.PingEvent',
[
@@ -29,7 +29,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return '';
}
}
diff --git a/app/Analyzers/GitHub/Events/PullRequestEvent.php b/app/Analyzers/GitHub/Events/PullRequestEvent.php
--- a/app/Analyzers/GitHub/Events/PullRequestEvent.php
+++ b/app/Analyzers/GitHub/Events/PullRequestEvent.php
@@ -30,7 +30,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$action = $this->payload->action;
if (!static::isValidAction($action)) {
@@ -84,7 +84,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->pull_request->html_url;
}
diff --git a/app/Analyzers/GitHub/Events/PushEvent.php b/app/Analyzers/GitHub/Events/PushEvent.php
--- a/app/Analyzers/GitHub/Events/PushEvent.php
+++ b/app/Analyzers/GitHub/Events/PushEvent.php
@@ -33,7 +33,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$n = count($this->payload->commits);
if ($n === 1) {
@@ -55,7 +55,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
$n = count($this->payload->commits);
if ($n === 1) {
diff --git a/app/Analyzers/GitHub/Events/RepositoryEvent.php b/app/Analyzers/GitHub/Events/RepositoryEvent.php
--- a/app/Analyzers/GitHub/Events/RepositoryEvent.php
+++ b/app/Analyzers/GitHub/Events/RepositoryEvent.php
@@ -25,7 +25,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
$action = $this->payload->action;
if (!static::isValidAction($action)) {
@@ -59,7 +59,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->repository->html_url;
}
}
diff --git a/app/Analyzers/GitHub/Events/StatusEvent.php b/app/Analyzers/GitHub/Events/StatusEvent.php
--- a/app/Analyzers/GitHub/Events/StatusEvent.php
+++ b/app/Analyzers/GitHub/Events/StatusEvent.php
@@ -41,7 +41,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return trans('GitHub.EventsDescriptions.StatusEvent', [
'commit' => substr($this->payload->sha, 0, 8),
'status' => $this->getStatusResult(),
@@ -53,7 +53,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
$url = $this->payload->target_url;
if ($url === null) {
diff --git a/app/Analyzers/GitHub/Events/UnknownEvent.php b/app/Analyzers/GitHub/Events/UnknownEvent.php
--- a/app/Analyzers/GitHub/Events/UnknownEvent.php
+++ b/app/Analyzers/GitHub/Events/UnknownEvent.php
@@ -30,7 +30,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return "Some $this->eventType happened";
}
@@ -39,7 +39,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return "";
}
}
diff --git a/app/Analyzers/GitHub/Events/WatchEvent.php b/app/Analyzers/GitHub/Events/WatchEvent.php
--- a/app/Analyzers/GitHub/Events/WatchEvent.php
+++ b/app/Analyzers/GitHub/Events/WatchEvent.php
@@ -20,7 +20,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return trans(
'GitHub.EventsDescriptions.WatchEvent',
[
@@ -35,7 +35,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->payload->sender->html_url;
}
}
diff --git a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
--- a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
+++ b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
@@ -41,7 +41,7 @@
* @param string $event
* @param \stdClass $payload
*/
- public function __construct($project, $event, $payload) {
+ public function __construct(string $project, string $event, \stdClass $payload) {
parent::__construct($project, $payload);
$this->event = $event;
@@ -62,7 +62,7 @@
*
* @var string
*/
- public function getItemName () {
+ public function getItemName () : string {
if ($this->isAdministrativeEvent()) {
return '';
}
@@ -77,7 +77,7 @@
/**
* @return bool
*/
- public function isAdministrativeEvent () {
+ public function isAdministrativeEvent () : bool {
$administrativeEvents = [
'membership', // Member added to team
'ping', // Special ping pong event, fired on new hook
@@ -96,7 +96,7 @@
*
* @return string
*/
- public function getDescription () {
+ public function getDescription () : string {
return $this->analyzerEvent->getDescription();
}
@@ -105,7 +105,7 @@
*
* @return string The most relevant URL
*/
- public function getLink () {
+ public function getLink () : string {
return $this->analyzerEvent->getLink();
}
diff --git a/app/Analyzers/ItemGroupMapping.php b/app/Analyzers/ItemGroupMapping.php
--- a/app/Analyzers/ItemGroupMapping.php
+++ b/app/Analyzers/ItemGroupMapping.php
@@ -38,7 +38,7 @@
* @param string $item The item name to compare with the pattern
* @return bool
*/
- public static function doesItemMatch ($pattern, $item) {
+ public static function doesItemMatch (string $pattern, string $item) : bool {
return str_is($pattern, $item);
}
@@ -47,7 +47,7 @@
*
* @return bool
*/
- public function doesItemBelong ($actualItem) {
+ public function doesItemBelong (string $actualItem) : bool {
foreach ($this->items as $candidateItem) {
if (static::doesItemMatch($candidateItem, $actualItem)) {
return true;
diff --git a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
--- a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
+++ b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
@@ -20,7 +20,7 @@
*
* @var string
*/
- public function getItemName () {
+ public function getItemName () : string {
return $this->payload->name;
}
@@ -34,7 +34,7 @@
* @param out string $status
* @return bool indicates if the build status is defined in the payload
*/
- private function tryGetBuildStatus (&$status) {
+ private function tryGetBuildStatus (string &$status) : bool {
if (!isset($this->payload->build->status)) {
return false;
}
@@ -46,7 +46,7 @@
/**
* @return bool
*/
- public function shouldNotifyOnlyOnFailure () {
+ public function shouldNotifyOnlyOnFailure () : bool {
return in_array(
$this->getItemName(),
$this->configuration->notifyOnlyOnFailure
@@ -58,7 +58,9 @@
*
* @return bool
*/
- public function isFailure () {
+ public function isFailure () : bool {
+ $status = "";
+
if (!$this->tryGetBuildStatus($status)) {
return false;
}
@@ -73,7 +75,7 @@
*
* @return bool if false, this payload is to be ignored for notifications
*/
- public function shouldNotify () {
+ public function shouldNotify () : bool {
return $this->isFailure() || !$this->shouldNotifyOnlyOnFailure();
}
diff --git a/app/Analyzers/PayloadAnalyzerConfiguration.php b/app/Analyzers/PayloadAnalyzerConfiguration.php
--- a/app/Analyzers/PayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/PayloadAnalyzerConfiguration.php
@@ -49,7 +49,7 @@
*
* @param string $project The project name this configuration is related to
*/
- public function __construct ($project) {
+ public function __construct (string $project) {
$this->project = $project;
}
@@ -63,7 +63,7 @@
* @return string the default group, as set in the configuration,
* or if omitted, the project name as fallback.
*/
- public function getDefaultGroup () {
+ public function getDefaultGroup () : string {
if (empty($this->defaultGroup)) {
return strtolower($this->project);
}
diff --git a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
--- a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
+++ b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
@@ -27,7 +27,7 @@
*
* @return bool
*/
- public function doesStoryBelong (PhabricatorStory $story) {
+ public function doesStoryBelong (PhabricatorStory $story) : bool {
foreach ($this->words as $word) {
if (stripos($story->text, $word) !== false) {
return true;
diff --git a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
--- a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
+++ b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
@@ -33,7 +33,7 @@
* @param string $project
* @param PhabricatorStory $story
*/
- public function __construct($project, PhabricatorStory $story) {
+ public function __construct(string $project, PhabricatorStory $story) {
$this->project = $project;
$this->story = $story;
@@ -49,7 +49,7 @@
*
* @return string the group, central part of the routing key
*/
- public function getGroup () {
+ public function getGroup () : string {
// If the payload is about some repository matching a table of
// symbols, we need to sort it to the right group.
foreach ($this->configuration->map as $mapping) {
diff --git a/app/Console/Commands/ConfigShow.php b/app/Console/Commands/ConfigShow.php
--- a/app/Console/Commands/ConfigShow.php
+++ b/app/Console/Commands/ConfigShow.php
@@ -5,6 +5,7 @@
use Illuminate\Console\Command;
use Nasqueron\Notifications\Features;
+use Nasqueron\Notifications\Services\Service;
use Config;
use ProjectsMap;
@@ -28,8 +29,6 @@
/**
* Creates a new command instance.
- *
- * @return void
*/
public function __construct () {
parent::__construct();
@@ -40,11 +39,11 @@
///
/**
- * Gets the services (defined in credentials.json) as table rows
+ * Gets the services (defined in credentials.json) as table rows.
*
- * @return array
+ * @return \Nasqueron\Notifications\Services\Service[]
*/
- protected function getServicesTableRows () {
+ protected function getServicesTableRows () : array {
$rows = [];
foreach (Services::get() as $service) {
$rows[] = [
@@ -58,12 +57,12 @@
}
/**
- * Gets service status
+ * Gets service status.
*
- * @param $service The service to check
+ * @param \Nasqueron\Notifications\Services\Service $service The service to check
* @return string A description of the issue if something is wrong; otherwise, "✓".
*/
- protected function getServiveStatus ($service) {
+ protected function getServiveStatus (Service $service) : string {
if ($service->gate === 'Phabricator') {
// Ensure the projects map is cached
$map = \ProjectsMap::fetch($service->door);
@@ -80,7 +79,7 @@
*
* @return array
*/
- protected function getFeaturesTableRows () {
+ protected function getFeaturesTableRows () : array {
$rows = [];
foreach (Features::getAll() as $key => $value) {
if ($value) {
@@ -100,23 +99,21 @@
/**
* Executes the console command.
- *
- * @return mixed
*/
- public function handle () {
+ public function handle () : void {
$this->printGates();
$this->printFeatures();
$this->printServices();
}
- protected final function printGates () {
+ protected final function printGates () : void {
$this->info("Gates:\n");
foreach (Config::get('gate.controllers') as $gate) {
$this->line('- ' . $gate);
}
}
- protected final function printFeatures () {
+ protected final function printFeatures () : void {
$this->info("\nFeatures:\n");
$this->table(
['Feature', 'Enabled'],
@@ -124,7 +121,7 @@
);
}
- protected final function printServices () {
+ protected final function printServices () : void {
$this->info("\nServices declared in credentials:\n");
$this->table(
['Gate', 'Door', 'Instance', 'Status'],
diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php
--- a/app/Console/Commands/Inspire.php
+++ b/app/Console/Commands/Inspire.php
@@ -5,8 +5,7 @@
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
-class Inspire extends Command
-{
+class Inspire extends Command {
/**
* The name and signature of the console command.
*
@@ -22,12 +21,9 @@
protected $description = 'Display an inspiring quote';
/**
- * Execute the console command.
- *
- * @return mixed
+ * Executes the console command.
*/
- public function handle()
- {
- $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
+ public function handle() : void {
+ $this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL);
}
}
diff --git a/app/Console/Commands/NotificationsPayload.php b/app/Console/Commands/NotificationsPayload.php
--- a/app/Console/Commands/NotificationsPayload.php
+++ b/app/Console/Commands/NotificationsPayload.php
@@ -2,6 +2,7 @@
namespace Nasqueron\Notifications\Console\Commands;
+use Nasqueron\Notifications\Notification;
use Nasqueron\Notifications\Phabricator\PhabricatorStory;
use Illuminate\Console\Command;
@@ -48,18 +49,9 @@
private $constructor;
/**
- * Creates a new command instance.
- *
- * @return void
- */
- public function __construct() {
- parent::__construct();
- }
-
- /**
* Executes the console command.
*/
- public function handle() {
+ public function handle() : void {
if ($this->parseArguments()) {
$this->printNotification();
}
@@ -70,7 +62,7 @@
*
* @return bool true if arguments looks good; otherwise, false.
*/
- private function parseArguments () {
+ private function parseArguments () : bool {
try {
$this->parseService();
$this->parsePayload();
@@ -90,7 +82,7 @@
*
* @throws InvalidArgumentException when a notification class can't be found for the requested service.
*/
- private function parseService () {
+ private function parseService () : void {
$this->service = $this->argument('service');
if (!class_exists($this->getNotificationClass())) {
@@ -105,7 +97,7 @@
*
* @throws InvalidArgumentException when payload file is not found.
*/
- private function parsePayload () {
+ private function parsePayload () : void {
$payloadFile = $this->argument('payload');
if (!file_exists($payloadFile)) {
@@ -121,7 +113,7 @@
*
* @throws InvalidArgumentException when too many or too few arguments have been given.
*/
- private function parseConstructorParameters () {
+ private function parseConstructorParameters () : void {
$keys = $this->getNotificationConstructorParameters();
$values = $this->argument('args');
@@ -154,7 +146,7 @@
*
* @throws InvalidArgumentException when keys and values counts don't match
*/
- public static function argumentsArrayCombine ($keys, $values) {
+ public static function argumentsArrayCombine (array $keys, array $values) : array {
$countKeys = count($keys);
$countValues = count($values);
@@ -171,7 +163,7 @@
*
* @return \Nasqueron\Notifications\Notification
*/
- private function getNotification () {
+ private function getNotification () : Notification {
$class = $this->getNotificationClass();
$args = array_values($this->constructor);
return new $class(...$args);
@@ -182,14 +174,14 @@
*
* @return string
*/
- private function formatNotification () {
+ private function formatNotification () : string {
return json_encode($this->getNotification(), JSON_PRETTY_PRINT);
}
/**
* Prints the notification for the service, payload and specified arguments.
*/
- private function printNotification () {
+ private function printNotification () : void {
$this->line($this->formatNotification());
}
@@ -198,7 +190,7 @@
*
* @return string
*/
- private function getNotificationClass () {
+ private function getNotificationClass () : string {
$namespace = "Nasqueron\Notifications\Notifications\\";
return $namespace . $this->service . "Notification";
}
@@ -209,7 +201,7 @@
*
* @return array
*/
- private function getNotificationConstructorParameters () {
+ private function getNotificationConstructorParameters () : array {
$parameters = [];
$class = new ReflectionClass($this->getNotificationClass());
diff --git a/app/Console/Commands/PhabricatorProjectsMap.php b/app/Console/Commands/PhabricatorProjectsMap.php
--- a/app/Console/Commands/PhabricatorProjectsMap.php
+++ b/app/Console/Commands/PhabricatorProjectsMap.php
@@ -23,20 +23,16 @@
protected $description = 'Regenerate the projects map for each Phabricator instances';
/**
- * Create a new command instance.
- *
- * @return void
+ * Creates a new command instance.
*/
public function __construct() {
parent::__construct();
}
/**
- * Execute the console command.
- *
- * @return mixed
+ * Executes the console command.
*/
- public function handle() {
+ public function handle() : void {
foreach (Services::getForGate('Phabricator') as $service) {
$this->info("Querying projects map for " . $service->instance);
$map = ProjectsMap::fetch($service->door);
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -10,7 +10,7 @@
/**
* The Artisan commands provided by your application.
*
- * @var array
+ * @var string[]
*/
protected $commands = [
\Nasqueron\Notifications\Console\Commands\ConfigShow::class,
@@ -25,8 +25,7 @@
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
- protected function schedule(Schedule $schedule)
- {
+ protected function schedule (Schedule $schedule) : void {
$schedule->command('inspire')
->hourly();
}
diff --git a/app/Events/DockerHubPayloadEvent.php b/app/Events/DockerHubPayloadEvent.php
--- a/app/Events/DockerHubPayloadEvent.php
+++ b/app/Events/DockerHubPayloadEvent.php
@@ -31,7 +31,7 @@
*
* @return string
*/
- public function getEvent () {
+ public function getEvent () : string {
if (isset($this->payload->repository->repo_url)) {
return "push";
}
diff --git a/app/Facades/Broker.php b/app/Facades/Broker.php
--- a/app/Facades/Broker.php
+++ b/app/Facades/Broker.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'broker';
}
diff --git a/app/Facades/DockerHub.php b/app/Facades/DockerHub.php
--- a/app/Facades/DockerHub.php
+++ b/app/Facades/DockerHub.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'dockerhub';
}
diff --git a/app/Facades/Mailgun.php b/app/Facades/Mailgun.php
--- a/app/Facades/Mailgun.php
+++ b/app/Facades/Mailgun.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'mailgun';
}
diff --git a/app/Facades/PhabricatorAPI.php b/app/Facades/PhabricatorAPI.php
--- a/app/Facades/PhabricatorAPI.php
+++ b/app/Facades/PhabricatorAPI.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'phabricator-api';
}
diff --git a/app/Facades/ProjectsMap.php b/app/Facades/ProjectsMap.php
--- a/app/Facades/ProjectsMap.php
+++ b/app/Facades/ProjectsMap.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'phabricator-projectsmap';
}
diff --git a/app/Facades/Raven.php b/app/Facades/Raven.php
--- a/app/Facades/Raven.php
+++ b/app/Facades/Raven.php
@@ -16,14 +16,14 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'raven';
}
/**
* Determines if a Sentry DSN is provided in the configuration
*/
- public static function isConfigured () {
+ public static function isConfigured () : bool {
return Config::get('services.sentry.dsn') !== null;
}
}
diff --git a/app/Facades/Report.php b/app/Facades/Report.php
--- a/app/Facades/Report.php
+++ b/app/Facades/Report.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'report';
}
diff --git a/app/Facades/Services.php b/app/Facades/Services.php
--- a/app/Facades/Services.php
+++ b/app/Facades/Services.php
@@ -14,7 +14,7 @@
*
* @return string
*/
- protected static function getFacadeAccessor() {
+ protected static function getFacadeAccessor() : string {
return 'services';
}
diff --git a/app/Features.php b/app/Features.php
--- a/app/Features.php
+++ b/app/Features.php
@@ -20,7 +20,7 @@
* @param string $feature The feature to get the config key
* @return string The config key
*/
- private static function getFeatureConfigKey ($feature) {
+ private static function getFeatureConfigKey (string $feature) : string {
return 'app.features.' . $feature;
}
@@ -30,7 +30,7 @@
* @param string $feature The feature to check in the config
* @return bool
*/
- public static function isEnabled ($feature) {
+ public static function isEnabled (string $feature) : bool {
$key = self::getFeatureConfigKey($feature);
return Config::has($key) && (bool)Config::get($key);
}
@@ -40,7 +40,7 @@
*
* @param string $feature The feature
*/
- public static function enable ($feature) {
+ public static function enable (string $feature) : void {
$key = self::getFeatureConfigKey($feature);
Config::set($key, true);
}
@@ -50,7 +50,7 @@
*
* @param string $feature The feature
*/
- public static function disable ($feature) {
+ public static function disable (string $feature) : void {
$key = self::getFeatureConfigKey($feature);
Config::set($key, false);
}
@@ -64,7 +64,7 @@
*
* @return array An array with features as keys, bool as values (true if enabled)
*/
- public static function getAll () {
+ public static function getAll () : array {
return Config::get('app.features');
}
@@ -73,7 +73,7 @@
*
* @return string[] a list of all features
*/
- public static function getAvailable () {
+ public static function getAvailable () : array {
$features = self::getAll();
return array_keys($features);
}
@@ -83,7 +83,7 @@
*
* @return string[] a list of enabled features
*/
- public static function getEnabled () {
+ public static function getEnabled () : array {
$features = self::getAll();
$enabledFeatures = array_filter($features);
return array_keys($enabledFeatures);
diff --git a/app/Http/Controllers/Gate/DockerHubGateController.php b/app/Http/Controllers/Gate/DockerHubGateController.php
--- a/app/Http/Controllers/Gate/DockerHubGateController.php
+++ b/app/Http/Controllers/Gate/DockerHubGateController.php
@@ -2,11 +2,13 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
+use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
+
+use Symfony\Component\HttpFoundation\Response;
+
use Event;
use Request;
-use Nasqueron\Notifications\Events\DockerHubPayloadEvent;
-
class DockerHubGateController extends GateController {
///
@@ -44,9 +46,9 @@
* Handles POST requests
*
* @param Request $request the HTTP request
- * @return \Illuminate\Http\Response
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) {
+ public function onPost ($door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
diff --git a/app/Http/Controllers/Gate/GateController.php b/app/Http/Controllers/Gate/GateController.php
--- a/app/Http/Controllers/Gate/GateController.php
+++ b/app/Http/Controllers/Gate/GateController.php
@@ -4,6 +4,10 @@
use Nasqueron\Notifications\Features;
use Nasqueron\Notifications\Http\Controllers\Controller;
+use Nasqueron\Notifications\Services\Service;
+
+use Symfony\Component\HttpFoundation\Response as BaseResponse;
+use Illuminate\View\View;
use App;
use Log;
@@ -32,7 +36,7 @@
/**
* Handles GET requests
*/
- public function onGet () {
+ public function onGet () : View {
// Virtually all the push APIs will send they payloads
// using a POST request, so we can provide a sensible
// default GET error message.
@@ -42,7 +46,7 @@
/**
* Logs the request
*/
- protected function logRequest ($extraContextualData = []) {
+ protected function logRequest (array $extraContextualData = []) : void {
Log::info('[Gate] New payload.', [
'service' => static::SERVICE_NAME,
'door' => $this->door,
@@ -56,7 +60,7 @@
/**
* Initializes the report and registers it
*/
- protected function initializeReport () {
+ protected function initializeReport () : void {
if (Features::isEnabled('ActionsReport')) {
Report::attachToGate(static::SERVICE_NAME, $this->door);
}
@@ -65,15 +69,17 @@
/**
* Renders the report
*
- * @return \Illuminate\Http\Response|null
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- protected function renderReport () {
- if (Features::isEnabled('ActionsReport')) {
- $report = App::make('report');
- $statusCode = $report->containsError() ? 503 : 200;
- return Response::json($report)
- ->setStatusCode($statusCode);
+ protected function renderReport () : BaseResponse {
+ if (!Features::isEnabled('ActionsReport')) {
+ return response("");
}
+
+ $report = App::make('report');
+ $statusCode = $report->containsError() ? 503 : 200;
+ return Response::json($report)
+ ->setStatusCode($statusCode);
}
///
@@ -83,16 +89,16 @@
/**
* Gets service credentials for this gate and door
*
- * @return \stdClass the service credentials
+ * @return Nasqueron\Notifications\Services\Service|null The service information is found; otherwise, null.
*/
- public function getService () {
+ public function getService () : ?Service {
return Services::findServiceByDoor(static::SERVICE_NAME, $this->door);
}
/**
- * Checks if a registered service exists for this service and door
+ * Checks if a registered service exists for this service and door.
*/
- protected function doesServiceExist () {
+ protected function doesServiceExist () : bool {
return $this->getService() !== null;
}
@@ -101,7 +107,7 @@
*
* @return string the secret, or if unknown, an empty string
*/
- protected function getSecret () {
+ protected function getSecret () : string {
$service= $this->getService();
if ($service !== null) {
diff --git a/app/Http/Controllers/Gate/GitHubGateController.php b/app/Http/Controllers/Gate/GitHubGateController.php
--- a/app/Http/Controllers/Gate/GitHubGateController.php
+++ b/app/Http/Controllers/Gate/GitHubGateController.php
@@ -2,11 +2,13 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
-use Event;
-use Request;
-
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
+
use Keruald\GitHub\XHubSignature;
+use Symfony\Component\HttpFoundation\Response;
+
+use Event;
+use Request;
class GitHubGateController extends GateController {
@@ -66,9 +68,9 @@
* Handles POST requests
*
* @param Request $request the HTTP request
- * @return \Illuminate\Http\Response
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) {
+ public function onPost ($door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
diff --git a/app/Http/Controllers/Gate/JenkinsGateController.php b/app/Http/Controllers/Gate/JenkinsGateController.php
--- a/app/Http/Controllers/Gate/JenkinsGateController.php
+++ b/app/Http/Controllers/Gate/JenkinsGateController.php
@@ -2,11 +2,13 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
+use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
+
+use Symfony\Component\HttpFoundation\Response;
+
use Event;
use Request;
-use Nasqueron\Notifications\Events\JenkinsPayloadEvent;
-
class JenkinsGateController extends GateController {
///
@@ -44,9 +46,9 @@
* Handles POST requests
*
* @param Request $request the HTTP request
- * @return \Illuminate\Http\Response
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) {
+ public function onPost ($door) : Response {
// Parses the request and check if it's legit
$this->door = $door;
diff --git a/app/Http/Controllers/Gate/PhabricatorGateController.php b/app/Http/Controllers/Gate/PhabricatorGateController.php
--- a/app/Http/Controllers/Gate/PhabricatorGateController.php
+++ b/app/Http/Controllers/Gate/PhabricatorGateController.php
@@ -2,11 +2,13 @@
namespace Nasqueron\Notifications\Http\Controllers\Gate;
+use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
+
+use Symfony\Component\HttpFoundation\Response;
+
use Event;
use Request;
-use Nasqueron\Notifications\Events\PhabricatorPayloadEvent;
-
class PhabricatorGateController extends GateController {
///
@@ -37,8 +39,9 @@
* Handles POST requests
*
* @param Request $request the HTTP request
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- public function onPost ($door) {
+ public function onPost ($door) : Response {
$this->door = $door;
if (!$this->doesServiceExist()) {
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
--- a/app/Http/Middleware/EncryptCookies.php
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -9,7 +9,7 @@
/**
* The names of the cookies that should not be encrypted.
*
- * @var array
+ * @var string[]
*/
protected $except = [
//
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -9,7 +9,7 @@
/**
* The URIs that should be excluded from CSRF verification.
*
- * @var array
+ * @var string[]
*/
protected $except = [
'gate/*',
diff --git a/app/Jobs/FireDockerHubNotification.php b/app/Jobs/FireDockerHubNotification.php
--- a/app/Jobs/FireDockerHubNotification.php
+++ b/app/Jobs/FireDockerHubNotification.php
@@ -31,10 +31,8 @@
/**
* Executes the job.
- *
- * @return void
*/
- public function handle() {
+ public function handle() : void {
$notification = $this->createNotification();
Event::fire(new NotificationEvent($notification));
}
@@ -45,7 +43,7 @@
* @param DockerHubPayloadEvent $event
* @return \Nasqueron\Notifications\Notification The notification
*/
- protected function createNotification() {
+ protected function createNotification() : DockerHubNotification {
return new DockerHubNotification(
$this->event->door, // project
$this->event->event, // event type
diff --git a/app/Jobs/FireGitHubNotification.php b/app/Jobs/FireGitHubNotification.php
--- a/app/Jobs/FireGitHubNotification.php
+++ b/app/Jobs/FireGitHubNotification.php
@@ -31,10 +31,8 @@
/**
* Executes the job.
- *
- * @return void
*/
- public function handle() {
+ public function handle() : void {
$notification = $this->createNotification();
Event::fire(new NotificationEvent($notification));
}
@@ -45,7 +43,7 @@
* @param GitHubPayloadEvent $event
* @return \Nasqueron\Notifications\Notification The notification
*/
- protected function createNotification() {
+ protected function createNotification() : GitHubNotification {
return new GitHubNotification(
$this->event->door, // project
$this->event->event, // event type
diff --git a/app/Jobs/FireJenkinsNotification.php b/app/Jobs/FireJenkinsNotification.php
--- a/app/Jobs/FireJenkinsNotification.php
+++ b/app/Jobs/FireJenkinsNotification.php
@@ -34,7 +34,7 @@
*
* @return void
*/
- public function handle() {
+ public function handle() : void {
$notification = $this->createNotification();
if ($notification->shouldNotify()) {
Event::fire(new NotificationEvent($notification));
@@ -47,7 +47,7 @@
* @param JenkinsPayloadEvent $event
* @return \Nasqueron\Notifications\Notification The notification
*/
- protected function createNotification() {
+ protected function createNotification() : JenkinsNotification {
return new JenkinsNotification(
$this->event->door, // project
$this->event->payload // raw content
diff --git a/app/Jobs/FirePhabricatorNotification.php b/app/Jobs/FirePhabricatorNotification.php
--- a/app/Jobs/FirePhabricatorNotification.php
+++ b/app/Jobs/FirePhabricatorNotification.php
@@ -31,10 +31,8 @@
/**
* Executes the job.
- *
- * @return void
*/
- public function handle() {
+ public function handle() : void {
$notification = $this->createNotification();
Event::fire(new NotificationEvent($notification));
}
@@ -45,7 +43,7 @@
* @param PhabricatorPayloadEvent $event
* @return \Nasqueron\Notifications\Notification The notification
*/
- protected function createNotification() {
+ protected function createNotification() : PhabricatorNotification {
return new PhabricatorNotification(
$this->event->door, // Project
$this->event->story // Story
diff --git a/app/Jobs/NotifyNewCommitsToDiffusion.php b/app/Jobs/NotifyNewCommitsToDiffusion.php
--- a/app/Jobs/NotifyNewCommitsToDiffusion.php
+++ b/app/Jobs/NotifyNewCommitsToDiffusion.php
@@ -71,7 +71,7 @@
*
* @return void
*/
- public function handle () {
+ public function handle () : void {
if (!$this->fetchRequirements()) {
return;
}
@@ -84,14 +84,14 @@
/**
* Initializes the actions report.
*/
- private function initializeReport () {
+ private function initializeReport () : void {
$this->actionToReport = new NotifyNewCommitsAction($this->callSign);
}
/**
* Notifies Phabricator to pull from the repository.
*/
- private function notifyPhabricator () {
+ private function notifyPhabricator () : void {
try {
$this->callDiffusionLookSoon();
} catch (PhabricatorAPIException $ex) {
@@ -104,7 +104,7 @@
/**
* Fires a report event with the actions report.
*/
- private function sendReport () {
+ private function sendReport () : void {
$event = new ReportEvent($this->actionToReport);
Event::fire($event);
}
@@ -119,7 +119,7 @@
*
* @return string The Phabricator project name
*/
- private function getPhabricatorProject () {
+ private function getPhabricatorProject () : string {
return $this->sourceProject;
}
@@ -132,7 +132,7 @@
*
* @return bool true if all requirement have been fetched ; otherwise, false.
*/
- private function fetchRequirements () {
+ private function fetchRequirements () : bool {
return $this->fetchAPI() && $this->fetchCallSign();
}
@@ -141,7 +141,7 @@
*
* @return bool true if an API instance has been fetch ; otherwise, false.
*/
- private function fetchAPI () {
+ private function fetchAPI () : bool {
$project = $this->getPhabricatorProject();
$this->api = PhabricatorAPI::getForProject($project);
@@ -153,7 +153,7 @@
*
* @return bool true if a call sign have been found ; otherwise, false.
*/
- private function fetchCallSign () {
+ private function fetchCallSign () : bool {
$this->callSign = $this->getCallSign();
return $this->callSign !== "";
@@ -168,7 +168,7 @@
*
* @return string the repository call sign "OPS", or "" if not in Phabricator
*/
- private function getCallSign () {
+ private function getCallSign () : string {
$reply = $this->api->call(
'repository.query',
[ 'remoteURIs[0]' => $this->repository ]
@@ -186,7 +186,7 @@
*
* @throws PhabricatorAPIException
*/
- private function callDiffusionLookSoon () {
+ private function callDiffusionLookSoon () : void {
$this->api->call(
'diffusion.looksoon',
[ 'callsigns[0]' => $this->callSign ]
diff --git a/app/Jobs/SendMessageToBroker.php b/app/Jobs/SendMessageToBroker.php
--- a/app/Jobs/SendMessageToBroker.php
+++ b/app/Jobs/SendMessageToBroker.php
@@ -50,14 +50,15 @@
///
/**
- * Create a new job instance.
+ * Creates a new job instance.
*
- * @param string $routingKey the routing key, for topic exchange
- * @param string $message the message to send
+ * @param string $target The queue or exchange to send the message to
+ * @param string $routingKey The routing key, for topic exchange
+ * @param string $message The message to send
*
* @return void
*/
- public function __construct ($target, $routingKey, $message) {
+ public function __construct (string $target, string $routingKey, string $message) {
$this->target = $target;
$this->routingKey = $routingKey;
$this->message = $message;
@@ -72,15 +73,15 @@
*
* @return void
*/
- public function handle() {
+ public function handle() : void {
$this->sendMessage();
$this->report();
}
/**
- * Sends the message to the broker
+ * Sends the message to the broker.
*/
- protected function sendMessage () {
+ protected function sendMessage () : void {
try {
Broker::setExchangeTarget($this->target, "topic", true)
->routeTo($this->routingKey)
@@ -92,9 +93,9 @@
}
/**
- * Prepares a report and fires a report event
+ * Prepares a report and fires a report event.
*/
- protected function report () {
+ protected function report () : void {
$actionToReport = new AMQPAction(
"publish",
$this->target,
diff --git a/app/Jobs/TriggerDockerHubBuild.php b/app/Jobs/TriggerDockerHubBuild.php
--- a/app/Jobs/TriggerDockerHubBuild.php
+++ b/app/Jobs/TriggerDockerHubBuild.php
@@ -50,7 +50,7 @@
*
* @return void
*/
- public function handle () {
+ public function handle () : void {
$this->initializeReport();
$this->triggerBuild();
$this->sendReport();
@@ -59,14 +59,14 @@
/**
* Initializes the actions report.
*/
- private function initializeReport () {
+ private function initializeReport () : void {
$this->actionToReport = new TriggerDockerHubBuildAction($this->image);
}
/**
* Triggers a new Docker Hub build.
*/
- private function triggerBuild () {
+ private function triggerBuild () : void {
try {
DockerHub::build($this->image);
} catch (Exception $ex) {
@@ -78,7 +78,7 @@
/**
* Fires a report event with the actions report.
*/
- private function sendReport () {
+ private function sendReport () : void {
$event = new ReportEvent($this->actionToReport);
Event::fire($event);
}
diff --git a/app/Listeners/AMQPEventListener.php b/app/Listeners/AMQPEventListener.php
--- a/app/Listeners/AMQPEventListener.php
+++ b/app/Listeners/AMQPEventListener.php
@@ -20,7 +20,7 @@
*
* @param GitHubPayloadEvent $event the payload event
*/
- protected static function getGitHubEventRoutingKey (GitHubPayloadEvent $event) {
+ protected static function getGitHubEventRoutingKey (GitHubPayloadEvent $event) : string {
$key = [
strtolower($event->door),
self::getGroup($event),
@@ -29,7 +29,7 @@
return implode('.', $key);
}
- protected static function getAnalyzer (GitHubPayloadEvent $event) {
+ protected static function getAnalyzer (GitHubPayloadEvent $event) : GitHubPayloadAnalyzer {
return new GitHubPayloadAnalyzer(
$event->door,
$event->event,
@@ -42,7 +42,7 @@
*
* @return string the group, central part of the routing key
*/
- protected static function getGroup (GitHubPayloadEvent $event) {
+ protected static function getGroup (GitHubPayloadEvent $event) : string {
$analyzer = self::getAnalyzer($event);
return $analyzer->getGroup();
}
@@ -51,9 +51,8 @@
* Handles a GitHub payload event.
*
* @param GitHubPayloadEvent $event
- * @return void
*/
- public function onGitHubPayload(GitHubPayloadEvent $event) {
+ public function onGitHubPayload(GitHubPayloadEvent $event) : void {
$this->sendRawPayload($event);
}
@@ -62,7 +61,7 @@
*
* @param GitHubPayloadEvent $event
*/
- protected function sendRawPayload(GitHubPayloadEvent $event) {
+ protected function sendRawPayload(GitHubPayloadEvent $event) : void {
$target = Config::get('broker.targets.github_events');
$routingKey = static::getGitHubEventRoutingKey($event);
$message = json_encode($event->payload);
@@ -79,9 +78,8 @@
* Handles a notification event.
*
* @param NotificationEvent $event
- * @return void
*/
- public function onNotification(NotificationEvent $event) {
+ public function onNotification(NotificationEvent $event) : void {
$this->sendNotification($event);
}
@@ -90,7 +88,7 @@
*
* @param NotificationEvent $event
*/
- protected static function getNotificationRoutingKey (Notification $notification) {
+ protected static function getNotificationRoutingKey (Notification $notification) : string {
$key = [
$notification->project,
$notification->group,
@@ -106,7 +104,7 @@
*
* @param NotificationEvent $event
*/
- protected function sendNotification(NotificationEvent $event) {
+ protected function sendNotification(NotificationEvent $event) : void {
$notification = $event->notification;
$target = Config::get('broker.targets.notifications');
@@ -126,7 +124,7 @@
*
* @param \Illuminate\Events\Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) {
+ public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
$class = 'Nasqueron\Notifications\Listeners\AMQPEventListener';
$events->listen(
'Nasqueron\Notifications\Events\GitHubPayloadEvent',
diff --git a/app/Listeners/DockerHubListener.php b/app/Listeners/DockerHubListener.php
--- a/app/Listeners/DockerHubListener.php
+++ b/app/Listeners/DockerHubListener.php
@@ -23,7 +23,7 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function onGitHubPayload (GitHubPayloadEvent $event) {
+ public function onGitHubPayload (GitHubPayloadEvent $event) : void {
if ($this->shouldNotify($event)) {
$this->notifyNewCommits($event);
}
@@ -37,7 +37,7 @@
* @param GitHubPayloadEvent $event The GitHub payload event
* @return bool
*/
- public function shouldNotify (GitHubPayloadEvent $event) {
+ public function shouldNotify (GitHubPayloadEvent $event) : bool {
return $event->event === 'push'
&& DockerHub::hasToken($this->getRepository($event));
}
@@ -47,7 +47,7 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function notifyNewCommits (GitHubPayloadEvent $event) {
+ public function notifyNewCommits (GitHubPayloadEvent $event) : void {
$job = new TriggerDockerHubBuild($this->getRepository($event));
$job->handle();
}
@@ -57,7 +57,7 @@
*
* @var string
*/
- private function getRepository (GitHubPayloadEvent $event) {
+ private function getRepository (GitHubPayloadEvent $event) : string {
return $event->payload->repository->full_name;
}
@@ -70,7 +70,7 @@
*
* @param Dispatcher $events
*/
- public function subscribe (Dispatcher $events) {
+ public function subscribe (Dispatcher $events) : void {
$class = DockerHubListener::class;
$events->listen(
GitHubPayloadEvent::class,
diff --git a/app/Listeners/LastPayloadSaver.php b/app/Listeners/LastPayloadSaver.php
--- a/app/Listeners/LastPayloadSaver.php
+++ b/app/Listeners/LastPayloadSaver.php
@@ -12,16 +12,16 @@
/**
* Handles payload events
*/
- public function onPayload (Event $event) {
+ public function onPayload (Event $event) : void {
self::savePayload($event->payload);
}
/**
* Saves payload to log file
*
- * @param string $payload The payload to save
+ * @param mixed $payload The payload to save
*/
- public static function savePayload ($payload) {
+ public static function savePayload ($payload) : void {
$filename = storage_path('logs/payload.json');
$content = json_encode($payload);
file_put_contents($filename, $content);
@@ -36,7 +36,7 @@
*
* @param \Illuminate\Events\Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) {
+ public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
$ns = 'Nasqueron\Notifications\Events';
$class = 'Nasqueron\Notifications\Listeners\LastPayloadSaver';
$eventsToListen = [
diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php
--- a/app/Listeners/NotificationListener.php
+++ b/app/Listeners/NotificationListener.php
@@ -23,7 +23,7 @@
* @param DockerHubPayloadEvent $event
* @return void
*/
- public function onDockerHubPayload(DockerHubPayloadEvent $event) {
+ public function onDockerHubPayload(DockerHubPayloadEvent $event) : void {
$job = new FireDockerHubNotification($event);
$job->handle();
}
@@ -34,7 +34,7 @@
* @param GitHubPayloadEvent $event
* @return void
*/
- public function onGitHubPayload(GitHubPayloadEvent $event) {
+ public function onGitHubPayload(GitHubPayloadEvent $event) : void {
$job = new FireGitHubNotification($event);
$job->handle();
}
@@ -45,7 +45,7 @@
* @param PhabricatorPayloadEvent $event
* @return void
*/
- public function onPhabricatorPayload(PhabricatorPayloadEvent $event) {
+ public function onPhabricatorPayload(PhabricatorPayloadEvent $event) : void {
$job = new FirePhabricatorNotification($event);
$job->handle();
}
@@ -56,7 +56,7 @@
* @param JenkinsPayloadEvent $event
* @return void
*/
- public function onJenkinsPayload (JenkinsPayloadEvent $event) {
+ public function onJenkinsPayload (JenkinsPayloadEvent $event) : void {
$job = new FireJenkinsNotification($event);
$job->handle();
}
@@ -70,7 +70,7 @@
*
* @param \Illuminate\Events\Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) {
+ public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
$class = 'Nasqueron\Notifications\Listeners\NotificationListener';
$events->listen(
'Nasqueron\Notifications\Events\DockerHubPayloadEvent',
diff --git a/app/Listeners/PhabricatorListener.php b/app/Listeners/PhabricatorListener.php
--- a/app/Listeners/PhabricatorListener.php
+++ b/app/Listeners/PhabricatorListener.php
@@ -21,7 +21,7 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function onGitHubPayload (GitHubPayloadEvent $event) {
+ public function onGitHubPayload (GitHubPayloadEvent $event) : void {
if ($event->event === 'push') {
$this->notifyNewCommits($event);
}
@@ -32,7 +32,7 @@
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
- public function notifyNewCommits (GitHubPayloadEvent $event) {
+ public function notifyNewCommits (GitHubPayloadEvent $event) : void {
$job = new NotifyNewCommitsToDiffusion(
$event->door,
$event->payload->repository->clone_url
@@ -49,7 +49,7 @@
*
* @param Dispatcher $events
*/
- public function subscribe (Dispatcher $events) {
+ public function subscribe (Dispatcher $events) : void {
$class = PhabricatorListener::class;
$events->listen(
GitHubPayloadEvent::class,
diff --git a/app/Notifications/DockerHubNotification.php b/app/Notifications/DockerHubNotification.php
--- a/app/Notifications/DockerHubNotification.php
+++ b/app/Notifications/DockerHubNotification.php
@@ -2,6 +2,7 @@
namespace Nasqueron\Notifications\Notifications;
+use Nasqueron\Notifications\Analyzers\DockerHub\BaseEvent;
use Nasqueron\Notifications\Notification;
use InvalidArgumentException;
@@ -27,7 +28,7 @@
*/
class DockerHubNotification extends Notification {
- public function __construct ($project, $event, $payload) {
+ public function __construct (string $project, string $event, \stdClass $payload) {
// Straightforward properties
$this->service = "DockerHub";
$this->project = $project;
@@ -46,7 +47,7 @@
/**
* Fills properties from event payload.
*/
- public function analyzeByEvent () {
+ public function analyzeByEvent () : void {
$analyzer = $this->getAnalyzer();
$this->rawContent = $analyzer->getPayload();
$this->text = $analyzer->getText();
@@ -58,7 +59,7 @@
*
* @return string
*/
- private function getAnalyzerClassName () {
+ private function getAnalyzerClassName () : string {
return "Nasqueron\Notifications\Analyzers\DockerHub\\"
. ucfirst($this->type)
. "Event";
@@ -69,7 +70,7 @@
*
* @return \Nasqueron\Notifications\Analyzers\DockerHub\BaseEvent
*/
- private function getAnalyzer () {
+ private function getAnalyzer () : BaseEvent {
$class = $this->getAnalyzerClassName();
if (!class_exists($class)) {
diff --git a/app/Notifications/GitHubNotification.php b/app/Notifications/GitHubNotification.php
--- a/app/Notifications/GitHubNotification.php
+++ b/app/Notifications/GitHubNotification.php
@@ -12,7 +12,7 @@
*/
private $analyzer = null;
- public function __construct ($project, $event, $payload) {
+ public function __construct (string $project, string $event, \stdClass $payload) {
// Straightforward properties
$this->service = "GitHub";
$this->project = $project;
@@ -28,7 +28,7 @@
/**
* Gets analyzer
*/
- private function getAnalyzer () {
+ private function getAnalyzer () : GitHubPayloadAnalyzer {
if ($this->analyzer === null) {
$this->analyzer = new GitHubPayloadAnalyzer(
$this->project,
@@ -44,7 +44,7 @@
*
* @return string the target group for the notification
*/
- public function getGroup () {
+ public function getGroup () : string {
return $this->getAnalyzer()->getGroup();
}
@@ -53,7 +53,7 @@
*
* @return string
*/
- public function getText () {
+ public function getText () : string {
return $this->getAnalyzer()->getDescription();
}
@@ -62,7 +62,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return $this->getAnalyzer()->getLink();
}
diff --git a/app/Notifications/JenkinsNotification.php b/app/Notifications/JenkinsNotification.php
--- a/app/Notifications/JenkinsNotification.php
+++ b/app/Notifications/JenkinsNotification.php
@@ -42,7 +42,7 @@
*
* @return string
*/
- public function getType () {
+ public function getType () : string {
$build = $this->rawContent->build;
$type = strtolower($build->phase);
@@ -60,7 +60,7 @@
*
* @return string
*/
- public function getText () {
+ public function getText () : string {
$name = $this->rawContent->name;
$build = $this->rawContent->build;
@@ -81,7 +81,7 @@
*
* @return \Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzer
*/
- private function getAnalyzer () {
+ private function getAnalyzer () : JenkinsPayloadAnalyzer {
if ($this->analyzer === null) {
$this->analyzer = new JenkinsPayloadAnalyzer(
$this->project,
@@ -96,7 +96,7 @@
*
* @return string
*/
- public function getGroup () {
+ public function getGroup () : string {
return $this->getAnalyzer()->getGroup();
}
@@ -105,7 +105,7 @@
*
* @return bool if false, this payload is to be ignored for notifications
*/
- public function shouldNotify () {
+ public function shouldNotify () : bool {
return $this->getAnalyzer()->shouldNotify();
}
diff --git a/app/Notifications/PhabricatorNotification.php b/app/Notifications/PhabricatorNotification.php
--- a/app/Notifications/PhabricatorNotification.php
+++ b/app/Notifications/PhabricatorNotification.php
@@ -19,7 +19,7 @@
* @param string $project The project for this notification
* @param PhabricatorStory $payload The story to convert into a notification
*/
- public function __construct ($project, PhabricatorStory $payload) {
+ public function __construct (string $project, PhabricatorStory $payload) {
// Straightforward properties
$this->service = "Phabricator";
$this->project = $project;
@@ -37,7 +37,7 @@
*
* @return \Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzer
*/
- private function getAnalyzer () {
+ private function getAnalyzer () : PhabricatorPayloadAnalyzer {
if ($this->analyzer === null) {
$this->analyzer = new PhabricatorPayloadAnalyzer(
$this->project,
@@ -52,7 +52,7 @@
*
* @return string the target group for the notification
*/
- public function getGroup () {
+ public function getGroup () : string {
return $this->getAnalyzer()->getGroup();
}
@@ -61,7 +61,7 @@
*
* @return string
*/
- public function getLink () {
+ public function getLink () : string {
return "";
}
diff --git a/app/Services/Service.php b/app/Services/Service.php
--- a/app/Services/Service.php
+++ b/app/Services/Service.php
@@ -28,7 +28,7 @@
*
* @return string The instance name or "ø" if omitted
*/
- public function getInstanceName () {
+ public function getInstanceName () : string {
if (!isset($this->instance)) {
return "ø";
}
diff --git a/app/Services/Services.php b/app/Services/Services.php
--- a/app/Services/Services.php
+++ b/app/Services/Services.php
@@ -22,10 +22,10 @@
/**
* Initializes a new instance of the Services class deserializing a JSON file.
*
- * @param $file the JSON file to deserialize
- * @return Services the deserialized instance
+ * @param string $file The JSON file to deserialize
+ * @return Services The deserialized instance
*/
- public static function loadFromJson ($file) {
+ public static function loadFromJson (string $file) : Services {
$data = json_decode(Storage::get($file));
$mapper = new \JsonMapper();
@@ -37,21 +37,21 @@
///
/**
- * Gets the services found in credentials.json
+ * Gets the services found in credentials.json configuration file.
*
- * @return array
+ * @return Service[]
*/
public function get () {
return $this->services;
}
/**
- * Gets all the services for a specific gate
+ * Gets all the services for a specific gate.
*
* @param string $gate The gate (e.g. GitHub)
- * @return array
+ * @return Service[]
*/
- public function getForGate ($gate) {
+ public function getForGate (string $gate) : array {
$services = [];
foreach ($this->services as $service) {
@@ -72,9 +72,9 @@
*
* @param string $gate The gate (e.g. GitHub)
* @param string $door The door (e.g. Nasqueron)
- * @return \stdClass|null The service information is found; otherwise, null.
+ * @return Service|null The service information is found; otherwise, null.
*/
- public function findServiceByDoor ($gate, $door) {
+ public function findServiceByDoor (string $gate, string $door) : ?Service {
foreach ($this->services as $service) {
if ($service->gate === $gate && $service->door === $door) {
return $service;
@@ -90,9 +90,9 @@
* @param string $gate The gate (e.g. Phabricator)
* @param string $property The property to check (e.g. instance)
* @param mixed $value The property value to find (e.g. 'http://devcentral.nasqueron.org')
- * @return \stdClass|null The service information is found; otherwise, null.
+ * @return Service|null The service information is found; otherwise, null.
*/
- public function findServiceByProperty ($gate, $property, $value) {
+ public function findServiceByProperty (string $gate, string $property, $value) : ?Service {
foreach ($this->services as $service) {
if ($service->gate === $gate && $service->$property === $value) {
return $service;
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -69,7 +69,7 @@
///
/**
- * @expectedException InvalidArgumentException
+ * @expectedException TypeError
*/
public function testConstructorThrowsAnExceptionWhenPayloadIsInvalid () {
new GitHubPayloadAnalyzer(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 03:31 (1 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2484871
Default Alt Text
D784.id1983.diff (69 KB)
Attached To
Mode
D784: Declare explicitely return types
Attached
Detach File
Event Timeline
Log In to Comment