Skip to content

Commit

Permalink
Use static function.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Aug 3, 2019
1 parent db72ded commit 94e0b74
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Bootstrap/LoadCurrentTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ protected function setCurrentTheme(Application $app, Theme $theme): void
// event is fired.
$theme->setTheme($memory->get('site.theme.frontend'));

$events->listen('orchestra.started: admin', function () use ($theme, $memory) {
$events->listen('orchestra.started: admin', static function () use ($theme, $memory) {
$theme->setTheme($memory->get('site.theme.backend'));
});

$events->listen('composing: *', function () use ($theme) {
$events->listen('composing: *', static function () use ($theme) {
$theme->boot();
});
}
Expand All @@ -65,7 +65,7 @@ protected function setThemeResolver(Application $app, Theme $theme): void
if ($app->resolved('view')) {
$theme->resolving();
} else {
$app->resolving('view', function () use ($theme) {
$app->resolving('view', static function () use ($theme) {
$theme->resolving();
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/CommandServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CommandServiceProvider extends ServiceProvider
*/
public function registerActivateCommand(): void
{
$this->app->singleton('orchestra.view.command.activate', function (Application $app) {
$this->app->singleton('orchestra.view.command.activate', static function (Application $app) {
return new ActivateCommand($app->make('orchestra.theme.finder'));
});
}
Expand All @@ -40,7 +40,7 @@ public function registerActivateCommand(): void
*/
public function registerDetectCommand(): void
{
$this->app->singleton('orchestra.view.command.detect', function (Application $app) {
$this->app->singleton('orchestra.view.command.detect', static function (Application $app) {
return new DetectCommand($app->make('orchestra.theme.finder'));
});
}
Expand All @@ -52,7 +52,7 @@ public function registerDetectCommand(): void
*/
public function registerOptimizeCommand(): void
{
$this->app->singleton('orchestra.view.command.optimize', function () {
$this->app->singleton('orchestra.view.command.optimize', static function () {
return new OptimizeCommand();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ActivateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function getAvailableTheme(string $type): Collection
{
$themes = $this->finder->detect();

return $themes->filter(function (Manifest $manifest) use ($type) {
return $themes->filter(static function (Manifest $manifest) use ($type) {
$group = $manifest->get('type');

if (! empty($group) && ! \in_array($type, $group)) {
Expand Down
2 changes: 1 addition & 1 deletion src/DecoratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DecoratorServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->singleton('orchestra.decorator', function () {
$this->app->singleton('orchestra.decorator', static function () {
return new Decorator();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/FileViewFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function findNamespacedView($name)
// Prepend global view paths to namespace hints path. This would
// allow theme to take priority if such view exist.

return $this->findInPaths($view, Collection::make($this->paths)->map(function ($path) use ($namespace) {
return $this->findInPaths($view, Collection::make($this->paths)->map(static function ($path) use ($namespace) {
return "{$path}/packages/{$namespace}";
})->merge($this->hints[$namespace])->all());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Theme/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function items(): Fluent
*/
protected function generateManifestConfig(array $config): array
{
return Collection::make($this->manifestOptions)->mapWithKeys(function ($default, $key) use ($config) {
return Collection::make($this->manifestOptions)->mapWithKeys(static function ($default, $key) use ($config) {
return [$key => ($config[$key] ?? $default)];
})->all();
}
Expand Down
18 changes: 10 additions & 8 deletions src/Theme/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Theme implements ThemeContract
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
protected $filesystem;

/**
* Theme filesystem path.
Expand Down Expand Up @@ -85,13 +85,13 @@ class Theme implements ThemeContract
*
* @param \Illuminate\Contracts\Container\Container $app
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Filesystem\Filesystem $filesystem
*/
public function __construct(Container $app, Dispatcher $dispatcher, Filesystem $files)
public function __construct(Container $app, Dispatcher $dispatcher, Filesystem $filesystem)
{
$this->app = $app;
$this->dispatcher = $dispatcher;
$this->files = $files;
$this->filesystem = $filesystem;

$this->path = $app['path.public'].'/themes';
$this->cascadingPath = $app['path.base'].'/resources/themes';
Expand Down Expand Up @@ -166,7 +166,7 @@ public function boot(): bool

foreach ($autoload as $file) {
$file = \ltrim($file, '/');
$this->files->requireOnce("{$themePath}/{$file}");
$this->filesystem->requireOnce("{$themePath}/{$file}");
}

$this->dispatcher->dispatch("orchestra.theme.boot: {$this->theme}");
Expand Down Expand Up @@ -234,8 +234,10 @@ public function getThemePaths(): array
*/
public function getAvailableThemePaths(): array
{
return Collection::make($this->getThemePaths())->filter(function ($path) {
return $this->files->isDirectory($path);
$filesystem = $this->filesystem;

return Collection::make($this->getThemePaths())->filter(static function ($path) use ($filesystem) {
return $filesystem->isDirectory($path);
})->values()->all();
}

Expand Down Expand Up @@ -272,7 +274,7 @@ public function asset(string $url = ''): string
*/
protected function getThemeAutoloadFiles(string $themePath): array
{
$manifest = new Manifest($this->files, $themePath);
$manifest = new Manifest($this->filesystem, $themePath);

return $manifest->autoload ?? [];
}
Expand Down
6 changes: 3 additions & 3 deletions src/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function register()
*/
public function registerViewFinder()
{
$this->app->bind('view.finder', function (Application $app) {
$this->app->bind('view.finder', static function (Application $app) {
$paths = $app->make('config')->get('view.paths', []);

return new FileViewFinder($app->make('files'), $paths);
Expand All @@ -42,11 +42,11 @@ public function registerViewFinder()
*/
protected function registerTheme(): void
{
$this->app->singleton('orchestra.theme', function (Application $app) {
$this->app->singleton('orchestra.theme', static function (Application $app) {
return new ThemeManager($app);
});

$this->app->singleton('orchestra.theme.finder', function (Application $app) {
$this->app->singleton('orchestra.theme.finder', static function (Application $app) {
return new Finder($app->make('files'), $app->publicPath());
});
}
Expand Down

0 comments on commit 94e0b74

Please sign in to comment.