| 10 | |
| 11 | |
| 12 | class PhpParser(LanguageParser): |
| 13 | |
| 14 | FILTER_PATHS = ('test', 'tests') |
| 15 | |
| 16 | BLACKLISTED_FUNCTION_NAMES = ['__construct', '__destruct', '__call', '__callStatic', |
| 17 | '__get', '__set', '__isset', '__unset', |
| 18 | '__sleep', '__wakeup', '__toString', '__invoke', |
| 19 | '__set_state', '__clone', '__debugInfo', '__serialize', |
| 20 | '__unserialize'] |
| 21 | |
| 22 | @staticmethod |
| 23 | def get_docstring(node, blob: str=None) -> str: |
| 24 | if blob: |
| 25 | logger.info('From version `0.0.6` this function will update argument in the API') |
| 26 | docstring_node = PhpParser.get_docstring_node(node) |
| 27 | |
| 28 | docstring = '' |
| 29 | if docstring_node: |
| 30 | docstring = get_node_text(docstring_node[0]) |
| 31 | |
| 32 | return docstring |
| 33 | |
| 34 | @staticmethod |
| 35 | def get_docstring_node(node): |
| 36 | docstring_node = [] |
| 37 | |
| 38 | if node.prev_sibling is not None: |
| 39 | prev_node = node.prev_sibling |
| 40 | if prev_node.type == 'comment': |
| 41 | docstring_node.append(prev_node) |
| 42 | |
| 43 | return docstring_node |
| 44 | |
| 45 | @staticmethod |
| 46 | def get_comment_node(function_node): |
| 47 | comment_node = get_node_by_kind(function_node, kind='comment') |
| 48 | return comment_node |
| 49 | |
| 50 | @staticmethod |
| 51 | def get_class_list(node): |
| 52 | res = get_node_by_kind(node, ['class_declaration', |
| 53 | 'trait_declaration', |
| 54 | 'interface_declaration']) |
| 55 | return res |
| 56 | |
| 57 | @staticmethod |
| 58 | def get_function_list(node): |
| 59 | res = get_node_by_kind(node, ['function_definition', 'method_declaration']) |
| 60 | return res |
| 61 | |
| 62 | @staticmethod |
| 63 | def get_function_metadata(function_node, blob: str=None) -> Dict[str, str]: |
| 64 | if blob: |
| 65 | logger.info('From version `0.0.6` this function will update argument in the API') |
| 66 | metadata = { |
| 67 | 'identifier': '', |
| 68 | 'parameters': {}, |
| 69 | 'return_type': None, |
nothing calls this directly
no outgoing calls
no test coverage detected