/** * Returns false or the name of the extension the method belongs to * * @return string|boolean False or the name of the extension */ public function getExtensionName() { if ($this->reflectionSource instanceof ReflectionMethod) { return $this->reflectionSource->getExtensionName(); } else { return parent::getExtensionName(); } }
* will help Emacs organize the snippets into sub-menus, making it * easier for the user to navigate once he starts creating a large * number of snippets with this program. PHP groups many functions * into 'extensions', so we use the extension name for the group name. * Thus a function like json_encode() will get the directive '#group: * json'. If $function actually represents a method then we also try * to add the name of the class to the group, creating a sub-group * using that class name. * * However, not all functions and methods belong to an extension. For * methods we still use the class name for the group in the absence of * an extension name. But for functions we omit the '#group' * directive if there is no extension name. */ $group_name_pieces = array(); if ($function->getExtensionName()) { $group_name_pieces[] = $function->getExtensionName(); } if ($function instanceof ReflectionMethod) { $class_name = $function->getDeclaringClass()->getName(); /* If the class name belongs to a namespace then we create * further sub-groups to reflect that. */ str_replace("\\", ".", $class_name); $group_name_pieces[] = $class_name; } if (count($group_name_pieces) > 0) { $snippet_directives[] = sprintf("#group: %s", implode(".", $group_name_pieces)); } /* We assume the name of the function is already in the buffer and * that Emacs will append any output to that. So we create an array