Extract

Extracts doc blocks from PHP files. Uses regular expressions to fetch data out the sources. Works great for fairly clean and well formatted source codes, not made to win a challenging situation. This class extracts and outputs the documentations of a package in an array, the array may be rendered to HTML, text or any other document.
The documentation of "@param" and "@return" may include documents from an external file. You can add "[@file-name.keyword]" inside the comments, if possible "[@file-name.keyword]" will be replaces by a block of documentation (regardless of format) from "file-name" under "[@keyword]". The files will be searched inside the directory path set to "external-comments-dir" key in the configs.
Source
Extract.php
Since
Artaengine 1.4

Constants

PARAM_TYPE_VARNAME_COMMENTS = 2

method/function @param style is as: @param type var-name comments

PARAM_VARNAME_COMMENTS = 1

method/function @param style is as: @param comments

PARAM_VARNAME_TYPE_COMMENTS = 3

method/function @param style is as: @param var-name type comments

RETURN_COMMENTS = 1

method/function @return style is as: @return comments

RETURN_TYPE_COMMENTS = 2

method/function @return style is as: @return type comments

Static Methods

arrayUpdate

void Extract::arrayUpdate(array base, array source)

Updates base array with source array. The new elements of source will be added to base, the non array elements of base will be updated with the elements of source if they exists in source and have the same key. Elements with the same key that are array in base but not array in source will be updated with the source value. The elements with the same key that are array in both base and source will be updated recursively in the same way.

Arguments

    base (array)
    reference to base array which will be updated
    source (array)
    source array

Returns

void

trimArray

void Extract::trimArray(&a array)

Trim array values in place.

Arguments

    array (&a)
    to be processed

Returns

void

Methods

__construct

Extract $obj = new Extract(array configs)

Constructor.

Arguments

    configs (array)
    Extract configs

Returns

void

extractAll

array $obj->extractAll(string path)

Extract documentations from source codes and return an array. Recursively extracts docs from any file inside the directory and sub-directories.

Arguments

    path (string)
    Path to the root source directory

Returns

array
Look at return for extract()

extractFile

array $obj->extractFile(string path)

Extract documentations from a source code and return an array.

Arguments

    path (string)
    Path to source file

Returns

array
 {
     namespaces: {
         namespace-name: {
             globals: {
                 consts: {
                     const-name: {
                         file: (string),
                         atts: {
                             comment: (string),
                             doc-param: (string),
                         },
                         val: const-value,
                         type:   (string),
                     },
                 },
                 vars: {
                     var-name: {
                         file: (string),
                         atts: {
                             comment: (string),
                             other-doc-param: (string),
                         },
                         static: (bool),
                         val:    var-value,
                         type:   (string),
                     },
                 },
                 function: {
                     function-name: {
                         file: (string),
                         atts: {
                             comment: (string),
                             param:   {
                                 param-name: {
                                     comment: (string),
                                     type:    (string),
                                 },
                             },
                             return:  {
                                comment: (string),
                                type:    (string),
                            },
                             throws: {
                                 comment: (string),
                                 class:   (string),
                             },
                             other-doc-param: (string),
                         },
                         args: [function-args: default-value,],
                     },
                 },
             },
             interfaces: {
                 interface-name: {
                     file:       (string),
                     extends:    [interface-name,],
                     atts: {
                         comment:  (string),
                         att-name: att-value,
                         att-name: [att-value,],
                     },
                     consts:     same-as-for-classes,
                     methods:    same-as-for-classes,
                 },
             },
             classes: {
                 class-name: {
                     file:       (string),
                     abstract:   (bool),
                     final:      (bool),
                     extends:    class-name (string),
                     implements: [interface-names,],
                     atts: {
                         comment:  (string),
                         att-name: att-value,
                         att-name: [att-value,],
                     },
                     consts: {
                         const-name: {
                             atts: {
                                 comment:  (string),
                                 att-name: att-value,
                                 att-name: [att-value,],
                             },
                             val:  const-value,
                             type: (string),
                        },
                     },
                     properties: {
                         property-name: {
                             atts: {
                                 comment:  (string),
                                 att-name: att-value,
                                 att-name: [att-value,],
                             },
                             static: (bool),
                             access: (string) public|private|protected,
                             val:    property-value,
                             type:   (string),
                         },
                     },
                     methods: {
                         method-name: {
                             atts: {
                                 comment:  (string),
                                 att-name: att-value,
                                 att-name: [att-value,],
                                 param: {
                                     param-name: {
                                         comment: (string),
                                         type:    (string),
                                         type2:   (string),
                                     },
                                 },
                                 return: {
                                     comment: (string),
                                     type:    (string),
                                     type2:   (string),
                                 },
                                 throws: [{
                                     comment: (string),
                                     class:   (string),
                                 },],
                             },
                             final:  (bool),
                             static: (bool),
                             access: (string) public|private|protected,
                             args:   [method-args: default-value,],
                         },
                     },
                 },
             },
         },
     },
 }