Skip to content

Commit 47cb7d2

Browse files
committed
isCallable function added to filter random strings acting like callables
1 parent 7d58739 commit 47cb7d2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Table/TableColumn.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function renderHeader()
125125
return "";
126126
}
127127

128-
if (empty($this->title) && !is_callable($this->value)) {
128+
if (empty($this->title) && !$this->isCallable($this->value)) {
129129
if ($this->tableInstance->titlesMode == 'underscore') $this->title = $this->underscoreToTitle($this->value);
130130
elseif ($this->tableInstance->titlesMode == 'camelcase') $this->title = $this->camelToTitle($this->value);
131131
}
@@ -178,7 +178,7 @@ public function renderBody( &$row )
178178
$css = $this->css['td']->render('{prop}:{val}; ');
179179

180180
$val = "";
181-
if (is_callable($this->value)) {
181+
if ($this->isCallable($this->value)) {
182182
$val = $this->value;
183183
$val = $val($row);
184184
}
@@ -216,6 +216,15 @@ private function underscoreToTitle($str)
216216

217217
return $str;
218218
}
219-
220-
219+
220+
221+
/**
222+
* @param string $var
223+
* @return boolean
224+
*/
225+
private function isCallable($var)
226+
{
227+
return (!is_string($var) && is_callable($var)) || (is_object($var) && $var instanceof \Closure);
228+
}
229+
221230
}

0 commit comments

Comments
 (0)