Skip to content

Commit

Permalink
Use value helper when applicable (#36994)
Browse files Browse the repository at this point in the history
  • Loading branch information
netpok committed Apr 15, 2021
1 parent 74e7b29 commit 6116d51
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php
Expand Up @@ -94,9 +94,7 @@ public function makeVisible($attributes)
*/
public function makeVisibleIf($condition, $attributes)
{
$condition = $condition instanceof Closure ? $condition($this) : $condition;

return $condition ? $this->makeVisible($attributes) : $this;
return value($condition, $this) ? $this->makeVisible($attributes) : $this;
}

/**
Expand All @@ -123,8 +121,6 @@ public function makeHidden($attributes)
*/
public function makeHiddenIf($condition, $attributes)
{
$condition = $condition instanceof Closure ? $condition($this) : $condition;

return value($condition) ? $this->makeHidden($attributes) : $this;
return value($condition, $this) ? $this->makeHidden($attributes) : $this;
}
}
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Foundation\Testing\Concerns;

use Closure;
use Illuminate\Support\Facades\View as ViewFacade;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -57,11 +56,7 @@ protected function component(string $componentClass, array $data = [])
{
$component = $this->app->make($componentClass, $data);

$view = $component->resolveView();

if ($view instanceof Closure) {
$view = $view($data);
}
$view = value($component->resolveView(), $data);

return $view instanceof View
? new TestView($view->with($component->data()))
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/helpers.php
Expand Up @@ -659,7 +659,7 @@ function rescue(callable $callback, $rescue = null, $report = true)
report($e);
}

return $rescue instanceof Closure ? $rescue($e) : $rescue;
return value($rescue, $e);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/Illuminate/View/Concerns/ManagesComponents.php
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\View\Concerns;

use Closure;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -84,9 +83,7 @@ public function renderComponent()

$data = $this->componentData();

if ($view instanceof Closure) {
$view = $view($data);
}
$view = value($view, $data);

if ($view instanceof View) {
return $view->with($data)->render();
Expand Down Expand Up @@ -151,8 +148,7 @@ public function endSlot()
$this->slotStack[$this->currentComponent()]
);

$this->slots[$this->currentComponent()]
[$currentSlot] = new HtmlString(trim(ob_get_clean()));
$this->slots[$this->currentComponent()][$currentSlot] = new HtmlString(trim(ob_get_clean()));
}

/**
Expand Down

0 comments on commit 6116d51

Please sign in to comment.