From 7d21f0a47e416e9c8efba5d8c751d8287d54f70a Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 24 Mar 2020 01:26:00 -0500 Subject: [PATCH] fix(linting): Fix the whining --- composer.lock | 10 +++++----- src/Poet.php | 14 +++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index d07e702..3e8c1c0 100644 --- a/composer.lock +++ b/composer.lock @@ -70,16 +70,16 @@ "packages-dev": [ { "name": "squizlabs/php_codesniffer", - "version": "3.5.2", + "version": "3.5.4", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "65b12cdeaaa6cd276d4c3033a95b9b88b12701e7" + "reference": "dceec07328401de6211037abbb18bda423677e26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/65b12cdeaaa6cd276d4c3033a95b9b88b12701e7", - "reference": "65b12cdeaaa6cd276d4c3033a95b9b88b12701e7", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", + "reference": "dceec07328401de6211037abbb18bda423677e26", "shasum": "" }, "require": { @@ -117,7 +117,7 @@ "phpcs", "standards" ], - "time": "2019-10-28T04:36:32+00:00" + "time": "2020-01-30T22:20:29+00:00" } ], "aliases": [], diff --git a/src/Poet.php b/src/Poet.php index 02de666..9d01241 100644 --- a/src/Poet.php +++ b/src/Poet.php @@ -54,7 +54,9 @@ public function __construct($post = [], $taxonomy = [], $block = []) protected function register() { collect($this->post) - ->each(function ($config = [], $key) { + ->each(function ($config, $key) { + $config = $config ?? []; + if ($this->exists($key)) { return $this->modify($key, $config); } @@ -63,7 +65,9 @@ protected function register() }); collect($this->taxonomy) - ->each(function ($config = [], $key) { + ->each(function ($config, $key) { + $config = $config ?? []; + if ($this->exists($key)) { return $this->modify($key, $config); } @@ -72,13 +76,13 @@ protected function register() }); collect($this->block) - ->each(function ($config = [], $key) { + ->each(function ($config, $key) { + $config = collect($config ?? []); + if (! Str::contains($key, '/')) { $key = Str::start($key, 'block/'); } - $config = collect($config); - register_block_type($key, [ 'render_callback' => function ($data, $content) use ($key, $config) { return view($config->get('view', 'blocks.' . Str::after($key, '/')), [