change is_callable checks to instanceof Closure.

This commit is contained in:
Taylor Otwell
2011-08-26 00:31:18 -05:00
parent 429c9cee84
commit fb3a0df0dd
7 changed files with 8 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ class Arr {
{
if ( ! is_array($array) or ! array_key_exists($segment, $array))
{
return is_callable($default) ? call_user_func($default) : $default;
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
$array = $array[$segment];

View File

@@ -38,7 +38,7 @@ abstract class Driver {
{
if ( ! is_null($item = $this->retrieve($key))) return $item;
return (is_callable($default)) ? call_user_func($default) : $default;
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
/**
@@ -82,7 +82,7 @@ abstract class Driver {
{
if ( ! is_null($item = $this->get($key, null))) return $item;
$default = is_callable($default) ? call_user_func($default) : $default;
$default = ($default instanceof \Closure) ? call_user_func($default) : $default;
$this->put($key, $default, $minutes);

View File

@@ -58,7 +58,7 @@ class Config {
if ( ! static::load($file))
{
return is_callable($default) ? call_user_func($default) : $default;
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
if (is_null($key)) return static::$items[$file];

View File

@@ -88,7 +88,7 @@ class Lang {
if ( ! $this->load($file))
{
return is_callable($default) ? call_user_func($default) : $default;
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
$line = Arr::get(static::$lines[$this->language.$file], $line, $default);

View File

@@ -83,7 +83,7 @@ class Handler {
{
if (isset($route->callback['do'])) return $route->callback['do'];
foreach ($route->callback as $value) { if (is_callable($value)) return $value; }
foreach ($route->callback as $value) { if ($value instanceof Closure) return $value; }
}
/**

View File

@@ -104,7 +104,7 @@ abstract class Driver {
if (array_key_exists($possibility, $this->session['data'])) return $this->session['data'][$possibility];
}
return is_callable($default) ? call_user_func($default) : $default;
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
/**

View File

@@ -91,7 +91,7 @@ class View implements Renderable {
{
foreach ((array) $composers[$this->view] as $key => $value)
{
if (is_callable($value)) return call_user_func($value, $this);
if ($value instanceof \Closure) return call_user_func($value, $this);
}
}
}