Code formatting

This commit is contained in:
Cédric Belin
2019-04-15 19:22:15 +02:00
parent 94c3cddd21
commit 76e8cfa0a4
13 changed files with 91 additions and 273 deletions

View File

@ -4,14 +4,10 @@ use Robo\{Result, Tasks};
// Load the dependencies. // Load the dependencies.
require_once __DIR__.'/vendor/autoload.php'; require_once __DIR__.'/vendor/autoload.php';
/** /** Provides tasks for the build system. */
* Provides tasks for the build system.
*/
class RoboFile extends Tasks { class RoboFile extends Tasks {
/** /** Creates a new task runner. */
* Creates a new task runner.
*/
function __construct() { function __construct() {
$path = (string) getenv('PATH'); $path = (string) getenv('PATH');
$vendor = (string) realpath('vendor/bin'); $vendor = (string) realpath('vendor/bin');
@ -100,8 +96,6 @@ class RoboFile extends Tasks {
* @return Result The task result. * @return Result The task result.
*/ */
function watch(): Result { function watch(): Result {
return $this->taskWatch() return $this->taskWatch()->monitor('test', function() { $this->test(); })->run();
->monitor('test', function() { $this->test(); })
->run();
} }
} }

View File

@ -5,59 +5,37 @@ use Gitea\Models\{PayloadCommit, Repository, User};
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
/** /** Represents a Gitea push event. */
* Represents a Gitea push event.
*/
class PushEvent implements \JsonSerializable { class PushEvent implements \JsonSerializable {
/** /** @var string The hash of the new Git revision. */
* @var string The hash of the new Git revision.
*/
private $after = ''; private $after = '';
/** /** @var string The hash of the previous Git revision. */
* @var string The hash of the previous Git revision.
*/
private $before = ''; private $before = '';
/** /** @var \ArrayObject The revision commits. */
* @var \ArrayObject The revision commits.
*/
private $commits; private $commits;
/** /** @var UriInterface|null The URL for comparing the revisions. */
* @var UriInterface|null The URL for comparing the revisions.
*/
private $compareUrl; private $compareUrl;
/** /** @var User|null The user who pushed the commits. */
* @var User|null The user who pushed the commits.
*/
private $pusher; private $pusher;
/** /** @var string The Git reference. */
* @var string The Git reference.
*/
private $ref = ''; private $ref = '';
/** /** @var Repository|null The repository where the commits were pushed. */
* @var Repository|null The repository where the commits were pushed.
*/
private $repository; private $repository;
/** /** @var string The secret used to validate this event. */
* @var string The secret used to validate this event.
*/
private $secret = ''; private $secret = '';
/** /** @var User|null The user who sent this event. */
* @var User|null The user who sent this event.
*/
private $sender; private $sender;
/** /** Creates a new event. */
* Creates a new event.
*/
function __construct() { function __construct() {
$this->commits = new \ArrayObject; $this->commits = new \ArrayObject;
} }

View File

@ -4,44 +4,28 @@ namespace Gitea\Models;
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
/** /** Represents a commit. */
* Represents a commit.
*/
class PayloadCommit implements \JsonSerializable { class PayloadCommit implements \JsonSerializable {
/** /** @var PayloadUser|null The person who authored the commit. */
* @var PayloadUser|null The person who authored the commit.
*/
private $author; private $author;
/** /** @var PayloadUser|null The person who committed the code. */
* @var PayloadUser|null The person who committed the code.
*/
private $committer; private $committer;
/** /** @var string The commit hash. */
* @var string The commit hash.
*/
private $id; private $id;
/** /** @var string The commit message. */
* @var string The commit message.
*/
private $message; private $message;
/** /** @var \DateTime|null The commit date. */
* @var \DateTime|null The commit date.
*/
private $timestamp; private $timestamp;
/** /** @var UriInterface|null The URL to the commit's history. */
* @var UriInterface|null The URL to the commit's history.
*/
private $url; private $url;
/** /** @var PayloadCommitVerification|null The GPG verification of this commit. */
* @var PayloadCommitVerification|null The GPG verification of this commit.
*/
private $verification; private $verification;
/** /**

View File

@ -1,29 +1,19 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Represents the GPG verification of a commit. */
* Represents the GPG verification of a commit.
*/
class PayloadCommitVerification implements \JsonSerializable { class PayloadCommitVerification implements \JsonSerializable {
/** /** @var bool Value indicating whether the verification has succeeded. */
* @var bool Value indicating whether the verification has succeeded.
*/
private $isVerified; private $isVerified;
/** /** @var string A custom message sent with the verification request. */
* @var string A custom message sent with the verification request.
*/
private $payload = ''; private $payload = '';
/** /** @var string A message providing details about the verification. */
* @var string A message providing details about the verification.
*/
private $reason = ''; private $reason = '';
/** /** @var string The signing key used for the verification. */
* @var string The signing key used for the verification.
*/
private $signature = ''; private $signature = '';
/** /**

View File

@ -1,24 +1,16 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Represents the author or committer of a commit. */
* Represents the author or committer of a commit.
*/
class PayloadUser implements \JsonSerializable { class PayloadUser implements \JsonSerializable {
/** /** @var string The mail address. */
* @var string The mail address.
*/
private $email = ''; private $email = '';
/** /** @var string The full name. */
* @var string The full name.
*/
private $name = ''; private $name = '';
/** /** @var string The name of the Gitea account. */
* @var string The name of the Gitea account.
*/
private $username; private $username;
/** /**

View File

@ -1,24 +1,16 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Represents a set of permissions. */
* Represents a set of permissions.
*/
class Permission implements \JsonSerializable { class Permission implements \JsonSerializable {
/** /** @var bool Value indicating whether administrator access is allowed. */
* @var bool Value indicating whether administrator access is allowed.
*/
private $admin; private $admin;
/** /** @var bool Value indicating whether pull is allowed. */
* @var bool Value indicating whether pull is allowed.
*/
private $pull; private $pull;
/** /** @var bool Value indicating whether push is allowed. */
* @var bool Value indicating whether push is allowed.
*/
private $push; private $push;
/** /**

View File

@ -4,124 +4,76 @@ namespace Gitea\Models;
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
/** /** Represents a repository. */
* Represents a repository.
*/
class Repository implements \JsonSerializable { class Repository implements \JsonSerializable {
/** /** @var UriInterface|null The HTTP-based URL for cloning this repository. */
* @var UriInterface|null The HTTP-based URL for cloning this repository.
*/
private $cloneUrl; private $cloneUrl;
/** /** @var \DateTime|null The date the repository was created. */
* @var \DateTime|null The date the repository was created.
*/
private $createdAt; private $createdAt;
/** /** @var string The name of the default branch. */
* @var string The name of the default branch.
*/
private $defaultBranch = ''; private $defaultBranch = '';
/** /** @var string The repository description. */
* @var string The repository description.
*/
private $description = ''; private $description = '';
/** /** @var int The number of forks of this repository. */
* @var int The number of forks of this repository.
*/
private $forksCount = 0; private $forksCount = 0;
/** /** @var string The full name. */
* @var string The full name.
*/
private $fullName; private $fullName;
/** /** @var UriInterface|null The Gitea URL of this repository. */
* @var UriInterface|null The Gitea URL of this repository.
*/
private $htmlUrl; private $htmlUrl;
/** /** @var int The repository identifier. */
* @var int The repository identifier.
*/
private $id; private $id;
/** /** @var bool Value indicating whether this repository is empty. */
* @var bool Value indicating whether this repository is empty.
*/
private $isEmpty = true; private $isEmpty = true;
/** /** @var bool Value indicating whether this repository is a fork. */
* @var bool Value indicating whether this repository is a fork.
*/
private $isFork = false; private $isFork = false;
/** /** @var bool Value indicating whether this repository is a mirror. */
* @var bool Value indicating whether this repository is a mirror.
*/
private $isMirror = false; private $isMirror = false;
/** /** @var bool Value indicating whether this repository is private. */
* @var bool Value indicating whether this repository is private.
*/
private $isPrivate = false; private $isPrivate = false;
/** /** @var string The repository name. */
* @var string The repository name.
*/
private $name = ''; private $name = '';
/** /** @var int The number of open issues of this repository. */
* @var int The number of open issues of this repository.
*/
private $openIssuesCount = 0; private $openIssuesCount = 0;
/** /** @var User|null The repository owner. */
* @var User|null The repository owner.
*/
private $owner; private $owner;
/** /** @var Repository|null The parent repository, if this repository is a fork or a mirror. */
* @var Repository|null The parent repository, if this repository is a fork or a mirror.
*/
private $parent; private $parent;
/** /** @var Permission|null The repository permissions. */
* @var Permission|null The repository permissions.
*/
private $permissions; private $permissions;
/** /** @var int The repository size, in kilobytes. */
* @var int The repository size, in kilobytes.
*/
private $size = 0; private $size = 0;
/** /** @var UriInterface|null The SSH-based URL for cloning this repository. */
* @var UriInterface|null The SSH-based URL for cloning this repository.
*/
private $sshUrl; private $sshUrl;
/** /** @var int The number of stars of this repository. */
* @var int The number of stars of this repository.
*/
private $starsCount = 0; private $starsCount = 0;
/** /** @var \DateTime|null The date the repository was updated. */
* @var \DateTime|null The date the repository was updated.
*/
private $updatedAt; private $updatedAt;
/** /** @var int The number of watchers of this repository. */
* @var int The number of watchers of this repository.
*/
private $watchersCount = 0; private $watchersCount = 0;
/** /** @var UriInterface|null The URL of the repository website. */
* @var UriInterface|null The URL of the repository website.
*/
private $website; private $website;
/** /**

View File

@ -1,14 +1,10 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Wraps the version of the Gitea server. */
* Wraps the version of the Gitea server.
*/
class ServerVersion implements \JsonSerializable { class ServerVersion implements \JsonSerializable {
/** /** @var string The version number. */
* @var string The version number.
*/
private $version; private $version;
/** /**

View File

@ -3,34 +3,22 @@ namespace Gitea\Models;
use Enum\{EnumTrait}; use Enum\{EnumTrait};
/** /** Defines the state of a Gitea status. */
* Defines the state of a Gitea status.
*/
final class StatusState { final class StatusState {
use EnumTrait; use EnumTrait;
/** /** @var string The status is an error. */
* @var string The status is an error.
*/
const ERROR = 'error'; const ERROR = 'error';
/** /** @var string The status is a failure. */
* @var string The status is a failure.
*/
const FAILURE = 'failure'; const FAILURE = 'failure';
/** /** @var string The status is pending. */
* @var string The status is pending.
*/
const PENDING = 'pending'; const PENDING = 'pending';
/** /** @var string The status is a success. */
* @var string The status is a success.
*/
const SUCCESS = 'success'; const SUCCESS = 'success';
/** /** @var string The status is a warning. */
* @var string The status is a warning.
*/
const WARNING = 'warning'; const WARNING = 'warning';
} }

View File

@ -1,29 +1,19 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Represents a team in an organization. */
* Represents a team in an organization.
*/
class Team implements \JsonSerializable { class Team implements \JsonSerializable {
/** /** @var string The team description. */
* @var string The team description.
*/
private $description = ''; private $description = '';
/** /** @var int The team identifier. */
* @var int The team identifier.
*/
private $id; private $id;
/** /** @var string The team name. */
* @var string The team name.
*/
private $name; private $name;
/** /** @var string The team permission. */
* @var string The team permission.
*/
private $permission = TeamPermission::NONE; private $permission = TeamPermission::NONE;
/** /**

View File

@ -3,34 +3,22 @@ namespace Gitea\Models;
use Enum\{EnumTrait}; use Enum\{EnumTrait};
/** /** Defines the permission of a team. */
* Defines the permission of a team.
*/
final class TeamPermission { final class TeamPermission {
use EnumTrait; use EnumTrait;
/** /** @var string The team has the administrator permission. */
* @var string The team has the administrator permission.
*/
const ADMIN = 'admin'; const ADMIN = 'admin';
/** /** @var string The team doesn't have any permission. */
* @var string The team doesn't have any permission.
*/
const NONE = 'none'; const NONE = 'none';
/** /** @var string The team has the owner permission. */
* @var string The team has the owner permission.
*/
const OWNER = 'owner'; const OWNER = 'owner';
/** /** @var string The team has the read permission. */
* @var string The team has the read permission.
*/
const READ = 'read'; const READ = 'read';
/** /** @var string The team has the write permission. */
* @var string The team has the write permission.
*/
const WRITE = 'write'; const WRITE = 'write';
} }

View File

@ -1,34 +1,22 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Models;
/** /** Represents the worked time for an issue or pull request. */
* Represents the worked time for an issue or pull request.
*/
class TrackedTime implements \JsonSerializable { class TrackedTime implements \JsonSerializable {
/** /** @var \DateTime|null The date the entry was created. */
* @var \DateTime|null The date the entry was created.
*/
private $createdAt; private $createdAt;
/** /** @var int The entry identifier. */
* @var int The entry identifier.
*/
private $id; private $id;
/** /** @var int The identifier of the associated issue or pull request. */
* @var int The identifier of the associated issue or pull request.
*/
private $issueId = -1; private $issueId = -1;
/** /** @var int The elapsed time, in seconds. */
* @var int The elapsed time, in seconds.
*/
private $time; private $time;
/** /** @var int The identifier of the initiating user. */
* @var int The identifier of the initiating user.
*/
private $userId = -1; private $userId = -1;
/** /**

View File

@ -4,39 +4,25 @@ namespace Gitea\Models;
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
/** /** Represents a Gitea user. */
* Represents a Gitea user.
*/
class User implements \JsonSerializable { class User implements \JsonSerializable {
/** /** @var UriInterface|null The URL to the user's avatar. */
* @var UriInterface|null The URL to the user's avatar.
*/
private $avatarUrl; private $avatarUrl;
/** /** @var string The mail address. */
* @var string The mail address.
*/
private $email = ''; private $email = '';
/** /** @var string The full name. */
* @var string The full name.
*/
private $fullName = ''; private $fullName = '';
/** /** @var int The user identifier. */
* @var int The user identifier.
*/
private $id; private $id;
/** /** @var string The user locale. */
* @var string The user locale.
*/
private $language = ''; private $language = '';
/** /** @var string The name of the Gitea account. */
* @var string The name of the Gitea account.
*/
private $login; private $login;
/** /**