1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 16:07:34 +02:00

Apply fixes from StyleCI

This commit is contained in:
StyleCI Bot
2024-05-10 19:30:06 +00:00
committed by Sami Mazouz
parent aa39d0c11b
commit 7504e31399
7 changed files with 31 additions and 12 deletions

View File

@@ -9,7 +9,6 @@
namespace Flarum\Api\Endpoint\Concerns;
use Flarum\Api\Schema\Concerns\FlarumField;
use Flarum\Api\Schema\Concerns\HasValidationRules;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Translation\ArrayLoader;

View File

@@ -1,5 +1,12 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Api\Endpoint\Concerns;
use Flarum\Api\Serializer;

View File

@@ -212,7 +212,7 @@ class Index extends Endpoint
$collection = $context->collection;
if (! $collection instanceof AbstractResource) {
throw new RuntimeException('The collection ' . $collection::class . ' must extend ' . AbstractResource::class);
throw new RuntimeException('The collection '.$collection::class.' must extend '.AbstractResource::class);
}
$sorts = $collection->resolveSorts();

View File

@@ -62,7 +62,7 @@ class JsonApi extends BaseJsonApi
protected function findEndpoint(?Collection $collection): Endpoint
{
if (! $collection instanceof AbstractResource) {
throw new RuntimeException('Resource ' . $collection::class . ' must extend ' . AbstractResource::class);
throw new RuntimeException('Resource '.$collection::class.' must extend '.AbstractResource::class);
}
/** @var Endpoint $endpoint */
@@ -161,7 +161,7 @@ class JsonApi extends BaseJsonApi
$endpoint = $context->endpoint;
if (! $endpoint instanceof Endpoint) {
throw new RuntimeException('The endpoint ' . $endpoint::class . ' must extend ' . Endpoint::class);
throw new RuntimeException('The endpoint '.$endpoint::class.' must extend '.Endpoint::class);
}
$context = $context->withRequest(

View File

@@ -11,8 +11,6 @@ namespace Flarum\Api\Resource;
use Flarum\Api\Context as FlarumContext;
use Flarum\Api\Schema\Contracts\RelationAggregator;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

View File

@@ -1,5 +1,12 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Api\Resource\Concerns;
use Flarum\Api\Context as FlarumContext;

View File

@@ -1,5 +1,12 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Api;
use Closure;
@@ -8,6 +15,7 @@ use RuntimeException;
use Tobyz\JsonApiServer\Context;
use Tobyz\JsonApiServer\Resource\Resource;
use Tobyz\JsonApiServer\Schema\Field\Relationship;
use function Tobyz\JsonApiServer\has_value;
use function Tobyz\JsonApiServer\set_value;
@@ -60,7 +68,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
$url = "{$context->api->basePath}/$type/$id";
if (!isset($this->map[$key])) {
if (! isset($this->map[$key])) {
$this->map[$key] = [
'type' => $type,
'id' => $id,
@@ -77,7 +85,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
$context = $context->withField($field)->withInclude($include[$field->name] ?? null);
if (!$field->isVisible($context)) {
if (! $field->isVisible($context)) {
continue;
}
@@ -86,7 +94,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
$this->whenResolved($value, function (mixed $value) use ($key, $field, $context) {
if (
($value = $field->serializeValue($value, $context)) ||
!$field instanceof Relationship
! $field instanceof Relationship
) {
set_value($this->map[$key], $field, $value);
}
@@ -95,7 +103,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
// TODO: cache
foreach ($resource->meta() as $field) {
if (!$field->isVisible($context)) {
if (! $field->isVisible($context)) {
continue;
}
@@ -117,7 +125,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
private function whenResolved($value, $callback, bool $prepend = false): void
{
if ($value instanceof Closure) {
$callable = fn() => $this->whenResolved($value(), $callback);
$callable = fn () => $this->whenResolved($value(), $callback);
if ($prepend) {
$this->deferred->prepend($callable);
@@ -173,7 +181,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer
}
throw new RuntimeException(
'No resource type defined to represent model ' . get_class($model),
'No resource type defined to represent model '.get_class($model),
);
}