Complex classes like syntax_plugin_info often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use syntax_plugin_info, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 9 | class syntax_plugin_info extends DokuWiki_Syntax_Plugin |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * What kind of syntax are we? |
||
| 14 | */ |
||
| 15 | public function getType() |
||
| 19 | |||
| 20 | /** |
||
| 21 | * What about paragraphs? |
||
| 22 | */ |
||
| 23 | public function getPType() |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Where to sort in? |
||
| 30 | */ |
||
| 31 | public function getSort() |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * Connect pattern to lexer |
||
| 39 | */ |
||
| 40 | public function connectTo($mode) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Handle the match |
||
| 47 | * |
||
| 48 | * @param string $match The text matched by the patterns |
||
| 49 | * @param int $state The lexer state for the match |
||
| 50 | * @param int $pos The character position of the matched text |
||
| 51 | * @param Doku_Handler $handler The Doku_Handler object |
||
| 52 | * @return array Return an array with all data you want to use in render |
||
| 53 | */ |
||
| 54 | public function handle($match, $state, $pos, Doku_Handler $handler) |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Create output |
||
| 62 | * |
||
| 63 | * @param string $format string output format being rendered |
||
| 64 | * @param Doku_Renderer $renderer the current renderer object |
||
| 65 | * @param array $data data created by handler() |
||
| 66 | * @return boolean rendered correctly? |
||
| 67 | */ |
||
| 68 | public function render($format, Doku_Renderer $renderer, $data) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * list all installed plugins |
||
| 117 | * |
||
| 118 | * uses some of the original renderer methods |
||
| 119 | * |
||
| 120 | * @param string $type |
||
| 121 | * @param Doku_Renderer_xhtml $renderer |
||
| 122 | */ |
||
| 123 | protected function renderPlugins($type, Doku_Renderer_xhtml $renderer) |
||
| 156 | |||
| 157 | /** |
||
| 158 | * list all installed plugins |
||
| 159 | * |
||
| 160 | * uses some of the original renderer methods |
||
| 161 | * |
||
| 162 | * @param Doku_Renderer_xhtml $renderer |
||
| 163 | */ |
||
| 164 | protected function renderHelperMethods(Doku_Renderer_xhtml $renderer) |
||
| 209 | |||
| 210 | /** |
||
| 211 | * lists all known syntax types and their registered modes |
||
| 212 | * |
||
| 213 | * @return string |
||
| 214 | */ |
||
| 215 | protected function renderSyntaxTypes() |
||
| 234 | |||
| 235 | /** |
||
| 236 | * lists all known syntax modes and their sorting value |
||
| 237 | * |
||
| 238 | * @return string |
||
| 239 | */ |
||
| 240 | protected function renderSyntaxModes() |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Adds a TOC item |
||
| 278 | * |
||
| 279 | * @param string $text |
||
| 280 | * @param int $level |
||
| 281 | * @param Doku_Renderer_xhtml $renderer |
||
| 282 | * @return string |
||
| 283 | */ |
||
| 284 | protected function addToToc($text, $level, Doku_Renderer_xhtml $renderer) |
||
| 300 | } |
||
| 301 | |||
| 303 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.