Inspection Class
This class can be used to inspect other files and will return objects that can be further used to generate for example, this page and many of the other pages found in this User Guide. It is essentially a wrapper around many of the convenient objects and methods of the PHP Refelction class but provides extra functionality for parsing out comment information. Below is a list of related classes used by the Inspection class:
- Inspection_class
- Inspection_function
- Inspection_method
- Inspection_param
- Inspection_property
- Inspection_comment
- Inspection_base
Properties Reference
Property | Default Value | Description |
---|---|---|
public | ||
file | none | Path to the file to inspect |
protected | ||
_classes | N/A | Cache of classes found in the file |
_functions | N/A | Cache of functions found in the file |
_comments | N/A | Cache of page comments |
Function Reference [+]
$this->inspection->initialize(['$params'=NULL])
Initializes the object by grabbing the contents of a file for inspection. Accepts an associative array as input, containing preferences (optional).
Returns
void
Parameters
(array) $params config preferences
$this->inspection->classes(['$class'=NULL])
Returns the classes found in a file as an Inspection_class object.
Returns
void
Parameters
(string) $class The name of a class. If not provided, then an array of all the classes will be returned (optional)
$this->inspection->functions(['$function'=NULL])
Returns the functions found in a file as an Inspection_function object.
Returns
void
Parameters
(array) $function The name of a function. If not provided, then an array of all the functions will be returned (optional)
$this->inspection->comments(['$comment'=NULL])
Returns the main comment blocks found in a file as an Inspection_comment object.
Returns
void
Parameters
(array) $comment The name of a function. If not provided, then an array of all the functions will be returned (optional)
$this->inspection->parse_classes('$code')
Parses and returns the name of the classes found in the string. Originally found here: http://stackoverflow.com/questions/928928/determining-what-classes-are-defined-in-a-php-class-file.
Returns
void
Parameters
(string) $code The code to parse
$this->inspection->parse_functions('$code', ['$include_underscore_funcs'=FALSE])
Parses and returns the name of the function found in a string. Originally found here: http://stackoverflow.com/questions/2666554/how-to-get-list-of-declared-functions-with-their-data-from-php-file.
Returns
void
Parameters
(string) $code The code to parse (boolean) $include_underscore_funcs Determines whether to include functions that begin with an underscore
$this->inspection->parse_comments('$code')
Parses and returns an array of comments found in a string.
Returns
array
Parameters
(string) $code The code to parse
Inspection Class Class
This class extends the Inspection_base class.
Properties Reference
Property | Default Value | Description |
---|---|---|
protected | ||
_methods | N/A | The method objects of the class |
_file | N/A | For further processing for properties |
Function Reference [+]
$this->inspection_class->properties([$types=array()], ['$include_parent'=FALSE])
Properties of the class.
Returns
array An array of Inspection_property objects
Parameters
(array) $types The type of properties to include. Options are 'public', 'protected', and 'private. Default will only show public'(optional) (boolean) $include_parent Determines whether to include any parent properties. Default is FALSE (optional)
$this->inspection_class->parent()
The name of the parent class if it exists.
Returns
string
$this->inspection_class->method('$method')
Returns an Inspection_method
Returns
object
Parameters
(string) $method The name of the method to return
$this->inspection_class->methods([$types=array()], ['$include_parent'=FALSE], ['$include_constructor'=FALSE])
Returns an array of all the class methods. The array contains Inspection_method objects.
Returns
array
Parameters
(array) $types The type of properties to include. Options are 'public', 'protected', and 'private. Default will only show public'(optional) (boolean) $include_parent Determines whether to include any parent properties. Default is FALSE (optional) (boolean) $include_constructor Determines whether to include the contstructor method. Default is FALSE (optional)
Inspection Function Class
This class extends the Inspection_base class.
Inspection Method Class
This class extends the Inspection_base class.
Properties Reference
Property | Default Value | Description |
---|---|---|
protected | ||
_params | N/A | The parameters objects of the method |
Inspection Property Class
This class extends the Inspection_base class.
Properties Reference
Property | Default Value | Description |
---|---|---|
public | ||
class | none | The name of the class the property belongs to |
value | none | The value of the class property |
Inspection Param Class
This class extends the Inspection_base class.
Function Reference [+]
$this->inspection_param->default_value(['$to_string'=FALSE])
Returns the default value of a parameter.
Returns
array
Parameters
(boolean) $to_string Determines whether you want the default value as a string or as an object
$this->inspection_param->is_default_array()
Returns whether the function parameter is an array or not.
Returns
boolean
Inspection Comment Class
Properties Reference
Property | Default Value | Description |
---|---|---|
protected | ||
_text | N/A | The comment raw text |
_description | N/A | The description part of the comment |
_example | N/A | Examples found in the comment |
_tags | N/A | Tags found in the comment |
_filters | N/A | Pre processing functions |
Function Reference [+]
$this->inspection_comment->initialize('$comment')
Initializes the comment.
Returns
void
Parameters
(string) $comment
$this->inspection_comment->tags(['$type'='param'])
Returns a comment "tag" (e.g. param, return, access... etc). If no value is passed, an array of tags will be returned.
Returns
mixed
Parameters
(string) $type The name of the tag (optional)
$this->inspection_comment->param('$index', ['$type'=NULL])
Returns a parameter tag.
Returns
boolean
Parameters
(int) $index The index (order) of the parameter to retrieve (string) $type The part of the parameter to retrieve. Options are 'type' and 'comment'
$this->inspection_comment->return_value(['$type'=NULL])
Returns a parameter tag.
Returns
boolean
Parameters
(int) $type The index (order) of the parameter to retrieve
$this->inspection_comment->description(['$format'=FALSE])
Returns the comment description. You can pass it an array of formatting parameters which include:.
- markdown: applies the markdown function
- short: filters just the first paragraphs of the description if multiple paragraphs
- long: returns the entire description
- one_line: filters the description to appear on one line by removing returns
- entities: converts html entities
- eval: evaluates php code
- periods: adds periods at the end of lines that don't have them
- ucfirst: uppercases the first word
Returns
boolean
Parameters
(int) $format The index (order) of the parameter to retrieve
$this->inspection_comment->example(['$opening'=''], ['$closing'=''])
Returns a code example. Must be wrapped in a "code" HTML tag.
Returns
string
Parameters
(string) $opening The opening tag to wrap the example in (string) $closing The closing tag to wrap the example in
$this->inspection_comment->text()
Returns the raw text of the description.
Returns
string
$this->inspection_comment->set_text('$text')
Sets the comment text.
Returns
boolean
Parameters
(string) $text The comment text
$this->inspection_comment->add_filter('$func', ['$key'=NULL])
Adds a filter to be used for processing comments (e.g. the [ user_guide_url ] is rendered using a filter).
Returns
boolean
Parameters
(string) $func The name of the function or a lamda (string) $key A key value to assign to the filter which can be used in removing filters later
$this->inspection_comment->remove_filter('$key')
Removes a filter from the comment.
Returns
boolean
Parameters
(string) $key The key value of the filter you want to remove
Inspection Base Class
Properties Reference
Property | Default Value | Description |
---|---|---|
public | ||
reflection | none | Reflection object |
comment | none | Inspection_comment |
name | none | Basic name value |
obj | none | The object (if any) |
params | none | The parameters of the object (if any) |
Function Reference [+]
$this->inspection_base->initialize('$ref_class', '$method', ['$obj'=NULL])
Executes the filter on a source (e.g. the comment).
Returns
void
Parameters
(string) $ref_class The comment text
$this->inspection_base->friendly_name()
The friendly name of the object.
Returns
string
$this->inspection_base->comment()
The comment object.
Returns
void
$this->inspection_base->param('$index')
Returns a method or function Inspection_parameter object.
Returns
object
Parameters
(int) $index The index number of the parameter you want to retrieve
$this->inspection_base->params()
Returns an array of method or function Inspection_parameters.
Returns
boolean
$this->inspection_base->__call('$name', $args)
Magic method that will automatically look on the Reflection class object for a camelized version of the method name.
Returns
boolean
Parameters
(string) $name The method name (array) $args An array of arguments to pass to the Reflection class method being called