From 6e2763579f7da2fff01cba8e7dfae079a86f924d Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Fri, 4 Sep 2015 17:54:01 +1000 Subject: [PATCH 1/4] Changes StyleCi to use laravel recommended preset --- .styleci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index a06277ca..c3bb259c 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,4 +1 @@ -preset: psr2 - -enabled: - - short_array_syntax \ No newline at end of file +preset: laravel \ No newline at end of file From b0221dae53ed70b8728d8bee472c686b55bad8fa Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Fri, 4 Sep 2015 03:56:36 -0400 Subject: [PATCH 2/4] Applied fixes from StyleCI --- .../Commands/ApiaryValidateCommand.php | 3 - .../Console/Commands/GenerateKeysCommand.php | 2 +- api/app/Exceptions/ForbiddenException.php | 4 +- api/app/Exceptions/Handler.php | 4 +- .../Controller/RequestValidationTrait.php | 27 ++++--- api/app/Extensions/JWTAuth/ClaimFactory.php | 12 ++-- api/app/Extensions/JWTAuth/JWTAuth.php | 10 +-- api/app/Extensions/JWTAuth/JWTManager.php | 2 +- api/app/Extensions/JWTAuth/NamshiAdapter.php | 2 +- api/app/Extensions/JWTAuth/PayloadFactory.php | 5 +- api/app/Extensions/JWTAuth/UserClaim.php | 4 +- api/app/Extensions/Lock/CallerLock.php | 4 +- api/app/Extensions/Lock/LockFactory.php | 5 +- api/app/Extensions/Lock/LockTrait.php | 4 +- api/app/Extensions/Lock/Manager.php | 4 +- api/app/Extensions/Lock/Privilege.php | 6 +- api/app/Extensions/Lock/RoleLock.php | 4 +- api/app/Extensions/Lock/UserOwnership.php | 4 +- .../Socialite/Parsers/UsernameTrait.php | 4 +- .../Socialite/Two/ProviderTrait.php | 2 +- api/app/Helpers/RouteHelper.php | 7 +- api/app/Http/Controllers/ApiController.php | 7 +- api/app/Http/Controllers/ApiaryController.php | 1 - .../Http/Controllers/ArticleController.php | 3 +- .../Controllers/ArticleMetaController.php | 4 +- .../ArticlePermalinkController.php | 3 +- .../Http/Controllers/ArticleTagController.php | 6 +- api/app/Http/Controllers/AuthController.php | 19 ++--- .../Controllers/ChildEntityController.php | 10 +-- .../Http/Controllers/ChildTestController.php | 3 +- .../Http/Controllers/CountriesController.php | 4 +- api/app/Http/Controllers/EntityController.php | 17 ++--- api/app/Http/Controllers/TagController.php | 3 +- api/app/Http/Controllers/TestController.php | 7 +- .../Http/Controllers/TimezoneController.php | 4 +- api/app/Http/Controllers/UserController.php | 24 ++++--- .../Http/Middleware/PermissionMiddleware.php | 6 +- .../Http/Middleware/TransactionMiddleware.php | 4 +- .../TransformInputDataMiddleware.php | 4 +- .../Middleware/UserResolverMiddleware.php | 4 +- .../Transformers/ArticleTagTransformer.php | 3 +- .../Http/Transformers/ArticleTransformer.php | 5 +- .../Transformers/AuthTokenTransformer.php | 3 +- api/app/Http/Transformers/BaseTransformer.php | 4 +- .../Transformers/EloquentModelTransformer.php | 16 ++--- api/app/Http/routes.php | 12 ++-- api/app/Jobs/SendEmailConfirmationEmail.php | 6 +- api/app/Jobs/SendPasswordResetEmail.php | 6 +- api/app/Models/Article.php | 20 +++--- api/app/Models/ArticleDiscussion.php | 4 +- api/app/Models/ArticleImage.php | 3 +- api/app/Models/ArticleMeta.php | 5 +- api/app/Models/ArticlePermalink.php | 7 +- api/app/Models/AuthToken.php | 7 +- api/app/Models/Image.php | 3 +- api/app/Models/SecondTestEntity.php | 5 +- api/app/Models/SocialLogin.php | 4 +- api/app/Models/Tag.php | 5 +- api/app/Models/TestEntity.php | 10 +-- api/app/Models/User.php | 22 +++--- api/app/Models/UserCredential.php | 4 +- api/app/Models/UserProfile.php | 6 +- api/app/Providers/JWTAuthServiceProvider.php | 6 +- api/app/Providers/LockServiceProvider.php | 6 +- .../Services/Api/Vanilla/Api/ApiAbstract.php | 2 +- api/app/Services/Api/Vanilla/Api/Comment.php | 2 +- .../Services/Api/Vanilla/Api/Discussion.php | 4 +- api/app/Services/Api/Vanilla/Api/User.php | 4 +- api/app/Services/Api/Vanilla/Client.php | 6 +- api/app/Services/Datasets/Countries.php | 6 +- api/app/Services/Datasets/Dataset.php | 6 +- api/app/Services/Datasets/Timezones.php | 7 +- api/app/Services/ModelFactoryInstance.php | 11 +-- .../Exceptions/VanillaException.php | 2 +- .../SingleSignOn/VanillaSingleSignOn.php | 26 +++---- api/app/Services/SpiraValidator.php | 4 +- api/app/Services/TransformerService.php | 4 +- api/app/SpiraApplication.php | 2 +- api/bootstrap/app.php | 3 +- api/config/elasticquent.php | 2 +- api/database/factories/ModelFactory.php | 16 ++--- ...ermalink_foreign_key_to_articles_table.php | 1 + api/database/seeds/ArticleSeeder.php | 4 +- api/database/seeds/UserStorySeeder.php | 4 +- api/resources/lang/en/validation.php | 12 ++-- api/src/Model/Collection/Collection.php | 15 ++-- .../Model/Collection/ItemTypeException.php | 3 +- .../Collection/ModelCollectionIterator.php | 6 +- api/src/Model/Model/BaseModel.php | 54 +++++++------- api/src/Model/Model/IndexedModel.php | 13 ++-- api/src/Model/Model/SetRelationException.php | 3 +- api/src/Model/Validation/TypeAwareMessage.php | 3 +- .../ValidationExceptionCollection.php | 5 +- api/src/Model/Validation/Validator.php | 3 +- .../Contract/TransformableInterface.php | 3 +- .../Contract/TransformerInterface.php | 3 +- .../PaginatedRequestDecoratorInterface.php | 5 +- api/src/Responder/Paginator/RangeRequest.php | 24 ++++--- api/src/Responder/Response/ApiResponse.php | 38 +++++----- api/tests/ElasticSearchTest.php | 13 ++-- api/tests/Extensions/SocialiteTest.php | 4 +- api/tests/ModelFactoryTest.php | 1 + api/tests/ModelTest.php | 2 - api/tests/Models/ArticleModelTest.php | 12 ++-- api/tests/RouteHelperTest.php | 6 +- api/tests/Services/Api/VanillaApiTest.php | 22 +++--- .../Services/Api/VanillaIntegrationTest.php | 5 +- api/tests/Services/SingleSignOnTest.php | 2 +- api/tests/TestCase.php | 11 +-- api/tests/Traits/HelpersTrait.php | 4 +- api/tests/Traits/ModelFactoryTrait.php | 2 +- api/tests/TransformerTest.php | 5 +- api/tests/ValidatorTest.php | 12 ++-- api/tests/integration/ArticleImageTest.php | 8 +-- api/tests/integration/ArticleTagTest.php | 5 +- api/tests/integration/ArticleTest.php | 24 +++---- api/tests/integration/AuthTest.php | 9 ++- api/tests/integration/ChildEntityTest.php | 6 +- api/tests/integration/DocumentationTest.php | 2 +- api/tests/integration/EntityTest.php | 59 +++++++-------- api/tests/integration/ExceptionTest.php | 2 +- api/tests/integration/ImageTest.php | 8 +-- api/tests/integration/QueueTest.php | 2 +- api/tests/integration/UserTest.php | 72 +++++++++---------- forum/config.php | 4 +- forum/server.php | 1 + forum/src/Spira/Build.php | 10 +-- forum/src/VanillaConfigurator.php | 22 +++--- .../class.apidiscussioncontroller.php | 10 +-- .../controllers/class.apiusercontroller.php | 4 +- forum/src/apiextended/settings/about.php | 2 +- forum/src/apiextended/settings/bootstrap.php | 3 +- .../src/apiextended/settings/class.hooks.php | 10 +-- 133 files changed, 569 insertions(+), 525 deletions(-) diff --git a/api/app/Console/Commands/ApiaryValidateCommand.php b/api/app/Console/Commands/ApiaryValidateCommand.php index f462a29f..e673286a 100644 --- a/api/app/Console/Commands/ApiaryValidateCommand.php +++ b/api/app/Console/Commands/ApiaryValidateCommand.php @@ -39,13 +39,10 @@ public function handle() { $apiaryController = new ApiaryController(); - $apib = $apiaryController->getDocumentationApib('/'); - $fs = new Filesystem(); - $fileLocation = storage_path().'/app/apiary.apib'; $fs->put($fileLocation, $apib); diff --git a/api/app/Console/Commands/GenerateKeysCommand.php b/api/app/Console/Commands/GenerateKeysCommand.php index 95fe6130..0a74ff17 100644 --- a/api/app/Console/Commands/GenerateKeysCommand.php +++ b/api/app/Console/Commands/GenerateKeysCommand.php @@ -53,7 +53,7 @@ public function handle() $rsa = new Crypt_RSA(); $keys = $rsa->createKey(); - if (!$this->file->exists(storage_path('app/keys'))) { + if (! $this->file->exists(storage_path('app/keys'))) { $this->file->makeDirectory(storage_path('app/keys')); } diff --git a/api/app/Exceptions/ForbiddenException.php b/api/app/Exceptions/ForbiddenException.php index 3e30ec19..5e7617bf 100644 --- a/api/app/Exceptions/ForbiddenException.php +++ b/api/app/Exceptions/ForbiddenException.php @@ -1,4 +1,6 @@ -getMessage(); - if (!$message) { + if (! $message) { $message = 'An error occurred'; } diff --git a/api/app/Extensions/Controller/RequestValidationTrait.php b/api/app/Extensions/Controller/RequestValidationTrait.php index 7e33ff44..a1a33043 100644 --- a/api/app/Extensions/Controller/RequestValidationTrait.php +++ b/api/app/Extensions/Controller/RequestValidationTrait.php @@ -1,9 +1,10 @@ getValidationFactory()->make([$keyName=>$keyName], [$keyName=>'notFound']); - if (!$validation->fails()) { + $validation = $this->getValidationFactory()->make([$keyName => $keyName], [$keyName => 'notFound']); + if (! $validation->fails()) { // @codeCoverageIgnoreStart - throw new \LogicException("Validator should have failed"); + throw new \LogicException('Validator should have failed'); // @codeCoverageIgnoreEnd } @@ -57,7 +57,7 @@ protected function notFoundException($keyName = '') } /** - * Get notFoundManyException + * Get notFoundManyException. * @param $ids * @param Collection $models * @param string $keyName @@ -81,7 +81,6 @@ protected function notFoundManyException($ids, $models, $keyName = '') throw new ValidationExceptionCollection($errors); } - /** * @param $requestEntity * @param array $validationRules @@ -105,7 +104,7 @@ public function validateRequest($requestEntity, $validationRules, $limitToKeysPr } /** - * Validate a request collection + * Validate a request collection. * @param $requestCollection * @param $validationRules * @param bool|false $limitToKeysPresent @@ -133,8 +132,6 @@ public function validateRequestCollection($requestCollection, $validationRules, return true; } - - /** * @param Request $request * @param $id @@ -145,16 +142,16 @@ public function validateRequestCollection($requestCollection, $validationRules, protected function checkEntityIdMatchesRoute(Request $request, $id, BaseModel $model, $requireEntityKey = true) { $keyName = $model->getKeyName(); - if (!$request->has($keyName)) { - if (!$requireEntityKey) { + if (! $request->has($keyName)) { + if (! $requireEntityKey) { return true; //it is ok if the key is not set (for patch requests etc) } else { throw new BadRequestException("Request entity must include entity id ($keyName) for ".get_class($model)); } } - if ((string)$request->input($keyName) !== (string)$id) { - throw new BadRequestException("Provided entity body does not match route parameter. The entity key cannot be updated"); + if ((string) $request->input($keyName) !== (string) $id) { + throw new BadRequestException('Provided entity body does not match route parameter. The entity key cannot be updated'); } return true; diff --git a/api/app/Extensions/JWTAuth/ClaimFactory.php b/api/app/Extensions/JWTAuth/ClaimFactory.php index 81deb10d..b8297426 100644 --- a/api/app/Extensions/JWTAuth/ClaimFactory.php +++ b/api/app/Extensions/JWTAuth/ClaimFactory.php @@ -1,4 +1,6 @@ - 'Tymon\JWTAuth\Claims\JwtId', 'nbf' => 'Tymon\JWTAuth\Claims\NotBefore', 'sub' => 'Tymon\JWTAuth\Claims\Subject', - '_user' => 'App\Extensions\JWTAuth\UserClaim' + '_user' => 'App\Extensions\JWTAuth\UserClaim', ]; /** - * Get the instance of the claim when passing the name and value + * Get the instance of the claim when passing the name and value. * * @param string $name * @param mixed $value @@ -36,10 +38,10 @@ public function get($name, $value) } /** - * Check whether the claim exists + * Check whether the claim exists. * * @param string $name - * @return boolean + * @return bool */ public function has($name) { diff --git a/api/app/Extensions/JWTAuth/JWTAuth.php b/api/app/Extensions/JWTAuth/JWTAuth.php index c2c93158..6c9a3b03 100644 --- a/api/app/Extensions/JWTAuth/JWTAuth.php +++ b/api/app/Extensions/JWTAuth/JWTAuth.php @@ -1,4 +1,6 @@ -setRequest($this->request)->getToken()) { + if (! $token = $this->setRequest($this->request)->getToken()) { throw new BadRequestException('Token not provided.'); } @@ -48,7 +50,7 @@ public function getUser() throw new UnprocessableEntityException($e->getMessage(), null, $e); } - if (!$user) { + if (! $user) { throw new RuntimeException('The user does not exist.'); } @@ -99,7 +101,7 @@ protected function makePayload($user, array $customClaims = []) return $this->manager->getPayloadFactory()->make( array_merge($customClaims, [ 'sub' => $user->user_id, - '_user' => $user + '_user' => $user, ]) ); } diff --git a/api/app/Extensions/JWTAuth/JWTManager.php b/api/app/Extensions/JWTAuth/JWTManager.php index 829457b0..442345d5 100644 --- a/api/app/Extensions/JWTAuth/JWTManager.php +++ b/api/app/Extensions/JWTAuth/JWTManager.php @@ -8,7 +8,7 @@ class JWTManager extends JWTManagerBase { /** - * Refresh a Token and return a new Token + * Refresh a Token and return a new Token. * * @param \Tymon\JWTAuth\Token $token * @return \Tymon\JWTAuth\Token diff --git a/api/app/Extensions/JWTAuth/NamshiAdapter.php b/api/app/Extensions/JWTAuth/NamshiAdapter.php index b39490ef..3bd401a7 100644 --- a/api/app/Extensions/JWTAuth/NamshiAdapter.php +++ b/api/app/Extensions/JWTAuth/NamshiAdapter.php @@ -71,7 +71,7 @@ public function decode($token) throw new TokenInvalidException('Could not decode token: '.$e->getMessage(), null, $e); } - if (!$jws->verify($this->secret['public'], $this->algo)) { + if (! $jws->verify($this->secret['public'], $this->algo)) { throw new TokenInvalidException('Token Signature could not be verified.'); } diff --git a/api/app/Extensions/JWTAuth/PayloadFactory.php b/api/app/Extensions/JWTAuth/PayloadFactory.php index 3d9ed3ea..780bf25b 100644 --- a/api/app/Extensions/JWTAuth/PayloadFactory.php +++ b/api/app/Extensions/JWTAuth/PayloadFactory.php @@ -1,6 +1,7 @@ -usernameIsUnique($tryName)); + } while (! $this->usernameIsUnique($tryName)); return $tryName; } diff --git a/api/app/Extensions/Socialite/Two/ProviderTrait.php b/api/app/Extensions/Socialite/Two/ProviderTrait.php index a3aa43ea..7e36d370 100644 --- a/api/app/Extensions/Socialite/Two/ProviderTrait.php +++ b/api/app/Extensions/Socialite/Two/ProviderTrait.php @@ -67,7 +67,7 @@ protected function getCodeFields($state = null) 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUrl, 'scope' => $this->formatScopes($this->scopes, $this->scopeSeparator), 'response_type' => 'code', - 'state' => $state + 'state' => $state, ]; return $fields; diff --git a/api/app/Helpers/RouteHelper.php b/api/app/Helpers/RouteHelper.php index ce365aef..defb4fb9 100644 --- a/api/app/Helpers/RouteHelper.php +++ b/api/app/Helpers/RouteHelper.php @@ -1,9 +1,10 @@ $model->getQueueableId()]); + return route(get_class($model), ['id' => $model->getQueueableId()]); } catch (\InvalidArgumentException $e) { static::$badRoutes[get_class($model)] = true; } diff --git a/api/app/Http/Controllers/ApiController.php b/api/app/Http/Controllers/ApiController.php index ac342c95..10e9aa47 100644 --- a/api/app/Http/Controllers/ApiController.php +++ b/api/app/Http/Controllers/ApiController.php @@ -1,9 +1,10 @@ headers->get('With-Nested'); - if (!$nested) { + if (! $nested) { return $modelOrCollection; } diff --git a/api/app/Http/Controllers/ApiaryController.php b/api/app/Http/Controllers/ApiaryController.php index 30a01f86..b594def4 100644 --- a/api/app/Http/Controllers/ApiaryController.php +++ b/api/app/Http/Controllers/ApiaryController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; use Illuminate\Support\Facades\View; use Laravel\Lumen\Routing\Controller; use Faker; diff --git a/api/app/Http/Controllers/ArticleController.php b/api/app/Http/Controllers/ArticleController.php index 9129b6ef..5df6bed8 100644 --- a/api/app/Http/Controllers/ArticleController.php +++ b/api/app/Http/Controllers/ArticleController.php @@ -1,9 +1,10 @@ getChildModel() ->hydrateRequestCollection($requestCollection, $existingChildModels) ->each(function (BaseModel $model) { - if (!$model->exists) { + if (! $model->exists) { $model->save(); } }); - $this->getRelation($parent)->sync($childModels->lists('tag_id')->toArray()); return $this->getResponse() diff --git a/api/app/Http/Controllers/AuthController.php b/api/app/Http/Controllers/AuthController.php index bfa92379..7b27cb19 100644 --- a/api/app/Http/Controllers/AuthController.php +++ b/api/app/Http/Controllers/AuthController.php @@ -82,11 +82,11 @@ public function login(Request $request) 'password' => $request->getPassword(), ]; - if (!$token = $this->attemptLogin($credentials)) { + if (! $token = $this->attemptLogin($credentials)) { // Check to see if the user has recently requested to change their email and try to log in using it if ($oldEmail = User::findCurrentEmail($credentials['email'])) { $credentials['email'] = $oldEmail; - if (!$token = $this->attemptLogin($credentials)) { + if (! $token = $this->attemptLogin($credentials)) { throw new UnauthorizedException('Credentials failed.'); } } else { @@ -107,7 +107,7 @@ public function login(Request $request) */ private function attemptLogin($credentials) { - if (!$this->auth->attempt($credentials)) { + if (! $this->auth->attempt($credentials)) { return false; } @@ -121,7 +121,7 @@ private function attemptLogin($credentials) } /** - * Refresh a login token + * Refresh a login token. * * @return ApiResponse */ @@ -153,14 +153,14 @@ public function refresh() public function token(Request $request, User $userModel) { $header = $request->headers->get('authorization'); - if (!starts_with(strtolower($header), 'token')) { + if (! starts_with(strtolower($header), 'token')) { throw new BadRequestException('Single use token not provided.'); } $token = trim(substr($header, 5)); // If we didn't find the user, it was an expired/invalid token. No access granted - if (!$user = $userModel->findByLoginToken($token)) { + if (! $user = $userModel->findByLoginToken($token)) { throw new UnauthorizedException('Token invalid.'); } @@ -207,7 +207,7 @@ public function handleProviderCallback($provider, Socialite $socialite, User $us // with Twitter for instance, that isn't whitelisted, no email // address will be returned with the response. // See the notes in Spira API doc under Social Login for more info. - if (!$socialUser->email) { + if (! $socialUser->email) { // The app is connected with the service, but the 3rd party service // is not configured or allowed to return email addresses, so we // can't process the data further. Let's throw an exception. @@ -232,10 +232,11 @@ public function handleProviderCallback($provider, Socialite $socialite, User $us // Prepare response data $token = $this->jwtAuth->fromUser($user, ['method' => $provider]); - $returnUrl = $socialite->with($provider)->getCachedReturnUrl() . '?jwtAuthToken=' . $token; + $returnUrl = $socialite->with($provider)->getCachedReturnUrl().'?jwtAuthToken='.$token; $response = $this->getResponse(); $response->redirect($returnUrl, 302); + return $response; } @@ -275,7 +276,7 @@ public function singleSignOn($requester, Request $request) */ protected function validateProvider($provider) { - if (!in_array($provider, array_keys($this->app['config']['services']))) { + if (! in_array($provider, array_keys($this->app['config']['services']))) { throw new NotImplementedException('Provider '.$provider.' is not supported.'); } } diff --git a/api/app/Http/Controllers/ChildEntityController.php b/api/app/Http/Controllers/ChildEntityController.php index 29abd453..e76cd31a 100644 --- a/api/app/Http/Controllers/ChildEntityController.php +++ b/api/app/Http/Controllers/ChildEntityController.php @@ -1,9 +1,10 @@ parentModel = $parentModel; - if (!$this->relationName) { + if (! $this->relationName) { throw new \InvalidArgumentException('You must specify relationName in '.static::class); } - if (!method_exists($parentModel, $this->relationName)) { + if (! method_exists($parentModel, $this->relationName)) { throw new \InvalidArgumentException('Relation '.$this->relationName.', required by '. static::class.', does not exist in '.get_class($parentModel) ); @@ -51,7 +52,6 @@ public function __construct(BaseModel $parentModel, TransformerInterface $transf parent::__construct($transformer); } - /** * Get all entities. * @@ -263,6 +263,7 @@ public function getChildModel() if (is_null($this->cacheChildModel)) { $this->cacheChildModel = $this->getRelation($this->parentModel)->getRelated(); } + return $this->cacheChildModel; } @@ -275,7 +276,6 @@ protected function getRelation(BaseModel $model) return $model->{$this->relationName}(); } - /** * @param $id * @return BaseModel diff --git a/api/app/Http/Controllers/ChildTestController.php b/api/app/Http/Controllers/ChildTestController.php index 16fd6aa3..5ed3bbf0 100644 --- a/api/app/Http/Controllers/ChildTestController.php +++ b/api/app/Http/Controllers/ChildTestController.php @@ -1,9 +1,10 @@ getAllEntities(); $collection = $this->getWithNested($collection, $request); - + return $this->getResponse() ->transformer($this->getTransformer()) ->collection($collection); @@ -54,7 +55,7 @@ public function getAllPaginated(Request $request, RangeRequest $rangeRequest) { $totalCount = $this->countEntities(); $limit = $rangeRequest->getLimit($this->paginatorDefaultLimit, $this->paginatorMaxLimit); - $offset = $rangeRequest->isGetLast()?$totalCount-$limit:$rangeRequest->getOffset(); + $offset = $rangeRequest->isGetLast() ? $totalCount - $limit : $rangeRequest->getOffset(); if ($request->has('q')) { $collection = $this->searchAllEntities($request->query('q'), $limit, $offset, $totalCount); @@ -83,8 +84,7 @@ public function getOne(Request $request, $id) return $this->getResponse() ->transformer($this->getTransformer()) - ->item($model) - ; + ->item($model); } /** @@ -285,12 +285,12 @@ protected function searchAllEntities($queryString, $limit = null, $offset = null $searchResults = $model->searchByQuery([ 'match_phrase' => [ - '_all' => $queryString - ] + '_all' => $queryString, + ], ], null, null, $limit, $offset); if ($searchResults->totalHits() === 0) { - throw new NotFoundHttpException(sprintf("No results found with query `%s` for model `%s`", $queryString, get_class($model))); + throw new NotFoundHttpException(sprintf('No results found with query `%s` for model `%s`', $queryString, get_class($model))); } if (isset($totalCount) && $searchResults->totalHits() < $totalCount) { @@ -328,6 +328,7 @@ protected function findOrFailCollection($requestCollection) protected function findCollection($requestCollection) { $ids = $this->getIds($requestCollection, $this->getModel()->getKeyName()); + return $this->getModel()->findMany($ids); //if $ids is empty, findMany returns an empty collection } diff --git a/api/app/Http/Controllers/TagController.php b/api/app/Http/Controllers/TagController.php index 5018228c..c7f57eaa 100644 --- a/api/app/Http/Controllers/TagController.php +++ b/api/app/Http/Controllers/TagController.php @@ -1,9 +1,10 @@ getResponse()->item(['test'=>$id]); + return $this->getResponse()->item(['test' => $id]); } /** diff --git a/api/app/Http/Controllers/TimezoneController.php b/api/app/Http/Controllers/TimezoneController.php index e469b929..09ce741c 100644 --- a/api/app/Http/Controllers/TimezoneController.php +++ b/api/app/Http/Controllers/TimezoneController.php @@ -1,4 +1,6 @@ -input('_user_profile', []); // Set new users to guest - $request->merge(['user_type' =>'guest']); + $request->merge(['user_type' => 'guest']); if ($this->getModel()->find($id)) { throw new ValidationException( @@ -116,7 +118,7 @@ public function putOne(Request $request, $id) $model->setCredential(new UserCredential($credential)); // Finally create the profile if it exists - if (!empty($profile)) { + if (! empty($profile)) { $this->validateRequest($profile, UserProfile::getValidationRules()); $model->setProfile(new UserProfile($profile)); } @@ -150,7 +152,7 @@ public function patchOne(Request $request, $id) // Change in email has been confirmed, set the new email if ($token = $request->headers->get('email-confirm-token')) { - if (!$email = $model->getEmailFromToken($token)) { + if (! $email = $model->getEmailFromToken($token)) { throw new ValidationException( new MessageBag(['email_confirmed' => 'The email confirmation token is not valid.']) ); @@ -165,7 +167,7 @@ public function patchOne(Request $request, $id) // Extract the profile and update if necessary $profileUpdateDetails = $request->input('_user_profile', []); - if (!empty($profileUpdateDetails)) { + if (! empty($profileUpdateDetails)) { /** @var UserProfile $profile */ $profile = UserProfile::findOrNew($id); // The user profile may not exist for the user $this->validateRequest($profileUpdateDetails, UserProfile::getValidationRules(), $profile->exists); @@ -173,10 +175,10 @@ public function patchOne(Request $request, $id) $model->setProfile($profile); } - /** @var \Tymon\JWTAuth\JWTAuth $jwtAuth */ + /* @var \Tymon\JWTAuth\JWTAuth $jwtAuth */ // Extract the credentials and update if necessary $credentialUpdateDetails = $request->input('_user_credential', []); - if (!empty($credentialUpdateDetails)) { + if (! empty($credentialUpdateDetails)) { // Invalidate token for the user when user changes their password if ($this->jwtAuth->user()->user_id == $model->user_id) { $token = $this->jwtAuth->getTokenFromRequest(); @@ -184,7 +186,7 @@ public function patchOne(Request $request, $id) } $credentials = UserCredential::findOrNew($id); - /** @var UserCredential $credentials */ + /* @var UserCredential $credentials */ $credentials->fill($credentialUpdateDetails); $model->setCredential($credentials); } @@ -220,7 +222,7 @@ public function resetPassword($email) } /** - * Deletes a social login entry from the database + * Deletes a social login entry from the database. * * @param $id * @param $provider @@ -228,7 +230,7 @@ public function resetPassword($email) */ public function unlinkSocialLogin($id, $provider) { - if (!$socialLogin = SocialLogin::where('user_id', '=', $id) + if (! $socialLogin = SocialLogin::where('user_id', '=', $id) ->where('provider', '=', $provider) ->first()) { throw new NotFoundHttpException('Sorry, this provider does not exist for this user.'); @@ -244,7 +246,7 @@ public function unlinkSocialLogin($id, $provider) } /** - * Get full user details + * Get full user details. * * @param Request $request * @param string $id diff --git a/api/app/Http/Middleware/PermissionMiddleware.php b/api/app/Http/Middleware/PermissionMiddleware.php index 071361d5..3bc9d61e 100644 --- a/api/app/Http/Middleware/PermissionMiddleware.php +++ b/api/app/Http/Middleware/PermissionMiddleware.php @@ -1,4 +1,6 @@ -jwtAuth->getUser(); $lock = $this->lock->makeCallerLockAware($user); - if (!$user->can($action, $resource)) { + if (! $user->can($action, $resource)) { throw new ForbiddenException; } diff --git a/api/app/Http/Middleware/TransactionMiddleware.php b/api/app/Http/Middleware/TransactionMiddleware.php index a75eee1d..a98ef1bd 100644 --- a/api/app/Http/Middleware/TransactionMiddleware.php +++ b/api/app/Http/Middleware/TransactionMiddleware.php @@ -1,9 +1,10 @@ connectionResolver->connection()->commit(); + return $response; } } diff --git a/api/app/Http/Middleware/TransformInputDataMiddleware.php b/api/app/Http/Middleware/TransformInputDataMiddleware.php index d5aa3c95..52c96c75 100644 --- a/api/app/Http/Middleware/TransformInputDataMiddleware.php +++ b/api/app/Http/Middleware/TransformInputDataMiddleware.php @@ -39,7 +39,7 @@ protected function renameKeys(array $array) $value = (is_array($value)) ? $this->renameKeys($value) : $value; // Convert camelCase to snake_case - if (is_string($key) && !ctype_lower($key)) { + if (is_string($key) && ! ctype_lower($key)) { $newArray[snake_case($key)] = $value; } else { $newArray[$key] = $value; @@ -64,7 +64,7 @@ protected function transformRequestInput(Request $request, $input) // Find any potential camelCase keys in the 'root' array, and convert // them to snake_case - if (!ctype_lower($key)) { + if (! ctype_lower($key)) { // Only convert if the key will change if ($key != snake_case($key)) { $request->offsetSet(snake_case($key), $value); diff --git a/api/app/Http/Middleware/UserResolverMiddleware.php b/api/app/Http/Middleware/UserResolverMiddleware.php index b24d57cc..c198981d 100644 --- a/api/app/Http/Middleware/UserResolverMiddleware.php +++ b/api/app/Http/Middleware/UserResolverMiddleware.php @@ -1,4 +1,6 @@ - ArticleTagTransformer::class + 'tags' => ArticleTagTransformer::class, ]; /** diff --git a/api/app/Http/Transformers/AuthTokenTransformer.php b/api/app/Http/Transformers/AuthTokenTransformer.php index ddc2f356..801580b0 100644 --- a/api/app/Http/Transformers/AuthTokenTransformer.php +++ b/api/app/Http/Transformers/AuthTokenTransformer.php @@ -30,11 +30,10 @@ protected function transformToken($token) return [ 'token' => (string) $token, - 'decodedTokenBody' => $jwtAuth->decode($token)->toArray() + 'decodedTokenBody' => $jwtAuth->decode($token)->toArray(), ]; } - /** * Collections are not used for token transformations. * diff --git a/api/app/Http/Transformers/BaseTransformer.php b/api/app/Http/Transformers/BaseTransformer.php index 34553ffc..b893df9a 100644 --- a/api/app/Http/Transformers/BaseTransformer.php +++ b/api/app/Http/Transformers/BaseTransformer.php @@ -1,4 +1,6 @@ -transformItem($childModelOrCollection); } - $array = $array + ['_' . $relation => $childTransformed]; + $array = $array + ['_'.$relation => $childTransformed]; unset($array[$relation]); } } @@ -221,7 +221,7 @@ private function nestRelations($object, $array) * @param string $default * @return TransformerInterface */ - private function getTransformerForNested($relationName, $default = EloquentModelTransformer::class) + private function getTransformerForNested($relationName, $default = self::class) { if (isset($this->nestedMap[$relationName])) { $className = $this->nestedMap[$relationName]; diff --git a/api/app/Http/routes.php b/api/app/Http/routes.php index 62fd9858..c6ad6af5 100644 --- a/api/app/Http/routes.php +++ b/api/app/Http/routes.php @@ -32,7 +32,7 @@ $app->group(['prefix' => 'articles'], function (Application $app) { $app->get('/', 'App\Http\Controllers\ArticleController@getAllPaginated'); - $app->get('{id}', ['as'=>\App\Models\Article::class, 'uses'=>'App\Http\Controllers\ArticleController@getOne']); + $app->get('{id}', ['as' => \App\Models\Article::class, 'uses' => 'App\Http\Controllers\ArticleController@getOne']); $app->post('/', 'App\Http\Controllers\ArticleController@postOne'); $app->put('{id}', 'App\Http\Controllers\ArticleController@putOne'); $app->patch('{id}', 'App\Http\Controllers\ArticleController@patchOne'); @@ -56,7 +56,7 @@ }); $app->group(['prefix' => 'tags'], function (Application $app) { - $app->get('{id}', ['as'=>\App\Models\Tag::class, 'uses'=>'App\Http\Controllers\TagController@getOne']); + $app->get('{id}', ['as' => \App\Models\Tag::class, 'uses' => 'App\Http\Controllers\TagController@getOne']); $app->post('/', 'App\Http\Controllers\TagController@postOne'); $app->patch('{id}', 'App\Http\Controllers\TagController@patchOne'); $app->delete('{id}', 'App\Http\Controllers\TagController@deleteOne'); @@ -64,12 +64,11 @@ $app->group(['prefix' => 'images'], function (Application $app) { $app->get('/', 'App\Http\Controllers\ImageController@getAllPaginated'); - $app->get('{id}', ['as'=>\App\Models\Image::class, 'uses'=>'App\Http\Controllers\ImageController@getOne']); + $app->get('{id}', ['as' => \App\Models\Image::class, 'uses' => 'App\Http\Controllers\ImageController@getOne']); $app->put('{id}', 'App\Http\Controllers\ImageController@putOne'); $app->patch('{id}', 'App\Http\Controllers\ImageController@patchOne'); $app->delete('{id}', 'App\Http\Controllers\ImageController@deleteOne'); - // @TODO add version, same way as permalinks ?? // $app->get('{id}/versions', 'App\Http\Controllers\ImageVersionsController@getAll'); }); @@ -82,8 +81,8 @@ $app->get('/entities', 'App\Http\Controllers\TestController@getAll'); $app->get('/entities/pages', 'App\Http\Controllers\TestController@getAllPaginated'); $app->get('/entities_encoded/{id}', 'App\Http\Controllers\TestController@urlEncode'); - $app->get('/entities/{id}', ['as'=>\App\Models\TestEntity::class, 'uses'=>'App\Http\Controllers\TestController@getOne']); - $app->get('/entities-second/{id}', ['as'=>\App\Models\SecondTestEntity::class, 'uses'=>'App\Http\Controllers\TestController@getOne']); + $app->get('/entities/{id}', ['as' => \App\Models\TestEntity::class, 'uses' => 'App\Http\Controllers\TestController@getOne']); + $app->get('/entities-second/{id}', ['as' => \App\Models\SecondTestEntity::class, 'uses' => 'App\Http\Controllers\TestController@getOne']); $app->post('/entities', 'App\Http\Controllers\TestController@postOne'); $app->put('/entities/{id}', 'App\Http\Controllers\TestController@putOne'); $app->put('/entities', 'App\Http\Controllers\TestController@putMany'); @@ -92,7 +91,6 @@ $app->delete('/entities/{id}', 'App\Http\Controllers\TestController@deleteOne'); $app->delete('/entities', 'App\Http\Controllers\TestController@deleteMany'); - $app->get('/entities/{id}/children', 'App\Http\Controllers\ChildTestController@getAll'); $app->get('/entities/{id}/child/{childId}', 'App\Http\Controllers\ChildTestController@getOne'); $app->post('/entities/{id}/child', 'App\Http\Controllers\ChildTestController@postOne'); diff --git a/api/app/Jobs/SendEmailConfirmationEmail.php b/api/app/Jobs/SendEmailConfirmationEmail.php index 91346fb1..6fd851ff 100644 --- a/api/app/Jobs/SendEmailConfirmationEmail.php +++ b/api/app/Jobs/SendEmailConfirmationEmail.php @@ -1,4 +1,6 @@ -send('emails.emailConfirmation', [ 'user' => $this->user, 'email' => $this->email, - 'emailConfirmationRedirectionUrl' => Config::get('hosts.app') . '/profile?emailConfirmationToken=' . $this->emailConfirmToken . '&loginToken=' . $this->loginToken + 'emailConfirmationRedirectionUrl' => Config::get('hosts.app').'/profile?emailConfirmationToken='.$this->emailConfirmToken.'&loginToken='.$this->loginToken, ], function ($m) { $m->to($this->email, $this->user->full_name) diff --git a/api/app/Jobs/SendPasswordResetEmail.php b/api/app/Jobs/SendPasswordResetEmail.php index 0832fa7e..a684fc6d 100644 --- a/api/app/Jobs/SendPasswordResetEmail.php +++ b/api/app/Jobs/SendPasswordResetEmail.php @@ -1,4 +1,6 @@ -send('emails.resetPassword', [ 'user' => $this->user, - 'passwordResetRedirectionUrl' => Config::get('hosts.app') . '/profile?loginToken='.$this->loginToken + 'passwordResetRedirectionUrl' => Config::get('hosts.app').'/profile?loginToken='.$this->loginToken, ], function ($m) { $m->to($this->user->email, $this->user->full_name) ->subject('Password Reset'); diff --git a/api/app/Models/Article.php b/api/app/Models/Article.php index 3f3d0bd3..3634ee6b 100644 --- a/api/app/Models/Article.php +++ b/api/app/Models/Article.php @@ -1,4 +1,6 @@ - 'required|string', 'excerpt' => 'string', 'primaryImage' => 'string', - 'status' => 'in:' . implode(',', static::$statuses), + 'status' => 'in:'.implode(',', static::$statuses), 'permalink' => 'string|unique:article_permalinks,permalink', 'author_id' => 'required|uuid|exists:users,user_id', ]; @@ -78,18 +76,20 @@ protected static function boot() { parent::boot(); static::saving(function (Article $model) { - if ($model->getOriginal('permalink') !== $model->permalink && !is_null($model->permalink)) { - $articlePermalink = new ArticlePermalink(['permalink'=>$model->permalink]); + if ($model->getOriginal('permalink') !== $model->permalink && ! is_null($model->permalink)) { + $articlePermalink = new ArticlePermalink(['permalink' => $model->permalink]); $articlePermalink->save(); } + return true; }); static::saved(function (Article $model) { - if ($model->getOriginal('permalink') !== $model->permalink && !is_null($model->permalink)) { + if ($model->getOriginal('permalink') !== $model->permalink && ! is_null($model->permalink)) { $articlePermalink = ArticlePermalink::findOrFail($model->permalink); $model->permalinks()->save($articlePermalink); } + return true; }); @@ -140,7 +140,7 @@ public function setPermalinkAttribute($permalink) } /** - * If there is no defined excerpt for the text, create it from the content + * If there is no defined excerpt for the text, create it from the content. * @param $excerpt * @return string */ diff --git a/api/app/Models/ArticleDiscussion.php b/api/app/Models/ArticleDiscussion.php index c4e68b85..a65e2b8e 100644 --- a/api/app/Models/ArticleDiscussion.php +++ b/api/app/Models/ArticleDiscussion.php @@ -276,7 +276,7 @@ public function getEager() $results = new Collection; foreach ($this->eagerConstraints as $model) { - $comments = new ArticleDiscussion; + $comments = new self; $comments->setArticle($model); $results->offsetSet($model->getKey(), $comments->getResults()); } @@ -330,7 +330,7 @@ public function setArticle(Article $article) */ protected function getClient() { - if (!$this->client) { + if (! $this->client) { $this->client = App::make(VanillaClient::class); } diff --git a/api/app/Models/ArticleImage.php b/api/app/Models/ArticleImage.php index 4de7bff5..404139fd 100644 --- a/api/app/Models/ArticleImage.php +++ b/api/app/Models/ArticleImage.php @@ -1,9 +1,10 @@ 'required|string', 'meta_content' => 'string', - 'meta_property' => 'string' + 'meta_property' => 'string', ]; } diff --git a/api/app/Models/ArticlePermalink.php b/api/app/Models/ArticlePermalink.php index 42c18100..913a3396 100644 --- a/api/app/Models/ArticlePermalink.php +++ b/api/app/Models/ArticlePermalink.php @@ -1,9 +1,10 @@ 'string|required', 'check_entity_id' => 'uuid', - 'value' => 'required|string' + 'value' => 'required|string', ]; public function article() diff --git a/api/app/Models/AuthToken.php b/api/app/Models/AuthToken.php index 3da68c0b..cf7e3b21 100644 --- a/api/app/Models/AuthToken.php +++ b/api/app/Models/AuthToken.php @@ -1,11 +1,12 @@ - 'required|uuid', 'check_entity_id' => 'uuid', - 'value' => 'required|string' + 'value' => 'required|string', ]; } diff --git a/api/app/Models/SocialLogin.php b/api/app/Models/SocialLogin.php index d18bf4ea..d842866f 100644 --- a/api/app/Models/SocialLogin.php +++ b/api/app/Models/SocialLogin.php @@ -1,4 +1,6 @@ - 'required|uuid', - 'tag' => 'required|string|alphaDashSpace|max:20' + 'tag' => 'required|string|alphaDashSpace|max:20', ]; /** diff --git a/api/app/Models/TestEntity.php b/api/app/Models/TestEntity.php index 0b237155..35218e1f 100644 --- a/api/app/Models/TestEntity.php +++ b/api/app/Models/TestEntity.php @@ -1,11 +1,12 @@ - 'required|string', 'date' => 'required|date', 'multi_word_column_title' => 'required|boolean', - 'hidden' => 'required|boolean' + 'hidden' => 'required|boolean', ]; } - public function testOne() { return $this->hasOne(SecondTestEntity::class, 'check_entity_id', 'entity_id'); diff --git a/api/app/Models/User.php b/api/app/Models/User.php index df99d595..ef101e56 100644 --- a/api/app/Models/User.php +++ b/api/app/Models/User.php @@ -1,4 +1,6 @@ -userCredential) { + if (! $this->userCredential) { return ''; } @@ -275,7 +275,7 @@ public function findByLoginToken($token) return $user; } - return null; + return; } /** @@ -317,9 +317,9 @@ public function createEmailConfirmToken($newEmail, $oldEmail) { $token = hash_hmac('sha256', str_random(40), str_random(40)); - Cache::put('email_confirmation_' . $token, $newEmail, $this->token_ttl); + Cache::put('email_confirmation_'.$token, $newEmail, $this->token_ttl); - Cache::put('email_change_' . $newEmail, $oldEmail, $this->token_ttl); + Cache::put('email_change_'.$newEmail, $oldEmail, $this->token_ttl); return $token; } @@ -332,10 +332,10 @@ public function createEmailConfirmToken($newEmail, $oldEmail) */ public function getEmailFromToken($token) { - $newEmail = Cache::pull('email_confirmation_' . $token, false); + $newEmail = Cache::pull('email_confirmation_'.$token, false); if ($newEmail) { - Cache::forget('email_change_' . $newEmail); + Cache::forget('email_change_'.$newEmail); } return $newEmail; @@ -349,6 +349,6 @@ public function getEmailFromToken($token) */ public static function findCurrentEmail($newEmail) { - return Cache::get('email_change_' . $newEmail, false); // Return false on cache miss + return Cache::get('email_change_'.$newEmail, false); // Return false on cache miss } } diff --git a/api/app/Models/UserCredential.php b/api/app/Models/UserCredential.php index 61b006e5..729f47b5 100644 --- a/api/app/Models/UserCredential.php +++ b/api/app/Models/UserCredential.php @@ -1,4 +1,6 @@ - $body, - 'Format' => $format + 'Format' => $format, ]; return $this->post('discussions/'.$discussionId.'/comments', $parameters); diff --git a/api/app/Services/Api/Vanilla/Api/Discussion.php b/api/app/Services/Api/Vanilla/Api/Discussion.php index ca1d39ee..5dc33a0e 100644 --- a/api/app/Services/Api/Vanilla/Api/Discussion.php +++ b/api/app/Services/Api/Vanilla/Api/Discussion.php @@ -35,7 +35,7 @@ public function create($name, $body, $categoryId, array $additional = []) $parameters = [ 'Name' => $name, 'Body' => $body, - 'CategoryID' => $categoryId + 'CategoryID' => $categoryId, ]; $parameters = array_merge($parameters, $additional); @@ -90,7 +90,7 @@ public function update($id, $name, $body) { $parameters = [ 'Name' => $name, - 'Body' => $body + 'Body' => $body, ]; return $this->put('discussions/'.$id, $parameters); diff --git a/api/app/Services/Api/Vanilla/Api/User.php b/api/app/Services/Api/Vanilla/Api/User.php index f57eddc7..40fd56a9 100644 --- a/api/app/Services/Api/Vanilla/Api/User.php +++ b/api/app/Services/Api/Vanilla/Api/User.php @@ -22,7 +22,7 @@ public function sso($userId, $username, $email, $photo = '', array $roles = []) 'Name' => $username, 'Email' => $email, 'Photo' => $photo, - 'Roles' => $roles + 'Roles' => $roles, ]; $parameters = array_filter($parameters); @@ -51,7 +51,7 @@ public function sso($userId, $username, $email, $photo = '', array $roles = []) public function remove($id, $method = 'delete') { $parameters = [ - 'Method' => $method + 'Method' => $method, ]; return $this->delete('users/hotfix/'.$id, $parameters); diff --git a/api/app/Services/Api/Vanilla/Client.php b/api/app/Services/Api/Vanilla/Client.php index 925edc24..d5ffb747 100644 --- a/api/app/Services/Api/Vanilla/Client.php +++ b/api/app/Services/Api/Vanilla/Client.php @@ -245,7 +245,7 @@ public function sign(array $options, $method, $path) 'path' => $path, 'username' => $this->user['username'], 'email' => $this->user['email'], - 'timestamp' => time() + 'timestamp' => time(), ]; // Strip away any empty records (username/email might not be provided) @@ -280,12 +280,12 @@ public function setUser($username = null, $email = null) { $this->user = [ 'username' => $username, - 'email' => $email + 'email' => $email, ]; } /** - * Get the forum host url + * Get the forum host url. * @return string */ protected function getForumHost() diff --git a/api/app/Services/Datasets/Countries.php b/api/app/Services/Datasets/Countries.php index 6a889e01..48372e8a 100644 --- a/api/app/Services/Datasets/Countries.php +++ b/api/app/Services/Datasets/Countries.php @@ -1,4 +1,6 @@ -json() as $country) { $countries->push(new Collection([ 'country_name' => $country['name'], - 'country_code' => $country['alpha2Code'] + 'country_code' => $country['alpha2Code'], ])); } diff --git a/api/app/Services/Datasets/Dataset.php b/api/app/Services/Datasets/Dataset.php index f62bc3d7..7339c3f4 100644 --- a/api/app/Services/Datasets/Dataset.php +++ b/api/app/Services/Datasets/Dataset.php @@ -1,4 +1,6 @@ - $this->formatDisplayOffset($offset), ])); } + return $timezones; } @@ -46,6 +49,6 @@ protected function formatDisplayOffset($offset) $inital->setTimestamp(abs($offset)); $hoursFormatted = $inital->format('H:i'); - return ($offset >= 0 ? '+':'-') . $hoursFormatted; + return ($offset >= 0 ? '+' : '-').$hoursFormatted; } } diff --git a/api/app/Services/ModelFactoryInstance.php b/api/app/Services/ModelFactoryInstance.php index d09d45ed..54680540 100644 --- a/api/app/Services/ModelFactoryInstance.php +++ b/api/app/Services/ModelFactoryInstance.php @@ -107,7 +107,7 @@ public function hide(array $hide) } /** - * Add properties to the returned entity + * Add properties to the returned entity. * * @param $key * @param $value @@ -135,6 +135,7 @@ public function append($key, $value) public function setTransformer($transformerName) { $this->transformer = new $transformerName($this->transformerService); + return $this; } @@ -175,7 +176,7 @@ private function modifyEntity($entity) $attributes = $entity->getAttributes(); $appends = $entity->appends; $modifiedArray = array_keys($attributes); - if (!empty($appends)) { + if (! empty($appends)) { $modifiedArray = array_merge($modifiedArray, $appends); } $newHidden = array_diff($modifiedArray, $this->showOnly); @@ -198,7 +199,7 @@ private function modifyEntity($entity) $entity->setHidden($newHidden); } - if (!empty($this->appends)) { + if (! empty($this->appends)) { foreach ($this->appends as $appendKey => $appendValue) { $entity->{$appendKey} = $appendValue; } @@ -252,7 +253,7 @@ public function transformed() $entity = $this->modified(); } - if (!$this->transformer) { + if (! $this->transformer) { $this->transformer = new EloquentModelTransformer($this->transformerService); } $method = 'transform'.ucfirst($this->entityType); @@ -298,7 +299,7 @@ public function toJson($options = 0) /** * Create a collection of models. - * Shortcut for FactoryBuilder + * Shortcut for FactoryBuilder. * @param array $attributes * @return mixed */ diff --git a/api/app/Services/SingleSignOn/Exceptions/VanillaException.php b/api/app/Services/SingleSignOn/Exceptions/VanillaException.php index e6aa2f74..aab14b59 100644 --- a/api/app/Services/SingleSignOn/Exceptions/VanillaException.php +++ b/api/app/Services/SingleSignOn/Exceptions/VanillaException.php @@ -2,7 +2,7 @@ namespace App\Services\SingleSignOn\Exceptions; -use \Exception; +use Exception; abstract class VanillaException extends Exception { diff --git a/api/app/Services/SingleSignOn/VanillaSingleSignOn.php b/api/app/Services/SingleSignOn/VanillaSingleSignOn.php index f15ea76e..6266f643 100644 --- a/api/app/Services/SingleSignOn/VanillaSingleSignOn.php +++ b/api/app/Services/SingleSignOn/VanillaSingleSignOn.php @@ -68,7 +68,7 @@ public function getResponse() } catch (VanillaException $e) { return $this->formatResponse([ 'error' => $e->getType(), - 'message' => $e->getMessage() + 'message' => $e->getMessage(), ]); } } @@ -90,15 +90,15 @@ protected function getUser() if (empty($user)) { return [ 'name' => '', - 'photourl' => '' + 'photourl' => '', ]; } // When no signature and timestamp is sent, only return public information - if (!$this->request->has('timestamp') && !$this->request->has('signature')) { + if (! $this->request->has('timestamp') && ! $this->request->has('signature')) { return [ 'name' => $user['name'], - 'photourl' => @$user['photourl'] + 'photourl' => @$user['photourl'], ]; } @@ -120,7 +120,7 @@ protected function getUser() */ public function formatUser() { - if (!$this->user) { + if (! $this->user) { return []; } else { return [ @@ -128,7 +128,7 @@ public function formatUser() 'name' => $this->user->username, 'email' => $this->user->email, 'photourl' => $this->user->avatar_img_url, - 'roles' => $this->getMappedRoles() + 'roles' => $this->getMappedRoles(), ]; } } @@ -146,7 +146,7 @@ protected function getMappedRoles() $roles = $roles->map(function ($role) { $mapping = [ 'admin' => 'administrator', - 'guest' => 'member' + 'guest' => 'member', ]; if (array_key_exists($role, $mapping)) { @@ -182,7 +182,7 @@ protected function formatResponse(array $data) * * @param array $data * @param string $hashType - * @param boolean $returnData + * @param bool $returnData * * @return mixed */ @@ -247,7 +247,7 @@ protected function hash($string, $secure = true) */ protected function ssoString(array $user) { - if (!isset($user['client_id'])) { + if (! isset($user['client_id'])) { $user['client_id'] = $this->clientId; } @@ -291,7 +291,7 @@ protected function validateRequest() if ($condition) { $method = camel_case('validCondition_'.$condition); - if (!$this->{$method}()) { + if (! $this->{$method}()) { continue; } } @@ -322,7 +322,7 @@ protected function validConditionSigned() */ protected function validHasClientId() { - if (!$this->request->has('client_id')) { + if (! $this->request->has('client_id')) { throw new VanillaInvalidRequestException('The client_id parameter is missing.'); } } @@ -350,7 +350,7 @@ protected function validKnownClientId() */ protected function validTimestamp() { - if (!$this->request->has('timestamp') || !is_numeric($this->request->get('timestamp'))) { + if (! $this->request->has('timestamp') || ! is_numeric($this->request->get('timestamp'))) { throw new VanillaInvalidRequestException('The timestamp parameter is missing or invalid.'); } } @@ -364,7 +364,7 @@ protected function validTimestamp() */ protected function validHasSignature() { - if (!$this->request->has('signature')) { + if (! $this->request->has('signature')) { throw new VanillaInvalidRequestException('Missing signature parameter.'); } } diff --git a/api/app/Services/SpiraValidator.php b/api/app/Services/SpiraValidator.php index ffe083fa..39d3b2ec 100644 --- a/api/app/Services/SpiraValidator.php +++ b/api/app/Services/SpiraValidator.php @@ -1,4 +1,6 @@ -getTransformer($transformer), $resourceKey); + return $this->manager->createData($resource)->toArray()['data']; } @@ -59,6 +58,7 @@ public function collection($data, $transformer = null, $resourceKey = null) public function item($data, $transformer = null, $resourceKey = null) { $resource = new Item($data, $this->getTransformer($transformer), $resourceKey); + return $this->manager->createData($resource)->toArray(); } diff --git a/api/app/SpiraApplication.php b/api/app/SpiraApplication.php index 8fb65fe6..3e2e1b9b 100644 --- a/api/app/SpiraApplication.php +++ b/api/app/SpiraApplication.php @@ -19,7 +19,7 @@ protected function registerErrorHandling() // Don't display additional errors on top of the exception being rendered // @codeCoverageIgnoreStart ini_set('display_errors', 0); - if ('cli' !== php_sapi_name() && (!ini_get('log_errors') || ini_get('error_log'))) { + if ('cli' !== php_sapi_name() && (! ini_get('log_errors') || ini_get('error_log'))) { // CLI - display errors only if they're not already logged to STDERR ini_set('display_errors', 1); } diff --git a/api/bootstrap/app.php b/api/bootstrap/app.php index a871c606..310a9316 100644 --- a/api/bootstrap/app.php +++ b/api/bootstrap/app.php @@ -1,4 +1,5 @@ routeMiddleware([ 'permission' => 'App\Http\Middleware\PermissionMiddleware', - 'transaction' => App\Http\Middleware\TransactionMiddleware::class + 'transaction' => App\Http\Middleware\TransactionMiddleware::class, ]); /* diff --git a/api/config/elasticquent.php b/api/config/elasticquent.php index 5d0e3787..d7f60134 100644 --- a/api/config/elasticquent.php +++ b/api/config/elasticquent.php @@ -16,7 +16,7 @@ 'config' => [ 'hosts' => [sprintf('%s:%s', env('ELASTICSEARCH_HOST'), env('ELASTICSEARCH_PORT_NUMBER'))], 'logging' => true, - 'logPath' => storage_path() . '/logs/elasticsearch.log', + 'logPath' => storage_path().'/logs/elasticsearch.log', 'logLevel' => Monolog\Logger::WARNING, ], diff --git a/api/database/factories/ModelFactory.php b/api/database/factories/ModelFactory.php index 2bc72227..637aff7b 100644 --- a/api/database/factories/ModelFactory.php +++ b/api/database/factories/ModelFactory.php @@ -12,7 +12,6 @@ */ use Illuminate\Support\Str; -use Carbon\Carbon; use Spira\Model\Collection\Collection; $factory->define(App\Models\TestEntity::class, function (\Faker\Generator $faker) { @@ -27,7 +26,7 @@ 'text' => $faker->paragraph(3), 'date' => $faker->date(), 'multi_word_column_title' => true, - 'hidden' => $faker->boolean() + 'hidden' => $faker->boolean(), ]; }); @@ -37,7 +36,6 @@ return array_merge($testEntity, ['varchar' => 'custom']); }); - $factory->define(App\Models\User::class, function (\Faker\Generator $faker) { return [ 'user_id' => $faker->uuid, @@ -49,7 +47,7 @@ 'country' => $faker->randomElement(['AU', 'BE', 'DE', 'NZ', 'US']), 'timezone_identifier' => $faker->timezone, 'avatar_img_url' => $faker->optional(0.8)->imageUrl(500, 500, 'people'), - 'user_type' => $faker->randomElement(App\Models\User::$userTypes) + 'user_type' => $faker->randomElement(App\Models\User::$userTypes), ]; }); @@ -61,7 +59,7 @@ 'gender' => $faker->optional(0.5)->randomElement(['M', 'F', 'N/A']), 'about' => $faker->optional(0.5)->text(120), 'facebook' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, - 'twitter' => $faker->boolean() ? '@' . $faker->userName() : null, + 'twitter' => $faker->boolean() ? '@'.$faker->userName() : null, 'pinterest' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, 'instagram' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, 'website' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, @@ -76,7 +74,7 @@ $factory->define(App\Models\UserCredential::class, function ($faker) { return [ - 'password' => 'password' + 'password' => 'password', ]; }); @@ -91,7 +89,7 @@ return [ 'entity_id' => $faker->uuid, 'check_entity_id' => $faker->uuid, - 'value' => $faker->word + 'value' => $faker->word, ]; }); @@ -150,7 +148,7 @@ // http://cloudinary.com/documentation/image_transformations#format_conversion 'format' => $faker->randomElement(['jpg', 'png', 'gif', 'bmp', 'tiff', 'ico', 'pdf', 'eps', 'psd', 'svg', 'WebP']), 'alt' => $faker->sentence, - 'title' => $faker->optional()->sentence + 'title' => $faker->optional()->sentence, ]; }); @@ -160,7 +158,7 @@ 'image_type' => $imageType = $faker->optional()->randomElement(['primary','thumbnail','carousel']), 'position' => ($imageType == 'carousel') ? $faker->numberBetween(1, 10) : null, 'alt' => $faker->optional()->sentence, - 'title' => $faker->optional()->sentence + 'title' => $faker->optional()->sentence, ]; }); diff --git a/api/database/migrations/2015_07_28_005041_add_permalink_foreign_key_to_articles_table.php b/api/database/migrations/2015_07_28_005041_add_permalink_foreign_key_to_articles_table.php index aa1a8299..f451124f 100644 --- a/api/database/migrations/2015_07_28_005041_add_permalink_foreign_key_to_articles_table.php +++ b/api/database/migrations/2015_07_28_005041_add_permalink_foreign_key_to_articles_table.php @@ -1,4 +1,5 @@ make()->all(); $article->tags()->saveMany($tags); - //create & link images factory(Image::class, 5) ->create() @@ -44,7 +43,6 @@ public function run() ]); }); - }) - ; + }); } } diff --git a/api/database/seeds/UserStorySeeder.php b/api/database/seeds/UserStorySeeder.php index 54854131..f30ee8df 100644 --- a/api/database/seeds/UserStorySeeder.php +++ b/api/database/seeds/UserStorySeeder.php @@ -21,11 +21,11 @@ public function run() 'first_name' => 'John', 'last_name' => 'Smith', 'email' => 'john.smith@example.com', - 'user_type'=>'admin', + 'user_type' => 'admin', 'avatar_img_url' => $faker->imageUrl(100, 100, 'people'), ]); - for ($i=0; $i < 99; $i++) { + for ($i = 0; $i < 99; $i++) { $this->createUser(); } } diff --git a/api/resources/lang/en/validation.php b/api/resources/lang/en/validation.php index 3722f10a..f48e3929 100644 --- a/api/resources/lang/en/validation.php +++ b/api/resources/lang/en/validation.php @@ -70,12 +70,12 @@ 'string' => 'The :attribute must be :size characters.', 'array' => 'The :attribute must contain :size items.', ], - "unique" => "The :attribute has already been taken.", - "url" => "The :attribute format is invalid.", - "timezone" => "The :attribute must be a valid zone.", - 'uuid' => "The :attribute must be an UUID string.", - 'decimal' => "The :attribute must be a decimal.", - 'not_found' => "The selected :attribute is invalid.", + 'unique' => 'The :attribute has already been taken.', + 'url' => 'The :attribute format is invalid.', + 'timezone' => 'The :attribute must be a valid zone.', + 'uuid' => 'The :attribute must be an UUID string.', + 'decimal' => 'The :attribute must be a decimal.', + 'not_found' => 'The selected :attribute is invalid.', 'country' => 'The :attribute must be a valid country code.', 'alpha_dash_space' => 'The :attribute may only contain letters, numbers, dashes and spaces.', diff --git a/api/src/Model/Collection/Collection.php b/api/src/Model/Collection/Collection.php index 3843ecd5..7d4b9c34 100644 --- a/api/src/Model/Collection/Collection.php +++ b/api/src/Model/Collection/Collection.php @@ -1,9 +1,10 @@ items, function (BaseModel $item) { - return !$item->isDeleted(); + return ! $item->isDeleted(); })); } @@ -54,7 +55,7 @@ public function all($includingMarkedForDeletion = false) } return array_filter($this->items, function (BaseModel $item) { - return !$item->isDeleted(); + return ! $item->isDeleted(); }); } @@ -96,8 +97,8 @@ public function remove(BaseModel $item) } } - if (!is_null($model)) { - /** @var BaseModel $model */ + if (! is_null($model)) { + /* @var BaseModel $model */ $model->markAsDeleted(); } } @@ -109,7 +110,7 @@ public function remove(BaseModel $item) protected function checkItem($item) { $className = $this->className; - if (!is_null($className) && !($item instanceof $className)) { + if (! is_null($className) && ! ($item instanceof $className)) { throw new ItemTypeException('Item must be instance of '.$className); } } @@ -125,7 +126,7 @@ public function getIterator() } /** - * In case new entity was addedm then saved, then added again + * In case new entity was addedm then saved, then added again. * @param BaseModel $item */ protected function preventAddingSameItem(BaseModel $item) diff --git a/api/src/Model/Collection/ItemTypeException.php b/api/src/Model/Collection/ItemTypeException.php index 9f1bd192..c661c5c3 100644 --- a/api/src/Model/Collection/ItemTypeException.php +++ b/api/src/Model/Collection/ItemTypeException.php @@ -1,9 +1,10 @@ items); $var = ($key !== null && $key !== false); + return $var; } /** * (PHP 5 >= 5.1.0)
- * Check whether the current element of the iterator is acceptable + * Check whether the current element of the iterator is acceptable. * @link http://php.net/manual/en/filteriterator.accept.php * @return bool true if the current element is acceptable, otherwise false. */ diff --git a/api/src/Model/Model/BaseModel.php b/api/src/Model/Model/BaseModel.php index 7973d1ae..99c63c05 100644 --- a/api/src/Model/Model/BaseModel.php +++ b/api/src/Model/Model/BaseModel.php @@ -1,9 +1,10 @@ 'datetime', ]; - /** * @var MessageBag|null */ @@ -85,7 +83,6 @@ public static function getValidationRules() return static::$validationRules; } - /** * @return mixed */ @@ -108,7 +105,7 @@ public function getErrors() */ public function getRelationErrors($relationName) { - return isset($this->relationErrors[$relationName])?$this->relationErrors[$relationName]:null; + return isset($this->relationErrors[$relationName]) ? $this->relationErrors[$relationName] : null; } /** @@ -132,9 +129,10 @@ public function setAttribute($key, $value) } if (in_array($key, $this->getDates()) && $value) { - if (!$value instanceof Carbon && ! $value instanceof \DateTime) { + if (! $value instanceof Carbon && ! $value instanceof \DateTime) { $value = new Carbon($value); $this->attributes[$key] = $value; + return; } } @@ -142,10 +140,8 @@ public function setAttribute($key, $value) parent::setAttribute($key, $value); } - - /** - * Prepare value for proper assignment + * Prepare value for proper assignment. * @param array|Collection|false|BaseModel $value * Can be array, empty array, null, false, Collection or Model * @return null|Collection|BaseModel|false false on bad value @@ -153,7 +149,7 @@ public function setAttribute($key, $value) protected function prepareValue($value) { if (empty($value)) { - return null; + return; } if ($this->isModel($value) || $this->isCollection($value)) { @@ -162,9 +158,10 @@ protected function prepareValue($value) if (is_array($value)) { $firstModel = current($value); - if ($firstModel instanceof BaseModel) { + if ($firstModel instanceof self) { return $firstModel->newCollection($value); } + return false; } @@ -177,7 +174,7 @@ protected function prepareValue($value) protected function addPreviousValueToDeleteStack($models) { /** @var Collection|BaseModel[] $models */ - $models = $this->isCollection($models)?$models->all(true):[$models]; + $models = $this->isCollection($models) ? $models->all(true) : [$models]; $deleteArray = []; foreach ($models as $model) { if ($model && $model->exists) { @@ -188,7 +185,6 @@ protected function addPreviousValueToDeleteStack($models) $this->deleteStack = array_merge($this->deleteStack, $deleteArray); } - /** * Save the model and all of its relationships. * @@ -206,7 +202,7 @@ public function push() } foreach ($this->deleteStack as $modelToDelete) { - if (!$modelToDelete->delete()) { + if (! $modelToDelete->delete()) { return false; } $this->deleteStack = []; @@ -228,12 +224,12 @@ public function push() $relation = static::$relationsCache[$this->getRelationCacheKey($key)]; if ($this->isCollection($models)) { - /** @var Collection $models */ + /* @var Collection $models */ $modelsArray = $models->all(true); $error = false; $errors = []; foreach (array_filter($modelsArray) as $model) { - /** @var BaseModel $model */ + /* @var BaseModel $model */ $model->preserveKeys($relation); try { $model->push(); @@ -249,7 +245,7 @@ public function push() $this->errors->add($key, $errors); } } elseif ($models) { - /** @var BaseModel $models */ + /* @var BaseModel $models */ $models->preserveKeys($relation); try { $models->push(); @@ -269,7 +265,7 @@ public function push() } /** - * Checks relation against value + * Checks relation against value. * @param $method * @param $value * @return bool @@ -302,7 +298,7 @@ protected function isValueCompatibleWithRelation($method, $value) */ protected function isModel($value) { - return $value instanceof BaseModel; + return $value instanceof self; } /** @@ -351,7 +347,7 @@ public function newCollection(array $models = []) } /** - * @return boolean + * @return bool */ public function isDeleted() { @@ -368,7 +364,7 @@ public function markAsDeleted() /** * Get a relationship value from a method. - * Relation cache added + * Relation cache added. * * @param string $method * @return mixed @@ -379,7 +375,7 @@ protected function getRelationshipFromMethod($method) { $relations = $this->$method(); - if (!$relations instanceof Relation) { + if (! $relations instanceof Relation) { throw new LogicException('Relationship method must return an object of type ' .'Illuminate\Database\Eloquent\Relations\Relation'); } else { @@ -425,10 +421,9 @@ protected function getRelationCacheKey($method) return spl_object_hash($this).'_'.$method; } - /** * Create a collection of models from a request collection - * The method is more efficient if is passed a Collection of existing entries otherwise it will do a query for every entity + * The method is more efficient if is passed a Collection of existing entries otherwise it will do a query for every entity. * @param array $requestCollection * @param EloquentCollection|null $existingModels * @return Collection @@ -439,7 +434,7 @@ public function hydrateRequestCollection(array $requestCollection, EloquentColle $models = array_map(function ($item) use ($keyName, $existingModels) { $model = null; - $entityId = isset($item[$keyName])?$item[$keyName]:null; + $entityId = isset($item[$keyName]) ? $item[$keyName] : null; if ($existingModels) { //get the model from the collection, or create a new instance @@ -458,9 +453,8 @@ public function hydrateRequestCollection(array $requestCollection, EloquentColle return $this->newCollection($models); } - /** - * Handle case where the value might be from Carbon::toArray + * Handle case where the value might be from Carbon::toArray. * @param mixed $value * @return Carbon|static */ diff --git a/api/src/Model/Model/IndexedModel.php b/api/src/Model/Model/IndexedModel.php index 0e4c85a5..b71f80b1 100644 --- a/api/src/Model/Model/IndexedModel.php +++ b/api/src/Model/Model/IndexedModel.php @@ -1,4 +1,6 @@ -addToIndex(); + return true; }, PHP_INT_MAX ); @@ -85,6 +88,7 @@ function (IndexedModel $model) { static::deleted( function (IndexedModel $model) { $model->removeFromIndex(); + return true; }, PHP_INT_MAX ); @@ -92,6 +96,7 @@ function (IndexedModel $model) { static::updated( function (IndexedModel $model) { $model->updateIndex(); + return true; }, PHP_INT_MAX ); diff --git a/api/src/Model/Model/SetRelationException.php b/api/src/Model/Model/SetRelationException.php index 593d0028..bdd925c0 100644 --- a/api/src/Model/Model/SetRelationException.php +++ b/api/src/Model/Model/SetRelationException.php @@ -1,9 +1,10 @@ exceptions as $exception) { - if (!is_null($exception)) { + if (! is_null($exception)) { $responses[] = $exception->getErrors(); } else { $responses[] = null; diff --git a/api/src/Model/Validation/Validator.php b/api/src/Model/Validation/Validator.php index 4dc7d5af..4b4ab363 100644 --- a/api/src/Model/Validation/Validator.php +++ b/api/src/Model/Validation/Validator.php @@ -1,9 +1,10 @@ parse(); - return is_null($this->offset)?$default:$this->offset; + + return is_null($this->offset) ? $default : $this->offset; } /** @@ -52,17 +54,19 @@ public function getOffset($default = null) public function getLimit($default = null, $max = null) { $this->parse(); - $limit = is_null($this->limit)?$default:$this->limit; - return ($limit > $max)?$max:$limit; + $limit = is_null($this->limit) ? $default : $this->limit; + + return ($limit > $max) ? $max : $limit; } /** - * states that limit should be applied to the end of the result set + * states that limit should be applied to the end of the result set. * @return bool */ public function isGetLast() { $this->parse(); + return $this->isGetLast; } @@ -96,7 +100,7 @@ private function parse() } } - if (!is_null($this->limit) && $this->limit <= 0) { + if (! is_null($this->limit) && $this->limit <= 0) { throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid Range header'); } @@ -112,7 +116,7 @@ public function getRequest() } /** - * Get requested range + * Get requested range. * @return mixed */ protected function getRequestedRange() @@ -120,10 +124,10 @@ protected function getRequestedRange() if ($this->getRequest()->headers) { $range = $this->getRequest()->headers->get('Range'); - if (strpos($range, $this->rangeKey . '=') !== 0) { - throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid Range header, Expected format example - `Range: ' . $this->rangeKey . '=0-100`'); + if (strpos($range, $this->rangeKey.'=') !== 0) { + throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid Range header, Expected format example - `Range: '.$this->rangeKey.'=0-100`'); } else { - return str_replace($this->rangeKey . '=', '', $range); + return str_replace($this->rangeKey.'=', '', $range); } } diff --git a/api/src/Responder/Response/ApiResponse.php b/api/src/Responder/Response/ApiResponse.php index 68fabfe3..f3168429 100644 --- a/api/src/Responder/Response/ApiResponse.php +++ b/api/src/Responder/Response/ApiResponse.php @@ -1,9 +1,10 @@ transformer = $transformer; + return $this; } @@ -42,11 +44,9 @@ public function created($location = null) return $this ->setContent(null) - ->setStatusCode(self::HTTP_CREATED) - ; + ->setStatusCode(self::HTTP_CREATED); } - /** * Respond with a no content response. * @@ -57,11 +57,9 @@ public function noContent($code = self::HTTP_NO_CONTENT) { return $this ->setStatusCode($code) - ->setContent(null) - ; + ->setContent(null); } - /** * Bind an item to a transformer and start building a response. * @param $item @@ -77,11 +75,9 @@ public function item($item, $statusCode = self::HTTP_OK) return $this ->header('Content-Type', 'application/json') ->setContent($this->encode($item)) - ->setStatusCode($statusCode) - ; + ->setStatusCode($statusCode); } - /** * Respond with a created response. * @param $item @@ -90,6 +86,7 @@ public function item($item, $statusCode = self::HTTP_OK) public function createdItem($item) { $item->setVisible(['']); + return $this->item($item, self::HTTP_CREATED); } @@ -107,13 +104,11 @@ public function collection($items, $statusCode = Response::HTTP_OK) return $this ->header('Content-Type', 'application/json') ->setContent($this->encode($items)) - ->setStatusCode($statusCode) - ; + ->setStatusCode($statusCode); } - /** - * Respond with a created response and hide all the items (except self) + * Respond with a created response and hide all the items (except self). * @param $items * @return ApiResponse */ @@ -126,7 +121,6 @@ public function createdCollection($items) return $this->collection($items, self::HTTP_CREATED); } - /** * Build paginated response. * @param $items @@ -145,8 +139,7 @@ public function paginatedCollection($items, $offset = null, $totalCount = null) ->header('Accept-Ranges', 'entities') ->header('Content-Type', 'application/json') ->header('Content-Range', $rangeHeader) - ->collection($items, self::HTTP_PARTIAL_CONTENT) - ; + ->collection($items, self::HTTP_PARTIAL_CONTENT); } /** @@ -172,20 +165,21 @@ protected function prepareRangeHeader($itemCount, $offset, $totalCount) { $offset = is_null($offset) ? 0 : $offset; $totalCount = is_null($totalCount) ? '*' : $totalCount; - $rangeHeader = 'entities '.$offset . '-' . ($itemCount + $offset - 1) . '/' . $totalCount; + $rangeHeader = 'entities '.$offset.'-'.($itemCount + $offset - 1).'/'.$totalCount; return $rangeHeader; } /** - * Json encode + * Json encode. * @param $data * @return string */ protected function encode($data) { $debug = env('APP_DEBUG', false); - $prettyPrint = $debug?JSON_PRETTY_PRINT:0; + $prettyPrint = $debug ? JSON_PRETTY_PRINT : 0; + return json_encode($data, $prettyPrint); } @@ -208,7 +202,7 @@ public function redirect($url, $status = 302) $this->setStatusCode($status); $this->header('Location', $url); - if (!$this->isRedirect()) { + if (! $this->isRedirect()) { throw new InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); } } diff --git a/api/tests/ElasticSearchTest.php b/api/tests/ElasticSearchTest.php index f55e7179..ff84a664 100644 --- a/api/tests/ElasticSearchTest.php +++ b/api/tests/ElasticSearchTest.php @@ -3,7 +3,7 @@ use App\Models\TestEntity; /** - * Class ElasticSearchTest + * Class ElasticSearchTest. */ class ElasticSearchTest extends TestCase { @@ -17,7 +17,7 @@ public function setUp() } /** - * Test model is automatically added to index on save + * Test model is automatically added to index on save. */ public function testElasticSearchAddToIndex() { @@ -29,10 +29,9 @@ public function testElasticSearchAddToIndex() $search = $testEntity->searchByQuery([ 'match' => [ 'entity_id' => $testEntity->entity_id, - ] + ], ]); - $this->assertEquals(1, $search->totalHits()); $testEntity->delete(); //clean up so it doesn't remain in the index @@ -50,10 +49,9 @@ public function testElasticSearchRemoveFromIndex() $search = $testEntity->searchByQuery([ 'match' => [ 'entity_id' => $testEntity->entity_id, - ] + ], ]); - $this->assertEquals(0, $search->totalHits()); } @@ -65,13 +63,12 @@ public function testElasticSearchUpdateIndex() $testEntity->setAttribute('varchar', 'searchforthisvalue'); $testEntity->save(); - sleep(1); //elastic search takes some time to index $search = $testEntity->searchByQuery([ 'match' => [ 'varchar' => 'searchforthisvalue', - ] + ], ]); $this->assertEquals(1, $search->totalHits()); diff --git a/api/tests/Extensions/SocialiteTest.php b/api/tests/Extensions/SocialiteTest.php index 96af22e6..bf4b9ff6 100644 --- a/api/tests/Extensions/SocialiteTest.php +++ b/api/tests/Extensions/SocialiteTest.php @@ -11,7 +11,7 @@ use League\OAuth1\Client\Credentials\TemporaryCredentials; /** - * Class SocialiteTest + * Class SocialiteTest. */ class SocialiteTest extends TestCase { @@ -38,7 +38,7 @@ public function testCreateFacebookDriver() public function testCreateTwitterDriver() { // If no twitter credentials exists in the env, add mock credentials - if (!$this->app->config->get('services.twitter.client_id')) { + if (! $this->app->config->get('services.twitter.client_id')) { $this->app->config->set('services.twitter.client_id', 'foo'); $this->app->config->set('services.twitter.client_secret', 'bar'); } diff --git a/api/tests/ModelFactoryTest.php b/api/tests/ModelFactoryTest.php index 367cc095..7fede637 100644 --- a/api/tests/ModelFactoryTest.php +++ b/api/tests/ModelFactoryTest.php @@ -1,4 +1,5 @@ assertEquals($dynamicTableName, $staticTableName); } } diff --git a/api/tests/Models/ArticleModelTest.php b/api/tests/Models/ArticleModelTest.php index b48436a5..d24f9ea7 100644 --- a/api/tests/Models/ArticleModelTest.php +++ b/api/tests/Models/ArticleModelTest.php @@ -1,9 +1,10 @@ make([ 'excerpt' => null, - 'content' => implode("\n\n", $faker->paragraphs(3)) //use seeded faker paragraph so the unit test will always use the same data + 'content' => implode("\n\n", $faker->paragraphs(3)), //use seeded faker paragraph so the unit test will always use the same data ]); $excerpt = $articleWithoutExcerpt->excerpt; @@ -35,11 +35,11 @@ public function testAutomaticExcerpt() public function testManualExcerpt() { - $excerpt = "This is the article excerpt"; + $excerpt = 'This is the article excerpt'; $articleWithExcerpt = factory(Article::class)->make([ - 'excerpt' => $excerpt + 'excerpt' => $excerpt, ]); - $this->assertEquals($excerpt, $articleWithExcerpt->excerpt, "Article excerpt has not been overridden"); + $this->assertEquals($excerpt, $articleWithExcerpt->excerpt, 'Article excerpt has not been overridden'); } } diff --git a/api/tests/RouteHelperTest.php b/api/tests/RouteHelperTest.php index ba2f3807..0ad528f1 100644 --- a/api/tests/RouteHelperTest.php +++ b/api/tests/RouteHelperTest.php @@ -1,11 +1,11 @@ $uuid])); + $route = \App\Helpers\RouteHelper::getRoute(new \App\Models\TestEntity(['entity_id' => $uuid])); $this->assertStringEndsWith('/test/entities/'.$uuid, $route); } diff --git a/api/tests/Services/Api/VanillaApiTest.php b/api/tests/Services/Api/VanillaApiTest.php index 8958d435..45d572c8 100644 --- a/api/tests/Services/Api/VanillaApiTest.php +++ b/api/tests/Services/Api/VanillaApiTest.php @@ -23,7 +23,6 @@ protected function getApiMock($apiClass) ->getMock(); } - // Configuration /** @@ -34,8 +33,8 @@ public function shouldGetConfiguration() $expected = [ 'Configuration' => [ 'Title' => 'Spira', - 'Domain' => '' - ] + 'Domain' => '', + ], ]; $api = $this->getApiMock(Configuration::class); @@ -47,7 +46,6 @@ public function shouldGetConfiguration() $this->assertEquals($expected, $api->current()); } - // Discussions /** @@ -73,7 +71,7 @@ public function shouldCreateDiscussion() $data = [ 'Name' => $name = 'Some name', 'Body' => $body = 'Some body', - 'CategoryID' => $categoryId = 1 + 'CategoryID' => $categoryId = 1, ]; $api = $this->getApiMock(Discussion::class); @@ -94,7 +92,7 @@ public function shouldGetDiscussion() 'CategoryID' => 1, 'Category' => [], 'Comments' => [], - 'Page' => 1 + 'Page' => 1, ]; $api = $this->getApiMock(Discussion::class); @@ -116,7 +114,7 @@ public function shouldGetDiscussionByForeignId() 'CategoryID' => 1, 'Category' => [], 'Comments' => [], - 'Page' => 1 + 'Page' => 1, ]; $api = $this->getApiMock(Discussion::class); @@ -135,7 +133,7 @@ public function shouldUpdateDiscussion() { $input = [ 'Name' => $name = 'New name', - 'Body' => $body = 'New body' + 'Body' => $body = 'New body', ]; $api = $this->getApiMock(Discussion::class); @@ -174,7 +172,6 @@ public function shouldRemoveDiscussionByForeignId() $api->removeByForeignId(123); } - // Comments /** @@ -184,7 +181,7 @@ public function shouldCreateComment() { $input = [ 'Body' => $body = 'Some body', - 'Format' => 'Html' + 'Format' => 'Html', ]; $api = $this->getApiMock(Comment::class); @@ -201,7 +198,7 @@ public function shouldCreateComment() public function shouldUpdateComment() { $input = [ - 'Body' => $body = 'New body' + 'Body' => $body = 'New body', ]; $api = $this->getApiMock(Comment::class); @@ -226,7 +223,6 @@ public function shouldRemoveComment() $api->remove(456); } - // Users /** @@ -254,7 +250,7 @@ public function shouldLinkSsoUser() public function shouldRemoveUser() { $input = [ - 'Method' => 'delete' + 'Method' => 'delete', ]; $api = $this->getApiMock(User::class); diff --git a/api/tests/Services/Api/VanillaIntegrationTest.php b/api/tests/Services/Api/VanillaIntegrationTest.php index 932a7029..00a87342 100644 --- a/api/tests/Services/Api/VanillaIntegrationTest.php +++ b/api/tests/Services/Api/VanillaIntegrationTest.php @@ -163,7 +163,6 @@ public function shouldReturnNoneJsonBodyUnmodified() $this->assertEquals($body, $response); } - // Generic /** @@ -181,7 +180,6 @@ public function shouldCreateDiscussionWithAdminUser() $this->client->api('discussions')->remove($discussion['Discussion']['DiscussionID']); } - // Discussions /** @@ -278,7 +276,7 @@ public function shoulePaginateCommentsInDiscussion() // Create discussion thread $id = (string) Uuid::uuid4(); $discussion = $this->client->api('discussions')->create('Foo', 'Bar', 1, ['ForeignID' => $id]); - for ($i=0; $i < 20; $i++) { + for ($i = 0; $i < 20; $i++) { $comment = $this->client->api('comments')->create( $discussion['Discussion']['DiscussionID'], 'Comment #'.$i @@ -301,7 +299,6 @@ public function shoulePaginateCommentsInDiscussion() $this->client->api('discussions')->removeByForeignId($id); } - // Comments /** diff --git a/api/tests/Services/SingleSignOnTest.php b/api/tests/Services/SingleSignOnTest.php index ee6660b2..93f17c47 100644 --- a/api/tests/Services/SingleSignOnTest.php +++ b/api/tests/Services/SingleSignOnTest.php @@ -243,7 +243,7 @@ public function testSignNoReturnData() { $user = [ 'username' => null, - 'avatar_img_url' => null + 'avatar_img_url' => null, ]; $requester = Mockery::mock(VanillaSingleSignOn::class); diff --git a/api/tests/TestCase.php b/api/tests/TestCase.php index ce931faa..50975c8c 100644 --- a/api/tests/TestCase.php +++ b/api/tests/TestCase.php @@ -52,9 +52,8 @@ public function createApplication() return require __DIR__.'/../bootstrap/app.php'; } - /** - * Assert status code, and on failure print the output to assist debugging + * Assert status code, and on failure print the output to assist debugging. * @param int $code */ public function assertResponseStatus($code) @@ -92,7 +91,7 @@ protected function transformHeadersToServerVars(array $headers) $server[$name] = $value; //set the server header to SNAKE_CASE if (! starts_with($name, 'HTTP_')) { - $name = 'HTTP_' . $name; + $name = 'HTTP_'.$name; $server[$name] = $value; //add the HTTP_* key } } @@ -117,6 +116,7 @@ public function requestJson($method, $uri, array $data = [], array $headers = [] $server = $this->transformHeadersToServerVars($headers); $this->call($method, $uri, [], [], [], $server, $content); + return $this; } @@ -129,14 +129,15 @@ protected function addJsonHeaders(array $headers, $content) { $headers['Content-Type'] = 'application/json'; $headers['Content-Length'] = mb_strlen($content, '8bit'); - if (!isset($headers['Accept'])) { + if (! isset($headers['Accept'])) { $headers['Accept'] = 'application/json'; + return $headers; } + return $headers; } - /** * Visit the given URI with a GET request with content type of application/json. * diff --git a/api/tests/Traits/HelpersTrait.php b/api/tests/Traits/HelpersTrait.php index 06ab51db..dc31609f 100644 --- a/api/tests/Traits/HelpersTrait.php +++ b/api/tests/Traits/HelpersTrait.php @@ -20,7 +20,7 @@ protected function getFakerWithUniqueUserData() { // Prepare an array with user data already used $users = User::all(); - if (!$this->uniqueUserValues) { + if (! $this->uniqueUserValues) { $uniques = ['username' => [], 'email' => []]; foreach ($users as $user) { array_push($uniques['username'], [$user->username => null]); @@ -63,7 +63,7 @@ protected function createUser(array $attributes = [], $times = 1) $default = [ 'email' => $faker->unique()->email, 'username' => $faker->unique()->username, - 'user_type' => 'admin' + 'user_type' => 'admin', ]; $attr = array_merge($default, $attributes); diff --git a/api/tests/Traits/ModelFactoryTrait.php b/api/tests/Traits/ModelFactoryTrait.php index dbd8f500..982451c5 100644 --- a/api/tests/Traits/ModelFactoryTrait.php +++ b/api/tests/Traits/ModelFactoryTrait.php @@ -5,7 +5,7 @@ trait ModelFactoryTrait { /** - * Making it static not to reinit for each TestCase + * Making it static not to reinit for each TestCase. * @var ModelFactory */ protected static $modelFactory; diff --git a/api/tests/TransformerTest.php b/api/tests/TransformerTest.php index b432a916..7647539c 100644 --- a/api/tests/TransformerTest.php +++ b/api/tests/TransformerTest.php @@ -3,7 +3,6 @@ use App\Http\Transformers\EloquentModelTransformer; use App\Services\TransformerService; use Mockery as m; -use Illuminate\Pagination\LengthAwarePaginator; /** * @property EloquentModelTransformer transformer @@ -39,7 +38,7 @@ public function testItemNestedData() ->once() ->andReturn([ 'foo_bar' => 'foobar', - 'nested_data' => ['foo_bar' => true, 'foo' => true, 'bar_foo' => true] + 'nested_data' => ['foo_bar' => true, 'foo' => true, 'bar_foo' => true], ]); $data = $this->transformer->transformItem($data); @@ -72,7 +71,7 @@ public function testItem() public function testTransfomerService() { - $checkArray = ['item'=>'foo']; + $checkArray = ['item' => 'foo']; $transformed = $this->transformer->getService()->item(new \Illuminate\Database\Eloquent\Collection($checkArray)); $this->assertEquals($checkArray, $transformed); } diff --git a/api/tests/ValidatorTest.php b/api/tests/ValidatorTest.php index 1ea561ee..8b8c90f1 100644 --- a/api/tests/ValidatorTest.php +++ b/api/tests/ValidatorTest.php @@ -15,23 +15,23 @@ public function setUp() public function testSpiraValidator() { $data = ['decimal' => 'foo']; - $validation = $this->validator->make($data, ['decimal'=>'decimal']); + $validation = $this->validator->make($data, ['decimal' => 'decimal']); $this->assertInstanceOf(SpiraValidator::class, $validation); } public function testPassingDecimalValidation() { $data = ['decimal' => 12.042]; - $this->assertTrue($this->validator->make($data, ['decimal'=>'decimal'])->passes()); + $this->assertTrue($this->validator->make($data, ['decimal' => 'decimal'])->passes()); $data = ['decimal' => 12]; - $this->assertTrue($this->validator->make($data, ['decimal'=>'decimal'])->passes()); + $this->assertTrue($this->validator->make($data, ['decimal' => 'decimal'])->passes()); } public function testFailingDecimalValidation() { $data = ['decimal' => 'foo']; - $validation = $this->validator->make($data, ['decimal'=>'decimal']); + $validation = $this->validator->make($data, ['decimal' => 'decimal']); $this->assertFalse($validation->passes()); $this->assertStringEndsWith('must be a decimal.', $validation->messages()->get('decimal')[0]); @@ -40,13 +40,13 @@ public function testFailingDecimalValidation() public function testPassingUuidValidation() { $data = ['uuid' => (string) Uuid::uuid4()]; - $this->assertTrue($this->validator->make($data, ['uuid'=>'uuid'])->passes()); + $this->assertTrue($this->validator->make($data, ['uuid' => 'uuid'])->passes()); } public function testFailingUuidValidation() { $data = ['uuid' => 'foobar']; - $validation = $this->validator->make($data, ['uuid'=>'uuid']); + $validation = $this->validator->make($data, ['uuid' => 'uuid']); $this->assertFalse($validation->passes()); $this->assertStringEndsWith('must be an UUID string.', $validation->messages()->get('uuid')[0]); } diff --git a/api/tests/integration/ArticleImageTest.php b/api/tests/integration/ArticleImageTest.php index 95906fde..1c0a83a2 100644 --- a/api/tests/integration/ArticleImageTest.php +++ b/api/tests/integration/ArticleImageTest.php @@ -5,7 +5,7 @@ use App\Models\ArticleImage; /** - * Class ArticleImageTest + * Class ArticleImageTest. * @group integration */ class ArticleImageTest extends TestCase @@ -90,7 +90,6 @@ public function testPutManyNew() $this->assertCount(5, $object); } - public function testPutManyNewInvalid() { $article = $this->getFactory()->get(Article::class)->create(); @@ -100,7 +99,7 @@ public function testPutManyNewInvalid() ->get($images) ->count(5) ->customize([ - 'article_id'=>null + 'article_id' => null, ]) ->transformed(); @@ -115,8 +114,6 @@ public function testPutManyNewInvalid() $this->assertEquals($childCount, Article::find($article->article_id)->articleImages->count()); } - - public function testDeleteMany() { $article = $this->getFactory()->get(Article::class)->create(); @@ -136,7 +133,6 @@ public function testDeleteMany() $this->assertEquals($childCount - 5, Article::find($article->article_id)->articleImages->count()); } - public function testGetManyImages() { $article = $this->getFactory()->get(Article::class)->create(); diff --git a/api/tests/integration/ArticleTagTest.php b/api/tests/integration/ArticleTagTest.php index 6a87084b..29767c32 100644 --- a/api/tests/integration/ArticleTagTest.php +++ b/api/tests/integration/ArticleTagTest.php @@ -5,7 +5,7 @@ use Spira\Model\Collection\Collection; /** - * Class ArticleTagTest + * Class ArticleTagTest. * @group integration */ class ArticleTagTest extends TestCase @@ -69,7 +69,7 @@ public function testGetTags() /** * Current scenario is tested * Say we got 5 tags for article - * foo, bar, zoo, dar, kar + * foo, bar, zoo, dar, kar. * * In request we put only "foo" + 4 new tags * So "bar, zoo, dar, kar" are detached from article, "foo" remains and 4 new tags created @@ -193,7 +193,6 @@ public function testDeleteTagGlobal() $this->assertEquals(4, Article::find($entity->article_id)->tags->count()); $tag = $entity->tags->first(); - $this->deleteJson('/tags/'.$tag->tag_id); $this->assertResponseStatus(204); diff --git a/api/tests/integration/ArticleTest.php b/api/tests/integration/ArticleTest.php index 9b2a7a22..03692e40 100644 --- a/api/tests/integration/ArticleTest.php +++ b/api/tests/integration/ArticleTest.php @@ -1,11 +1,12 @@ push(); } - $this->getJson('/articles', ['Range'=>'entities=0-19']); + $this->getJson('/articles', ['Range' => 'entities=0-19']); $this->assertResponseStatus(206); $this->shouldReturnJson(); $this->assertJsonArray(); @@ -119,7 +120,7 @@ public function testGetOne() $this->assertTrue(is_string($object->title)); $this->assertTrue(is_string($object->content)); - $this->assertTrue(is_string($object->permalink)||is_null($object->permalink)); + $this->assertTrue(is_string($object->permalink) || is_null($object->permalink)); $this->cleanupDiscussions([$entity]); } @@ -130,7 +131,7 @@ public function testGetOneWithNestedTags() $tags = factory(\App\Models\Tag::class, 4)->create(); $entity->tags()->sync($tags->lists('tag_id')->toArray()); - $this->getJson('/articles/'.$entity->article_id, ['with-nested'=> 'tags']); + $this->getJson('/articles/'.$entity->article_id, ['with-nested' => 'tags']); $this->assertResponseOk(); $this->shouldReturnJson(); @@ -143,7 +144,7 @@ public function testGetOneWithNestedAuthor() { $entity = $this->getFactory()->get(Article::class)->create(); - $this->getJson('/articles/'.$entity->article_id, ['with-nested'=> 'author']); + $this->getJson('/articles/'.$entity->article_id, ['with-nested' => 'author']); $this->assertResponseOk(); $this->shouldReturnJson(); @@ -176,7 +177,7 @@ public function testGetOneByFirstPermalink() $this->assertTrue(is_string($object->title)); $this->assertTrue(is_string($object->content)); - $this->assertTrue(is_string($object->permalink)||is_null($object->permalink)); + $this->assertTrue(is_string($object->permalink) || is_null($object->permalink)); $this->cleanupDiscussions([$entity]); } @@ -206,7 +207,7 @@ public function testGetOneByLastPermalink() $this->assertTrue(is_string($object->title)); $this->assertTrue(is_string($object->content)); - $this->assertTrue(is_string($object->permalink)||is_null($object->permalink)); + $this->assertTrue(is_string($object->permalink) || is_null($object->permalink)); $this->cleanupDiscussions([$entity]); } @@ -252,7 +253,7 @@ public function testPutOneNew() public function testPutOneNonExistingAuthor() { $entity = $this->getFactory()->get(Article::class) - ->customize(['author_id'=>(string) \Rhumsaa\Uuid\Uuid::uuid4()]) + ->customize(['author_id' => (string) \Rhumsaa\Uuid\Uuid::uuid4()]) ->transformed(); $this->putJson('/articles/'.$entity['articleId'], $entity); @@ -281,7 +282,6 @@ public function testPutMissingIdInBody() $this->assertResponseStatus(400); } - public function testPatchOne() { $entity = factory(Article::class)->create(); @@ -316,7 +316,7 @@ public function testPatchOneNewPermalink() $checkEntity = Article::find($id); $this->assertEquals($checkEntity->permalink, $entity->permalink); - $this->assertEquals($checkEntity->permalinks->count(), $linksCount+1); + $this->assertEquals($checkEntity->permalinks->count(), $linksCount + 1); $this->cleanupDiscussions([$entity]); } @@ -443,7 +443,7 @@ public function testPutMetas() $this->assertResponseStatus(201); $updatedArticle = Article::find($article->article_id); - $this->assertEquals($metaCount+2, $updatedArticle->metas->count()); + $this->assertEquals($metaCount + 2, $updatedArticle->metas->count()); $counter = 0; foreach ($updatedArticle->metas as $meta) { if ($meta->meta_content == 'foobar') { @@ -467,7 +467,7 @@ public function deleteMeta() $metaCount = ArticleMeta::where('article_id', '=', $article->article_id)->count(); $this->deleteJson('/articles/'.$article->article_id.'/meta/'.$metaEntity->name); $updatedArticle = Article::find($article->article_id); - $this->assertEquals($metaCount-1, $updatedArticle->metas->count()); + $this->assertEquals($metaCount - 1, $updatedArticle->metas->count()); $this->cleanupDiscussions($articles); } diff --git a/api/tests/integration/AuthTest.php b/api/tests/integration/AuthTest.php index 68688f6d..2b17f056 100644 --- a/api/tests/integration/AuthTest.php +++ b/api/tests/integration/AuthTest.php @@ -2,7 +2,6 @@ use App\Models\User; use GuzzleHttp\Client; -use GuzzleHttp\Exception\RequestException; use Illuminate\Support\Facades\Cache; use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Claims\IssuedAt; @@ -15,7 +14,7 @@ use Tymon\JWTAuth\Token; /** - * Class AuthTest + * Class AuthTest. * @group integration */ class AuthTest extends TestCase @@ -395,7 +394,7 @@ public function testProviderRedirectReturnUrlOAuthOne() // tests against twitter if credentials is available, and if not // available, we still can test that the cache with the returnurl is // properly set. - if (!$this->app->config->get('services.twitter.client_id')) { + if (! $this->app->config->get('services.twitter.client_id')) { Cache::put('oauth_return_url_'.'foobar', $returnUrl, 1); $mock = Mockery::mock('App\Extensions\Socialite\SocialiteManager'); $this->app->instance('Laravel\Socialite\Contracts\Factory', $mock); @@ -440,7 +439,7 @@ public function testProviderCallbackNoEmail() ->once() ->andReturn((object) [ 'email' => null, - 'token' => 'foobar' + 'token' => 'foobar', ]); $this->getJson('/auth/social/facebook/callback'); @@ -582,7 +581,7 @@ public function testSingleSignOnVanillaWithUserAndSignature() $params = [ 'client_id' => env('VANILLA_JSCONNECT_CLIENT_ID'), 'timestamp' => $timestamp, - 'signature' => sha1($timestamp.env('VANILLA_JSCONNECT_SECRET')) + 'signature' => sha1($timestamp.env('VANILLA_JSCONNECT_SECRET')), ]; $cookies = [\App\Http\Controllers\AuthController::JWT_AUTH_TOKEN_COOKIE => $token]; diff --git a/api/tests/integration/ChildEntityTest.php b/api/tests/integration/ChildEntityTest.php index dfe7cc83..204000e0 100644 --- a/api/tests/integration/ChildEntityTest.php +++ b/api/tests/integration/ChildEntityTest.php @@ -5,7 +5,7 @@ use Spira\Model\Collection\Collection; /** - * Class ChildEntityTest + * Class ChildEntityTest. * @group integration */ class ChildEntityTest extends TestCase @@ -39,6 +39,7 @@ protected function prepareEntity($entity) // as if they came from the frontend. $transformer = $this->app->make(\App\Http\Transformers\EloquentModelTransformer::class); $entity = $transformer->transform($entity); + return $entity; } @@ -155,7 +156,7 @@ public function testPutOneCollidingIds() $this->assertTrue(is_object($object)); $this->assertObjectHasAttribute('message', $object); - $this->assertEquals("Provided entity body does not match route parameter. The entity key cannot be updated", $object->message); + $this->assertEquals('Provided entity body does not match route parameter. The entity key cannot be updated', $object->message); } public function testPutOneNewInvalidId() @@ -436,7 +437,6 @@ public function testDeleteManyInvalidId() ]; }, $childEntities->all()); - $this->deleteJson('/test/entities/'.$entity->entity_id.'/children', $data); $object = json_decode($this->response->getContent()); diff --git a/api/tests/integration/DocumentationTest.php b/api/tests/integration/DocumentationTest.php index 8f75f78e..70c01418 100644 --- a/api/tests/integration/DocumentationTest.php +++ b/api/tests/integration/DocumentationTest.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Artisan; /** - * Class DocumentationTest + * Class DocumentationTest. * @group integration */ class DocumentationTest extends TestCase diff --git a/api/tests/integration/EntityTest.php b/api/tests/integration/EntityTest.php index bcc01d0b..6abaafb7 100644 --- a/api/tests/integration/EntityTest.php +++ b/api/tests/integration/EntityTest.php @@ -4,7 +4,7 @@ use Rhumsaa\Uuid\Uuid; /** - * Class EntityTest + * Class EntityTest. * @group integration */ class EntityTest extends TestCase @@ -68,7 +68,7 @@ public function testGetAllWithNested() $entity = factory(App\Models\TestEntity::class)->create(); $this->addRelatedEntities($entity); - $this->getJson('/test/entities', ['with-nested'=>'testMany']); + $this->getJson('/test/entities', ['with-nested' => 'testMany']); $objects = json_decode($this->response->getContent()); $this->assertResponseOk(); @@ -97,8 +97,8 @@ public function testGetAllWithNested() public function testGetAllPaginated() { $defaultLimit = 10; - $entities = factory(App\Models\TestEntity::class, $defaultLimit+1)->create(); - $this->getJson('/test/entities/pages', ['Range'=>'entities=0-']); + $entities = factory(App\Models\TestEntity::class, $defaultLimit + 1)->create(); + $this->getJson('/test/entities/pages', ['Range' => 'entities=0-']); $this->assertResponseStatus(206); $this->shouldReturnJson(); $this->assertJsonArray(); @@ -111,12 +111,12 @@ public function testGetAllPaginated() public function testGetAllPaginatedWithNested() { $defaultLimit = 10; - $entities = factory(App\Models\TestEntity::class, $defaultLimit+1)->create(); + $entities = factory(App\Models\TestEntity::class, $defaultLimit + 1)->create(); foreach ($entities as $entity) { $this->addRelatedEntities($entity); } - $this->getJson('/test/entities/pages', ['Range'=>'entities=-10','with-nested'=>'testMany']); + $this->getJson('/test/entities/pages', ['Range' => 'entities=-10','with-nested' => 'testMany']); $object = json_decode($this->response->getContent()); $this->assertResponseStatus(206); @@ -143,15 +143,15 @@ public function testGetAllPaginatedNoRangeHeader() public function testGetAllPaginatedInvalidRangeHeader() { - $this->getJson('/test/entities/pages', ['Range'=>'0-']); + $this->getJson('/test/entities/pages', ['Range' => '0-']); $this->assertResponseStatus(400); } public function testGetAllPaginatedSimpleRange() { $entities = factory(App\Models\TestEntity::class, 20)->create(); - $totalCount =TestEntity::count(); - $this->getJson('/test/entities/pages', ['Range'=>'entities=0-19']); + $totalCount = TestEntity::count(); + $this->getJson('/test/entities/pages', ['Range' => 'entities=0-19']); $object = json_decode($this->response->getContent()); $this->assertResponseStatus(206); $this->shouldReturnJson(); @@ -167,7 +167,7 @@ public function testGetAllPaginatedSimpleRange() public function testPaginationBadRanges() { $entities = factory(App\Models\TestEntity::class, 20)->create(); - $this->getJson('/test/entities/pages', ['Range'=>'entities=19-18']); + $this->getJson('/test/entities/pages', ['Range' => 'entities=19-18']); $this->assertResponseStatus(400); } @@ -175,7 +175,7 @@ public function testPaginationOutOfRange() { $entities = factory(App\Models\TestEntity::class, 10)->create(); $totalCount = TestEntity::count(); - $this->getJson('/test/entities/pages', ['Range'=>'entities='.$totalCount.'-']); + $this->getJson('/test/entities/pages', ['Range' => 'entities='.$totalCount.'-']); $this->assertResponseStatus(416); } @@ -183,7 +183,7 @@ public function testPaginationMoreThanInRepo() { $entities = factory(App\Models\TestEntity::class, 10)->create(); $totalCount = TestEntity::count(); - $this->getJson('/test/entities/pages', ['Range'=>'entities='.($totalCount-2).'-'.($totalCount+20)]); + $this->getJson('/test/entities/pages', ['Range' => 'entities='.($totalCount - 2).'-'.($totalCount + 20)]); $object = json_decode($this->response->getContent()); $this->assertResponseStatus(206); $this->shouldReturnJson(); @@ -192,15 +192,15 @@ public function testPaginationMoreThanInRepo() $this->assertEquals(2, count($object)); list($first, $last, $total) = $this->parseRange($this->response->headers->get('content-range')); $this->assertEquals($total, $totalCount); - $this->assertEquals($first, $totalCount-2); - $this->assertEquals($last, $totalCount-1); + $this->assertEquals($first, $totalCount - 2); + $this->assertEquals($last, $totalCount - 1); } public function testPaginationGetLast() { $entities = factory(App\Models\TestEntity::class, 10)->create(); $totalCount = TestEntity::count(); - $this->getJson('/test/entities/pages', ['Range'=>'entities=-5']); + $this->getJson('/test/entities/pages', ['Range' => 'entities=-5']); $object = json_decode($this->response->getContent()); $this->assertResponseStatus(206); $this->shouldReturnJson(); @@ -209,8 +209,8 @@ public function testPaginationGetLast() $this->assertEquals(5, count($object)); list($first, $last, $total) = $this->parseRange($this->response->headers->get('content-range')); $this->assertEquals($total, $totalCount); - $this->assertEquals($first, $totalCount-5); - $this->assertEquals($last, $totalCount-1); + $this->assertEquals($first, $totalCount - 5); + $this->assertEquals($last, $totalCount - 1); } protected function parseRange($header) @@ -256,8 +256,8 @@ public function testGetOne() $this->assertTrue(is_string($object->varchar), 'Varchar column type is text'); $this->assertTrue(is_string($object->hash), 'Hash column is a hash'); - $this->assertTrue(is_integer($object->integer), 'Integer column type is integer'); - $this->assertTrue(is_float($object->decimal) || is_integer($object->decimal), 'Decimal column type is integer'); + $this->assertTrue(is_int($object->integer), 'Integer column type is integer'); + $this->assertTrue(is_float($object->decimal) || is_int($object->decimal), 'Decimal column type is integer'); $this->assertNull($object->nullable, 'Nullable column type is null'); $this->assertTrue(is_string($object->text), 'Text column type is text'); $this->assertValidIso8601Date($object->date, 'Date column type is a valid ISO8601 date'); @@ -274,7 +274,7 @@ public function testGetOneWithNested() $entity = factory(App\Models\TestEntity::class)->create(); $this->addRelatedEntities($entity); - $this->getJson('/test/entities/'.$entity->entity_id, ['with-nested'=>'testMany']); + $this->getJson('/test/entities/'.$entity->entity_id, ['with-nested' => 'testMany']); $object = json_decode($this->response->getContent()); $this->assertResponseOk(); @@ -300,7 +300,7 @@ public function testGetOneWithInvalidNested() $entity = factory(App\Models\TestEntity::class)->create(); $this->addRelatedEntities($entity); - $this->getJson('/test/entities/'.$entity->entity_id, ['with-nested'=>'not-a-valid-nesting']); + $this->getJson('/test/entities/'.$entity->entity_id, ['with-nested' => 'not-a-valid-nesting']); $object = json_decode($this->response->getContent()); $this->shouldReturnJson(); @@ -372,7 +372,7 @@ public function testPutOneCollidingIds() $this->assertTrue(is_object($object)); $this->assertObjectHasAttribute('message', $object); - $this->assertEquals("Provided entity body does not match route parameter. The entity key cannot be updated", $object->message); + $this->assertEquals('Provided entity body does not match route parameter. The entity key cannot be updated', $object->message); } public function testPutOneNewInvalidId() @@ -444,7 +444,6 @@ public function testPutManySomeNew() { $entities = factory(App\Models\TestEntity::class, 5)->create(); - $entities = array_map(function ($entity) { return $this->prepareEntity($entity); }, $entities->all()); @@ -504,8 +503,6 @@ public function testPutManyNewInvalid() $this->assertEquals($rowCount, TestEntity::count()); } - - public function testPatchOne() { $entity = factory(App\Models\TestEntity::class)->create(); @@ -554,7 +551,7 @@ public function testPatchManyInvalidId() $data = array_map(function ($entity) { return [ 'entity_id' => (string) Uuid::uuid4(), - 'varchar' => 'foobar' + 'varchar' => 'foobar', ]; }, $entities->all()); @@ -572,7 +569,7 @@ public function testPatchManyInvalid() $data = array_map(function ($entity) { return [ 'entity_id' => $entity->entity_id, - 'multi_word_column_title' => 'foobar' + 'multi_word_column_title' => 'foobar', ]; }, $entities->all()); @@ -640,7 +637,6 @@ public function testDeleteManyInvalidId() $this->assertEquals($rowCount, TestEntity::count()); } - public function testNoInnerLumenUrlDecode() { $compareString = '%foo?*:bar/"foo'; @@ -657,19 +653,18 @@ public function testEntitySearch() TestEntity::removeAllFromIndex(); $searchEntity = factory(App\Models\TestEntity::class)->create([ - 'varchar' => 'searchforthisstring' + 'varchar' => 'searchforthisstring', ]); sleep(1); //give the elastic search agent time to index - $this->getJson('/test/entities/pages?q=searchforthisstring', ['Range'=>'entities=0-9']); + $this->getJson('/test/entities/pages?q=searchforthisstring', ['Range' => 'entities=0-9']); $collection = json_decode($this->response->getContent()); $this->assertResponseStatus(206); $this->shouldReturnJson(); $this->assertJsonArray(); - $this->assertCount(1, $collection); $this->assertEquals($searchEntity->entity_id, $collection[0]->entityId); @@ -677,7 +672,7 @@ public function testEntitySearch() public function testEntitySearchNoResults() { - $this->getJson('/test/entities/pages?q=thisstringwontreturnresults', ['Range'=>'entities=0-9']); + $this->getJson('/test/entities/pages?q=thisstringwontreturnresults', ['Range' => 'entities=0-9']); $this->assertResponseStatus(404); $this->shouldReturnJson(); diff --git a/api/tests/integration/ExceptionTest.php b/api/tests/integration/ExceptionTest.php index 0b04fa60..1e84436e 100644 --- a/api/tests/integration/ExceptionTest.php +++ b/api/tests/integration/ExceptionTest.php @@ -4,7 +4,7 @@ use GuzzleHttp\Exception\ServerException; /** - * Class RestExceptionTest + * Class RestExceptionTest. * @group integration */ class RestExceptionTest extends TestCase diff --git a/api/tests/integration/ImageTest.php b/api/tests/integration/ImageTest.php index 5751cf88..6e120c5a 100644 --- a/api/tests/integration/ImageTest.php +++ b/api/tests/integration/ImageTest.php @@ -4,7 +4,7 @@ use App\Models\Image; /** - * Class ImageTest + * Class ImageTest. * @group integration */ class ImageTest extends TestCase @@ -40,12 +40,11 @@ protected function prepareEntity($entity) return $entity; } - public function testGetAllPaginated() { $entities = factory(Image::class, 30)->create()->all(); - $this->getJson('/images', ['Range'=>'entities=0-19']); + $this->getJson('/images', ['Range' => 'entities=0-19']); $this->assertResponseStatus(206); $this->shouldReturnJson(); $this->assertJsonArray(); @@ -81,7 +80,6 @@ public function testGetOne() $this->assertTrue(is_numeric($object->version)); } - public function testPutOneNew() { $entity = factory(Image::class)->make(); @@ -99,7 +97,6 @@ public function testPutOneNew() $this->assertStringStartsWith('http', $object->_self); } - public function testPatchOne() { $entity = factory(Image::class)->create(); @@ -113,7 +110,6 @@ public function testPatchOne() $this->assertEquals($checkEntity->alt, $entity->alt); } - public function testDeleteOne() { $entities = factory(Image::class, 4)->create()->all(); diff --git a/api/tests/integration/QueueTest.php b/api/tests/integration/QueueTest.php index 47b7f4e6..3dd1c4d1 100644 --- a/api/tests/integration/QueueTest.php +++ b/api/tests/integration/QueueTest.php @@ -4,7 +4,7 @@ use Pheanstalk\Pheanstalk; /** - * Class QueueTest + * Class QueueTest. * @group integration */ class QueueTest extends TestCase diff --git a/api/tests/integration/UserTest.php b/api/tests/integration/UserTest.php index 65246c02..8a4a0e73 100644 --- a/api/tests/integration/UserTest.php +++ b/api/tests/integration/UserTest.php @@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Hash; /** - * Class UserTest + * Class UserTest. * @group integration */ class UserTest extends TestCase @@ -38,7 +38,7 @@ public function testGetAllPaginatedByAdminUser() $this->getJson('/users', [ 'HTTP_AUTHORIZATION' => 'Bearer '.$token, - 'Range' => 'entities=0-19' + 'Range' => 'entities=0-19', ]); $this->assertResponseStatus(206); @@ -54,7 +54,7 @@ public function testGetAllPaginatedByGuestUser() $this->getJson('/users', [ 'HTTP_AUTHORIZATION' => 'Bearer '.$token, - 'Range' => 'entities=0-19' + 'Range' => 'entities=0-19', ]); $this->assertException('Denied', 403, 'ForbiddenException'); @@ -67,7 +67,7 @@ public function testGetOneByAdminUser() $token = $this->tokenFromUser($user); $this->getJson('/users/'.$userToGet->user_id, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertResponseOk(); @@ -82,7 +82,7 @@ public function testGetOneByGuestUser() $token = $this->tokenFromUser($user); $this->getJson('/users/'.$userToGet->user_id, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertException('Denied', 403, 'ForbiddenException'); @@ -95,7 +95,7 @@ public function testGetOneBySelfUser() $token = $this->tokenFromUser($user); $this->getJson('/users/'.$userToGet->user_id, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertResponseOk(); @@ -112,7 +112,7 @@ public function testGetProfileByGuestUser() $token = $this->tokenFromUser($user); $this->getJson('/users/'.$userToGet->user_id.'/profile', [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertException('Denied', 403, 'ForbiddenException'); @@ -225,11 +225,11 @@ public function testPatchOneByAdminUserNoProfile() $token = $this->tokenFromUser($user); $update = [ - 'firstName' => 'foobar' + 'firstName' => 'foobar', ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedUser = User::find($userToUpdate->user_id); @@ -248,12 +248,12 @@ public function testPatchOneByAdminUser() $update = [ 'firstName' => 'foobar', '_userProfile' => [ - 'dob' => '1221-05-14' // We have to change the dob to a date we know will never get randomly generated - ] + 'dob' => '1221-05-14', // We have to change the dob to a date we know will never get randomly generated + ], ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedUser = User::find($userToUpdate->user_id); @@ -273,12 +273,12 @@ public function testPatchOneByAdminUserPassword() $update = [ '_userCredential' => [ - 'password' => 'foobarfoobar' - ] + 'password' => 'foobarfoobar', + ], ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedCredentials = UserCredential::find($userToUpdate->user_id); @@ -296,12 +296,12 @@ public function testPatchOneBySelfUserPassword() $update = [ '_userCredential' => [ - 'password' => 'foobarfoobar' - ] + 'password' => 'foobarfoobar', + ], ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedCredentials = UserCredential::find($userToUpdate->user_id); @@ -325,7 +325,7 @@ public function testPatchOneByGuestUser() $token = $this->tokenFromUser($user); $this->patchJson('/users/'.$userToUpdate->user_id, [], [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertException('Denied', 403, 'ForbiddenException'); @@ -338,11 +338,11 @@ public function testPatchOneBySelfUserNoProfile() $token = $this->tokenFromUser($user); $update = [ - 'firstName' => 'foobar' + 'firstName' => 'foobar', ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedUser = User::find($userToUpdate->user_id); @@ -361,12 +361,12 @@ public function testPatchOneBySelfUser() $update = [ 'firstName' => 'foobar', '_userProfile' => [ - 'dob' => '1221-05-14' // We have to change the dob to a date we know will never get randomly generated - ] + 'dob' => '1221-05-14', // We have to change the dob to a date we know will never get randomly generated + ], ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $updatedUser = User::find($userToUpdate->user_id); @@ -386,11 +386,11 @@ public function testPatchOneBySelfUserUUID() $update = [ 'userId' => '1234', - 'firstName' => 'foobar' + 'firstName' => 'foobar', ]; $this->patchJson('/users/'.$userToUpdate->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertResponseStatus(400); @@ -403,7 +403,7 @@ public function testDeleteOneByAdminUser() $token = $this->tokenFromUser($user); $this->deleteJson('/users/'.$userToDelete->user_id, [], [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $user = User::find($userToDelete->user_id); @@ -422,7 +422,7 @@ public function testDeleteOneByGuestUser() $token = $this->tokenFromUser($user); $this->deleteJson('/users/'.$userToDelete->user_id, [], [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $user = User::find($userToDelete->user_id); @@ -440,7 +440,7 @@ public function testResetPasswordMail() $token = $this->tokenFromUser($user); $this->deleteJson('/users/'.$user->email.'/password', [], [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $mail = $this->getLastMessage(); @@ -481,8 +481,8 @@ public function testResetPasswordMailInvalidEmail() $user = $this->createUser(['user_type' => 'guest']); $token = $this->tokenFromUser($user); - $this->deleteJson('/users/foo.bar.' . $user->email . '/password', [], [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + $this->deleteJson('/users/foo.bar.'.$user->email.'/password', [], [ + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); $this->assertResponseStatus(404); @@ -499,7 +499,7 @@ public function testChangeEmail() // Make a request to change email $update = ['email' => 'foo@bar.com']; $this->patchJson('/users/'.$user->user_id, $update, [ - 'HTTP_AUTHORIZATION' => 'Bearer '.$token + 'HTTP_AUTHORIZATION' => 'Bearer '.$token, ]); // Ensure that we get the right response $this->assertResponseStatus(204); @@ -519,13 +519,13 @@ public function testChangeEmail() $emailToken = str_replace('emailConfirmationToken=', '', $tokens[0]); $loginToken = str_replace('loginToken=', '', $tokens[1]); // Ensure the login token is valid - $this->assertEquals($user->user_id, Cache::get('login_token_' . $loginToken, false)); + $this->assertEquals($user->user_id, Cache::get('login_token_'.$loginToken, false)); // Confirm the email change $datetime = date(\DateTime::ISO8601); $update = ['emailConfirmed' => $datetime]; $this->patchJson('/users/'.$user->user_id, $update, [ 'HTTP_AUTHORIZATION' => 'Bearer '.$token, - 'email-confirm-token' => $emailToken + 'email-confirm-token' => $emailToken, ]); // Ensure we get the right response $this->assertResponseStatus(204); @@ -546,7 +546,7 @@ public function testUpdateEmailConfirmed() $emailToken = $user->createEmailConfirmToken($user->email, 'foo@bar.com'); $this->patchJson('/users/'.$user->user_id, $update, [ 'HTTP_AUTHORIZATION' => 'Bearer '.$token, - 'Email-Confirm-Token' => $emailToken + 'Email-Confirm-Token' => $emailToken, ]); $updatedUser = User::find($user->user_id); $this->assertResponseStatus(204); @@ -563,7 +563,7 @@ public function testUpdateEmailConfirmedInvalidToken() $emailToken = 'foobar'; $this->patchJson('/users/'.$user->user_id, $update, [ 'HTTP_AUTHORIZATION' => 'Bearer '.$token, - 'Email-Confirm-Token' => $emailToken + 'Email-Confirm-Token' => $emailToken, ]); $this->assertResponseStatus(422); } diff --git a/forum/config.php b/forum/config.php index 7a84c3b5..1d219978 100644 --- a/forum/config.php +++ b/forum/config.php @@ -1,4 +1,6 @@ -recurseCopy($source . '/' . $file, $dest . '/' . $file); + if (is_dir($source.'/'.$file)) { + $this->recurseCopy($source.'/'.$file, $dest.'/'.$file); } else { - copy($source . '/' . $file, $dest . '/' . $file); + copy($source.'/'.$file, $dest.'/'.$file); } } } @@ -98,11 +98,11 @@ protected function recurseCopy($source, $dest) */ protected static function getInstance() { - return new Build; + return new self; } /** - * Run the vanilla setup functions + * Run the vanilla setup functions. */ protected function setupVanilla() { diff --git a/forum/src/VanillaConfigurator.php b/forum/src/VanillaConfigurator.php index f059ef53..e5352f4c 100644 --- a/forum/src/VanillaConfigurator.php +++ b/forum/src/VanillaConfigurator.php @@ -55,7 +55,7 @@ protected function quickBootstrap() define('PATH_ROOT', getcwd().'/public'); // Boostrap Vanilla - require_once('public/bootstrap.php'); + require_once 'public/bootstrap.php'; } /** @@ -73,9 +73,9 @@ protected function migrate() ini_set('display_errors', 0); // Create the database tables - require_once('public/applications/dashboard/settings/structure.php'); - require_once('public/applications/vanilla/settings/structure.php'); - require_once('public/applications/conversations/settings/structure.php'); + require_once 'public/applications/dashboard/settings/structure.php'; + require_once 'public/applications/vanilla/settings/structure.php'; + require_once 'public/applications/conversations/settings/structure.php'; } /** @@ -88,16 +88,16 @@ protected function config() saveToConfig('Garden.Cookie.Salt', RandomString(10)); $ApplicationInfo = []; - include(CombinePaths([PATH_APPLICATIONS.DS.'dashboard'.DS.'settings'.DS.'about.php'])); + include CombinePaths([PATH_APPLICATIONS.DS.'dashboard'.DS.'settings'.DS.'about.php']); // Detect Internet connection for CDNs - $Disconnected = !(bool)@fsockopen('ajax.googleapis.com', 80); + $Disconnected = ! (bool) @fsockopen('ajax.googleapis.com', 80); saveToConfig([ 'Garden.Version' => arrayValue('Version', val('Dashboard', $ApplicationInfo, []), 'Undefined'), 'Garden.Cdns.Disable' => $Disconnected, 'Garden.CanProcessImages' => function_exists('gd_info'), - 'EnabledPlugins.HtmLawed' => 'HtmLawed' + 'EnabledPlugins.HtmLawed' => 'HtmLawed', ]); } @@ -114,7 +114,7 @@ protected function adminUser() $user = [ 'Name' => getenv('VANILLA_ADMIN_NAME'), 'Email' => getenv('VANILLA_ADMIN_EMAIL'), - 'Password' => getenv('VANILLA_ADMIN_PASSWORD') + 'Password' => getenv('VANILLA_ADMIN_PASSWORD'), ]; $AdminUserID = $UserModel->SaveAdminUser($user); @@ -158,14 +158,14 @@ protected function configureJsConnect() 'AssociationHashMethod' => 'md5', 'AuthenticationSchemeAlias' => 'jsconnect', 'Name' => 'Spira', - 'AuthenticateUrl' => 'http://' . getenv('HOSTNAME_BASE') . '/api/auth/sso/vanilla', + 'AuthenticateUrl' => 'http://'.getenv('HOSTNAME_BASE').'/api/auth/sso/vanilla', 'Attributes' => serialize([ 'HashType' => 'sha1', 'TestMode' => false, - 'Trusted' => true + 'Trusted' => true, ]), 'Active' => true, - 'IsDefault' => true + 'IsDefault' => true, ]; Gdn::SQL()->Options('Ignore', true)->Insert('UserAuthenticationProvider', $provider); diff --git a/forum/src/apiextended/controllers/class.apidiscussioncontroller.php b/forum/src/apiextended/controllers/class.apidiscussioncontroller.php index 5fa68169..72e72886 100644 --- a/forum/src/apiextended/controllers/class.apidiscussioncontroller.php +++ b/forum/src/apiextended/controllers/class.apidiscussioncontroller.php @@ -15,15 +15,15 @@ class ApiDiscussionController extends DiscussionController */ public function getByForeignId($foreignId = '', $page = '', $perPage = 10) { - if (!$this->isValidUuid($foreignId)) { + if (! $this->isValidUuid($foreignId)) { throw new Gdn_UserException('Bad Request', 400); } - if (!array_key_exists('Discussion', $this->Data)) { + if (! array_key_exists('Discussion', $this->Data)) { $this->setData('Discussion', $this->DiscussionModel->getForeignID($foreignId), true); } - if (!is_object($this->Discussion)) { + if (! is_object($this->Discussion)) { throw notFoundException('Discussion'); } @@ -48,13 +48,13 @@ public function getByForeignId($foreignId = '', $page = '', $perPage = 10) */ public function deleteByForeignId($foreignId = '') { - if (!$this->isValidUuid($foreignId)) { + if (! $this->isValidUuid($foreignId)) { throw new Gdn_UserException('Bad Request', 400); } $discussion = $this->DiscussionModel->getForeignID($foreignId); - if (!is_object($discussion)) { + if (! is_object($discussion)) { throw notFoundException('Discussion'); } diff --git a/forum/src/apiextended/controllers/class.apiusercontroller.php b/forum/src/apiextended/controllers/class.apiusercontroller.php index 7db78451..75d5ec7e 100644 --- a/forum/src/apiextended/controllers/class.apiusercontroller.php +++ b/forum/src/apiextended/controllers/class.apiusercontroller.php @@ -19,7 +19,7 @@ public function sso() 'Name' => '', 'Email' => '', 'Photo' => '', - 'Roles' => [8] + 'Roles' => [8], ]; $user = array_intersect_key($data, $default) + $default; @@ -28,7 +28,7 @@ public function sso() // Create or get existing user $id = Gdn::userModel()->connect($uniqueId, $clientId, $user); - if (!$id) { + if (! $id) { throw new Gdn_UserException('Bad Request', 400); } diff --git a/forum/src/apiextended/settings/about.php b/forum/src/apiextended/settings/about.php index fe22552a..3a27d744 100644 --- a/forum/src/apiextended/settings/about.php +++ b/forum/src/apiextended/settings/about.php @@ -4,5 +4,5 @@ 'Name' => 'API Extended', 'Description' => 'Extends API with additional features.', 'Version' => '0.1.0', - 'RequiredApplications' => ['api' => '0.4.0'] + 'RequiredApplications' => ['api' => '0.4.0'], ]; diff --git a/forum/src/apiextended/settings/bootstrap.php b/forum/src/apiextended/settings/bootstrap.php index 1abef488..c8640d57 100644 --- a/forum/src/apiextended/settings/bootstrap.php +++ b/forum/src/apiextended/settings/bootstrap.php @@ -1,5 +1,6 @@ 'ApiDiscussion', 'method' => 'getbyforeignid', 'arguments' => [ - 'Page' => val('Page', $data) - ] + 'Page' => val('Page', $data), + ], ]); $sender::delete('/foreign/[*:foreignID]', [ 'controller' => 'ApiDiscussion', - 'method' => 'deletebyforeignid' + 'method' => 'deletebyforeignid', ]); } @@ -44,8 +44,8 @@ public function UsersAPI_register_handler($sender) 'controller' => 'ApiUser', 'method' => 'delete', 'arguments' => [ - 'Method' => val('Method', $data) - ] + 'Method' => val('Method', $data), + ], ]); } From 240b52e310957e5de03fca1fef975e56e2777538 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Fri, 4 Sep 2015 18:13:49 +1000 Subject: [PATCH 3/4] Dropped all file block comments in prep for the styleci header add --- api/app/Extensions/Controller/RequestValidationTrait.php | 7 ------- api/app/Helpers/RouteHelper.php | 7 ------- api/app/Http/Controllers/ApiController.php | 7 ------- api/app/Http/Controllers/ArticleController.php | 7 ------- api/app/Http/Controllers/ArticleMetaController.php | 7 ------- api/app/Http/Controllers/ArticlePermalinkController.php | 7 ------- api/app/Http/Controllers/ChildEntityController.php | 7 ------- api/app/Http/Controllers/ChildTestController.php | 7 ------- api/app/Http/Controllers/EntityController.php | 7 ------- api/app/Http/Transformers/ArticleTransformer.php | 7 ------- api/app/Http/Transformers/EloquentModelTransformer.php | 7 ------- api/app/Models/ArticleMeta.php | 7 ------- api/app/Models/ArticlePermalink.php | 7 ------- api/app/Models/SecondTestEntity.php | 7 ------- api/app/Models/Tag.php | 7 ------- api/src/Model/Collection/Collection.php | 7 ------- api/src/Model/Collection/ItemTypeException.php | 7 ------- api/src/Model/Collection/ModelCollectionIterator.php | 7 ------- api/src/Model/Model/BaseModel.php | 7 ------- api/src/Model/Model/SetRelationException.php | 7 ------- api/src/Model/Validation/TypeAwareMessage.php | 7 ------- api/src/Model/Validation/ValidationExceptionCollection.php | 7 ------- api/src/Model/Validation/Validator.php | 7 ------- api/src/Responder/Contract/TransformableInterface.php | 7 ------- api/src/Responder/Contract/TransformerInterface.php | 7 ------- .../Paginator/PaginatedRequestDecoratorInterface.php | 7 ------- api/src/Responder/Paginator/RangeRequest.php | 7 ------- api/src/Responder/Response/ApiResponse.php | 7 ------- api/tests/RouteHelperTest.php | 6 ------ 29 files changed, 202 deletions(-) diff --git a/api/app/Extensions/Controller/RequestValidationTrait.php b/api/app/Extensions/Controller/RequestValidationTrait.php index a1a33043..c3d1c42f 100644 --- a/api/app/Extensions/Controller/RequestValidationTrait.php +++ b/api/app/Extensions/Controller/RequestValidationTrait.php @@ -1,12 +1,5 @@ Date: Fri, 4 Sep 2015 18:20:17 +1000 Subject: [PATCH 4/4] Applied StyleCi header patch --- .../Console/Commands/ApiaryValidateCommand.php | 8 ++++++++ api/app/Console/Commands/GenerateKeysCommand.php | 8 ++++++++ api/app/Console/Kernel.php | 8 ++++++++ api/app/Exceptions/BadRequestException.php | 8 ++++++++ api/app/Exceptions/FatalErrorException.php | 8 ++++++++ api/app/Exceptions/ForbiddenException.php | 8 ++++++++ api/app/Exceptions/Handler.php | 8 ++++++++ api/app/Exceptions/NotImplementedException.php | 8 ++++++++ .../Exceptions/ServiceUnavailableException.php | 8 ++++++++ api/app/Exceptions/TokenInvalidException.php | 8 ++++++++ api/app/Exceptions/UnauthorizedException.php | 8 ++++++++ .../Exceptions/UnprocessableEntityException.php | 8 ++++++++ .../Controller/RequestValidationTrait.php | 8 ++++++++ api/app/Extensions/JWTAuth/ClaimFactory.php | 8 ++++++++ api/app/Extensions/JWTAuth/JWTAuth.php | 8 ++++++++ api/app/Extensions/JWTAuth/JWTManager.php | 8 ++++++++ api/app/Extensions/JWTAuth/NamshiAdapter.php | 8 ++++++++ api/app/Extensions/JWTAuth/PayloadFactory.php | 8 ++++++++ api/app/Extensions/JWTAuth/UserClaim.php | 8 ++++++++ api/app/Extensions/Lock/CallerLock.php | 8 ++++++++ api/app/Extensions/Lock/LockFactory.php | 8 ++++++++ api/app/Extensions/Lock/LockTrait.php | 8 ++++++++ api/app/Extensions/Lock/Manager.php | 8 ++++++++ api/app/Extensions/Lock/Privilege.php | 8 ++++++++ api/app/Extensions/Lock/RoleLock.php | 8 ++++++++ api/app/Extensions/Lock/UserOwnership.php | 8 ++++++++ .../Extensions/Socialite/Contracts/Provider.php | 8 ++++++++ .../Extensions/Socialite/One/AbstractProvider.php | 8 ++++++++ .../Extensions/Socialite/One/TwitterProvider.php | 8 ++++++++ .../Socialite/Parsers/AbstractParser.php | 8 ++++++++ .../Socialite/Parsers/FacebookParser.php | 8 ++++++++ .../Extensions/Socialite/Parsers/GoogleParser.php | 8 ++++++++ .../Socialite/Parsers/ParserFactory.php | 8 ++++++++ .../Socialite/Parsers/TwitterParser.php | 8 ++++++++ .../Socialite/Parsers/UsernameTrait.php | 8 ++++++++ api/app/Extensions/Socialite/SocialiteManager.php | 8 ++++++++ .../Socialite/SocialiteServiceProvider.php | 8 ++++++++ .../Extensions/Socialite/Two/FacebookProvider.php | 8 ++++++++ .../Extensions/Socialite/Two/GoogleProvider.php | 8 ++++++++ .../Extensions/Socialite/Two/ProviderTrait.php | 8 ++++++++ api/app/Helpers/RouteHelper.php | 8 ++++++++ api/app/Http/Controllers/ApiController.php | 8 ++++++++ api/app/Http/Controllers/ApiaryController.php | 8 ++++++++ .../Http/Controllers/ArticleCommentController.php | 8 ++++++++ api/app/Http/Controllers/ArticleController.php | 8 ++++++++ .../Http/Controllers/ArticleImageController.php | 8 ++++++++ .../Http/Controllers/ArticleMetaController.php | 8 ++++++++ .../Controllers/ArticlePermalinkController.php | 8 ++++++++ api/app/Http/Controllers/ArticleTagController.php | 8 ++++++++ api/app/Http/Controllers/AuthController.php | 8 ++++++++ .../Http/Controllers/ChildEntityController.php | 8 ++++++++ api/app/Http/Controllers/ChildTestController.php | 8 ++++++++ api/app/Http/Controllers/CountriesController.php | 8 ++++++++ api/app/Http/Controllers/EntityController.php | 8 ++++++++ api/app/Http/Controllers/ImageController.php | 8 ++++++++ api/app/Http/Controllers/TagController.php | 8 ++++++++ api/app/Http/Controllers/TestController.php | 8 ++++++++ api/app/Http/Controllers/TimezoneController.php | 8 ++++++++ api/app/Http/Controllers/UserController.php | 8 ++++++++ api/app/Http/Middleware/PermissionMiddleware.php | 8 ++++++++ api/app/Http/Middleware/TransactionMiddleware.php | 8 ++++++++ .../Middleware/TransformInputDataMiddleware.php | 8 ++++++++ .../Http/Middleware/UserResolverMiddleware.php | 8 ++++++++ .../Http/Transformers/ArticleTagTransformer.php | 8 ++++++++ api/app/Http/Transformers/ArticleTransformer.php | 8 ++++++++ .../Http/Transformers/AuthTokenTransformer.php | 8 ++++++++ api/app/Http/Transformers/BaseTransformer.php | 8 ++++++++ .../Transformers/EloquentModelTransformer.php | 8 ++++++++ api/app/Http/routes.php | 15 ++++++--------- api/app/Jobs/Job.php | 8 ++++++++ api/app/Jobs/SendEmailConfirmationEmail.php | 8 ++++++++ api/app/Jobs/SendPasswordResetEmail.php | 8 ++++++++ api/app/Models/Article.php | 8 ++++++++ api/app/Models/ArticleComment.php | 8 ++++++++ api/app/Models/ArticleDiscussion.php | 8 ++++++++ api/app/Models/ArticleImage.php | 8 ++++++++ api/app/Models/ArticleMeta.php | 8 ++++++++ api/app/Models/ArticlePermalink.php | 8 ++++++++ api/app/Models/AuthToken.php | 8 ++++++++ api/app/Models/Image.php | 8 ++++++++ api/app/Models/SecondTestEntity.php | 8 ++++++++ api/app/Models/SocialLogin.php | 8 ++++++++ api/app/Models/Tag.php | 8 ++++++++ api/app/Models/TestEntity.php | 8 ++++++++ api/app/Models/User.php | 8 ++++++++ api/app/Models/UserCredential.php | 8 ++++++++ api/app/Models/UserProfile.php | 8 ++++++++ api/app/Providers/AppServiceProvider.php | 8 ++++++++ api/app/Providers/JWTAuthServiceProvider.php | 8 ++++++++ api/app/Providers/LockServiceProvider.php | 8 ++++++++ api/app/Services/Api/Vanilla/Api/ApiAbstract.php | 8 ++++++++ api/app/Services/Api/Vanilla/Api/Comment.php | 8 ++++++++ .../Services/Api/Vanilla/Api/Configuration.php | 8 ++++++++ api/app/Services/Api/Vanilla/Api/Discussion.php | 8 ++++++++ api/app/Services/Api/Vanilla/Api/User.php | 8 ++++++++ api/app/Services/Api/Vanilla/Client.php | 8 ++++++++ api/app/Services/Api/Vanilla/Error.php | 8 ++++++++ api/app/Services/Datasets/Countries.php | 8 ++++++++ api/app/Services/Datasets/Dataset.php | 8 ++++++++ api/app/Services/Datasets/Timezones.php | 8 ++++++++ api/app/Services/ModelFactory.php | 8 ++++++++ api/app/Services/ModelFactoryInstance.php | 8 ++++++++ .../Exceptions/VanillaAccessDeniedException.php | 8 ++++++++ .../SingleSignOn/Exceptions/VanillaException.php | 8 ++++++++ .../Exceptions/VanillaInvalidClientException.php | 8 ++++++++ .../Exceptions/VanillaInvalidRequestException.php | 8 ++++++++ .../SingleSignOn/SingleSignOnAbstract.php | 8 ++++++++ .../SingleSignOn/SingleSignOnContract.php | 8 ++++++++ .../Services/SingleSignOn/SingleSignOnFactory.php | 8 ++++++++ .../Services/SingleSignOn/VanillaSingleSignOn.php | 8 ++++++++ api/app/Services/SpiraValidator.php | 8 ++++++++ api/app/Services/TransformerService.php | 8 ++++++++ api/app/SpiraApplication.php | 8 ++++++++ api/bootstrap/app.php | 8 ++++++++ api/config/elasticquent.php | 8 ++++++++ api/config/filesystems.php | 8 ++++++++ api/config/hosts.php | 8 ++++++++ api/config/jwt.php | 8 ++++++++ api/config/queue.php | 8 ++++++++ api/config/services.php | 8 ++++++++ api/database/factories/ModelFactory.php | 15 ++++++--------- .../2015_03_29_081319_create_users_table.php | 8 ++++++++ ...2015_05_19_002311_create_failed_jobs_table.php | 8 ++++++++ ...15_06_01_014141_create_test_entities_table.php | 8 ++++++++ ...07_08_041115_create_user_credentials_table.php | 8 ++++++++ .../2015_07_13_060411_test_many_many_table.php | 8 ++++++++ ...5_07_13_060433_test_many_many_second_table.php | 8 ++++++++ .../2015_07_21_144551_create_articles_table.php | 8 ++++++++ ...21_144631_create_articles_permalinks_table.php | 8 ++++++++ ...dd_permalink_foreign_key_to_articles_table.php | 8 ++++++++ ...15_07_29_233138_create_social_logins_table.php | 8 ++++++++ ...015_08_03_082813_create_article_meta_table.php | 8 ++++++++ ...15_08_06_062319_create_user_profiles_table.php | 8 ++++++++ .../2015_08_19_150932_create_tags_table.php | 8 ++++++++ ...015_08_21_104824_create_article_tags_table.php | 8 ++++++++ .../2015_08_24_205244_create_image_table.php | 8 ++++++++ ...15_08_25_170420_create_article_image_table.php | 8 ++++++++ api/database/seeds/ArticleSeeder.php | 8 ++++++++ api/database/seeds/DatabaseSeeder.php | 8 ++++++++ api/database/seeds/TestEntitySeeder.php | 8 ++++++++ api/database/seeds/UserStorySeeder.php | 8 ++++++++ api/public/index.php | 15 ++++++--------- api/resources/lang/en/validation.php | 8 ++++++++ api/server.php | 8 ++++++++ api/src/Model/Collection/Collection.php | 8 ++++++++ api/src/Model/Collection/IndexedCollection.php | 8 ++++++++ api/src/Model/Collection/ItemTypeException.php | 8 ++++++++ .../Model/Collection/ModelCollectionIterator.php | 8 ++++++++ api/src/Model/Model/BaseModel.php | 8 ++++++++ api/src/Model/Model/IndexedModel.php | 8 ++++++++ api/src/Model/Model/SetRelationException.php | 8 ++++++++ api/src/Model/Model/VirtualRelationInterface.php | 8 ++++++++ api/src/Model/Validation/TypeAwareMessage.php | 8 ++++++++ api/src/Model/Validation/ValidationException.php | 8 ++++++++ .../Validation/ValidationExceptionCollection.php | 8 ++++++++ api/src/Model/Validation/Validator.php | 8 ++++++++ .../Responder/Contract/TransformableInterface.php | 8 ++++++++ .../Responder/Contract/TransformerInterface.php | 8 ++++++++ .../PaginatedRequestDecoratorInterface.php | 8 ++++++++ api/src/Responder/Paginator/RangeRequest.php | 8 ++++++++ api/src/Responder/Response/ApiResponse.php | 8 ++++++++ api/tests/CacheTest.php | 8 ++++++++ api/tests/CommandTest.php | 8 ++++++++ api/tests/ElasticSearchTest.php | 8 ++++++++ api/tests/EmailTest.php | 8 ++++++++ api/tests/Extensions/SocialiteTest.php | 8 ++++++++ api/tests/LogTest.php | 8 ++++++++ api/tests/MiddlewareTest.php | 8 ++++++++ api/tests/ModelFactoryTest.php | 8 ++++++++ api/tests/ModelTest.php | 7 +++++++ api/tests/Models/ArticleModelTest.php | 8 ++++++++ api/tests/Models/UserModelTest.php | 8 ++++++++ api/tests/ResponseTest.php | 8 ++++++++ api/tests/RouteHelperTest.php | 8 ++++++++ api/tests/Services/Api/VanillaApiTest.php | 8 ++++++++ api/tests/Services/Api/VanillaIntegrationTest.php | 8 ++++++++ api/tests/Services/DatasetsTest.php | 8 ++++++++ api/tests/Services/SingleSignOnTest.php | 8 ++++++++ api/tests/TestCase.php | 8 ++++++++ api/tests/Traits/AssertionsTrait.php | 8 ++++++++ api/tests/Traits/AssertionsTraitTest.php | 8 ++++++++ api/tests/Traits/HelpersTrait.php | 8 ++++++++ api/tests/Traits/MailcatcherTrait.php | 8 ++++++++ api/tests/Traits/ModelFactoryTrait.php | 8 ++++++++ api/tests/TransformerTest.php | 8 ++++++++ api/tests/ValidatorTest.php | 8 ++++++++ api/tests/integration/ArticleImageTest.php | 8 ++++++++ api/tests/integration/ArticleTagTest.php | 8 ++++++++ api/tests/integration/ArticleTest.php | 8 ++++++++ api/tests/integration/AuthTest.php | 8 ++++++++ api/tests/integration/ChildEntityTest.php | 8 ++++++++ api/tests/integration/DocumentationTest.php | 7 +++++++ api/tests/integration/EntityTest.php | 8 ++++++++ api/tests/integration/ExceptionTest.php | 8 ++++++++ api/tests/integration/ImageTest.php | 7 +++++++ api/tests/integration/QueueTest.php | 8 ++++++++ api/tests/integration/UserTest.php | 8 ++++++++ forum/bootstrap.before.php | 8 ++++++++ forum/bootstrap.database.php | 8 ++++++++ forum/config.php | 8 ++++++++ forum/server.php | 9 ++++++++- forum/src/Spira/Build.php | 8 ++++++++ forum/src/VanillaConfigurator.php | 8 ++++++++ .../controllers/class.apidiscussioncontroller.php | 8 ++++++++ .../controllers/class.apiusercontroller.php | 8 ++++++++ forum/src/apiextended/settings/about.php | 8 ++++++++ forum/src/apiextended/settings/bootstrap.php | 8 ++++++++ forum/src/apiextended/settings/class.hooks.php | 8 ++++++++ forum/tests/VanillaTest.php | 8 ++++++++ 209 files changed, 1663 insertions(+), 28 deletions(-) diff --git a/api/app/Console/Commands/ApiaryValidateCommand.php b/api/app/Console/Commands/ApiaryValidateCommand.php index e673286a..6d061e53 100644 --- a/api/app/Console/Commands/ApiaryValidateCommand.php +++ b/api/app/Console/Commands/ApiaryValidateCommand.php @@ -1,5 +1,13 @@ env('APP_HOST'), diff --git a/api/config/jwt.php b/api/config/jwt.php index 12c38372..7dd9720b 100644 --- a/api/config/jwt.php +++ b/api/config/jwt.php @@ -1,5 +1,13 @@ [ diff --git a/api/database/factories/ModelFactory.php b/api/database/factories/ModelFactory.php index 637aff7b..89ef92e6 100644 --- a/api/database/factories/ModelFactory.php +++ b/api/database/factories/ModelFactory.php @@ -1,15 +1,12 @@ getenv('VANILLADATABASE_ENV_MYSQL_DATABASE'), 'Database.Host' => getenv('VANILLADATABASE_PORT_3306_TCP_ADDR'), diff --git a/forum/config.php b/forum/config.php index 1d219978..aed93a06 100644 --- a/forum/config.php +++ b/forum/config.php @@ -1,5 +1,13 @@ 'API Extended', 'Description' => 'Extends API with additional features.', diff --git a/forum/src/apiextended/settings/bootstrap.php b/forum/src/apiextended/settings/bootstrap.php index c8640d57..28bdbad0 100644 --- a/forum/src/apiextended/settings/bootstrap.php +++ b/forum/src/apiextended/settings/bootstrap.php @@ -1,5 +1,13 @@