Fix coding standards to conform to PSR-2

This commit is contained in:
Franz Liedke 2015-05-19 01:03:12 +02:00
parent dcd67b9d5c
commit 0ca4e1ab7b
22 changed files with 239 additions and 242 deletions

View File

@ -4,8 +4,8 @@ use Flarum\Api\JsonApiRequest;
trait GetsPosts trait GetsPosts
{ {
protected function getPosts(JsonApiRequest $request, array $where) protected function getPosts(JsonApiRequest $request, array $where)
{ {
$user = $request->actor->getUser(); $user = $request->actor->getUser();
if (isset($where['discussion_id']) && ($near = $request->get('near')) > 1) { if (isset($where['discussion_id']) && ($near = $request->get('near')) > 1) {
@ -22,5 +22,5 @@ trait GetsPosts
$request->limit, $request->limit,
$offset $offset
); );
} }
} }

View File

@ -17,6 +17,5 @@ class ConsoleServiceProvider extends ServiceProvider
public function register() public function register()
{ {
} }
} }

View File

@ -5,41 +5,42 @@ use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
class InstallCommand extends Command { class InstallCommand extends Command
{
/** /**
* The console command name. * The console command name.
* *
* @var string * @var string
*/ */
protected $name = 'flarum:install'; protected $name = 'flarum:install';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Run Flarum\'s installation migrations and seeds.'; protected $description = 'Run Flarum\'s installation migrations and seeds.';
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void * @return void
*/ */
public function __construct(Application $app) public function __construct(Application $app)
{ {
parent::__construct(); parent::__construct();
$this->app = $app; $this->app = $app;
} }
/** /**
* Execute the console command. * Execute the console command.
* *
* @return mixed * @return mixed
*/ */
public function fire() public function fire()
{ {
$path = str_replace($this->laravel['path.base'].'/', '', __DIR__.'/../../migrations'); $path = str_replace($this->laravel['path.base'].'/', '', __DIR__.'/../../migrations');
$this->call('migrate', ['--path' => $path]); $this->call('migrate', ['--path' => $path]);
@ -50,30 +51,29 @@ class InstallCommand extends Command {
// Create config file so that we know Flarum is installed // Create config file so that we know Flarum is installed
copy(base_path('../config.example.php'), base_path('../config.php')); copy(base_path('../config.example.php'), base_path('../config.php'));
} }
/** /**
* Get the console command arguments. * Get the console command arguments.
* *
* @return array * @return array
*/ */
protected function getArguments() protected function getArguments()
{ {
return [ return [
// ['example', InputArgument::REQUIRED, 'An example argument.'], // ['example', InputArgument::REQUIRED, 'An example argument.'],
]; ];
} }
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
];
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
];
}
} }

View File

@ -5,67 +5,67 @@ use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
class SeedCommand extends Command { class SeedCommand extends Command
{
/** /**
* The console command name. * The console command name.
* *
* @var string * @var string
*/ */
protected $name = 'flarum:seed'; protected $name = 'flarum:seed';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Seed Flarum\'s database with fake data.'; protected $description = 'Seed Flarum\'s database with fake data.';
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void * @return void
*/ */
public function __construct(Application $app) public function __construct(Application $app)
{ {
parent::__construct(); parent::__construct();
$this->app = $app; $this->app = $app;
} }
/** /**
* Execute the console command. * Execute the console command.
* *
* @return mixed * @return mixed
*/ */
public function fire() public function fire()
{ {
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']); $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']);
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']); $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
} }
/** /**
* Get the console command arguments. * Get the console command arguments.
* *
* @return array * @return array
*/ */
protected function getArguments() protected function getArguments()
{ {
return [ return [
// ['example', InputArgument::REQUIRED, 'An example argument.'], // ['example', InputArgument::REQUIRED, 'An example argument.'],
]; ];
} }
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
];
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
];
}
} }

View File

@ -78,7 +78,7 @@ class CoreServiceProvider extends ServiceProvider
$this->app->when('Flarum\Core\Handlers\Commands\UploadAvatarCommandHandler') $this->app->when('Flarum\Core\Handlers\Commands\UploadAvatarCommandHandler')
->needs('League\Flysystem\FilesystemInterface') ->needs('League\Flysystem\FilesystemInterface')
->give(function(Container $app) { ->give(function (Container $app) {
return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver();
}); });
} }

View File

@ -2,5 +2,4 @@
class Extension class Extension
{ {
} }

View File

@ -2,5 +2,4 @@
class ExtensionManager class ExtensionManager
{ {
} }

View File

@ -4,35 +4,35 @@ use Illuminate\Container\Container;
class FormatterManager class FormatterManager
{ {
protected $formatters = []; protected $formatters = [];
/** /**
* The IoC container instance. * The IoC container instance.
* *
* @var \Illuminate\Container\Container * @var \Illuminate\Container\Container
*/ */
protected $container; protected $container;
/** /**
* Create a new formatter manager instance. * Create a new formatter manager instance.
* *
* @param \Illuminate\Container\Container $container * @param \Illuminate\Container\Container $container
* @return void * @return void
*/ */
public function __construct(Container $container = null) public function __construct(Container $container = null)
{ {
$this->container = $container ?: new Container; $this->container = $container ?: new Container;
} }
public function add($name, $formatter, $priority = 0) public function add($name, $formatter, $priority = 0)
{ {
$this->formatters[$name] = [$formatter, $priority]; $this->formatters[$name] = [$formatter, $priority];
} }
public function remove($name) public function remove($name)
{ {
unset($this->formatters[$name]); unset($this->formatters[$name]);
} }
protected function getFormatters() protected function getFormatters()
{ {
@ -54,14 +54,14 @@ class FormatterManager
return $result; return $result;
} }
public function format($text, $post = null) public function format($text, $post = null)
{ {
foreach ($this->getFormatters() as $formatter) { foreach ($this->getFormatters() as $formatter) {
$text = $this->container->make($formatter)->format($text, $post); $text = $this->container->make($formatter)->format($text, $post);
} }
return $text; return $text;
} }
public function strip($text) public function strip($text)
{ {

View File

@ -11,8 +11,8 @@ class LinkifyFormatter
$this->linkify = $linkify; $this->linkify = $linkify;
} }
public function format($text) public function format($text)
{ {
return $this->linkify->process($text, ['attr' => ['target' => '_blank']]); return $this->linkify->process($text, ['attr' => ['target' => '_blank']]);
} }
} }

View File

@ -46,6 +46,5 @@ class EmailConfirmationMailer
public function whenEmailWasChanged(EmailWasChanged $event) public function whenEmailWasChanged(EmailWasChanged $event)
{ {
} }
} }

View File

@ -9,22 +9,22 @@ class Guest extends User
* *
* @return \Flarum\Core\Models\Group * @return \Flarum\Core\Models\Group
*/ */
public function getGroupsAttribute() public function getGroupsAttribute()
{ {
if (! isset($this->attributes['groups'])) { if (! isset($this->attributes['groups'])) {
$this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get(); $this->attributes['groups'] = $this->relations['groups'] = Group::where('id', Group::GUEST_ID)->get();
} }
return $this->attributes['groups']; return $this->attributes['groups'];
} }
/** /**
* Check whether or not the user is a guest. * Check whether or not the user is a guest.
* *
* @return boolean * @return boolean
*/ */
public function guest() public function guest()
{ {
return true; return true;
} }
} }

View File

@ -20,7 +20,7 @@ class DiscussionSearchResults
return $this->discussions; return $this->discussions;
} }
public function getTotal() public function getTotal()
{ {
return $this->total; return $this->total;
} }

View File

@ -2,7 +2,7 @@
abstract class GambitAbstract abstract class GambitAbstract
{ {
protected $pattern; protected $pattern;
public function apply($bit, SearcherInterface $searcher) public function apply($bit, SearcherInterface $searcher)
{ {
@ -12,7 +12,7 @@ abstract class GambitAbstract
} }
} }
public function match($bit) public function match($bit)
{ {
if (preg_match('/^'.$this->pattern.'$/i', $bit, $matches)) { if (preg_match('/^'.$this->pattern.'$/i', $bit, $matches)) {
return $matches; return $matches;

View File

@ -20,14 +20,14 @@ class GambitManager
$this->gambits[] = $gambit; $this->gambits[] = $gambit;
} }
public function apply($string, $searcher) public function apply($string, $searcher)
{ {
$string = $this->applyGambits($string, $searcher); $string = $this->applyGambits($string, $searcher);
if ($string) { if ($string) {
$this->applyFulltext($string, $searcher); $this->applyFulltext($string, $searcher);
} }
} }
public function setFulltextGambit($gambit) public function setFulltextGambit($gambit)
{ {
@ -69,5 +69,4 @@ class GambitManager
$searcher->addActiveGambit($gambit); $searcher->addActiveGambit($gambit);
$gambit->apply($string, $searcher); $gambit->apply($string, $searcher);
} }
} }

View File

@ -20,7 +20,7 @@ class UserSearchResults
return $this->users; return $this->users;
} }
public function getTotal() public function getTotal()
{ {
return $this->total; return $this->total;
} }

View File

@ -3,15 +3,16 @@
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use DB; use DB;
class ConfigTableSeeder extends Seeder { class ConfigTableSeeder extends Seeder
{
/** /**
* Run the database seeds. * Run the database seeds.
* *
* @return void * @return void
*/ */
public function run() public function run()
{ {
$config = [ $config = [
'api_url' => 'http://flarum.dev/api', 'api_url' => 'http://flarum.dev/api',
'base_url' => 'http://flarum.dev', 'base_url' => 'http://flarum.dev',
@ -20,9 +21,8 @@ class ConfigTableSeeder extends Seeder {
'welcome_title' => 'Welcome to Flarum Demo Forum' 'welcome_title' => 'Welcome to Flarum Demo Forum'
]; ];
DB::table('config')->insert(array_map(function($key, $value) { DB::table('config')->insert(array_map(function ($key, $value) {
return compact('key', 'value'); return compact('key', 'value');
}, array_keys($config), $config)); }, array_keys($config), $config));
} }
} }

View File

@ -121,7 +121,6 @@ class DiscussionsTableSeeder extends Seeder
'read_time' => $faker->dateTimeBetween($discussion->start_time, 'now') 'read_time' => $faker->dateTimeBetween($discussion->start_time, 'now')
]); ]);
} catch (\Illuminate\Database\QueryException $e) { } catch (\Illuminate\Database\QueryException $e) {
} }
} }
} }

View File

@ -3,19 +3,20 @@
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Flarum\Core\Models\Group; use Flarum\Core\Models\Group;
class GroupsTableSeeder extends Seeder { class GroupsTableSeeder extends Seeder
{
/** /**
* Run the database seeds. * Run the database seeds.
* *
* @return void * @return void
*/ */
public function run() public function run()
{ {
Group::unguard(); Group::unguard();
Group::truncate(); Group::truncate();
$groups = [ $groups = [
['Admin', 'Admins', '#B72A2A', 'wrench'], ['Admin', 'Admins', '#B72A2A', 'wrench'],
['Guest', 'Guests', null, null], ['Guest', 'Guests', null, null],
['Member', 'Members', null, null], ['Member', 'Members', null, null],
@ -29,6 +30,5 @@ class GroupsTableSeeder extends Seeder {
'icon' => $group[3] 'icon' => $group[3]
]); ]);
} }
} }
} }

View File

@ -3,18 +3,19 @@
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Flarum\Core\Models\Permission; use Flarum\Core\Models\Permission;
class PermissionsTableSeeder extends Seeder { class PermissionsTableSeeder extends Seeder
{
/** /**
* Run the database seeds. * Run the database seeds.
* *
* @return void * @return void
*/ */
public function run() public function run()
{ {
Permission::truncate(); Permission::truncate();
$permissions = [ $permissions = [
// Guests can view the forum // Guests can view the forum
[2, 'forum.view'], [2, 'forum.view'],
@ -38,6 +39,5 @@ class PermissionsTableSeeder extends Seeder {
]; ];
} }
Permission::insert($permissions); Permission::insert($permissions);
} }
} }

View File

@ -6,10 +6,10 @@ use Flarum\Core\Models\User;
class UsersTableSeeder extends Seeder class UsersTableSeeder extends Seeder
{ {
/** /**
* Run the database seeds. * Run the database seeds.
* *
* @return void * @return void
*/ */
public function run() public function run()
{ {
User::unguard(); User::unguard();

View File

@ -4,40 +4,41 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class MappedMorphTo extends MorphTo { class MappedMorphTo extends MorphTo
{
/** /**
* *
* @var string * @var string
*/ */
protected $map; protected $map;
/** /**
* Create a new morph to relationship instance. * Create a new morph to relationship instance.
* *
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent * @param \Illuminate\Database\Eloquent\Model $parent
* @param string $foreignKey * @param string $foreignKey
* @param string $otherKey * @param string $otherKey
* @param string $type * @param string $type
* @param string $relation * @param string $relation
* @return void * @return void
*/ */
public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relation, $map) public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relation, $map)
{ {
$this->map = $map; $this->map = $map;
parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation); parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation);
} }
/** /**
* Create a new model instance by type. * Create a new model instance by type.
* *
* @param string $type * @param string $type
* @return \Illuminate\Database\Eloquent\Model * @return \Illuminate\Database\Eloquent\Model
*/ */
public function createModelByType($type) public function createModelByType($type)
{ {
return new $this->map[$type]; return new $this->map[$type];
} }
} }

View File

@ -14,7 +14,9 @@ class ExtensionsServiceProvider extends ServiceProvider
public function register() public function register()
{ {
// Extensions will not be registered if Flarum is not installed yet // Extensions will not be registered if Flarum is not installed yet
if (!Core::isInstalled()) return; if (!Core::isInstalled()) {
return;
}
$extensions = json_decode(DB::table('config')->where('key', 'extensions_enabled')->pluck('value'), true); $extensions = json_decode(DB::table('config')->where('key', 'extensions_enabled')->pluck('value'), true);
$providers = []; $providers = [];