Skip to content

Commit

Permalink
Apply fixes from StyleCI (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
specialtactics authored Jan 27, 2022
1 parent 9d875e7 commit 435d48e
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 72 deletions.
11 changes: 7 additions & 4 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function APIUser()
* Recursively camel-case an array's keys
*
* @deprecated Use Helpers.php
*
* @param $array
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @return array $array
*/
function camel_case_array_keys($array, $levels = null)
Expand All @@ -29,8 +30,9 @@ function camel_case_array_keys($array, $levels = null)
* Recursively snake-case an array's keys
*
* @deprecated Use Helpers.php
*
* @param $array
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @return array $array
*/
function snake_case_array_keys(array $array, $levels = null)
Expand All @@ -44,8 +46,9 @@ function snake_case_array_keys(array $array, $levels = null)
* Converts the name of a model class to the name of the relation of this resource on another model
*
* @deprecated Use Helpers.php
* @param string $resourceName The name of the resource we are dealing with
* @param string $relationType The type of relation - ie.. one to.. X ('one', 'many')
*
* @param string $resourceName The name of the resource we are dealing with
* @param string $relationType The type of relation - ie.. one to.. X ('one', 'many')
* @return string The name of the relation, as it would appear inside an eloquent model
*/
function model_relation_name($resourceName, $relationType = 'many')
Expand Down
9 changes: 5 additions & 4 deletions src/APIBoilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public static function getResponseCaseType()
/**
* Formats case of the input array or scalar to desired case
*
* @param array|string $input
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @param array|string $input
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @return array|string $transformed
*/
public static function formatKeyCaseAccordingToResponseFormat($input, $levels = null)
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function formatKeyCaseAccordingToResponseFormat($input, $levels =
/**
* Format the provided string into the required case response format, for attributes (ie. keys)
*
* @param string $attributeString
* @param string $attributeString
* @return string
*/
public static function formatCaseAccordingToResponseFormat($attributeString)
Expand All @@ -128,7 +128,8 @@ public static function formatCaseAccordingToResponseFormat($attributeString)
* Format the provided key string into the required case response format
*
* @deprecated Use the updated function name
* @param string $key
*
* @param string $key
* @return string
*/
public static function formatKeyCaseAccordingToReponseFormat($value)
Expand Down
12 changes: 6 additions & 6 deletions src/APIHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class APIHelpers
* Recursively camel-case an array's keys
*
* @param $array
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @return array $array
*/
public static function camelCaseArrayKeys($array, $levels = null)
Expand Down Expand Up @@ -43,7 +43,7 @@ public static function camelCaseArrayKeys($array, $levels = null)
* Recursively snake-case an array's keys
*
* @param $array
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null)
* @return array $array
*/
public static function snakeCaseArrayKeys(array $array, $levels = null)
Expand Down Expand Up @@ -76,7 +76,7 @@ public static function snakeCaseArrayKeys(array $array, $levels = null)
* Str::camel wrapper - for specific extra functionality
* Note this is generally only applicable when dealing with API input/output key case
*
* @param string $value
* @param string $value
* @return string
*/
public static function camel($value)
Expand All @@ -93,7 +93,7 @@ public static function camel($value)
* Str::snake wrapper - for specific extra functionality
* Note this is generally only applicable when dealing with API input/output key case
*
* @param string $value
* @param string $value
* @return mixed|string|string[]|null
*/
public static function snake($value)
Expand Down Expand Up @@ -125,8 +125,8 @@ public static function getCallingMethod()
/**
* Converts the name of a model class to the name of the relation of this resource on another model
*
* @param string $resourceName The name of the resource we are dealing with
* @param string $relationType The type of relation - ie.. one to.. X ('one', 'many')
* @param string $resourceName The name of the resource we are dealing with
* @param string $relationType The type of relation - ie.. one to.. X ('one', 'many')
* @return string The name of the relation, as it would appear inside an eloquent model
*/
public static function modelRelationName($resourceName, $relationType = 'many')
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/RestfulApiExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RestfulApiExceptionHandler extends ExceptionHandler
/**
* Override prepare replacements function to add extra functionality
*
* @param Throwable $exception
* @param Throwable $exception
* @return array
*/
protected function prepareReplacements(Throwable $exception)
Expand Down Expand Up @@ -67,7 +67,7 @@ public function getOriginalReplacements()
/**
* Formats the case of validation message keys, if response case is not snake-case
*
* @param array $replacements
* @param array $replacements
* @return array
*/
protected function formatCaseOfValidationMessages($replacements)
Expand Down
8 changes: 4 additions & 4 deletions src/Exceptions/UnauthorizedHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
class UnauthorizedHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/BaseRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BaseRestfulController extends Controller
/**
* RestfulController constructor.
*
* @param RestfulService $restfulService
* @param RestfulService $restfulService
*/
public function __construct(RestfulService $restfulService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ trait AuthorizesUserActionsOnModelsTrait
*
* Only checks if a policy exists for that model.
*
* @param string $ability
* @param array|mixed $arguments
* @param string $ability
* @param array|mixed $arguments
*
* @throws AccessDeniedHttpException
*/
public function authorizeUserAction($ability, $arguments = [])
Expand All @@ -39,7 +40,7 @@ public function authorizeUserAction($ability, $arguments = [])
* This function can be used to add conditions to the query builder,
* which will specify the currently logged in user's ownership of the model
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder|null
*/
public function qualifyCollectionQuery($query)
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Features/JWTAuthenticationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait JWTAuthenticationTrait
/**
* Get a JWT via given credentials.
*
* @param Request $request
* @param Request $request
* @return Response
*/
public function token(Request $request)
Expand Down Expand Up @@ -71,7 +71,7 @@ public function getUser()
/**
* Get the token array structure.
*
* @param string $token
* @param string $token
* @return Response
*/
protected function respondWithToken($token)
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Features/RestfulControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function shouldTransform()
* Prepend a Response message with a custom message
* Useful for adding error info to internal request responses before returning them
*
* @param \Dingo\Api\Http\Response $response
* @param \Dingo\Api\Http\Response $response
* @param $message
* @return \Dingo\Api\Http\Response
*/
Expand Down
29 changes: 17 additions & 12 deletions src/Http/Controllers/RestfulChildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class RestfulChildController extends BaseRestfulController
/**
* Request to retrieve a collection of all items owned by the parent of this resource
*
* @param string $uuid
* @param Request $request
* @param string $uuid
* @param Request $request
* @return \Dingo\Api\Http\Response
*/
public function getAll($uuid, Request $request)
Expand Down Expand Up @@ -79,8 +79,8 @@ public function getAll($uuid, Request $request)
/**
* Request to retrieve a single child owned by the parent of this resource (hasOne relationship)
*
* @param string $uuid
* @param Request $request
* @param string $uuid
* @param Request $request
* @return \Dingo\Api\Http\Response
*/
public function getOneFromParent($uuid, Request $request)
Expand Down Expand Up @@ -119,9 +119,10 @@ public function getOneFromParent($uuid, Request $request)
/**
* Request to retrieve a single item of this resource
*
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the resource
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the resource
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function get($parentUuid, $uuid)
Expand Down Expand Up @@ -157,8 +158,10 @@ public function get($parentUuid, $uuid)
* Request to create the child resource owned by the parent resource
*
* @oaram string $parentUuid Parent's UUID
* @param Request $request
*
* @param Request $request
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function post($parentUuid, Request $request)
Expand Down Expand Up @@ -203,10 +206,11 @@ public function post($parentUuid, Request $request)
/**
* Request to update the specified child resource
*
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the child resource
* @param Request $request
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the child resource
* @param Request $request
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function patch($parentUuid, $uuid, Request $request)
Expand Down Expand Up @@ -251,9 +255,10 @@ public function patch($parentUuid, $uuid, Request $request)
/**
* Deletes a child resource by UUID
*
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the child resource
* @param string $parentUuid UUID of the parent resource
* @param string $uuid UUID of the child resource
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function delete($parentUuid, $uuid)
Expand Down
20 changes: 12 additions & 8 deletions src/Http/Controllers/RestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public function getAll()
/**
* Request to retrieve a single item of this resource
*
* @param string $uuid UUID of the resource
* @param string $uuid UUID of the resource
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function get($uuid)
Expand All @@ -93,8 +94,9 @@ public function get($uuid)
/**
* Request to create a new resource
*
* @param Request $request
* @param Request $request
* @return \Dingo\Api\Http\Response
*
* @throws HttpException|QueryException
*/
public function post(Request $request)
Expand Down Expand Up @@ -122,8 +124,8 @@ public function post(Request $request)
/**
* Request to create or replace a resource
*
* @param Request $request
* @param string $uuid
* @param Request $request
* @param string $uuid
* @return \Dingo\Api\Http\Response
*/
public function put(Request $request, $uuid)
Expand Down Expand Up @@ -166,9 +168,10 @@ public function put(Request $request, $uuid)
/**
* Request to update the specified resource
*
* @param string $uuid UUID of the resource
* @param Request $request
* @param string $uuid UUID of the resource
* @param Request $request
* @return \Dingo\Api\Http\Response
*
* @throws HttpException
*/
public function patch($uuid, Request $request)
Expand All @@ -193,8 +196,9 @@ public function patch($uuid, Request $request)
/**
* Deletes a resource by UUID
*
* @param string $uuid UUID of the resource
* @param string $uuid UUID of the resource
* @return \Dingo\Api\Http\Response
*
* @throws NotFoundHttpException
*/
public function delete($uuid)
Expand All @@ -215,7 +219,7 @@ public function delete($uuid)
/**
* Get the cache key for a given endpoint in this controller
*
* @param string $endpoint
* @param string $endpoint
* @return string $cacheKey
*/
public static function getCacheKey(string $endpoint = 'getAll'): ?string
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/CheckUserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CheckUserRole
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param array|string $roles Roles to check for
* @param array|string $roles Roles to check for
* @return mixed
*/
public function handle($request, Closure $next, ...$roles)
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/SnakeCaseInputParameterKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handle($request, Closure $next, $guard = null)
/**
* Process parameters within a ParameterBag to snake_case the keys
*
* @param ParameterBag $bag
* @param ParameterBag $bag
*/
protected function processParamBag(ParameterBag $bag)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Response/Format/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Json extends \Dingo\Api\Http\Response\Format\Json
/**
* Format an array or instance implementing Arrayable.
*
* @param array|\Illuminate\Contracts\Support\Arrayable $content
*
* @param array|\Illuminate\Contracts\Support\Arrayable $content
* @return string
*/
public function formatArray($content)
Expand Down
2 changes: 1 addition & 1 deletion src/L5ApiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function register()
/**
* Bootstrap the application services.
*
* @param \Illuminate\Routing\Router $router
* @param \Illuminate\Routing\Router $router
*/
public function boot(Router $router, Dispatcher $event)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Builder extends \Illuminate\Database\Eloquent\Builder
/**
* Wrapper to throw a 404 instead of a 500 on model not found
*
* @param mixed $id
* @param array $columns
* @param mixed $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
*/
public function findOrFail($id, $columns = ['*'])
Expand Down
1 change: 1 addition & 0 deletions src/Models/RestfulModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class RestfulModel extends Model
* always loaded in various service functions, for performance reasons
*
* @deprecated Use getItemWith() and getCollectionWith()
*
* @var array Relations to load implicitly by Restful controllers
*/
public static $localWith = null;
Expand Down
Loading

0 comments on commit 435d48e

Please sign in to comment.