From 4c7385d3db7c6f299f0ac157e84a2cfc59560ea2 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Tue, 13 Dec 2016 15:51:48 +0000 Subject: [PATCH 1/2] Adopt PSR-2 coding style The Laravel framework adopts the PSR-2 coding style in version 5.1. Laravel apps *should* adopt this coding style as well. Read the [PSR-2 coding style guide][1] for more details and check out [PHPCS][2] to use as a code formatting tool. [1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md [2]: https://github.com/squizlabs/PHP_CodeSniffer --- config/kurt_modules.php | 2 +- src/Console/Commands/SeedCommand.php | 5 +-- src/Http/Controllers/BlogController.php | 5 ++- src/Http/blogRoutes.php | 1 - src/Models/Comment.php | 10 ++--- src/Models/Model.php | 6 +-- src/Models/Post.php | 38 +++++++++---------- src/Models/Tag.php | 1 - src/Providers/BlogServiceProvider.php | 6 +-- .../Contracts/TagsRepositoryInterface.php | 1 - 10 files changed, 36 insertions(+), 39 deletions(-) diff --git a/config/kurt_modules.php b/config/kurt_modules.php index 229503b..6b8f805 100644 --- a/config/kurt_modules.php +++ b/config/kurt_modules.php @@ -43,7 +43,7 @@ 'vimeo' => 'default', /** - * `0`, `1`, `2`, `3`, `default`, `hqdefault`, `mqdefault`, `sddefault`, `maxresdefault`, + * `0`, `1`, `2`, `3`, `default`, `hqdefault`, `mqdefault`, `sddefault`, `maxresdefault`, */ 'youtube' => 'default', ], diff --git a/src/Console/Commands/SeedCommand.php b/src/Console/Commands/SeedCommand.php index 3b84260..8a147ac 100644 --- a/src/Console/Commands/SeedCommand.php +++ b/src/Console/Commands/SeedCommand.php @@ -29,7 +29,7 @@ class SeedCommand extends Command /** * Default configuration for seeding. - * + * * @var array */ protected $settings = [ @@ -44,8 +44,7 @@ class SeedCommand extends Command */ public function handle() { - if ($this->getUserModel()->count() == 0) - { + if ($this->getUserModel()->count() == 0) { $this->info("There is no user in the database, cannot seed."); $createUsers = $this->ask('Do you want to create some users? (y/N)'); diff --git a/src/Http/Controllers/BlogController.php b/src/Http/Controllers/BlogController.php index cb479ae..51a7a23 100644 --- a/src/Http/Controllers/BlogController.php +++ b/src/Http/Controllers/BlogController.php @@ -10,7 +10,7 @@ /** * Class BlogController - * + * * @package Kurt\Modules\Blog\Http\Controllers */ class BlogController extends Controller @@ -22,7 +22,8 @@ class BlogController extends Controller /** * Ready up blog repositories. */ - public function __construct() { + public function __construct() + { $this->blogCategoriesRepository = app(CategoriesRepositoryInterface::class); $this->blogPostsRepository = app(PostsRepositoryInterface::class); $this->blogTagsRepository = app(TagsRepositoryInterface::class); diff --git a/src/Http/blogRoutes.php b/src/Http/blogRoutes.php index 4ceb069..7daed6c 100644 --- a/src/Http/blogRoutes.php +++ b/src/Http/blogRoutes.php @@ -8,5 +8,4 @@ Route::get('welcome', function () { return 'Welcome!'; }); - }); diff --git a/src/Models/Comment.php b/src/Models/Comment.php index d643009..59bf712 100644 --- a/src/Models/Comment.php +++ b/src/Models/Comment.php @@ -57,7 +57,7 @@ class Comment extends Model /** * Casts columns to requested types. - * + * * @var array */ protected $casts = [ @@ -78,7 +78,7 @@ public static function boot() /** * Overwrite parents create to set a default approval state. - * + * * @param static */ public static function create(array $attributes = []) @@ -116,7 +116,7 @@ public function user() /** * Get is the comment is approved. - * + * * @return boolean */ public function isApproved() @@ -126,7 +126,7 @@ public function isApproved() /** * Update the comment as approved in the database. - * + * * @return $this */ public function approve($state = true) @@ -140,7 +140,7 @@ public function approve($state = true) /** * Update the comment as disapproved in the database. - * + * * @return $this */ public function disapprove() diff --git a/src/Models/Model.php b/src/Models/Model.php index 6d2f6cf..8896d79 100644 --- a/src/Models/Model.php +++ b/src/Models/Model.php @@ -4,7 +4,8 @@ use Illuminate\Database\Eloquent\Model as Eloquent; -class Model extends Eloquent { +class Model extends Eloquent +{ private $defaultModels = [ 'category' => Category::class, @@ -25,5 +26,4 @@ protected function getModel($modelKey) return $customModelClass; } - -} \ No newline at end of file +} diff --git a/src/Models/Post.php b/src/Models/Post.php index 7b9035e..5d6d9e0 100644 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -253,10 +253,10 @@ public function getTagsCountAttribute($value) /** * Popularity by view count. - * + * * @param [type] $query [description] * @param boolean $descending [description] - * + * * @return [type] [description] */ public function scopePopular($query, $descending = true) @@ -266,10 +266,10 @@ public function scopePopular($query, $descending = true) /** * [scopeInCategory description] - * + * * @param [type] $query [description] * @param [type] $categoryId [description] - * + * * @return [type] [description] */ public function scopeInCategory($query, $categoryId) @@ -279,11 +279,11 @@ public function scopeInCategory($query, $categoryId) /** * [scopeWithTags description] - * + * * @param [type] $query [description] * @param array $tagIds Tag id's * @param boolean $and If `true` posts should have all the given tags - * + * * @return [type] [description] */ public function scopeWithTags($query, $tagIds = [], $and = false) @@ -302,9 +302,9 @@ public function scopeWithTags($query, $tagIds = [], $and = false) /** * Determine if the posts media type is equal to the given type. - * + * * @param int $type One of the constants from this class. - * + * * @return boolean */ public function isMediaType($type) @@ -313,10 +313,10 @@ public function isMediaType($type) } /** - * Get the media value in a better and fitting type. - * + * Get the media value in a better and fitting type. + * * @param string $value - * + * * @return mixed */ public function getMediaAttribute($value) @@ -341,8 +341,8 @@ public function getMediaAttribute($value) } /** - * Set the media value in a better and fitting type. - * + * Set the media value in a better and fitting type. + * * @param mixed $value */ public function setMediaAttribute($value) @@ -370,7 +370,7 @@ public function setMediaAttribute($value) /** * Get the thumbnail image path of the post. - * + * * @return string|null */ public function getThumbnailAttribute() @@ -398,7 +398,7 @@ public function getThumbnailAttribute() /** * Get the thumbnail of youtube video. - * + * * @return string|null Thumbnail URL. */ public function getVideoTypeAttribute() @@ -418,7 +418,7 @@ public function getVideoTypeAttribute() /** * Get the video id of the post. - * + * * @return string */ public function getVideoIdAttribute() @@ -441,7 +441,7 @@ public function getVideoIdAttribute() /** * Get the video thumbnail of the post. - * + * * @return string */ private function getVideoThumbnail() @@ -470,7 +470,7 @@ private function getVideoThumbnail() /** * Get video location url. - * + * * @return string Url of the video. */ public function getVideoLocationAttribute() @@ -493,7 +493,7 @@ public function getVideoLocationAttribute() /** * Get the html to embed the video. - * + * * @return string */ public function getVideoEmbedAttribute() diff --git a/src/Models/Tag.php b/src/Models/Tag.php index 175582e..f5c5c63 100644 --- a/src/Models/Tag.php +++ b/src/Models/Tag.php @@ -124,5 +124,4 @@ public function latestPost() { return $this->posts()->latest()->first(); } - } diff --git a/src/Providers/BlogServiceProvider.php b/src/Providers/BlogServiceProvider.php index a9a1497..8886c4e 100644 --- a/src/Providers/BlogServiceProvider.php +++ b/src/Providers/BlogServiceProvider.php @@ -118,7 +118,7 @@ private function publishVendor() */ private function registerRepositories() { - $this->app->bind(CategoriesRepositoryInterface::class, function() { + $this->app->bind(CategoriesRepositoryInterface::class, function () { return $this->instantiateCategoriesRepository(); }); $this->app->bind(PostsRepositoryInterface::class, EloquentPostsRepository::class); @@ -150,7 +150,7 @@ private function registerFactories() { $factory = $this->app->make(Factory::class); - $factory->define(Category::class, function(Faker $faker) { + $factory->define(Category::class, function (Faker $faker) { $name = $faker->colorName; return [ 'name' => $name, @@ -158,7 +158,7 @@ private function registerFactories() ]; }); - $factory->define(Post::class, function(Faker $faker) { + $factory->define(Post::class, function (Faker $faker) { $userIds = $this->getUserModel()->lists('id')->toArray(); $categoryIds = Category::lists('id')->toArray(); diff --git a/src/Repositories/Contracts/TagsRepositoryInterface.php b/src/Repositories/Contracts/TagsRepositoryInterface.php index 6e2bad1..b9e24d7 100644 --- a/src/Repositories/Contracts/TagsRepositoryInterface.php +++ b/src/Repositories/Contracts/TagsRepositoryInterface.php @@ -20,5 +20,4 @@ public function getAllWithPosts(); public function paginateAll($postsPerPage); public function paginateAllWithPosts($postsPerPage); - } From e92fb77a30ff553e2b0d1119ec72fa0cc0d10f49 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Tue, 13 Dec 2016 15:51:48 +0000 Subject: [PATCH 2/2] Adopt PHP short array syntax Laravel 5 adopted the short array syntax which became available in PHP 5.4. --- src/Providers/BlogServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/BlogServiceProvider.php b/src/Providers/BlogServiceProvider.php index 8886c4e..ea4daaf 100644 --- a/src/Providers/BlogServiceProvider.php +++ b/src/Providers/BlogServiceProvider.php @@ -304,6 +304,6 @@ private function routesArePublished($blogRoutesPath) */ public function provides() { - return array('command.ide-helper.generate', 'command.ide-helper.models'); + return ['command.ide-helper.generate', 'command.ide-helper.models']; } }