Skip to content

Commit

Permalink
Merge pull request #229 from Tustin/php-81
Browse files Browse the repository at this point in the history
Enforce PHP 8.1
  • Loading branch information
Tustin authored Dec 4, 2022
2 parents 66b8e21 + 4359976 commit 3bc1a63
Show file tree
Hide file tree
Showing 61 changed files with 198 additions and 468 deletions.
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
}
},
"require": {
"guzzlehttp/guzzle": "^7.0",
"php": "^7.4|^8.0|^8.1",
"tustin/haste": "1.0.8",
"nesbot/carbon": "^2.41",
"myclabs/php-enum": "^1.7"
"guzzlehttp/guzzle": "^7.5",
"php": "^8.1",
"tustin/haste": "^1.1",
"nesbot/carbon": "^2.41"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand Down
2 changes: 1 addition & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function __construct(Client $client)
$this->httpClient = $client;
}

public function graphql(string $op, array $variables)
public function graphql(string $op, array $variables): object
{
// @Temp: This will hopefully be removed at some point for dynamic operation hashing.
$hashMap = [
Expand Down
8 changes: 3 additions & 5 deletions src/Enum/CloudStatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class CloudStatusType extends Enum
enum CloudStatusType: string
{
private const uploading = 'uploading';
private const active = 'active';
case Uploading = 'uploading';
case Active = 'active';
}
12 changes: 5 additions & 7 deletions src/Enum/ConsoleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class ConsoleType extends Enum
enum ConsoleType: string
{
private const vita = 'PSVITA';
private const ps3 = 'PS3';
private const ps4 = 'PS4';
private const ps5 = 'PS5';
case Vita = 'PSVITA';
case PS3 = 'PS3';
case PS4 = 'PS4';
case PS5 = 'PS5';
}
66 changes: 32 additions & 34 deletions src/Enum/LanguageType.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
<?php
namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class LanguageType extends Enum
enum LanguageType: string
{
private const english = 'en';
private const czech = 'cs';
private const danish = 'da';
private const german = 'de';
private const english_uk = 'en-GB';
private const english_us = 'en-US';
private const spanish = 'es'; //Spain
private const latin_america = 'es-MX';
private const french = 'fr';
private const french_canada = 'fr-CA'; // Canada (Quebec)
private const indonesian = 'id';
private const italian = 'it';
private const hungarian = 'hu';
private const dutch = 'nl';
private const norwegian = 'no';
private const polish = 'pl';
private const portuguese_brazil = 'pt-BR';
private const portuguese_portugal = 'pt';
private const russian = 'ru';
private const romanian = 'ro';
private const finnish = 'fi';
private const swedish = 'sv';
private const vietnamese = 'vi';
private const turkish = 'tr';
private const arabic = 'ar';
private const greek = 'el';
private const japanese = 'ja';
private const korean = 'ko';
private const thai = 'th';
private const chinese_simplified = 'zh-CN';
private const chinese_taiwan = 'zh-TW';
case English = 'en';
case Czech = 'cs';
case Danish = 'da';
case German = 'de';
case EnglishUK = 'en-GB';
case EnglishUS = 'en-US';
case Spanish = 'es'; //Spain
case LatinAmerica = 'es-MX';
case French = 'fr';
case FrenchCanada = 'fr-CA'; // Canada (Quebec)
case Indonesian = 'id';
case Italian = 'it';
case Hungarian = 'hu';
case Dutch = 'nl';
case Norwegian = 'no';
case Polish = 'pl';
case PortugueseBrazil = 'pt-BR';
case PortuguesePortugal = 'pt';
case Russian = 'ru';
case Romanian = 'ro';
case Finnish = 'fi';
case Swedish = 'sv';
case Vietnamese = 'vi';
case Turkish = 'tr';
case Arabic = 'ar';
case Greek = 'el';
case Japanese = 'ja';
case Korean = 'ko';
case Thai = 'th';
case ChineseSimplified = 'zh-CN';
case ChineseTaiwan = 'zh-TW';
}
22 changes: 10 additions & 12 deletions src/Enum/MessageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class MessageType extends Enum
enum MessageType: int
{
private const text = 1;
private const image = 3;
private const video = 210;
private const audio = 1011;
private const sticker = 1013;
private const leftGroup = 2002;
private const changedGroupImage = 2004;
private const startedVoiceChat = 2020;
case Text = 1;
case Image = 3;
case Video = 210;
case Audio = 1011;
case Sticker = 1013;
case LeftGroup = 2002;
case ChangedGroupImage = 2004;
case StartedVoiceChat = 2020;

// @TODO: Need to map out all of these events.
private const unknown = -1;
case Unknown = -1;
}
10 changes: 4 additions & 6 deletions src/Enum/SessionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class SessionType extends Enum
enum SessionType: int
{
// Flags
private const unknown = 1;
private const game = 2;
private const party = 4;
case Unknown = 1;
case Game = 2;
case Party = 4;
}
8 changes: 3 additions & 5 deletions src/Enum/TranscodeStatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class TranscodeStatusType extends Enum
enum TranscodeStatusType: string
{
private const complete = 'complete';
private const inProgress = 'in_progress';
case Complete = 'complete';
case InProgress = 'in_progress';
}
12 changes: 5 additions & 7 deletions src/Enum/TrophyType.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php
namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class TrophyType extends Enum
enum TrophyType: string
{
private const platinum = 'platinum';
private const bronze = 'bronze';
private const silver = 'silver';
private const gold = 'gold';
case Platinum = 'platinum';
case Bronze = 'bronze';
case Silver = 'silver';
case Gold = 'gold';
}
8 changes: 3 additions & 5 deletions src/Enum/UgcType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Tustin\PlayStation\Enum;

use MyCLabs\Enum\Enum;

class UgcType extends Enum
enum UgcType: int
{
private const image = 1;
private const video = 2;
case Image = 1;
case Video = 2;
}
11 changes: 1 addition & 10 deletions src/Factory/FriendsListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@

class FriendsListFactory extends Api implements IteratorAggregate, FactoryInterface
{
/**
* The user.
*
* @var User
*/
private $user;

private string $onlineId = '';
private bool $useCloseFriends = false;
private bool $verified = false;

public function __construct(User $user)
public function __construct(private User $user)
{
parent::__construct($user->getHttpClient());

$this->user = $user;
}

/**
Expand Down
11 changes: 1 addition & 10 deletions src/Factory/GameListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,9 @@

class GameListFactory extends Api implements IteratorAggregate, FactoryInterface
{
/**
* The user to get game list for.
*
* @var User|null
*/
private $user;

public function __construct(User $user)
public function __construct(private ?User $user)
{
parent::__construct($user->getHttpClient());

$this->user = $user;
}

/**
Expand Down
12 changes: 2 additions & 10 deletions src/Factory/GroupMembersFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@

class GroupMembersFactory implements IteratorAggregate, Countable
{
/**
* @var Group
*/
private $group;

/**
* The name to filter with.
*
* @var string
*/
private $name;
private string $name;

public function __construct(Group $group)
public function __construct(private Group $group)
{
$this->group = $group;
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/Factory/GroupsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@

class GroupsFactory extends Api implements IteratorAggregate
{
private $with = [];
private array $with = [];

/**
* @var boolean
*/
private $only = false;
private bool $only = false;

/**
* @var Carbon|null
*/
private $since = null;
private ?Carbon $since = null;

public $favorited = false;
public bool $favorited = false;

/**
* Filters groups that only contain these onlineIds.
Expand Down
18 changes: 2 additions & 16 deletions src/Factory/MessagesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,15 @@

class MessagesFactory extends Api implements IteratorAggregate
{
/**
* @var MessageThread
*/
private $thread;
private string $typeFilter;

private $typeFilter;

public function __construct(MessageThread $thread)
public function __construct(private MessageThread $thread)
{
parent::__construct($thread->getHttpClient());

$this->thread = $thread;
}

/**
* Gets messages only of a certain type.
*
* @param string $class
* @return MessagesFactory
*/
public function of(string $class): MessagesFactory
{
Expand All @@ -42,8 +32,6 @@ public function of(string $class): MessagesFactory

/**
* Gets the iterator and applies any filters.
*
* @return Iterator
*/
public function getIterator(): Iterator
{
Expand All @@ -58,8 +46,6 @@ public function getIterator(): Iterator

/**
* Gets the first message in the message thread.
*
* @return Message
*/
public function first(): AbstractMessage
{
Expand Down
10 changes: 1 addition & 9 deletions src/Factory/TrophyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@

class TrophyFactory implements IteratorAggregate
{
/**
* The trophy groups' title.
*
* @var TrophyGroup
*/
private $group;

private array $platforms = [];

private string $withName = '';
private string $withDetail = '';

public function __construct(TrophyGroup $group)
public function __construct(private TrophyGroup $group)
{
$this->group = $group;
}

/**
Expand Down
Loading

0 comments on commit 3bc1a63

Please sign in to comment.