Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Sep 5, 2022
1 parent c4957e7 commit 5be39d6
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 41 deletions.
4 changes: 1 addition & 3 deletions camel/BaseDTOCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Knuckles\Camel;

use ArrayIterator;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Spatie\DataTransferObject\DataTransferObjectCollection;

Expand Down Expand Up @@ -49,4 +47,4 @@ public function toArray(): array
$this->items
);
}
}
}
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ parameters:
- '/Instantiated class League\\Flysystem\\Adapter\\Local not found./'
- '/Parameter #1 \$adapter of class League\\Flysystem\\Filesystem constructor expects League\\Flysystem\\FilesystemAdapter, League\\Flysystem\\Adapter\\Local given./'
- '/Call to method getPathPrefix\(\) on an unknown class League\\Flysystem\\Adapter\\Local/'
- '/Access to an undefined property Knuckles\\Scribe\\Extracting\\Shared\\ResponseFieldTools::\$config./'
2 changes: 1 addition & 1 deletion src/Commands/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function handle(): void

$isMajorUpgrade = array_key_exists("default_group", $oldConfig) || array_key_exists("faker_seed", $oldConfig);

$isMajorUpgrade && $this->info("Welcome to the Scribe v3 to v4 upgrader.");
if ($isMajorUpgrade) $this->info("Welcome to the Scribe v3 to v4 upgrader.");
$this->line("Checking for config file changes...");

$upgrader = Upgrader::ofConfigFile("config/$configName.php", __DIR__ . '/../../config/scribe.php')
Expand Down
1 change: 0 additions & 1 deletion src/Exceptions/DatabaseTransactionsNotSupported.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Knuckles\Scribe\Exceptions;

use Knuckles\Scribe\Exceptions\ScribeException;
use RuntimeException;

class DatabaseTransactionsNotSupported extends RuntimeException implements ScribeException
Expand Down
1 change: 0 additions & 1 deletion src/Extracting/DatabaseTransactionHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Knuckles\Scribe\Exceptions\DatabaseTransactionsNotSupported;
use Knuckles\Scribe\Tools\DocumentationConfig;
use Knuckles\Scribe\Tools\Globals;
use PDOException;

trait DatabaseTransactionHelpers
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function processRoute(Route $route, array $routeRules = []): ExtractedEnd
$endpointData = ExtractedEndpointData::fromRoute($route);

$inheritedDocsOverrides = [];
if ($endpointData?->controller->hasMethod('inheritedDocsOverrides')) {
if ($endpointData->controller->hasMethod('inheritedDocsOverrides')) {
$inheritedDocsOverrides = call_user_func([$endpointData->controller->getName(), 'inheritedDocsOverrides']);
$inheritedDocsOverrides = $inheritedDocsOverrides[$endpointData->method->getName()] ?? [];
}
Expand Down
26 changes: 22 additions & 4 deletions src/Extracting/InstantiatesExampleModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Knuckles\Scribe\Extracting;

use Illuminate\Database\Eloquent\Model;
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
use Knuckles\Scribe\Tools\ErrorHandlingUtils as e;
use Knuckles\Scribe\Tools\Utils;
Expand All @@ -11,10 +10,11 @@
trait InstantiatesExampleModels
{
/**
* @param string $type
* @param class-string $type
* @param string[] $factoryStates
* @param string[] $relations
*
* @param array $relations
* @param array $factoryStates
* @return \Illuminate\Database\Eloquent\Model|object
*/
protected function instantiateExampleModel(string $type, array $factoryStates = [], array $relations = [])
{
Expand All @@ -39,18 +39,36 @@ protected function instantiateExampleModel(string $type, array $factoryStates =
return new $type;
}

/**
* @param class-string $type
* @param string[] $factoryStates
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
protected function getExampleModelFromFactoryCreate(string $type, array $factoryStates = [], array $relations = [])
{
$factory = Utils::getModelFactory($type, $factoryStates, $relations);
return $factory->create()->load($relations);
}

/**
* @param class-string $type
* @param string[] $factoryStates
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
protected function getExampleModelFromFactoryMake(string $type, array $factoryStates = [], array $relations = [])
{
$factory = Utils::getModelFactory($type, $factoryStates, $relations);
return $factory->make();
}

/**
* @param class-string $type
* @param string[] $relations
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
protected function getExampleModelFromDatabaseFirst(string $type, array $relations = [])
{
return $type::with($relations)->first();
Expand Down
10 changes: 0 additions & 10 deletions src/Extracting/Shared/TransformerResponseTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

namespace Knuckles\Scribe\Extracting\Shared;

use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Knuckles\Camel\Extraction\ExtractedEndpointData;
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
use Knuckles\Scribe\Tools\ErrorHandlingUtils as e;
use Knuckles\Scribe\Tools\Utils;
use League\Fractal\Manager;
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\Item;
Expand Down
1 change: 0 additions & 1 deletion src/Extracting/Strategies/GetFieldsFromTagStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Knuckles\Scribe\Extracting\Strategies;

use Knuckles\Scribe\Extracting\ParamHelpers;
use Mpociot\Reflection\DocBlock\Tag;

abstract class GetFieldsFromTagStrategy extends TagStrategyWithFormRequestFallback
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
use Knuckles\Scribe\Attributes\Authenticated;
use Knuckles\Scribe\Attributes\Endpoint;
use Knuckles\Scribe\Attributes\Group;
use Knuckles\Scribe\Attributes\Response;
use Knuckles\Scribe\Attributes\ResponseFromApiResource;
use Knuckles\Scribe\Attributes\ResponseFromFile;
use Knuckles\Scribe\Attributes\ResponseFromTransformer;
use Knuckles\Scribe\Attributes\Subgroup;
use Knuckles\Scribe\Attributes\Unauthenticated;
use Knuckles\Scribe\Extracting\DatabaseTransactionHelpers;
use Knuckles\Scribe\Extracting\InstantiatesExampleModels;
use Knuckles\Scribe\Extracting\ParamHelpers;
use Knuckles\Scribe\Extracting\Shared\ApiResourceResponseTools;
use Knuckles\Scribe\Extracting\Shared\TransformerResponseTools;
use Knuckles\Scribe\Extracting\Strategies\PhpAttributeStrategy;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Strategies/PhpAttributeStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class PhpAttributeStrategy extends Strategy
use ParamHelpers;

/**
* @var array<class-string<T>>
* @var string[]
*/
protected array $attributeNames;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Knuckles\Scribe\Extracting\Strategies\ResponseFields;

use Knuckles\Camel\Extraction\ExtractedEndpointData;
use Knuckles\Camel\Extraction\Response;
use Knuckles\Scribe\Attributes\ResponseField;
use Knuckles\Scribe\Extracting\Shared\ResponseFieldTools;
use Knuckles\Scribe\Extracting\Strategies\PhpAttributeStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function extractFromAttributes(
{
$responses = [];
foreach ([...$attributesOnController, ...$attributesOnMethod] as $attributeInstance) {
/* @phpstan-ignore-next-line */
$responses[] = match (get_class($attributeInstance)) {
Response::class => $attributeInstance->toArray(),
ResponseFromFile::class => $attributeInstance->toArray(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ public function getParametersFromDocBlockInFormRequestOrMethod(Route $route, Ref
return $this->getFromTags($methodDocBlock->getTags(), $classTags);
}

/**
* @param \Mpociot\Reflection\DocBlock\Tag[] $tagsOnMethod
* @param \Mpociot\Reflection\DocBlock\Tag[] $tagsOnClass
*
* @return array
*/
abstract public function getFromTags(array $tagsOnMethod, array $tagsOnClass = []): array;
}
1 change: 0 additions & 1 deletion src/GroupedEndpoints/GroupedEndpointsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Knuckles\Scribe\GroupedEndpoints;

use Knuckles\Camel\Camel;
use Knuckles\Scribe\Commands\GenerateDocumentation;
use Knuckles\Scribe\Matching\RouteMatcherInterface;

Expand Down
1 change: 0 additions & 1 deletion src/GroupedEndpoints/GroupedEndpointsFromCamelDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Knuckles\Scribe\GroupedEndpoints;

use Knuckles\Camel\Camel;
use Knuckles\Scribe\Commands\GenerateDocumentation;

class GroupedEndpointsFromCamelDir implements GroupedEndpointsContract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Matching/MatchedRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function offsetExists($offset): bool
return is_callable([$this, 'get' . ucfirst($offset)]);
}

public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return call_user_func([$this, 'get' . ucfirst($offset)]);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/Fixtures/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Validation\ValidationException;
use Knuckles\Scribe\Tests\Unit\ExtractorTest;
use Knuckles\Scribe\Tools\Utils;

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/Strategies/Responses/UseResponseFileTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Knuckles\Scribe\Tests\Strategies\Responses;

use Illuminate\Support\Facades\Route as RouteFacade;
use Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseFileTag;
use Knuckles\Scribe\Tests\Fixtures\TestController;
use Knuckles\Scribe\Tools\DocumentationConfig;
use Mpociot\Reflection\DocBlock\Tag;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
Expand Down
1 change: 0 additions & 1 deletion tests/Strategies/Responses/UseTransformerTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Knuckles\Scribe\Tests\Strategies\Responses;

use Knuckles\Scribe\Extracting\Strategies\Responses\UseTransformerTags;
use Knuckles\Scribe\ScribeServiceProvider;
use Knuckles\Scribe\Tests\BaseLaravelTest;
use Knuckles\Scribe\Tests\Fixtures\TestUser;
use Knuckles\Scribe\Tools\DocumentationConfig;
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/ExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Routing\Route;
use Knuckles\Camel\Extraction\ExtractedEndpointData;
use Knuckles\Camel\Extraction\Parameter;
use Knuckles\Scribe\Attributes\UrlParam;
use Knuckles\Scribe\Extracting\Extractor;
use Knuckles\Scribe\Tests\Fixtures\TestController;
use Knuckles\Scribe\Tools\DocumentationConfig;
Expand Down

0 comments on commit 5be39d6

Please sign in to comment.