diff --git a/resources/config/sluggable.php b/resources/config/sluggable.php index 2b1495b..ceeaab0 100644 --- a/resources/config/sluggable.php +++ b/resources/config/sluggable.php @@ -1,8 +1,7 @@ null, - /** + /* * The maximum length of a generated slug. Defaults to "null", which means * no length restrictions are enforced. Set it to a positive integer if you * want to make sure your slugs aren't too long. @@ -28,7 +27,7 @@ 'maxLength' => null, - /** + /* * If you are setting a maximum length on your slugs, you may not want the * truncated string to split a word in half. The default setting of "true" * will ensure this, e.g. with a maxLength of 12: @@ -43,7 +42,7 @@ 'maxLengthKeepWords' => true, - /** + /* * If left to "null", then use the cocur/slugify package to generate the slug * (with the separator defined below). * @@ -61,13 +60,11 @@ 'method' => null, - /** - * Separator to use when generating slugs. Defaults to a hyphen. - */ + // Separator to use when generating slugs. Defaults to a hyphen. 'separator' => '-', - /** + /* * Enforce uniqueness of slugs? Defaults to true. * If a generated slug already exists, an incremental numeric * value will be appended to the end until a unique slug is found. e.g.: @@ -79,7 +76,7 @@ 'unique' => true, - /** + /* * If you are enforcing unique slugs, the default is to add an * incremental value to the end of the base slug. Alternatively, you * can change this value to a closure that accepts three parameters: @@ -87,10 +84,10 @@ * "similar" slugs. The closure should return the new unique * suffix to append to the slug. */ - + 'uniqueSuffix' => null, - /** + /* * What is the first suffix to add to a slug to make it unique? * For the default method of adding incremental integers, we start * counting at 2, so the list of slugs would be, e.g.: @@ -101,7 +98,7 @@ */ 'firstUniqueSuffix' => 2, - /** + /* * Should we include the trashed items when generating a unique slug? * This only applies if the softDelete property is set for the Eloquent model. * If set to "false", then a new slug could duplicate one that exists on a trashed model. @@ -110,7 +107,7 @@ 'includeTrashed' => false, - /** + /* * An array of slug names that can never be used for this model, * e.g. to prevent collisions with existing routes or controller methods, etc.. * Defaults to null (i.e. no reserved names). @@ -136,7 +133,7 @@ 'reserved' => null, - /** + /* * Whether to update the slug value when a model is being * re-saved (i.e. already exists). Defaults to false, which * means slugs are not updated. @@ -146,13 +143,12 @@ * is probably not a good idea from an SEO point of view. * Only set this to true if you understand the possible consequences. */ - + 'onUpdate' => false, - /** + /* * If the default slug engine of cocur/slugify is used, this array of * configuration options will be used when instantiating the engine. */ 'slugEngineOptions' => [], - ]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 7cadfb5..aac8f3d 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -1,4 +1,6 @@ -app->singleton(SluggableObserver::class, function($app) { + $this->app->singleton(SluggableObserver::class, function ($app) { return new SluggableObserver(new SlugService(), $app['events']); }); } @@ -37,9 +36,9 @@ protected function setUpConfig(): void if ($this->app instanceof LaravelApplication) { $this->publishes([$source => config_path('sluggable.php')], 'config'); - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line } elseif ($this->app instanceof LumenApplication) { - $this->app->configure('sluggable'); /** @phpstan-ignore class.notFound */ + $this->app->configure('sluggable'); // @phpstan-ignore class.notFound } $this->mergeConfigFrom($source, 'sluggable'); diff --git a/src/Services/SlugService.php b/src/Services/SlugService.php index 039d6c5..ea21839 100644 --- a/src/Services/SlugService.php +++ b/src/Services/SlugService.php @@ -1,33 +1,28 @@ -model->getAttributeValue($attribute); if ( - $config['onUpdate'] === true || - $value === null || - trim($value) === '' + $config['onUpdate'] === true + || $value === null + || trim($value) === '' ) { return true; } @@ -119,15 +99,13 @@ protected function needsSlugging(string $attribute, array $config): bool return false; } - return (!$this->model->exists); + return !$this->model->exists; } /** * Get the source string for the slug. * * @param mixed $from - * - * @return string */ protected function getSlugSource($from): string { @@ -135,7 +113,7 @@ protected function getSlugSource($from): string return $this->model->__toString(); } - $sourceStrings = array_map(function($key) { + $sourceStrings = array_map(function ($key) { $value = data_get($this->model, $key, $this->model->getAttribute($key)); if (is_bool($value)) { $value = (int) $value; @@ -150,11 +128,6 @@ protected function getSlugSource($from): string /** * Generate a slug from the given source string. * - * @param string $source - * @param array $config - * @param string $attribute - * - * @return string * @throws \UnexpectedValueException */ protected function generateSlug(string $source, array $config, string $attribute): string @@ -190,11 +163,6 @@ protected function generateSlug(string $source, array $config, string $attribute /** * Return a class that has a `slugify()` method, used to convert * strings into slugs. - * - * @param string $attribute - * - * @param array $config - * @return \Cocur\Slugify\Slugify */ protected function getSlugEngine(string $attribute, array $config): Slugify { @@ -215,11 +183,6 @@ protected function getSlugEngine(string $attribute, array $config): Slugify /** * Checks that the given slug is not a reserved word. * - * @param string $slug - * @param array $config - * @param string $attribute - * - * @return string * @throws \UnexpectedValueException */ protected function validateSlug(string $slug, array $config, string $attribute): string @@ -261,11 +224,6 @@ protected function validateSlug(string $slug, array $config, string $attribute): /** * Checks if the slug should be unique, and makes it so if needed. * - * @param string $slug - * @param array $config - * @param string $attribute - * - * @return string * @throws \UnexpectedValueException */ protected function makeSlugUnique(string $slug, array $config, string $attribute): string @@ -284,8 +242,8 @@ protected function makeSlugUnique(string $slug, array $config, string $attribute // b) our slug isn't in the list // ... we are okay if ( - $list->count() === 0 || - $list->contains($slug) === false + $list->count() === 0 + || $list->contains($slug) === false ) { return $slug; } @@ -298,8 +256,8 @@ protected function makeSlugUnique(string $slug, array $config, string $attribute $currentSlug = $list->get($this->model->getKey()); if ( - $currentSlug === $slug || - !$slug || strpos($currentSlug, $slug) === 0 + $currentSlug === $slug + || !$slug || strpos($currentSlug, $slug) === 0 ) { return $currentSlug; } @@ -322,12 +280,7 @@ protected function makeSlugUnique(string $slug, array $config, string $attribute /** * Generate a unique suffix for the given slug (and list of existing, "similar" slugs. * - * @param string $slug - * @param string $separator - * @param \Illuminate\Support\Collection $list * @param mixed $firstSuffix - * - * @return string */ protected function generateSuffix(string $slug, string $separator, Collection $list, $firstSuffix): string { @@ -341,7 +294,7 @@ protected function generateSuffix(string $slug, string $separator, Collection $l return end($suffix); } - $list->transform(function($value, $key) use ($len) { + $list->transform(function ($value, $key) use ($len) { return (int) substr($value, $len); }); @@ -354,12 +307,6 @@ protected function generateSuffix(string $slug, string $separator, Collection $l /** * Get all existing slugs that are similar to the given slug. - * - * @param string $slug - * @param string $attribute - * @param array $config - * - * @return \Illuminate\Support\Collection */ protected function getExistingSlugs(string $slug, string $attribute, array $config): Collection { @@ -389,8 +336,6 @@ protected function getExistingSlugs(string $slug, string $attribute, array $conf /** * Does this model use softDeleting? - * - * @return bool */ protected function usesSoftDeleting(): bool { @@ -400,19 +345,13 @@ protected function usesSoftDeleting(): bool /** * Generate a unique slug for a given string. * - * @param \Illuminate\Database\Eloquent\Model|string $model - * @param string $attribute - * @param string $fromString - * @param array|null $config - * - * @return string * @throws \InvalidArgumentException * @throws \UnexpectedValueException */ public static function createSlug(Model|string $model, string $attribute, string $fromString, ?array $config = null): string { if (is_string($model)) { - $model = new $model; + $model = new $model(); } $instance = (new static())->setModel($model); @@ -421,6 +360,7 @@ public static function createSlug(Model|string $model, string $attribute, string $config = Arr::get($model->sluggable(), $attribute); if ($config === null) { $modelClass = get_class($model); + throw new \InvalidArgumentException("Argument 2 passed to SlugService::createSlug ['{$attribute}'] is not a valid slug attribute for model {$modelClass}."); } } @@ -435,8 +375,6 @@ public static function createSlug(Model|string $model, string $attribute, string } /** - * @param \Illuminate\Database\Eloquent\Model $model - * * @return $this */ public function setModel(Model $model): self diff --git a/src/Sluggable.php b/src/Sluggable.php index 1ff6354..cefe74c 100644 --- a/src/Sluggable.php +++ b/src/Sluggable.php @@ -1,4 +1,6 @@ -where(function(Builder $q) use ($attribute, $slug, $separator) { + return $query->where(function (Builder $q) use ($attribute, $slug, $separator) { $q->where($attribute, '=', $slug) ->orWhere($attribute, 'LIKE', $slug . $separator . '%'); }); @@ -91,18 +82,11 @@ public function scopeFindSimilarSlugs(Builder $query, string $attribute, array $ /** * Return the sluggable configuration array for this model. - * - * @return array */ abstract public function sluggable(): array; - /** * Optionally customize the cocur/slugify engine. - * - * @param \Cocur\Slugify\Slugify $engine - * @param string $attribute - * @return \Cocur\Slugify\Slugify */ public function customizeSlugEngine(Slugify $engine, string $attribute): Slugify { @@ -111,13 +95,6 @@ public function customizeSlugEngine(Slugify $engine, string $attribute): Slugify /** * Optionally add constraints to the query that determines uniqueness. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $attribute - * @param array $config - * @param string $slug - * @return \Illuminate\Database\Eloquent\Builder */ public function scopeWithUniqueSlugConstraints( Builder $query, @@ -125,8 +102,7 @@ public function scopeWithUniqueSlugConstraints( string $attribute, array $config, string $slug - ): Builder - { + ): Builder { return $query; } } diff --git a/src/SluggableObserver.php b/src/SluggableObserver.php index 8686a0c..96f44f6 100644 --- a/src/SluggableObserver.php +++ b/src/SluggableObserver.php @@ -1,17 +1,16 @@ -sluggableEvent() !== self::SAVING) { return; } @@ -55,12 +50,11 @@ public function saving(Model $model) } /** - * @param \Illuminate\Database\Eloquent\Model $model * @return bool|void */ public function saved(Model $model) { - /** @phpstan-ignore-next-line */ + // @phpstan-ignore-next-line if ($model->sluggableEvent() !== self::SAVED) { return; } @@ -69,11 +63,6 @@ public function saved(Model $model) } } - /** - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $event - * @return bool - */ protected function generateSlug(Model $model, string $event): bool { // If the "slugging" event returns false, abort @@ -89,10 +78,6 @@ protected function generateSlug(Model $model, string $event): bool /** * Fire the namespaced validating event. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $event - * @return bool|null */ protected function fireSluggingEvent(Model $model, string $event): ?bool { @@ -101,10 +86,6 @@ protected function fireSluggingEvent(Model $model, string $event): ?bool /** * Fire the namespaced post-validation event. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $status - * @return void */ protected function fireSluggedEvent(Model $model, string $status): void { diff --git a/src/SluggableScopeHelpers.php b/src/SluggableScopeHelpers.php index 78a5716..c6d5126 100644 --- a/src/SluggableScopeHelpers.php +++ b/src/SluggableScopeHelpers.php @@ -1,22 +1,22 @@ - 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('my-first-post', $post->slug); } @@ -51,7 +52,7 @@ public function testSimpleSlug(): void public function testShortConfig(): void { $post = PostShortConfig::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('my-first-post', $post->slug); } @@ -62,7 +63,7 @@ public function testShortConfig(): void public function testAccentedCharacters(): void { $post = Post::create([ - 'title' => 'My Dinner With André & François' + 'title' => 'My Dinner With André & François', ]); self::assertEquals('my-dinner-with-andre-francois', $post->slug); } @@ -73,8 +74,8 @@ public function testAccentedCharacters(): void public function testMultipleSource(): void { $post = PostWithMultipleSources::create([ - 'title' => 'A Post Title', - 'subtitle' => 'A Subtitle' + 'title' => 'A Post Title', + 'subtitle' => 'A Subtitle', ]); self::assertEquals('a-post-title-a-subtitle', $post->slug); } @@ -82,7 +83,7 @@ public function testMultipleSource(): void public function testLeadingTrailingSpaces(): void { $post = Post::create([ - 'title' => "\tMy First Post \r\n" + 'title' => "\tMy First Post \r\n", ]); self::assertEquals('my-first-post', $post->slug); } @@ -93,8 +94,8 @@ public function testLeadingTrailingSpaces(): void public function testCustomMethod(): void { $post = PostWithCustomMethod::create([ - 'title' => 'A Post Title', - 'subtitle' => 'A Subtitle' + 'title' => 'A Post Title', + 'subtitle' => 'A Subtitle', ]); self::assertEquals('eltit-tsop-a', $post->slug); } @@ -105,8 +106,8 @@ public function testCustomMethod(): void public function testCustomCallableMethod(): void { $post = PostWithCustomCallableMethod::create([ - 'title' => 'A Post Title', - 'subtitle' => 'A Subtitle' + 'title' => 'A Post Title', + 'subtitle' => 'A Subtitle', ]); self::assertEquals('eltit-tsop-a', $post->slug); } @@ -118,7 +119,7 @@ public function testCustomSuffix(): void { for ($i = 1; $i <= 20; $i++) { $post = PostWithCustomSuffix::create([ - 'title' => 'A Post Title', + 'title' => 'A Post Title', 'subtitle' => 'A Subtitle', ]); @@ -136,7 +137,7 @@ public function testCustomSuffix(): void public function testToStringMethod(): void { $post = PostWithNoSource::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title', $post->slug); } @@ -147,7 +148,7 @@ public function testToStringMethod(): void public function testCustomSeparator(): void { $post = PostWithCustomSeparator::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a.post.title', $post->slug); } @@ -158,7 +159,7 @@ public function testCustomSeparator(): void public function testReservedWord(): void { $post = PostWithReservedSlug::create([ - 'title' => 'Add' + 'title' => 'Add', ]); self::assertEquals('add-2', $post->slug); } @@ -171,7 +172,7 @@ public function testReservedWord(): void public function testIssue5(): void { $post = Post::create([ - 'title' => 'My first post' + 'title' => 'My first post', ]); self::assertEquals('my-first-post', $post->slug); @@ -194,7 +195,7 @@ public function testIssue5(): void public function testIssue20(): void { $post1 = Post::create([ - 'title' => 'My first post' + 'title' => 'My first post', ]); self::assertEquals('my-first-post', $post1->slug); @@ -208,7 +209,7 @@ public function testIssue20(): void public function testNonSluggableModels(): void { $post = PostNotSluggable::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals(null, $post->slug); } @@ -219,7 +220,7 @@ public function testNonSluggableModels(): void public function testMaxLength(): void { $post = PostWithMaxLength::create([ - 'title' => 'A post with a really long title' + 'title' => 'A post with a really long title', ]); self::assertEquals('a-post', $post->slug); } @@ -230,7 +231,7 @@ public function testMaxLength(): void public function testMaxLengthSplitWords(): void { $post = PostWithMaxLengthSplitWords::create([ - 'title' => 'A post with a really long title' + 'title' => 'A post with a really long title', ]); self::assertEquals('a-post-wit', $post->slug); } @@ -242,7 +243,7 @@ public function testMaxLengthWithIncrements(): void { for ($i = 1; $i <= 20; $i++) { $post = PostWithMaxLength::create([ - 'title' => 'A post with a really long title' + 'title' => 'A post with a really long title', ]); if ($i === 1) { self::assertEquals('a-post', $post->slug); @@ -259,7 +260,7 @@ public function testMaxLengthSplitWordsWithIncrements(): void { for ($i = 1; $i <= 20; $i++) { $post = PostWithMaxLengthSplitWords::create([ - 'title' => 'A post with a really long title' + 'title' => 'A post with a really long title', ]); if ($i === 1) { self::assertEquals('a-post-wit', $post->slug); @@ -275,7 +276,7 @@ public function testMaxLengthSplitWordsWithIncrements(): void public function testMaxLengthDoesNotEndInSeparator(): void { $post = PostWithMaxLengthSplitWords::create([ - 'title' => 'It should work' + 'title' => 'It should work', ]); self::assertEquals('it-should', $post->slug); } @@ -289,7 +290,7 @@ public function testDoesNotNeedSluggingWhenSlugIsSet(): void { $post = Post::create([ 'title' => 'My first post', - 'slug' => 'custom-slug' + 'slug' => 'custom-slug', ]); self::assertEquals('custom-slug', $post->slug); } @@ -303,7 +304,7 @@ public function testDoesNotNeedSluggingWithUpdateWhenSlugIsSet(): void { $post = Post::create([ 'title' => 'My first post', - 'slug' => 'custom-slug' + 'slug' => 'custom-slug', ]); self::assertEquals('custom-slug', $post->slug); @@ -325,7 +326,7 @@ public function testDoesNotNeedSluggingWithUpdateWhenSlugIsSet(): void public function testModelStillSavesWhenSlugIsNotUpdated() { $post = Post::create([ - 'title' => 'My Post', + 'title' => 'My Post', 'subtitle' => 'My First Subtitle', ]); @@ -345,10 +346,10 @@ public function testModelStillSavesWhenSlugIsNotUpdated() public function testSlugFromRelatedModel(): void { $author = Author::create([ - 'name' => 'Arthur Conan Doyle' + 'name' => 'Arthur Conan Doyle', ]); $post = new PostWithRelation([ - 'title' => 'First' + 'title' => 'First', ]); $post->author()->associate($author); $post->save(); @@ -361,7 +362,7 @@ public function testSlugFromRelatedModel(): void public function testSlugFromRelatedModelNotExists(): void { $post = PostWithRelation::create([ - 'title' => 'First' + 'title' => 'First', ]); self::assertEquals('first', $post->slug); } @@ -372,7 +373,7 @@ public function testSlugFromRelatedModelNotExists(): void public function testNullSourceGeneratesEmptySlug(): void { $post = PostWithCustomSource::create([ - 'title' => 'My Test Post' + 'title' => 'My Test Post', ]); self::assertEquals(null, $post->slug); } @@ -383,7 +384,7 @@ public function testNullSourceGeneratesEmptySlug(): void public function testZeroLengthSourceGeneratesEmptySlug(): void { $post = Post::create([ - 'title' => '' + 'title' => '', ]); self::assertNull($post->slug); } @@ -394,7 +395,7 @@ public function testZeroLengthSourceGeneratesEmptySlug(): void public function testCustomEngineRules(): void { $post = PostWithCustomEngine::create([ - 'title' => 'The quick brown fox jumps over the lazy dog' + 'title' => 'The quick brown fox jumps over the lazy dog', ]); self::assertEquals('tha-qaack-brawn-fax-jamps-avar-tha-lazy-dag', $post->slug); } @@ -405,7 +406,7 @@ public function testCustomEngineRules(): void public function testCustomEngineRules2(): void { $post = PostWithCustomEngine2::create([ - 'title' => 'The quick brown fox/jumps over/the lazy dog' + 'title' => 'The quick brown fox/jumps over/the lazy dog', ]); self::assertEquals('the-quick-brown-fox/jumps-over/the-lazy-dog', $post->slug); } @@ -413,7 +414,7 @@ public function testCustomEngineRules2(): void public function testCustomEngineOptions(): void { $post = PostWithCustomEngineOptions::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('My-First-Post', $post->slug); } @@ -424,7 +425,7 @@ public function testCustomEngineOptions(): void public function testForeignRuleset(): void { $post = PostWithForeignRuleset::create([ - 'title' => 'Mia unua poŝto' + 'title' => 'Mia unua poŝto', ]); self::assertEquals('mia-unua-posxto', $post->slug); } @@ -435,7 +436,7 @@ public function testForeignRuleset(): void public function testForeignRuleset2(): void { $post = PostWithForeignRuleset2::create([ - 'title' => 'Jyväskylä' + 'title' => 'Jyväskylä', ]); self::assertEquals('jyvaskyla', $post->slug); } @@ -448,7 +449,7 @@ public function testForeignRuleset2(): void public function testEmptySeparator(): void { $post = PostWithEmptySeparator::create([ - 'title' => 'My Test Post' + 'title' => 'My Test Post', ]); self::assertEquals('mytestpost', $post->slug); } @@ -459,7 +460,7 @@ public function testEmptySeparator(): void public function testMultipleSlugs(): void { $post = PostWithMultipleSlugs::create([ - 'title' => 'My Test Post', + 'title' => 'My Test Post', 'subtitle' => 'My Subtitle', ]); @@ -468,12 +469,12 @@ public function testMultipleSlugs(): void } /** - * Test subscript characters in slug field + * Test subscript characters in slug field. */ public function testSubscriptCharacters(): void { $post = Post::create([ - 'title' => 'RDA-125-15/30/45m³/h CAV' + 'title' => 'RDA-125-15/30/45m³/h CAV', ]); self::assertEquals('rda-125-15-30-45m3-h-cav', $post->slug); @@ -485,7 +486,7 @@ public function testSubscriptCharacters(): void public function testFalsyString(): void { $post = Post::create([ - 'title' => '0' + 'title' => '0', ]); self::assertEquals('0', $post->slug); } @@ -496,7 +497,7 @@ public function testFalsyString(): void public function testFalsyInt(): void { $post = Post::create([ - 'title' => 0 + 'title' => 0, ]); self::assertEquals('0', $post->slug); } @@ -507,7 +508,7 @@ public function testFalsyInt(): void public function testTrueSource(): void { $post = Post::create([ - 'title' => true + 'title' => true, ]); self::assertEquals('1', $post->slug); } @@ -518,7 +519,7 @@ public function testTrueSource(): void public function testFalseSource(): void { $post = Post::create([ - 'title' => false + 'title' => false, ]); self::assertEquals('0', $post->slug); } @@ -530,7 +531,7 @@ public function testFalseSource(): void public function testIssue527(): void { $post = Post::create([ - 'title' => 'example title' + 'title' => 'example title', ]); self::assertEquals('example-title', $post->slug); @@ -551,12 +552,12 @@ public function testIssue527(): void public function testPrimaryKeyInSource(): void { $post = PostWithIdSourceOnSaved::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('my-first-post-1', $post->slug); $post2 = PostWithIdSourceOnSaved::create([ - 'title' => 'My Second Post' + 'title' => 'My Second Post', ]); self::assertEquals('my-second-post-2', $post2->slug); @@ -587,7 +588,7 @@ public function testOnSavedPersistsSlug() public function testPrimaryKeyInSourceOnSaving(): void { $post = PostWithIdSource::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('my-first-post', $post->slug); @@ -603,8 +604,8 @@ public function testPrimaryKeyInSourceOnSaving(): void public function testCustomMethodArrayCall(): void { $post = PostWithCustomMethodArrayCall::create([ - 'title' => 'A Post Title', - 'subtitle' => 'A Subtitle' + 'title' => 'A Post Title', + 'subtitle' => 'A Subtitle', ]); self::assertEquals('eltit-tsop-a', $post->slug); } diff --git a/tests/EventTests.php b/tests/EventTests.php index 4862128..766d8f3 100644 --- a/tests/EventTests.php +++ b/tests/EventTests.php @@ -1,4 +1,6 @@ - 'My Test Post' + 'title' => 'My Test Post', ]); Event::assertDispatched('eloquent.slugging: ' . Post::class); @@ -43,7 +44,7 @@ public function testDoNotCancelSluggingEventWhenItReturnsAnythingOtherThanFalse( $this->app['events']->listen('eloquent.slugging: ' . Post::class, DoNotAbortSlugging::class); $post = Post::create([ - 'title' => 'My Test Post' + 'title' => 'My Test Post', ]); self::assertEquals('my-test-post', $post->slug); @@ -59,7 +60,7 @@ public function testCancelSluggingEvent(): void $this->app['events']->listen('eloquent.slugging: ' . Post::class, AbortSlugging::class); $post = Post::create([ - 'title' => 'My Test Post' + 'title' => 'My Test Post', ]); self::assertEquals(null, $post->slug); diff --git a/tests/Listeners/AbortSlugging.php b/tests/Listeners/AbortSlugging.php index ab52509..ed5a321 100644 --- a/tests/Listeners/AbortSlugging.php +++ b/tests/Listeners/AbortSlugging.php @@ -1,20 +1,14 @@ - [ - 'source' => 'title' - ] + 'source' => 'title', + ], ]; } } diff --git a/tests/Models/PostNotSluggable.php b/tests/Models/PostNotSluggable.php index 9bcff5d..91b4998 100644 --- a/tests/Models/PostNotSluggable.php +++ b/tests/Models/PostNotSluggable.php @@ -1,36 +1,35 @@ - [ 'source' => 'title', - 'method' => [ static::class, 'makeSlug' ] - ] + 'method' => [static::class, 'makeSlug'], + ], ]; } - public static function makeSlug($string, $separator) { + public static function makeSlug($string, $separator) + { return strrev(Str::slug($string, $separator)); } } diff --git a/tests/Models/PostWithCustomEngine.php b/tests/Models/PostWithCustomEngine.php index 4e7b561..6d134de 100644 --- a/tests/Models/PostWithCustomEngine.php +++ b/tests/Models/PostWithCustomEngine.php @@ -1,23 +1,16 @@ -addRule('e', 'a'); diff --git a/tests/Models/PostWithCustomEngine2.php b/tests/Models/PostWithCustomEngine2.php index 8da8c35..496e26c 100644 --- a/tests/Models/PostWithCustomEngine2.php +++ b/tests/Models/PostWithCustomEngine2.php @@ -1,25 +1,18 @@ -'|[^A-Za-z0-9/]+|']); + return new Slugify(['regexp' => '|[^A-Za-z0-9/]+|']); } } diff --git a/tests/Models/PostWithCustomEngineOptions.php b/tests/Models/PostWithCustomEngineOptions.php index 7d08f36..fd93ec8 100644 --- a/tests/Models/PostWithCustomEngineOptions.php +++ b/tests/Models/PostWithCustomEngineOptions.php @@ -1,30 +1,26 @@ - [ - 'source' => 'title', + 'source' => 'title', 'slugEngineOptions' => [ - 'lowercase' => false - ] - ] + 'lowercase' => false, + ], + ], ]; } - } diff --git a/tests/Models/PostWithCustomMethod.php b/tests/Models/PostWithCustomMethod.php index 24d42b2..62c39e6 100644 --- a/tests/Models/PostWithCustomMethod.php +++ b/tests/Models/PostWithCustomMethod.php @@ -1,20 +1,16 @@ - 'title', 'method' => function ($string, $separator) { return strrev(Str::slug($string, $separator)); - } - ] + }, + ], ]; } } diff --git a/tests/Models/PostWithCustomMethodArrayCall.php b/tests/Models/PostWithCustomMethodArrayCall.php index f77532b..4b637c3 100644 --- a/tests/Models/PostWithCustomMethodArrayCall.php +++ b/tests/Models/PostWithCustomMethodArrayCall.php @@ -8,16 +8,14 @@ class PostWithCustomMethodArrayCall extends Post { /** * Return the sluggable configuration array for this model. - * - * @return array */ public function sluggable(): array { return [ 'slug' => [ 'source' => 'title', - 'method' => [SluggableCustomMethod::class, 'slug'] - ] + 'method' => [SluggableCustomMethod::class, 'slug'], + ], ]; } } diff --git a/tests/Models/PostWithCustomSeparator.php b/tests/Models/PostWithCustomSeparator.php index 7594980..98e6eeb 100644 --- a/tests/Models/PostWithCustomSeparator.php +++ b/tests/Models/PostWithCustomSeparator.php @@ -1,27 +1,24 @@ - [ - 'source' => 'title', - 'separator' => '.' - ] + 'source' => 'title', + 'separator' => '.', + ], ]; } } diff --git a/tests/Models/PostWithCustomSource.php b/tests/Models/PostWithCustomSource.php index aaf06a0..ea8b09d 100644 --- a/tests/Models/PostWithCustomSource.php +++ b/tests/Models/PostWithCustomSource.php @@ -1,26 +1,23 @@ - [ - 'source' => 'subtitle' - ] + 'source' => 'subtitle', + ], ]; } } diff --git a/tests/Models/PostWithCustomSuffix.php b/tests/Models/PostWithCustomSuffix.php index d96b72d..9c3e524 100644 --- a/tests/Models/PostWithCustomSuffix.php +++ b/tests/Models/PostWithCustomSuffix.php @@ -1,34 +1,30 @@ - [ - 'source' => 'title', + 'source' => 'title', 'uniqueSuffix' => function ($slug, $separator, Collection $list) { $size = count($list); return chr($size + 96); - } - ] + }, + ], ]; } } diff --git a/tests/Models/PostWithEagerRelation.php b/tests/Models/PostWithEagerRelation.php index 959d3dc..752b9de 100644 --- a/tests/Models/PostWithEagerRelation.php +++ b/tests/Models/PostWithEagerRelation.php @@ -1,14 +1,11 @@ - [ - 'source' => 'title', + 'source' => 'title', 'separator' => '', - ] + ], ]; } } diff --git a/tests/Models/PostWithFirstUniqueSuffix.php b/tests/Models/PostWithFirstUniqueSuffix.php index 6620ddd..93277c4 100644 --- a/tests/Models/PostWithFirstUniqueSuffix.php +++ b/tests/Models/PostWithFirstUniqueSuffix.php @@ -1,25 +1,22 @@ - [ - 'source' => 'title', + 'source' => 'title', 'firstUniqueSuffix' => '42', - ] + ], ]; } } diff --git a/tests/Models/PostWithForeignRuleset.php b/tests/Models/PostWithForeignRuleset.php index 77a9da2..5769599 100644 --- a/tests/Models/PostWithForeignRuleset.php +++ b/tests/Models/PostWithForeignRuleset.php @@ -1,19 +1,18 @@ - [ - 'source' => 'title', + 'source' => 'title', 'slugEngineOptions' => [ - 'ruleset' => 'finnish' + 'ruleset' => 'finnish', ], ], ]; diff --git a/tests/Models/PostWithIdSource.php b/tests/Models/PostWithIdSource.php index fb5afca..6babd36 100644 --- a/tests/Models/PostWithIdSource.php +++ b/tests/Models/PostWithIdSource.php @@ -1,25 +1,22 @@ - [ - 'source' => ['title','id'], + 'source' => ['title', 'id'], 'onUpdate' => true, ], ]; diff --git a/tests/Models/PostWithIdSourceOnSaved.php b/tests/Models/PostWithIdSourceOnSaved.php index 01f65ed..7c3bd75 100644 --- a/tests/Models/PostWithIdSourceOnSaved.php +++ b/tests/Models/PostWithIdSourceOnSaved.php @@ -1,20 +1,19 @@ - [ - 'source' => ['title','id'], + 'source' => ['title', 'id'], 'onUpdate' => true, ], ]; diff --git a/tests/Models/PostWithIncludeTrashed.php b/tests/Models/PostWithIncludeTrashed.php index a57eebd..05110c0 100644 --- a/tests/Models/PostWithIncludeTrashed.php +++ b/tests/Models/PostWithIncludeTrashed.php @@ -1,23 +1,22 @@ - [ - 'source' => 'title', - 'includeTrashed' => true - ] + 'source' => 'title', + 'includeTrashed' => true, + ], ]; } } diff --git a/tests/Models/PostWithMaxLength.php b/tests/Models/PostWithMaxLength.php index 72b0cf0..efab612 100644 --- a/tests/Models/PostWithMaxLength.php +++ b/tests/Models/PostWithMaxLength.php @@ -1,25 +1,22 @@ - [ - 'source' => 'title', + 'source' => 'title', 'maxLength' => 10, - ] + ], ]; } } diff --git a/tests/Models/PostWithMaxLengthSplitWords.php b/tests/Models/PostWithMaxLengthSplitWords.php index c76f549..aeefa0e 100644 --- a/tests/Models/PostWithMaxLengthSplitWords.php +++ b/tests/Models/PostWithMaxLengthSplitWords.php @@ -1,24 +1,21 @@ - [ - 'source' => 'title', - 'maxLength' => 10, + 'source' => 'title', + 'maxLength' => 10, 'maxLengthKeepWords' => false, ], ]; diff --git a/tests/Models/PostWithMultipleSlugs.php b/tests/Models/PostWithMultipleSlugs.php index 04dd16a..8e82c5c 100644 --- a/tests/Models/PostWithMultipleSlugs.php +++ b/tests/Models/PostWithMultipleSlugs.php @@ -1,17 +1,14 @@ - 'title', ], 'dummy' => [ - 'source' => 'subtitle', + 'source' => 'subtitle', 'separator' => '.', ], ]; diff --git a/tests/Models/PostWithMultipleSlugsAndCustomSlugKey.php b/tests/Models/PostWithMultipleSlugsAndCustomSlugKey.php index 55d5ad2..b3eb763 100644 --- a/tests/Models/PostWithMultipleSlugsAndCustomSlugKey.php +++ b/tests/Models/PostWithMultipleSlugsAndCustomSlugKey.php @@ -1,13 +1,11 @@ - [ 'source' => ['title', 'subtitle'], - ] + ], ]; } } diff --git a/tests/Models/PostWithNoSource.php b/tests/Models/PostWithNoSource.php index ece5f1c..53ec8ac 100644 --- a/tests/Models/PostWithNoSource.php +++ b/tests/Models/PostWithNoSource.php @@ -1,26 +1,23 @@ - [ - 'source' => null - ] + 'source' => null, + ], ]; } } diff --git a/tests/Models/PostWithOnUpdate.php b/tests/Models/PostWithOnUpdate.php index a60a86e..fe5ef31 100644 --- a/tests/Models/PostWithOnUpdate.php +++ b/tests/Models/PostWithOnUpdate.php @@ -1,27 +1,24 @@ - [ - 'source' => 'title', - 'onUpdate' => true - ] + 'source' => 'title', + 'onUpdate' => true, + ], ]; } } diff --git a/tests/Models/PostWithRelation.php b/tests/Models/PostWithRelation.php index e1c4b6e..95e1046 100644 --- a/tests/Models/PostWithRelation.php +++ b/tests/Models/PostWithRelation.php @@ -1,37 +1,32 @@ - [ 'source' => ['author.name', 'title'], - ] + ], ]; } /** * Relation to Author model. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function author(): BelongsTo { diff --git a/tests/Models/PostWithReservedSlug.php b/tests/Models/PostWithReservedSlug.php index 76727f4..8a11e31 100644 --- a/tests/Models/PostWithReservedSlug.php +++ b/tests/Models/PostWithReservedSlug.php @@ -1,27 +1,24 @@ - [ - 'source' => 'title', - 'reserved' => ['add','add-1'] - ] + 'source' => 'title', + 'reserved' => ['add', 'add-1'], + ], ]; } } diff --git a/tests/Models/PostWithSoftDeleting.php b/tests/Models/PostWithSoftDeleting.php index bc90c36..128c687 100644 --- a/tests/Models/PostWithSoftDeleting.php +++ b/tests/Models/PostWithSoftDeleting.php @@ -1,16 +1,15 @@ - [ - 'source' => 'title', - 'includeTrashed' => true - ] + 'source' => 'title', + 'includeTrashed' => true, + ], ]; } } diff --git a/tests/Models/PostWithUniqueSlugConstraints.php b/tests/Models/PostWithUniqueSlugConstraints.php index d43fbcd..96f4af8 100644 --- a/tests/Models/PostWithUniqueSlugConstraints.php +++ b/tests/Models/PostWithUniqueSlugConstraints.php @@ -1,23 +1,20 @@ -where('author_id', $author->getKey()); } - } diff --git a/tests/OnUpdateTests.php b/tests/OnUpdateTests.php index 33c4aa3..a15cfcb 100644 --- a/tests/OnUpdateTests.php +++ b/tests/OnUpdateTests.php @@ -1,29 +1,30 @@ - 'My First Post' + 'title' => 'My First Post', ]); $post->save(); self::assertEquals('my-first-post', $post->slug); $post->update([ - 'title' => 'A New Title' + 'title' => 'A New Title', ]); self::assertEquals('my-first-post', $post->slug); } @@ -34,14 +35,14 @@ public function testSlugDoesntChangeWithoutOnUpdate(): void public function testSlugDoesChangeWhenEmptiedManually(): void { $post = Post::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); $post->save(); self::assertEquals('my-first-post', $post->slug); $post->slug = null; $post->update([ - 'title' => 'A New Title' + 'title' => 'A New Title', ]); self::assertEquals('a-new-title', $post->slug); } @@ -52,13 +53,13 @@ public function testSlugDoesChangeWhenEmptiedManually(): void public function testSlugDoesChangeWithOnUpdate(): void { $post = PostWithOnUpdate::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); $post->save(); self::assertEquals('my-first-post', $post->slug); $post->update([ - 'title' => 'A New Title' + 'title' => 'A New Title', ]); self::assertEquals('a-new-title', $post->slug); } @@ -70,13 +71,13 @@ public function testSlugDoesChangeWithOnUpdate(): void public function testSlugDoesNotChangeIfSourceDoesNotChange(): void { $post = PostWithOnUpdate::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); $post->save(); self::assertEquals('my-first-post', $post->slug); $post->update([ - 'subtitle' => 'A Subtitle' + 'subtitle' => 'A Subtitle', ]); self::assertEquals('my-first-post', $post->slug); } @@ -91,7 +92,7 @@ public function testSlugDoesNotChangeIfSourceDoesNotChange(): void public function testSlugDoesNotChangeIfSourceDoesNotChangeMultiple(): void { $data = [ - 'title' => 'My First Post' + 'title' => 'My First Post', ]; $post1 = PostWithOnUpdate::create($data); $post2 = PostWithOnUpdate::create($data); @@ -100,7 +101,7 @@ public function testSlugDoesNotChangeIfSourceDoesNotChangeMultiple(): void self::assertEquals('my-first-post-4', $post4->slug); $post4->update([ - 'subtitle' => 'A Subtitle' + 'subtitle' => 'A Subtitle', ]); self::assertEquals('my-first-post-4', $post4->slug); } @@ -112,13 +113,13 @@ public function testSlugDoesNotChangeIfSourceDoesNotChangeMultiple(): void public function testSlugDoesNotChangeIfSourceNotProvidedInModel(): void { $post = Post::create([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); self::assertEquals('my-first-post', $post->slug); - $post = Post::whereKey($post->id)->first(['id','subtitle']); + $post = Post::whereKey($post->id)->first(['id', 'subtitle']); $post->update([ - 'subtitle' => 'A Subtitle' + 'subtitle' => 'A Subtitle', ]); $post = Post::findOrFail($post->id); diff --git a/tests/RelationTests.php b/tests/RelationTests.php index 8735301..e10105b 100644 --- a/tests/RelationTests.php +++ b/tests/RelationTests.php @@ -1,17 +1,18 @@ - 'Arthur Conan Doyle' + 'name' => 'Arthur Conan Doyle', ]); $post = new PostWithEagerRelation([ - 'title' => 'My First Post' + 'title' => 'My First Post', ]); $post->author()->associate($author); $post->save(); @@ -37,5 +38,4 @@ public function testEagerLoading(): void $post2->save(); self::assertEquals('arthur-conan-doyle-my-second-post', $post2->slug); } - } diff --git a/tests/ScopeHelperTests.php b/tests/ScopeHelperTests.php index 8f16de2..153267d 100644 --- a/tests/ScopeHelperTests.php +++ b/tests/ScopeHelperTests.php @@ -1,4 +1,6 @@ -slugKeyName when set. */ public function testSlugKeyNameProperty(): void { - $post = PostWithMultipleSlugsAndCustomSlugKey::create([ - 'title' => 'A Post Title', - 'subtitle' => 'A Post Subtitle' + 'title' => 'A Post Title', + 'subtitle' => 'A Post Subtitle', ]); self::assertEquals('dummy', $post->getSlugKeyName()); @@ -35,7 +35,7 @@ public function testSlugKeyNameProperty(): void public function testFirstSlugAsFallback(): void { $post = PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('slug', $post->getSlugKeyName()); @@ -47,21 +47,22 @@ public function testFirstSlugAsFallback(): void */ public function testQueryScope(): void { - PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title A' + 'title' => 'A Post Title A', ]); $post = PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title B' + 'title' => 'A Post Title B', ]); PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title C' + 'title' => 'A Post Title C', ]); - self::assertEquals($post->getKey(), - PostWithMultipleSlugsAndHelperTrait::whereSlug('a-post-title-b')->first()->getKey()); + self::assertEquals( + $post->getKey(), + PostWithMultipleSlugsAndHelperTrait::whereSlug('a-post-title-b')->first()->getKey() + ); } /** @@ -69,21 +70,22 @@ public function testQueryScope(): void */ public function testFindBySlug(): void { - PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title A' + 'title' => 'A Post Title A', ]); $post = PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title B' + 'title' => 'A Post Title B', ]); PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title C' + 'title' => 'A Post Title C', ]); - self::assertEquals($post->getKey(), - PostWithMultipleSlugsAndHelperTrait::findBySlug('a-post-title-b')->getKey()); + self::assertEquals( + $post->getKey(), + PostWithMultipleSlugsAndHelperTrait::findBySlug('a-post-title-b')->getKey() + ); } /** @@ -100,19 +102,21 @@ public function testFindBySlugReturnsNullForNoRecord(): void public function testFindBySlugOrFail(): void { PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title A' + 'title' => 'A Post Title A', ]); $post = PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title B' + 'title' => 'A Post Title B', ]); PostWithMultipleSlugsAndHelperTrait::create([ - 'title' => 'A Post Title C' + 'title' => 'A Post Title C', ]); - self::assertEquals($post->getKey(), - PostWithMultipleSlugsAndHelperTrait::findBySlugOrFail('a-post-title-b')->getKey()); + self::assertEquals( + $post->getKey(), + PostWithMultipleSlugsAndHelperTrait::findBySlugOrFail('a-post-title-b')->getKey() + ); $this->expectException(ModelNotFoundException::class); diff --git a/tests/SoftDeleteTests.php b/tests/SoftDeleteTests.php index 1369a87..2d144c1 100644 --- a/tests/SoftDeleteTests.php +++ b/tests/SoftDeleteTests.php @@ -1,31 +1,32 @@ - 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title', $post1->slug); $post1->delete(); $post2 = PostWithSoftDeleting::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title', $post2->slug); } @@ -36,14 +37,14 @@ public function testSoftDeletesWithoutTrashed(): void public function testSoftDeletesWithTrashed(): void { $post1 = PostWithSoftDeletingIncludeTrashed::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title', $post1->slug); $post1->delete(); $post2 = PostWithSoftDeletingIncludeTrashed::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title-2', $post2->slug); } @@ -54,7 +55,7 @@ public function testSoftDeletesWithTrashed(): void public function testSoftDeletesWithNonSoftDeleteModel(): void { $post1 = PostWithIncludeTrashed::create([ - 'title' => 'A Post Title' + 'title' => 'A Post Title', ]); self::assertEquals('a-post-title', $post1->slug); } diff --git a/tests/StaticTests.php b/tests/StaticTests.php index 59ef1d2..eec23c8 100644 --- a/tests/StaticTests.php +++ b/tests/StaticTests.php @@ -1,16 +1,17 @@ - '.' + 'separator' => '.', ]; $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post', $config); self::assertEquals('my.test.post', $slug); } /** - * Test passing an invalid attribute to static method + * Test passing an invalid attribute to static method. */ public function testStaticSlugWithInvalidAttribute(): void { diff --git a/tests/TestCase.php b/tests/TestCase.php index 35e66d2..0a18bc8 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,22 +1,18 @@ -set('database.default', 'testbench'); $app['config']->set('database.connections.testbench', [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => '', + 'prefix' => '', ]); } /** - * @inheritDoc + * {@inheritDoc} */ protected function getPackageProviders($app) { return [ ServiceProvider::class, - TestServiceProvider::class + TestServiceProvider::class, ]; } @@ -61,7 +57,7 @@ protected function getPackageProviders($app) */ protected function withoutEvents(): self { - $mock = Mockery::mock(Dispatcher::class); + $mock = \Mockery::mock(Dispatcher::class); $mock->shouldReceive('fire', 'until'); diff --git a/tests/TestServiceProvider.php b/tests/TestServiceProvider.php index 39c0601..b49d97e 100644 --- a/tests/TestServiceProvider.php +++ b/tests/TestServiceProvider.php @@ -1,15 +1,14 @@ - 'A post title' + 'title' => 'A post title', ]); if ($i === 1) { self::assertEquals('a-post-title', $post->slug); @@ -36,19 +37,19 @@ public function testUnique(): void public function testUniqueAfterDelete(): void { $post1 = Post::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title', $post1->slug); $post2 = Post::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title-2', $post2->slug); $post1->delete(); $post3 = Post::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title', $post3->slug); } @@ -93,28 +94,28 @@ public function testCustomUniqueQueryScope(): void public function testIssue431(): void { $post1 = Post::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title', $post1->slug); - $post2 = new Post; + $post2 = new Post(); $post2->title = 'A post title'; $post2->save(); self::assertEquals('a-post-title-2', $post2->slug); } /** - * Test custom firstUniqueSuffix configuration + * Test custom firstUniqueSuffix configuration. */ public function testFirstUniqueSuffix(): void { $post1 = PostWithFirstUniqueSuffix::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title', $post1->slug); $post2 = PostWithFirstUniqueSuffix::create([ - 'title' => 'A post title' + 'title' => 'A post title', ]); self::assertEquals('a-post-title-42', $post2->slug); } diff --git a/tests/database/migrations/2013_11_04_163552_posts.php b/tests/database/migrations/2013_11_04_163552_posts.php index 4760c2c..e46ee55 100644 --- a/tests/database/migrations/2013_11_04_163552_posts.php +++ b/tests/database/migrations/2013_11_04_163552_posts.php @@ -4,17 +4,13 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; - /** - * Class Posts + * Class Posts. */ class Posts extends Migration { - /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -31,12 +27,9 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void { Schema::drop('posts'); } - } diff --git a/tests/database/migrations/2015_08_17_185144_authors.php b/tests/database/migrations/2015_08_17_185144_authors.php index 3332e50..17cf98b 100644 --- a/tests/database/migrations/2015_08_17_185144_authors.php +++ b/tests/database/migrations/2015_08_17_185144_authors.php @@ -4,17 +4,13 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; - /** - * Class Authors + * Class Authors. */ class Authors extends Migration { - /** * Run the migrations. - * - * @return void */ public function up(): void { @@ -26,8 +22,6 @@ public function up(): void /** * Reverse the migrations. - * - * @return void */ public function down(): void {