diff --git a/app/Analyzers/DockerHub/BaseEvent.php b/app/Analyzers/DockerHub/BaseEvent.php --- a/app/Analyzers/DockerHub/BaseEvent.php +++ b/app/Analyzers/DockerHub/BaseEvent.php @@ -14,7 +14,7 @@ * * @param \stdClass $payload The payload to analyze */ - public function __construct ($payload) { + public function __construct (\stdClass $payload) { $this->payload = $payload; } diff --git a/app/Analyzers/DockerHub/BuildFailureEvent.php b/app/Analyzers/DockerHub/BuildFailureEvent.php --- a/app/Analyzers/DockerHub/BuildFailureEvent.php +++ b/app/Analyzers/DockerHub/BuildFailureEvent.php @@ -11,7 +11,7 @@ * * @param \stdClass $payload The payload to analyze */ - public function __construct ($payload) { + public function __construct (\stdClass $payload) { parent::__construct($payload); $this->payload = $this->getMailGunPayload(); } 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 @@ -13,9 +13,10 @@ * Determines if the action is valid. * * @param string $action The action to check + * * @return bool true if the action is valid; otherwise, false */ - protected static function isValidAction ($action) { + protected static function isValidAction (string $action) { $actions = ['created', 'deleted', 'publicized', 'privatized']; return in_array($action, $actions); } diff --git a/app/Analyzers/GitHub/Events/WithCommit.php b/app/Analyzers/GitHub/Events/WithCommit.php --- a/app/Analyzers/GitHub/Events/WithCommit.php +++ b/app/Analyzers/GitHub/Events/WithCommit.php @@ -23,9 +23,10 @@ * Extracts the commit title from the whole commit message. * * @param string $message The commit message + * * @return string The commit title */ - public static function getCommitTitle ($message) { + public static function getCommitTitle (string $message) { // Discards extra lines $pos = strpos($message, "\n"); if ($pos > 0) { diff --git a/app/Config/Services/Services.php b/app/Config/Services/Services.php --- a/app/Config/Services/Services.php +++ b/app/Config/Services/Services.php @@ -94,7 +94,7 @@ public function findServiceByProperty ( string $gate, string $property, - $value + mixed $value ) : ?Service { foreach ($this->services as $service) { if ($service->gate === $gate && $service->$property === $value) { diff --git a/app/Events/DockerHubPayloadEvent.php b/app/Events/DockerHubPayloadEvent.php --- a/app/Events/DockerHubPayloadEvent.php +++ b/app/Events/DockerHubPayloadEvent.php @@ -41,10 +41,10 @@ /** * Creates a new event instance. * - * @param string $door + * @param string $door * @param \stdClass $payload */ - public function __construct($door, $payload) { + public function __construct(string $door, \stdClass $payload) { $this->door = $door; $this->payload = $payload; $this->event = $this->getEvent(); diff --git a/app/Events/GitHubPayloadEvent.php b/app/Events/GitHubPayloadEvent.php --- a/app/Events/GitHubPayloadEvent.php +++ b/app/Events/GitHubPayloadEvent.php @@ -28,11 +28,11 @@ /** * Creates a new event instance. * - * @param string $door - * @param string $event + * @param string $door + * @param string $event * @param \stdClass $payload */ - public function __construct($door, $event, $payload) { + public function __construct(string $door, string $event, \stdClass $payload) { $this->door = $door; $this->event = $event; $this->payload = $payload; diff --git a/app/Events/JenkinsPayloadEvent.php b/app/Events/JenkinsPayloadEvent.php --- a/app/Events/JenkinsPayloadEvent.php +++ b/app/Events/JenkinsPayloadEvent.php @@ -22,10 +22,10 @@ /** * Creates a new event instance. * - * @param string $door + * @param string $door * @param \stdClass $payload */ - public function __construct($door, $payload) { + public function __construct(string $door, \stdClass $payload) { $this->door = $door; $this->payload = $payload; } diff --git a/app/Listeners/LastPayloadSaver.php b/app/Listeners/LastPayloadSaver.php --- a/app/Listeners/LastPayloadSaver.php +++ b/app/Listeners/LastPayloadSaver.php @@ -21,7 +21,7 @@ * * @param mixed $payload The payload to save */ - public static function savePayload ($payload) : void { + public static function savePayload (mixed $payload) : void { $filename = storage_path('logs/payload.json'); $content = json_encode($payload); file_put_contents($filename, $content); diff --git a/app/Notifications/JenkinsNotification.php b/app/Notifications/JenkinsNotification.php --- a/app/Notifications/JenkinsNotification.php +++ b/app/Notifications/JenkinsNotification.php @@ -21,9 +21,9 @@ * Initializes a new instance of the JenkinsNotification class. * * @param string $project The project this message is for - * @param mixed $payload The message fired by Jenkins notification plugin + * @param mixed $payload The message fired by Jenkins notification plugin */ - public function __construct ($project, $payload) { + public function __construct (string $project, mixed $payload) { // Straightforward properties $this->service = "Jenkins"; $this->project = $project; diff --git a/app/Phabricator/PhabricatorAPI.php b/app/Phabricator/PhabricatorAPI.php --- a/app/Phabricator/PhabricatorAPI.php +++ b/app/Phabricator/PhabricatorAPI.php @@ -35,7 +35,7 @@ * @param string $endPoint The Phabricator main URL, without trailing slash * @param string $apiToken The token generated at /settings/panel/apitokens/ */ - public function __construct ($endPoint, $apiToken) { + public function __construct (string $endPoint, string $apiToken) { $this->endPoint = $endPoint; $this->apiToken = $apiToken; } @@ -79,18 +79,19 @@ * * @param string $url The API end point URL */ - public function setEndPoint ($url) { + public function setEndPoint (string $url) { $this->endPoint = $url; } /** * Calls a Conduit API method * - * @param string $method The method to call (e.g. repository.create) - * @param array $arguments The arguments to use + * @param string $method The method to call (e.g. repository.create) + * @param array $arguments The arguments to use + * * @return mixed The API result */ - public function call ($method, $arguments = []) { + public function call (string $method, array $arguments = []) { $url = $this->endPoint . '/api/' . $method; $arguments['api.token'] = $this->apiToken; @@ -114,9 +115,10 @@ * Gets the first result of an API reply. * * @param iterable $reply + * * @return mixed */ - public static function getFirstResult ($reply) { + public static function getFirstResult (iterable $reply) { if (is_object($reply) && property_exists($reply, 'data')) { $reply = $reply->data; } diff --git a/app/Phabricator/PhabricatorAPIFactory.php b/app/Phabricator/PhabricatorAPIFactory.php --- a/app/Phabricator/PhabricatorAPIFactory.php +++ b/app/Phabricator/PhabricatorAPIFactory.php @@ -10,9 +10,10 @@ * Gets an instance of the Phabricator API client class. * * @param string $instance The Phabricator instance + * * @return \Nasqueron\Notifications\Phabricator\PhabricatorAPI */ - public function get ($instance) { + public function get (string $instance) { return PhabricatorAPI::forInstance($instance); } @@ -20,9 +21,10 @@ * Gets an instance of the Phabricator API client class for a project. * * @param string $project The Phabricator project name + * * @return PhabricatorAPI */ - public function getForProject ($project) { + public function getForProject (string $project) { return PhabricatorAPI::forProject($project); } } diff --git a/app/Phabricator/PhabricatorStory.php b/app/Phabricator/PhabricatorStory.php --- a/app/Phabricator/PhabricatorStory.php +++ b/app/Phabricator/PhabricatorStory.php @@ -76,7 +76,7 @@ * * @param string $instanceName The Phabricator instance name */ - public function __construct ($instanceName) { + public function __construct (string $instanceName) { $this->instanceName = $instanceName; } @@ -186,9 +186,10 @@ * Gets the PHID of a repository * * @param string $method The API method to call (e.g. differential.query) + * * @return string The repository PHID or "" if not found */ - public function getRepositoryPHID ($method) { + public function getRepositoryPHID (string $method) { $objectPHID = $this->data['objectPHID']; $api = PhabricatorAPI::forProject($this->instanceName); @@ -216,11 +217,12 @@ /** * Gets the projects for a specific item * - * @param string $method The API method to call (e.g. differential.query) + * @param string $method The API method to call (e.g. differential.query) * @param string $objectPHID The object PHID to pass as method parameter + * * @return string[] The list of project PHIDs */ - public function getItemProjectsPHIDs ($method, $objectPHID) { + public function getItemProjectsPHIDs (string $method, string $objectPHID) { if (!$objectPHID) { return []; } @@ -314,9 +316,10 @@ * Maps a field of the API reply to a property of the PhabricatorStory class * * @param string $key The field of the API reply + * * @return string The property's name */ - public static function mapPhabricatorFeedKey ($key) { + public static function mapPhabricatorFeedKey (string $key) { if ($key == "storyID") { return "id"; } diff --git a/app/Phabricator/ProjectsMap.php b/app/Phabricator/ProjectsMap.php --- a/app/Phabricator/ProjectsMap.php +++ b/app/Phabricator/ProjectsMap.php @@ -54,7 +54,7 @@ * * @param string $instanceName The Phabricator instance name */ - public function __construct ($instanceName) { + public function __construct (string $instanceName) { $this->instanceName = $instanceName; } @@ -81,7 +81,7 @@ * @param mixed $offset The offset * @return bool */ - public function offsetExists ($offset) { + public function offsetExists (mixed $offset) { return array_key_exists($offset, $this->map); } @@ -91,7 +91,7 @@ * @param mixed $offset The offset. * @return mixed The value */ - public function offsetGet ($offset) { + public function offsetGet (mixed $offset) { return $this->map[$offset]; } @@ -101,7 +101,7 @@ * @param mixed $offset The offset * @param mixed $value The value to assign */ - public function offsetSet ($offset, $value) { + public function offsetSet (mixed $offset, mixed $value) { $this->map[$offset] = $value; } @@ -110,7 +110,7 @@ * * @param mixed $offset The offset where to remove the value */ - public function offsetUnset ($offset) { + public function offsetUnset (mixed $offset) { unset($this->map[$offset]); } @@ -122,9 +122,10 @@ * Gets a new ProjectsMap instance from cache or API when not cached. * * @param string $phabricatorInstanceName The Phabricator instance name + * * @return ProjectsMap */ - public static function load ($phabricatorInstanceName) { + public static function load (string $phabricatorInstanceName) { $instance = new self($phabricatorInstanceName); if ($instance->isCached()) { @@ -255,9 +256,10 @@ * Gets project name, refreshing the cache if needed. * * @param string $projectPHID the PHID of the project to query the name + * * @return string The name of the poject, or an empty string if not found */ - public function getProjectName ($projectPHID) { + public function getProjectName (string $projectPHID) { if ($this->offsetExists($projectPHID)) { return $this->offsetGet($projectPHID); }