/** Parse the method string to get the class and method names, and check * that they can be called. * @param eZTemplate $tpl The template the parse is being done for. * @param string $method The class::method string to parse into components. * @return array|null An associative array with the components of the * parsed string, or null on error. */ private function parseMethod($tpl, $method, $functionPlacement = false) { $static = false; $parts = explode('->', $method); if (count($parts) < 2) { $static = true; $parts = explode('::', $method); if (count($parts) < 2) { $tpl->warning($this->ESIncludeName, 'Invalid method, missing class/method separator.', $functionPlacement); return null; } } if (count($parts) > 2) { $tpl->warning($this->ESIncludeName, 'Invalid method, extra class/method separators.', $functionPlacement); return null; } $class = $parts[0]; $method = $parts[1]; if (!class_exists($class)) { $tpl->warning($this->ESIncludeName, 'Invalid method, no such class: ' . $class, $functionPlacement); return null; } if (!method_exists($class, $method)) { $tpl->warning($this->ESIncludeName, 'Invalid method, no such method in class ' . $class . ': ' . $method, $functionPlacement); return null; } if ($static) { $callable = is_callable(array($class, $method)); } else { $callable = is_callable(array(new $class(), $method)); } if (!$callable) { $tpl->warning($this->ESIncludeName, 'Invalid method, it is not callable: ' . $class . ($static ? '::' : '->') . $method, $functionPlacement); return null; } return array('class' => $class, 'method' => $method, 'static' => $static); }