You appear to be a bot. Output may be restricted
Description
Create a new first line for the functionSince we're loading this as a function we need to eliminate keywords that are applicable to methods but not functions. Handling abstract is belt and braces – since there shouldn't be any code.
Usage
oiksc_function_loader::create_dummy_function_line( $line );
Parameters
- $line
- ( mixed ) required –
Returns
voidTO DO
this is still messy. For JetPack it converted func and caused a fatal error. This current version alters variable names as well Would it not be better to tokenize the line, find the first literal and replace that? Answer: Yes. As demonstrated by [bw_api] public static protected function func( $func [/bw_api] being handled correctly.Source
File name: oik-shortcodes/classes/class-oiksc-function-loader.phpLines:
1 to 22 of 22
function create_dummy_function_line( $line ) { $tokens = token_get_all( "<?php " . $line ); $replaced = false; $newline = null; foreach ( $tokens as $token ) { if ( !$replaced ) { if ( is_array( $token ) && ( $token[0] === T_STRING ) ) { $replaced = true; $newline = "function " . $this->dummy_function_name; } else { // Not a string token - keep looking } } else { if ( is_array( $token )) { $newline .= $token[1]; } else { $newline .= $token; } } } return( $newline ); }View on GitHub