Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

from 280 to 233 errors (lvl 6) #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
},
"require-dev": {
"edgedesign/phpqa": "^v1.25",
"phpunit/phpunit": "^8.0",
"friendsofphp/php-cs-fixer": "^3.0",
"vimeo/psalm": "^4.3",
"php-parallel-lint/php-parallel-lint": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12"
"phpstan/phpstan": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^8.0",
"vimeo/psalm": "^4.3"
},
"minimum-stability": "stable",
"scripts": {
"cs-fix": "@php ./vendor/bin/php-cs-fixer fix",
"phpqa": "@php ./vendor/bin/phpqa --report --tools phpcs:0,phpmetrics,phploc,pdepend,security-checker:0,parallel-lint:0 --ignoredDirs vendor,tests",
"phpstan": "@php ./vendor/bin/phpstan analyse src --level 5 -c extension.neon",
"phpstan": "@php ./vendor/bin/phpstan analyse src --level 6 -c extension.neon",
"psalm": "@php ./vendor/bin/psalm --threads=8 --diff",
"test": "@php ./vendor/bin/phpunit"
},
Expand Down
1 change: 1 addition & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ includes:

parameters:
treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on va y aller mollo par contre, déjà parce que je suis pas sûr de ce que je veux retourner et que si je change le type actuel c'est parti pour une sacrée BC Break..

6 changes: 1 addition & 5 deletions src/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ final public function __construct($data)
$this->htmlUrl = $data['html_url'] ?? '';
$this->id = $data['id'] ?? '';

if (is_array($data['user'])) {
$user = $data['user'];
} else {
$user = [];
}
$user = is_array($data['user']) ? $data['user'] : [];

$this->user = User::createFromData($user);
$this->position = isset($data['position']) ? $data['position'] : '';
Expand Down
5 changes: 4 additions & 1 deletion src/Entity/CommitUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

class CommitUser
{
private $date;
/**
* @var \DateTime|\DateTimeImmutable
*/
private \DateTimeInterface $date;
private $name;
private $email;

Expand Down
5 changes: 1 addition & 4 deletions src/Entity/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ class Deployment
private $environment;
private $description;

/**
* @var User
*/
private $creator;
private \LoveOSS\Github\Entity\User $creator;
private $createdAt;
private $updatedAt;
private $statusesUrl;
Expand Down
5 changes: 1 addition & 4 deletions src/Entity/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ class Integration
*/
private $installationId;

/**
* @var User
*/
private $account;
private ?\LoveOSS\Github\Entity\User $account = null;

/**
* @var string
Expand Down
14 changes: 4 additions & 10 deletions src/Entity/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ class Issue
private $number;
private $title;

/**
* @var User
*/
private $user;
private $labels;
private \LoveOSS\Github\Entity\User $user;
private array $labels;
private $state;
private $isLocked;

/**
* @var User|null
*/
private $assignee;
private $milestone;
private ?\LoveOSS\Github\Entity\User $assignee = null;
private ?bool $milestone = null;
private $commentsCount;
private $createdAt;
private $updatedAt;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final public function __construct($data)
$this->htmlUrl = $data['html_url'];
$diffUrl = isset($data['diff_url']) ? $data['diff_url'] : null;
$diffUrlFromPR = isset($data['pull_request']['diff_url']) ? $data['pull_request']['diff_url'] : null;
$this->diffUrl = !is_null($diffUrl) ? $diffUrl : $diffUrlFromPR;
$this->diffUrl = is_null($diffUrl) ? $diffUrlFromPR : $diffUrl;
$this->issueUrl = isset($data['issue_url']) ? $data['issue_url'] : null;
$this->number = $data['number'];
$this->state = $data['state'];
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class Release
private $targetCommitish;
private $name;
private $isDraft;
private $author;
private \LoveOSS\Github\Entity\User $author;
private $isPreRelease;
private $createdAt;
private $publishedAt;
private $assets;
private $tarballUrl;
private $zipballUrl;
private $body;
private $repository;
private $sender;
private \LoveOSS\Github\Entity\Repository $repository;
private \LoveOSS\Github\Entity\User $sender;

public static function createFromData(array $data, Repository $repository, User $sender)
{
Expand Down
7 changes: 2 additions & 5 deletions src/Entity/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ class Repository
private $name;
private $fullName;

/**
* @var User
*/
private $owner;
private \LoveOSS\Github\Entity\User $owner;
private $isPrivate;
private $htmlUrl;
private $description;
Expand Down Expand Up @@ -73,7 +70,7 @@ class Repository
private $openIssues;
private $watchers;
private $defaultBranch;
private $isPublic;
private ?bool $isPublic = null;

public static function createFromData(array $data)
{
Expand Down
2 changes: 1 addition & 1 deletion src/EventType/AbstractEventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function name(): string
public static function isValid(array $data): bool
{
foreach (static::fields() as $field) {
if ((isset($data[$field]) || array_key_exists($field, $data)) === false) {
if (!isset($data[$field]) && !array_key_exists($field, $data)) {
return false;
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/EventType/DeploymentStatusEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class DeploymentStatusEvent extends RepositoryAwareEventType
*/
public $deployment;

/**
* @var User
*/
public $sender;
public ?\LoveOSS\Github\Entity\User $sender = null;

public static function name(): string
{
Expand Down
5 changes: 1 addition & 4 deletions src/EventType/ForkEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class ForkEvent extends RepositoryAwareEventType
*/
public $owner;

/**
* @var User
*/
public $forker;
public ?\LoveOSS\Github\Entity\User $forker = null;

public static function name(): string
{
Expand Down
8 changes: 1 addition & 7 deletions src/EventType/PullRequestReviewCommentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ public static function fields(): array

public static function isValid($data): bool
{
if (parent::isValid($data)) {
if ($data['action'] === 'created') {
return true;
}
}

return false;
return parent::isValid($data) && $data['action'] === 'created';
}

public function createFromData($data): self
Expand Down
2 changes: 1 addition & 1 deletion src/EventType/PushEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function fields(): array
return ['ref', 'head', 'before', 'commits'];
}

public function createFromData($data): self
public function createFromData(array $data): self
{
parent::createFromData($data);

Expand Down
6 changes: 3 additions & 3 deletions src/EventType/ReleaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class ReleaseEvent extends RepositoryAwareEventType implements ActionableEventInterface
{
public $action;
public string $action;

public Release $release;

public function getAction()
public function getAction(): string
{
return $this->action;
}
Expand All @@ -26,7 +26,7 @@ public static function fields(): array
return ['action', 'release', 'sender', 'repository'];
}

public function createFromData($data): self
public function createFromData(array $data): self
{
parent::createFromData($data);

Expand Down
2 changes: 1 addition & 1 deletion src/EventType/RepositoryAwareEventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getRepository(): Repository
return $this->repository;
}

public function createFromData($data): self
public function createFromData(array $data): self
{
parent::createFromData($data);

Expand Down
4 changes: 2 additions & 2 deletions src/EventType/StatusEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class StatusEvent extends RepositoryAwareEventType
{
public $branches;
public array $branches;

public User $committer;
public string $description;
Expand All @@ -24,7 +24,7 @@ public static function fields(): array
return ['sha', 'state', 'description', 'target_url', 'branches'];
}

public function createFromData($data): self
public function createFromData(array $data): self
{
parent::createFromData($data);

Expand Down
14 changes: 5 additions & 9 deletions src/EventType/WatchEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class WatchEvent extends RepositoryAwareEventType implements ActionableEventInterface
{
public $action;
public string $action;

public User $user;

public function getAction()
public function getAction(): string
{
return $this->action;
}
Expand All @@ -25,16 +25,12 @@ public static function fields(): array
return ['action'];
}

public static function isValid($data): bool
public static function isValid(array $data): bool
{
if (array_key_exists('action', $data) && $data['action'] === 'started') {
return true;
}

return false;
return array_key_exists('action', $data) && $data['action'] === 'started';
}

public function createFromData($data): self
public function createFromData(array $data): self
{
parent::createFromData($data);

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/RepositoryNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class RepositoryNotFoundException extends Exception
{
public function __construct($errorMessage)
public function __construct(string $errorMessage)
{
$exceptionMessage = sprintf("A repository can't be extracted from data: %s", $errorMessage);

Expand Down
7 changes: 4 additions & 3 deletions src/Parser/WebhookResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace LoveOSS\Github\Parser;

use LoveOSS\Github\EventType\GithubEventInterface;
use LoveOSS\Github\Exception\EventNotFoundException;

class WebhookResolver
{
public function resolve(array $data)
public function resolve(array $data): GithubEventInterface
{
foreach ($this->eventsType() as $eventType) {
if ($eventType['class']::isValid($data)) {
Expand All @@ -17,7 +18,7 @@ public function resolve(array $data)
throw new EventNotFoundException();
}

public function eventsType()
public function eventsType(): array
{
$classes = [
'LoveOSS\Github\EventType\IssuesEvent',
Expand Down Expand Up @@ -45,7 +46,7 @@ public function eventsType()
}

usort($eventTypes, function ($a, $b) {
if ($a['priority'] == $b['priority']) {
if ($a['priority'] === $b['priority']) {
return 0;
}

Expand Down