Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test more os and php versions #3

Merged
merged 7 commits into from
Nov 29, 2024
Merged
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
18 changes: 11 additions & 7 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ permissions:
contents: read

jobs:
build:

run:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.2', '8.3']
name: PHP ${{ matrix.php-versions }} Test
steps:
- uses: actions/checkout@v3

- name: Setup PHP
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: ${{ matrix.php-versions }}
- name: Check PHP Version
run: php -v

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Ergebnis\PhpCsFixer\Config;

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php82());
$config = Config\Factory::fromRuleSet(Config\RuleSet\Php82::create());

$config->getFinder()->in(__DIR__)
->exclude([
Expand Down
11 changes: 4 additions & 7 deletions src/Abstracts/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
namespace Vazaha\Mastodon\Abstracts;

use Carbon\Carbon;
use DateTimeInterface;
use ReflectionClass;
use ReflectionNamedType;
use Vazaha\Mastodon\Interfaces\ModelInterface;

abstract class Model implements ModelInterface
Expand Down Expand Up @@ -63,7 +60,7 @@ public function toArray(): array
continue;
}

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

continue;
Expand Down Expand Up @@ -111,7 +108,7 @@ protected static function resolvePropertyValue(string $property, $value)
return $type::fromArray($value);
}

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

protected static function getPropertyType(string $property): ?string
{
$reflectionClass = new ReflectionClass(static::class);
$reflectionClass = new \ReflectionClass(static::class);
$reflectionProperty = $reflectionClass->getProperty($property);
$reflectionType = $reflectionProperty->getType();

if (!$reflectionType instanceof ReflectionNamedType) {
if (!$reflectionType instanceof \ReflectionNamedType) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Abstracts/ModelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ abstract class ModelCollection extends Collection
abstract public static function getModelClass(): string;

/**
* @param array<int, mixed[]> $array
* @param list<array<string, mixed>> $array
*/
public static function fromArray(array $array): static
{
$modelClass = static::getModelClass();

$models = array_map(
static fn (array $modelData) => $modelClass::fromArray($modelData),
static fn (array $modelData): Model => $modelClass::fromArray($modelData),
$array,
);

Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getBody(): string
* @throws \RuntimeException
* @throws \Vazaha\Mastodon\Exceptions\InvalidResponseException
*
* @return null|array<int|string, mixed[]>
* @return null|array<int|string, list<mixed>>
*/
public function getDecodedBody(): ?array
{
Expand Down
6 changes: 2 additions & 4 deletions src/Exceptions/ApiErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

namespace Vazaha\Mastodon\Exceptions;

use Exception;
use Throwable;
use Vazaha\Mastodon\Models\ErrorModel;

class ApiErrorException extends Exception
class ApiErrorException extends \Exception
{
protected ?ErrorModel $error;

public function __construct(
string $message,
int $statusCode,
?Throwable $previous = null,
?\Throwable $previous = null,
?ErrorModel $error = null,
) {
parent::__construct($message, $statusCode, $previous);
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/BaseUriNotSetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Vazaha\Mastodon\Exceptions;

use Exception;

class BaseUriNotSetException extends Exception
class BaseUriNotSetException extends \Exception
{
}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Vazaha\Mastodon\Exceptions;

use Exception;

class InvalidResponseException extends Exception
class InvalidResponseException extends \Exception
{
}
7 changes: 3 additions & 4 deletions src/Factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Vazaha\Mastodon\Factories;

use LogicException;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Interfaces\ModelInterface;

Expand All @@ -13,15 +12,15 @@ class ModelFactory
/**
* @template T of \Vazaha\Mastodon\Abstracts\Model
*
* @param class-string<T> $className
* @param mixed[] $modelData
* @param class-string<T> $className
* @param array<string, mixed> $modelData
*
* @return T
*/
public function build(string $className, array $modelData): ModelInterface
{
if (!is_a($className, Model::class, true)) {
throw new LogicException($className . ' is not a subclass of ' . Model::class);
throw new \LogicException($className . ' is not a subclass of ' . Model::class);
}

return $className::fromArray($modelData);
Expand Down
4 changes: 2 additions & 2 deletions src/Factories/ResultFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Vazaha\Mastodon\Factories;

use LogicException;
use Psr\Http\Message\ResponseInterface;
use Vazaha\Mastodon\Abstracts\Result;
use Vazaha\Mastodon\ApiClient;
Expand All @@ -29,8 +28,9 @@ public function build(
ResponseInterface $response,
): ResultInterface {
if (!is_a($className, Result::class, true)) {
throw new LogicException($className . ' is not a subclass of ' . Result::class);
throw new \LogicException($className . ' is not a subclass of ' . Result::class);
}

$result = new $className();
$result->init($client, $request, $response);

Expand Down
4 changes: 1 addition & 3 deletions src/Helpers/MultipartFormData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Vazaha\Mastodon\Helpers;

use InvalidArgumentException;

class MultipartFormData
{
/**
Expand Down Expand Up @@ -87,6 +85,6 @@ protected function constructParts(
];
}

throw new InvalidArgumentException('Invalid format in form params encountered for param ' . $baseName);
throw new \InvalidArgumentException('Invalid format in form params encountered for param ' . $baseName);
}
}
4 changes: 2 additions & 2 deletions src/Helpers/PagingLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public function __construct(
}

/**
* @return null|array<int|string,string>
* @return null|array<int|string, string>
*/
public function getNextQueryParams(): ?array
{
return $this->getQueryParams($this->getNextUrl());
}

/**
* @return null|array<int|string,string>
* @return null|array<int|string, string>
*/
public function getPreviousQueryParams(): ?array
{
Expand Down
8 changes: 3 additions & 5 deletions src/Helpers/UploadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Vazaha\Mastodon\Helpers;

use InvalidArgumentException;

/**
* Helper class for files to be uploaded to the Mastodon API.
*/
Expand All @@ -20,15 +18,15 @@ public function __construct(
protected string $filePath,
) {
if (!file_exists($this->filePath)) {
throw new InvalidArgumentException('File does not exist: ' . $this->filePath);
throw new \InvalidArgumentException('File does not exist: ' . $this->filePath);
}

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

if (!is_readable($this->filePath)) {
throw new InvalidArgumentException('Path is not readable: ' . $this->filePath);
throw new \InvalidArgumentException('Path is not readable: ' . $this->filePath);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getResultClass(): string;
public function getPagingParams(): array;

/**
* @param array<int|string,string> $params
* @param array<int|string, string> $params
*/
public function setPagingParams(array $params): static;

Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getHttpResponse(): ResponseInterface;
public function getBody(): string;

/**
* @return null|array<int|string, mixed[]>
* @return null|array<int|string, list<mixed>>
*/
public function getDecodedBody(): ?array;

Expand Down
5 changes: 2 additions & 3 deletions src/Models/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\CustomEmojiCollection;
use Vazaha\Mastodon\Collections\FieldCollection;
Expand Down Expand Up @@ -130,12 +129,12 @@ class AccountModel extends Model
/**
* When the account was created.
*/
public DateTimeInterface $created_at;
public \DateTimeInterface $created_at;

/**
* When the most recent status was posted.
*/
public ?DateTimeInterface $last_status_at = null;
public ?\DateTimeInterface $last_status_at = null;

/**
* How many statuses are attached to this account.
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Admin/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\Admin\IpCollection;
use Vazaha\Mastodon\Models\AccountModel as ModelsAccountModel;
Expand Down Expand Up @@ -39,7 +38,7 @@ class AccountModel extends Model
/**
* When the account was first discovered.
*/
public DateTimeInterface $created_at;
public \DateTimeInterface $created_at;

/**
* The email address associated with the account.
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Admin/CohortModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\CohortDataCollection;

Expand All @@ -22,7 +21,7 @@ class CohortModel extends Model
/**
* The timestamp for the start of the period, at midnight.
*/
public DateTimeInterface $period;
public \DateTimeInterface $period;

/**
* The size of the bucket for the returned data.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/DimensionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DimensionModel extends Model
/**
* The data available for the requested dimension.
*
* @var array<mixed>
* @var list<mixed>
*/
public array $data;
}
3 changes: 1 addition & 2 deletions src/Models/Admin/DomainAllowModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;

/**
Expand All @@ -31,5 +30,5 @@ class DomainAllowModel extends Model
/**
* When the domain was allowed to federate.
*/
public DateTimeInterface $created_at;
public \DateTimeInterface $created_at;
}
3 changes: 1 addition & 2 deletions src/Models/Admin/DomainBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;

/**
Expand All @@ -31,7 +30,7 @@ class DomainBlockModel extends Model
/**
* When the domain was blocked from federating.
*/
public DateTimeInterface $created_at;
public \DateTimeInterface $created_at;

/**
* The policy to be applied by this domain block.
Expand Down
5 changes: 2 additions & 3 deletions src/Models/Admin/EmailDomainBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;

/**
Expand All @@ -31,12 +30,12 @@ class EmailDomainBlockModel extends Model
/**
* When the email domain was disallowed from signups.
*/
public DateTimeInterface $created_at;
public \DateTimeInterface $created_at;

/**
* Usage statistics for given days (typically the past week).
*
* @var array<mixed>
* @var list<mixed>
*/
public array $history;
}
Loading