HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: General Notes

» Return to Contents



Here is the code used to extract phpdoc style function comments  from PHP code.

sources/php.php

Global_functions_php.php

Function summary

void init__php ()
array get_php_file_api (ID_TEXT filename, boolean include_code)
array _read_php_function_line (string _line)
array _cleanup_array (array in)
void check_function_type (ID_TEXT type, string function_name, string name, ?mixed value, ?string range, ?string set, boolean echo)
void test_fail_php_type_check (ID_TEXT type, string function_name, string name, mixed value, boolean echo)
void _fail_php_type_check (string type, string function_name, string name, string value, boolean echo)
array render_php_function (array function, array class, boolean show_filename)
tempcode render_php_function_do_bits (array parameter)

void init__php()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

array get_php_file_api(ID_TEXT filename, boolean include_code)

Get a complex API information structure from a PHP file. It assumes the file has reasonably properly layed out class and function whitespaceThe return structure is…list of classeseach entry is a map containing 'functions' (list of functions) and 'name'each functions entry is a map containing 'parameters' and 'name' and 'return'each parameters entry is a map containing…namedescriptiontypedefaultsetrange

Parameters…

Name filename
Description The PHP code module to get API information for
Type ID_TEXT

Name include_code
Description Whether to include function source code
Default value boolean-true
Type boolean

Returns…

Description The complex structure of API information
Type array

Return to the function index for this class Expand: View the source code to this function

array _read_php_function_line(string _line)

Read a PHP function line and return parsed details.

Parameters…

Name _line
Description The line
Type string

Returns…

Description A pair: (function name, parameters), where parameters is a list of maps detailing each parameter
Type array

Return to the function index for this class Expand: View the source code to this function

array _cleanup_array(array in)

Remove and blank strings from the given array.

Parameters…

Name in
Description List of strings
Type array

Returns…

Description List of strings, with blank strings removed
Type array

Return to the function index for this class Expand: View the source code to this function

void check_function_type(ID_TEXT type, string function_name, string name, ?mixed value, ?string range, ?string set, boolean echo)

Type-check the specified parameter (giving an error if the type checking fails) [all checks]

Parameters…

Name type
Description The parameter type
Type ID_TEXT

Name function_name
Description The functions name (used in error message)
Type string

Name name
Description The parameter name (used in error message)
Type string

Name value
Description The parameters value (NULL: value actually is null)
Type ?mixed

Name range
Description The string of value range of the parameter (NULL: no range constraint)
Type ?string

Name set
Description The string of value set limitation for the parameter (NULL: no set constraint)
Type ?string

Name echo
Description Whether we just echo errors instead of exiting
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

void test_fail_php_type_check(ID_TEXT type, string function_name, string name, mixed value, boolean echo)

Type-check the specified parameter (giving an error if the type checking fails) [just value against type]

Parameters…

Name type
Description The parameter type
Type ID_TEXT

Name function_name
Description The functions name (used in error message)
Type string

Name name
Description The parameter name (used in error message)
Type string

Name value
Description The parameters value (cannot be null)
Type mixed

Name echo
Description Whether we just echo errors instead of exiting
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

void _fail_php_type_check(string type, string function_name, string name, string value, boolean echo)

Throw out a type checker error message.

Parameters…

Name type
Description The type involved
Type string

Name function_name
Description The function involved
Type string

Name name
Description The parameter name involved
Type string

Name value
Description The value involved
Type string

Name echo
Description Whether we just echo errors instead of exiting
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

array render_php_function(array function, array class, boolean show_filename)

Render a PHP function to display in a template.

Parameters…

Name function
Description The map of function information
Type array

Name class
Description The map of class information
Type array

Name show_filename
Description Show filenames in the function description
Default value boolean-false
Type boolean

Returns…

Description A pair: The rendered function, The rendered summary (for a TOC)
Type array

Return to the function index for this class Expand: View the source code to this function

tempcode render_php_function_do_bits(array parameter)

Get a PHP function parameter line.

Parameters…

Name parameter
Description A map containing: name, description, default, type, set, range
Type array

Returns…

Description The line
Type tempcode

Return to the function index for this class Expand: View the source code to this function