Skip to content

Commit b1574fb

Browse files
authored
Merge pull request #3 from vazaha-nl/gh-actions-test-scenarios
test more os and php versions
2 parents aa5c2b9 + de90d1c commit b1574fb

File tree

132 files changed

+575
-627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+575
-627
lines changed

.github/workflows/php.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
build:
14-
13+
run:
1514
runs-on: ubuntu-latest
16-
15+
strategy:
16+
matrix:
17+
php-versions: ['8.2', '8.3']
18+
name: PHP ${{ matrix.php-versions }} Test
1719
steps:
18-
- uses: actions/checkout@v3
19-
20-
- name: Setup PHP
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
- name: Install PHP
2123
uses: shivammathur/setup-php@v2
2224
with:
23-
php-version: 8.2
25+
php-version: ${{ matrix.php-versions }}
26+
- name: Check PHP Version
27+
run: php -v
2428

2529
- name: Validate composer.json and composer.lock
2630
run: composer validate --strict

.php-cs-fixer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Ergebnis\PhpCsFixer\Config;
66

7-
$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php82());
7+
$config = Config\Factory::fromRuleSet(Config\RuleSet\Php82::create());
88

99
$config->getFinder()->in(__DIR__)
1010
->exclude([

src/Abstracts/Model.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
namespace Vazaha\Mastodon\Abstracts;
66

77
use Carbon\Carbon;
8-
use DateTimeInterface;
9-
use ReflectionClass;
10-
use ReflectionNamedType;
118
use Vazaha\Mastodon\Interfaces\ModelInterface;
129

1310
abstract class Model implements ModelInterface
@@ -63,7 +60,7 @@ public function toArray(): array
6360
continue;
6461
}
6562

66-
if ($value instanceof DateTimeInterface) {
63+
if ($value instanceof \DateTimeInterface) {
6764
$array['name'] = $value->format('Y-m-d\TH:i:s.vp');
6865

6966
continue;
@@ -111,7 +108,7 @@ protected static function resolvePropertyValue(string $property, $value)
111108
return $type::fromArray($value);
112109
}
113110

114-
if (is_a($type, DateTimeInterface::class, true)) {
111+
if (is_a($type, \DateTimeInterface::class, true)) {
115112
if (is_int($value) || is_float($value)) {
116113
return Carbon::createFromTimestamp($value);
117114
}
@@ -126,11 +123,11 @@ protected static function resolvePropertyValue(string $property, $value)
126123

127124
protected static function getPropertyType(string $property): ?string
128125
{
129-
$reflectionClass = new ReflectionClass(static::class);
126+
$reflectionClass = new \ReflectionClass(static::class);
130127
$reflectionProperty = $reflectionClass->getProperty($property);
131128
$reflectionType = $reflectionProperty->getType();
132129

133-
if (!$reflectionType instanceof ReflectionNamedType) {
130+
if (!$reflectionType instanceof \ReflectionNamedType) {
134131
return null;
135132
}
136133

src/Abstracts/ModelCollection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ abstract class ModelCollection extends Collection
2020
abstract public static function getModelClass(): string;
2121

2222
/**
23-
* @param array<int, mixed[]> $array
23+
* @param list<array<string, mixed>> $array
2424
*/
2525
public static function fromArray(array $array): static
2626
{
2727
$modelClass = static::getModelClass();
2828

2929
$models = array_map(
30-
static fn (array $modelData) => $modelClass::fromArray($modelData),
30+
static fn (array $modelData): Model => $modelClass::fromArray($modelData),
3131
$array,
3232
);
3333

src/Abstracts/Result.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getBody(): string
5454
* @throws \RuntimeException
5555
* @throws \Vazaha\Mastodon\Exceptions\InvalidResponseException
5656
*
57-
* @return null|array<int|string, mixed[]>
57+
* @return null|array<int|string, list<mixed>>
5858
*/
5959
public function getDecodedBody(): ?array
6060
{

src/Exceptions/ApiErrorException.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44

55
namespace Vazaha\Mastodon\Exceptions;
66

7-
use Exception;
8-
use Throwable;
97
use Vazaha\Mastodon\Models\ErrorModel;
108

11-
class ApiErrorException extends Exception
9+
class ApiErrorException extends \Exception
1210
{
1311
protected ?ErrorModel $error;
1412

1513
public function __construct(
1614
string $message,
1715
int $statusCode,
18-
?Throwable $previous = null,
16+
?\Throwable $previous = null,
1917
?ErrorModel $error = null,
2018
) {
2119
parent::__construct($message, $statusCode, $previous);

src/Exceptions/BaseUriNotSetException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Vazaha\Mastodon\Exceptions;
66

7-
use Exception;
8-
9-
class BaseUriNotSetException extends Exception
7+
class BaseUriNotSetException extends \Exception
108
{
119
}

src/Exceptions/InvalidResponseException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Vazaha\Mastodon\Exceptions;
66

7-
use Exception;
8-
9-
class InvalidResponseException extends Exception
7+
class InvalidResponseException extends \Exception
108
{
119
}

src/Factories/ModelFactory.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Vazaha\Mastodon\Factories;
66

7-
use LogicException;
87
use Vazaha\Mastodon\Abstracts\Model;
98
use Vazaha\Mastodon\Interfaces\ModelInterface;
109

@@ -13,15 +12,15 @@ class ModelFactory
1312
/**
1413
* @template T of \Vazaha\Mastodon\Abstracts\Model
1514
*
16-
* @param class-string<T> $className
17-
* @param mixed[] $modelData
15+
* @param class-string<T> $className
16+
* @param array<string, mixed> $modelData
1817
*
1918
* @return T
2019
*/
2120
public function build(string $className, array $modelData): ModelInterface
2221
{
2322
if (!is_a($className, Model::class, true)) {
24-
throw new LogicException($className . ' is not a subclass of ' . Model::class);
23+
throw new \LogicException($className . ' is not a subclass of ' . Model::class);
2524
}
2625

2726
return $className::fromArray($modelData);

src/Factories/ResultFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Vazaha\Mastodon\Factories;
66

7-
use LogicException;
87
use Psr\Http\Message\ResponseInterface;
98
use Vazaha\Mastodon\Abstracts\Result;
109
use Vazaha\Mastodon\ApiClient;
@@ -29,8 +28,9 @@ public function build(
2928
ResponseInterface $response,
3029
): ResultInterface {
3130
if (!is_a($className, Result::class, true)) {
32-
throw new LogicException($className . ' is not a subclass of ' . Result::class);
31+
throw new \LogicException($className . ' is not a subclass of ' . Result::class);
3332
}
33+
3434
$result = new $className();
3535
$result->init($client, $request, $response);
3636

src/Helpers/MultipartFormData.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Vazaha\Mastodon\Helpers;
66

7-
use InvalidArgumentException;
8-
97
class MultipartFormData
108
{
119
/**
@@ -87,6 +85,6 @@ protected function constructParts(
8785
];
8886
}
8987

90-
throw new InvalidArgumentException('Invalid format in form params encountered for param ' . $baseName);
88+
throw new \InvalidArgumentException('Invalid format in form params encountered for param ' . $baseName);
9189
}
9290
}

src/Helpers/PagingLinks.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public function __construct(
1717
}
1818

1919
/**
20-
* @return null|array<int|string,string>
20+
* @return null|array<int|string, string>
2121
*/
2222
public function getNextQueryParams(): ?array
2323
{
2424
return $this->getQueryParams($this->getNextUrl());
2525
}
2626

2727
/**
28-
* @return null|array<int|string,string>
28+
* @return null|array<int|string, string>
2929
*/
3030
public function getPreviousQueryParams(): ?array
3131
{

src/Helpers/UploadFile.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Vazaha\Mastodon\Helpers;
66

7-
use InvalidArgumentException;
8-
97
/**
108
* Helper class for files to be uploaded to the Mastodon API.
119
*/
@@ -20,15 +18,15 @@ public function __construct(
2018
protected string $filePath,
2119
) {
2220
if (!file_exists($this->filePath)) {
23-
throw new InvalidArgumentException('File does not exist: ' . $this->filePath);
21+
throw new \InvalidArgumentException('File does not exist: ' . $this->filePath);
2422
}
2523

2624
if (!is_file($this->filePath)) {
27-
throw new InvalidArgumentException('Path is not a file: ' . $this->filePath);
25+
throw new \InvalidArgumentException('Path is not a file: ' . $this->filePath);
2826
}
2927

3028
if (!is_readable($this->filePath)) {
31-
throw new InvalidArgumentException('Path is not readable: ' . $this->filePath);
29+
throw new \InvalidArgumentException('Path is not readable: ' . $this->filePath);
3230
}
3331
}
3432

src/Interfaces/RequestInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getResultClass(): string;
4444
public function getPagingParams(): array;
4545

4646
/**
47-
* @param array<int|string,string> $params
47+
* @param array<int|string, string> $params
4848
*/
4949
public function setPagingParams(array $params): static;
5050

src/Interfaces/ResultInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function getHttpResponse(): ResponseInterface;
1818
public function getBody(): string;
1919

2020
/**
21-
* @return null|array<int|string, mixed[]>
21+
* @return null|array<int|string, list<mixed>>
2222
*/
2323
public function getDecodedBody(): ?array;
2424

src/Models/AccountModel.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312
use Vazaha\Mastodon\Collections\CustomEmojiCollection;
1413
use Vazaha\Mastodon\Collections\FieldCollection;
@@ -130,12 +129,12 @@ class AccountModel extends Model
130129
/**
131130
* When the account was created.
132131
*/
133-
public DateTimeInterface $created_at;
132+
public \DateTimeInterface $created_at;
134133

135134
/**
136135
* When the most recent status was posted.
137136
*/
138-
public ?DateTimeInterface $last_status_at = null;
137+
public ?\DateTimeInterface $last_status_at = null;
139138

140139
/**
141140
* How many statuses are attached to this account.

src/Models/Admin/AccountModel.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models\Admin;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312
use Vazaha\Mastodon\Collections\Admin\IpCollection;
1413
use Vazaha\Mastodon\Models\AccountModel as ModelsAccountModel;
@@ -39,7 +38,7 @@ class AccountModel extends Model
3938
/**
4039
* When the account was first discovered.
4140
*/
42-
public DateTimeInterface $created_at;
41+
public \DateTimeInterface $created_at;
4342

4443
/**
4544
* The email address associated with the account.

src/Models/Admin/CohortModel.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models\Admin;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312
use Vazaha\Mastodon\Collections\CohortDataCollection;
1413

@@ -22,7 +21,7 @@ class CohortModel extends Model
2221
/**
2322
* The timestamp for the start of the period, at midnight.
2423
*/
25-
public DateTimeInterface $period;
24+
public \DateTimeInterface $period;
2625

2726
/**
2827
* The size of the bucket for the returned data.

src/Models/Admin/DimensionModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DimensionModel extends Model
2525
/**
2626
* The data available for the requested dimension.
2727
*
28-
* @var array<mixed>
28+
* @var list<mixed>
2929
*/
3030
public array $data;
3131
}

src/Models/Admin/DomainAllowModel.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models\Admin;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312

1413
/**
@@ -31,5 +30,5 @@ class DomainAllowModel extends Model
3130
/**
3231
* When the domain was allowed to federate.
3332
*/
34-
public DateTimeInterface $created_at;
33+
public \DateTimeInterface $created_at;
3534
}

src/Models/Admin/DomainBlockModel.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models\Admin;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312

1413
/**
@@ -31,7 +30,7 @@ class DomainBlockModel extends Model
3130
/**
3231
* When the domain was blocked from federating.
3332
*/
34-
public DateTimeInterface $created_at;
33+
public \DateTimeInterface $created_at;
3534

3635
/**
3736
* The policy to be applied by this domain block.

src/Models/Admin/EmailDomainBlockModel.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Vazaha\Mastodon\Models\Admin;
1010

11-
use DateTimeInterface;
1211
use Vazaha\Mastodon\Abstracts\Model;
1312

1413
/**
@@ -31,12 +30,12 @@ class EmailDomainBlockModel extends Model
3130
/**
3231
* When the email domain was disallowed from signups.
3332
*/
34-
public DateTimeInterface $created_at;
33+
public \DateTimeInterface $created_at;
3534

3635
/**
3736
* Usage statistics for given days (typically the past week).
3837
*
39-
* @var array<mixed>
38+
* @var list<mixed>
4039
*/
4140
public array $history;
4241
}

0 commit comments

Comments
 (0)