Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
eZAutoloadGenerator Class Reference

## Public Member Functions
| __construct (ezpAutoloadGeneratorOptions $options=null)
| buildAutoloadArrays ()
| setMode ( $modeValue)
| setOutputCallback ( $callback)
| getMessages ()
| getWarnings ()
| printAutoloadArray ( $printForMode=null)
| setOptions ( $options)
| setOutputObject ( $outputObject)

## Static Public Member Functions
static | findRecursive ( $sourceDir, array $includeFilters, array $excludeFilters, eZAutoloadGenerator $gen)
static | findRecursiveCallback (ezpAutoloadFileFindContext $context, $sourceDir, $fileName, $fileInfo)

## Public Attributes
const | MODE_NONE = 0
const | MODE_KERNEL = 1
const | MODE_EXTENSION = 2
const | MODE_TESTS = 4
const | MODE_SINGLE_EXTENSION = 8
const | MODE_KERNEL_OVERRIDE = 16
const | OUTPUT_PROGRESS_PHASE1 = 1
const | OUTPUT_PROGRESS_PHASE2 = 2
const | DEFAULT_EXCLUDE_FILE = '.autoloadignore'
const | UNDEFINED_TOKEN = -1

## Protected Member Functions
| writeAutoloadFiles ()
| handleDefaultExcludeFile ()
| fetchFiles ()
| buildFileList ( $path, $extraFilter=null)
| getClassFileList ( $fileList, $mode)
| checkMaxClassLength ( $depData)
| dumpArray ( $sortedArray, $length)
| checkMode ()
| runMode ()
| nameTable ( $lookup)
| targetTable ( $lookup)
| dumpArrayStart ( $part)
| dumpArrayEnd ()
| classCanBeAdded ( $class, $file, $mode, $inProgressAutoloadArray)
| classExistsInArray ( $class, $checkMode, $file, $inProgressAutoloadArray=null, $generatingMode=null)
| logIssue ( $class, $checkMode, $file, $inProgressAutoloadArray, $generatingMode)
| log ( $message)
| logWarning ( $message)
| emit ( $message, $messageType)
| updateProgressOutput ( $phase)
| incrementProgressStat ( $phase, $stat)
| startProgressOutput ( $phase)
| stopProgressOutput ( $phase)
| getStatArray ( $phase)
| setStatArray ( $phase, $data)

## Static Protected Member Functions
static | walkRecursive ( $sourceDir, array $includeFilters, array $excludeFilters, $callback, &$callbackContext)

## Protected Attributes
| $options
| $mask
| $existingAutoloadArrays
| $messages
| $warnings
| $outputCallback
| $output
| $modeName
| $autoloadArrays

## Detailed Description

Definition at line 19 of file ezautoloadgenerator.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZAutoloadGenerator::__construct | ( | ezpAutoloadGeneratorOptions | $options = `null` | ) |

Constructs class to generate autoload arrays.

Definition at line 156 of file ezautoloadgenerator.php.

References $options, MODE_EXTENSION, MODE_KERNEL, MODE_TESTS, and runMode().

## Member Function Documentation

## ◆ buildAutoloadArrays()

eZAutoloadGenerator::buildAutoloadArrays | ( |  | ) |

Searches specified directories for classes, and build autoload arrays.

Exceptions

  Exception | if desired output directory is not a directory, or if the autoload arrays are not writeable by the script.

Returns
  void

Definition at line 186 of file ezautoloadgenerator.php.

References $fileList, checkMaxClassLength(), dumpArray(), fetchFiles(), getClassFileList(), and writeAutoloadFiles().

## ◆ buildFileList()

eZAutoloadGenerator::buildFileList | ( |  | $path,
|  |  | $extraFilter = `null`
| ) |  |
| protected

Builds a filelist of all PHP files in $path.

Parameters

  string | $path |
  array | $extraFilter |

Returns
  array

Definition at line 383 of file ezautoloadgenerator.php.

References findRecursive().

Referenced by fetchFiles().

## ◆ checkMaxClassLength()

eZAutoloadGenerator::checkMaxClassLength | ( |  | $depData | ) |
| protected

Calculates the length of the longest class name present in $depdata

Parameters

  array | $depData |

Returns
  mixed

Definition at line 729 of file ezautoloadgenerator.php.

References $location.

Referenced by buildAutoloadArrays().

## ◆ checkMode()

eZAutoloadGenerator::checkMode | ( |  | ) |
| protected

Checks which runmode the script should operate in: kernel-mode, extension-mode or both.

Parameters

  int | $mask | Bitmask to check for run mode.

Returns
  int

Definition at line 779 of file ezautoloadgenerator.php.

Referenced by fetchFiles().

## ◆ classCanBeAdded()

eZAutoloadGenerator::classCanBeAdded | ( |  | $class,
|  |  | $file,
|  |  | $mode,
|  |  | $inProgressAutoloadArray
| ) |  |
| protected

Determines if a class can be added to the autoload array.

1. When regenerating array for MODE, do not check for existance of class duplicates in the existing array for the same mode.
2. When adding a new class to the in-progress autoload array, check for matching keys, before adding. If match is found then add a warning message to the warnings stack, and mark the class not to be added.
3. If kernel array is not present, issue warning that class name collisions cannot be checked until kernel array is generated.
4. Class collisions with kernel classes is only allowed for MODE_KERNEL_OVERRIDE

Parameters

  string | $class | The name of the class being checked.
  string | $file | The filename where the class is found.
  int | $mode | The mode representing the current run mode.
  array | $inProgressAutoloadArray | Array of the already detected classes for the current mode.

Returns
  boolean

Definition at line 982 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

## ◆ classExistsInArray()

eZAutoloadGenerator::classExistsInArray | ( |  | $class,
|  |  | $checkMode,
|  |  | $file,
|  |  | $inProgressAutoloadArray = `null`,
|  |  | $generatingMode = `null`
| ) |  |
| protected

Internal method used to check if an class exist autoload arrays.

Parameters

  string | $class | The name of the class being checked.
  int | $checkMode | The mode whose autoload arrays will be checked.
  string | $file | Filename containing the class.
  array | $inProgressAutoloadArray | The autoload array generated so far.
  int | $generatingMode | The mode we are generating for autoloads for.

Returns
  boolean

Definition at line 1048 of file ezautoloadgenerator.php.

## ◆ dumpArray()

eZAutoloadGenerator::dumpArray | ( |  | $sortedArray,
|  |  | $length
| ) |  |
| protected

Build string version of the autoload array with correct indenting.

Parameters

  array | $sortedArray |
  int | $length |

Returns
  string

Definition at line 757 of file ezautoloadgenerator.php.

References $location, $offset, and $ret.

Referenced by buildAutoloadArrays().

## ◆ dumpArrayEnd()

eZAutoloadGenerator::dumpArrayEnd | ( |  | ) |
| protected

Prints generated code for end of the autoload files

Returns
  void

Definition at line 948 of file ezautoloadgenerator.php.

Referenced by writeAutoloadFiles().

## ◆ dumpArrayStart()

eZAutoloadGenerator::dumpArrayStart | ( |  | $part | ) |
| protected

Prints generated code used for the autoload files

Parameters

  string | $part |

Returns
  string

Definition at line 918 of file ezautoloadgenerator.php.

References $part, MODE_EXTENSION, MODE_KERNEL, MODE_KERNEL_OVERRIDE, MODE_SINGLE_EXTENSION, and MODE_TESTS.

Referenced by writeAutoloadFiles().

## ◆ emit()

eZAutoloadGenerator::emit | ( |  | $message,
|  |  | $messageType
| ) |  |
| protected

Will call output callback if defined.

The purpose of this function is to directly emit messages, for instance when the class is being used from shell scripts. If a valid callback has been setup with

See also
  setOutputCallback(), that method will be called with $message and $messageType

Parameters

  string | $message |
  string | $messageType |

Returns
  void

Definition at line 1163 of file ezautoloadgenerator.php.

## ◆ fetchFiles()

eZAutoloadGenerator::fetchFiles | ( |  | ) |
| protected

Returns an array indexed by location for classes and their filenames.

Parameters

  string | $path | The base path to start the search from.
  string | $mask | A binary mask which instructs the function whether to fetch kernel-related or extension-related files.

Returns
  array

Definition at line 303 of file ezautoloadgenerator.php.

References $dir, $file, buildFileList(), checkMode(), handleDefaultExcludeFile(), MODE_EXTENSION, MODE_KERNEL, MODE_KERNEL_OVERRIDE, MODE_SINGLE_EXTENSION, and MODE_TESTS.

Referenced by buildAutoloadArrays().

## ◆ findRecursive()

static eZAutoloadGenerator::findRecursive | ( |  | $sourceDir,
|  | array | $includeFilters,
|  | array | $excludeFilters,
|  | eZAutoloadGenerator | $gen
| ) |  |
| static

Uses the walker in ezcBaseFile to find files.

This also uses the callback to get progress information about the file search.

Parameters

  string | $sourceDir |
  array | $includeFilters |
  array | $excludeFilters |
  eZAutoloadGenerator | $gen |

Returns
  array

Definition at line 414 of file ezautoloadgenerator.php.

References log(), startProgressOutput(), stopProgressOutput(), and walkRecursive().

Referenced by buildFileList().

## ◆ findRecursiveCallback()

static eZAutoloadGenerator::findRecursiveCallback | ( | ezpAutoloadFileFindContext | $context,
|  |  | $sourceDir,
|  |  | $fileName,
|  |  | $fileInfo
| ) |  |
| static

Callback used ezcBaseFile

Parameters

  string | $ezpAutoloadFileFindContext |
  string | $sourceDir |
  string | $fileName |
  string | $fileInfo |

Returns
  void

Definition at line 565 of file ezautoloadgenerator.php.

References $fileName, and OUTPUT_PROGRESS_PHASE1.

## ◆ getClassFileList()

eZAutoloadGenerator::getClassFileList | ( |  | $fileList,
|  |  | $mode
| ) |  |
| protected

Extracts class information from PHP sourcecode.

Returns
  array (className=>filename)

Ignore token if class is anonymous: "new Class() {}"

See also
  https://www.php.net/manual/en/language.oop5.anonymous.php NEW_TOKEN - WHITESPACE_TOKEN - CLASS_TOKEN

Definition at line 583 of file ezautoloadgenerator.php.

References $file, $fileList, $filePath, $offset, classCanBeAdded(), getStatArray(), incrementProgressStat(), log(), setStatArray(), startProgressOutput(), stopProgressOutput(), UNDEFINED_TOKEN, and updateProgressOutput().

Referenced by buildAutoloadArrays().

## ◆ getMessages()

eZAutoloadGenerator::getMessages | ( |  | ) |

Get the array of logged messaages

Returns
  array

Definition at line 1177 of file ezautoloadgenerator.php.

## ◆ getStatArray()

eZAutoloadGenerator::getStatArray | ( |  | $phase | ) |
| protected

Fetches statistics array for $phase form the output object.

Parameters

  int | $phase |

Returns
  void

Definition at line 1302 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

## ◆ getWarnings()

eZAutoloadGenerator::getWarnings | ( |  | ) |

Get the array of logged warnings

Returns
  array

Definition at line 1187 of file ezautoloadgenerator.php.

## ◆ handleDefaultExcludeFile()

eZAutoloadGenerator::handleDefaultExcludeFile | ( |  | ) |
| protected

Adds exclude directories specified in the default excludes files, to the exclude array.

If the default exclude file '.autoloadignore' does not exist, the function will just return the user specified exclude directories. This function relies on the options object being available in the instance.

Returns
  array The exclude directories

Definition at line 284 of file ezautoloadgenerator.php.

References DEFAULT_EXCLUDE_FILE, and file_exists().

Referenced by fetchFiles().

## ◆ incrementProgressStat()

eZAutoloadGenerator::incrementProgressStat | ( |  | $phase,
|  |  | $stat
| ) |  |
| protected

Increment counters used for statistics in the progress output.

If the output object is not set, the method will not do anything.

Parameters

  int | $phase |
  array | $stat |

Returns
  void

Definition at line 1253 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

## ◆ log()

eZAutoloadGenerator::log | ( |  | $message | ) |
| protected

Pushes $message to the messages stack.

The $message will also tried to be emitted.

Parameters

  string | $message |

Returns
  void

Definition at line 1113 of file ezautoloadgenerator.php.

Referenced by findRecursive(), getClassFileList(), and logIssue().

## ◆ logIssue()

eZAutoloadGenerator::logIssue | ( |  | $class,
|  |  | $checkMode,
|  |  | $file,
|  |  | $inProgressAutoloadArray,
|  |  | $generatingMode
| ) |  |
| protected

Helper method for giving user feedback when check for class collisions.

The params are the same as for classExistsInArray().

Returns
  void

Definition at line 1075 of file ezautoloadgenerator.php.

References $checkMode, $message, log(), and logWarning().

## ◆ logWarning()

eZAutoloadGenerator::logWarning | ( |  | $message | ) |
| protected

Pushes $message to the warning stack.

The warning $message will also tried to be emitted.

Parameters

  string | $message |

Returns
  void

Definition at line 1127 of file ezautoloadgenerator.php.

Referenced by logIssue().

## ◆ nameTable()

eZAutoloadGenerator::nameTable | ( |  | $lookup | ) |
| protected

Table to look up file names to use for different run modes.

Parameters

  string | $lookup | Mode to look up, can be extension, or kernel.

Returns
  string

Definition at line 873 of file ezautoloadgenerator.php.

Referenced by writeAutoloadFiles().

## ◆ printAutoloadArray()

eZAutoloadGenerator::printAutoloadArray | ( |  | $printForMode = `null` | ) |

Prints out the generated autoload arrays.

Meant to provide a user-viewable output of the defined autoload arrays. If $printForMode is provided, only the array for that mode will be printed.

Parameters

  string | $printForMode | Run mode specified by the MODE_* constants.

Returns
  mixed

Definition at line 1202 of file ezautoloadgenerator.php.

## ◆ runMode()

eZAutoloadGenerator::runMode | ( |  | ) |
| protected

Generates the active bitmask for this instance of the autoload generation script depending on the parameters it sets the corresponding flags.

Returns
  int

Definition at line 802 of file ezautoloadgenerator.php.

References MODE_EXTENSION, MODE_KERNEL, MODE_KERNEL_OVERRIDE, MODE_NONE, MODE_SINGLE_EXTENSION, and MODE_TESTS.

Referenced by __construct().

## ◆ setMode()

eZAutoloadGenerator::setMode | ( |  | $modeValue | ) |

Convenience method to set the mode directly.

This is a method which allow you to set the operation mode directly and bypass the options object. The bitmask $modeValue can be set using the MODE_* class constants.

`$gen = new eZAutoloadGenerator(); $gen->setMode( eZAutoloadGenerator::MODE_EXTENSION | eZAutoloadGenerator::MODE_TESTS );`

Parameters

  int | $modeValue |

Returns
  void

Definition at line 859 of file ezautoloadgenerator.php.

## ◆ setOptions()

eZAutoloadGenerator::setOptions | ( |  | $options | ) |

Definition at line 1219 of file ezautoloadgenerator.php.

## ◆ setOutputCallback()

eZAutoloadGenerator::setOutputCallback | ( |  | $callback | ) |

Sets callback for outputting messages.

Parameters

  callback | $callback |

Returns
  void

Definition at line 1146 of file ezautoloadgenerator.php.

## ◆ setOutputObject()

eZAutoloadGenerator::setOutputObject | ( |  | $outputObject | ) |

Sets the object to handle out from the autoload generation.

Currently this is only handled for the CLI.

See also
  ezpAutoloadCliOutput

Parameters

  object | $outputObject |

Returns
  void

Definition at line 1336 of file ezautoloadgenerator.php.

## ◆ setStatArray()

eZAutoloadGenerator::setStatArray | ( |  | $phase,
|  |  | $data
| ) |  |
| protected

Updates internal statistics data for $phase, with new array $data.

Parameters

  int | $phase |
  array | $data |

Returns
  void

Definition at line 1318 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

## ◆ startProgressOutput()

eZAutoloadGenerator::startProgressOutput | ( |  | $phase | ) |
| protected

Initializes progress output for $phase

Parameters

  int | $phase |

Returns
  void

Definition at line 1270 of file ezautoloadgenerator.php.

Referenced by findRecursive(), and getClassFileList().

## ◆ stopProgressOutput()

eZAutoloadGenerator::stopProgressOutput | ( |  | $phase | ) |
| protected

Stops progress output for $phase

Parameters

  int | $phase |

Returns
  void

Definition at line 1286 of file ezautoloadgenerator.php.

Referenced by findRecursive(), and getClassFileList().

## ◆ targetTable()

eZAutoloadGenerator::targetTable | ( |  | $lookup | ) |
| protected

Provides a look-up for which base directory to use depending on mode.

Parameters

  int | $lookup |

Returns
  string

Definition at line 895 of file ezautoloadgenerator.php.

Referenced by writeAutoloadFiles().

## ◆ updateProgressOutput()

eZAutoloadGenerator::updateProgressOutput | ( |  | $phase | ) |
| protected

Calls updateProgress on the output object.

If progress output is not enabled or the output object is not set, this method will not do anything.

Parameters

  int | $phase |
  string | $array |

Returns
  void

Definition at line 1235 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

## ◆ walkRecursive()

static eZAutoloadGenerator::walkRecursive | ( |  | $sourceDir,
|  | array | $includeFilters,
|  | array | $excludeFilters,
|  |  | $callback,
|  | & | $callbackContext
| ) |  |
| static protected

Walks files and directories recursively on a file system. This methods is the same as ezcBaseFile::walkRecursive() except that it applies $excludeFilters directories where the original only applies $excludeFilters on files. As soon as https://issues.apache.org/jira/browse/ZETACOMP-85 is implemented, this method could be removed.

Parameters

  mixed | $sourceDir |
  array | $includeFilters |
  array | $excludeFilters |
  mixed | $callback |
  mixed | $callbackContext |

Exceptions

  ezcBaseFileNotFoundException | if the $sourceDir directory is not a directory or does not exist.
  ezcBaseFilePermissionException | if the $sourceDir directory could not be opened for reading.

Returns
  array

Definition at line 460 of file ezautoloadgenerator.php.

References $elements, and READ.

Referenced by findRecursive().

## ◆ writeAutoloadFiles()

eZAutoloadGenerator::writeAutoloadFiles | ( |  | ) |
| protected

Writes the autoload data in $data for the mode/location $location to actual files.

This method also make sure that the target directory exists, and directs the different autoload arrays to different destinations, depending on the operation mode.

Parameters

  int | $location |
  string | $data |

Returns
  void

Definition at line 217 of file ezautoloadgenerator.php.

References $file, $filePath, $location, dumpArrayEnd(), dumpArrayStart(), file_exists(), nameTable(), and targetTable().

Referenced by buildAutoloadArrays().

## Member Data Documentation

## ◆ $autoloadArrays

eZAutoloadGenerator::$autoloadArrays
| protected

Definition at line 94 of file ezautoloadgenerator.php.

## ◆ $existingAutoloadArrays

eZAutoloadGenerator::$existingAutoloadArrays
| protected

Definition at line 42 of file ezautoloadgenerator.php.

## ◆ $mask

eZAutoloadGenerator::$mask
| protected

Definition at line 33 of file ezautoloadgenerator.php.

## ◆ $messages

eZAutoloadGenerator::$messages
| protected

Definition at line 49 of file ezautoloadgenerator.php.

## ◆ $modeName

eZAutoloadGenerator::$modeName
| protected

Initial value:
= array(
self::MODE_KERNEL => "Kernel",
self::MODE_EXTENSION => "Extension",
self::MODE_TESTS => "Test",
self::MODE_SINGLE_EXTENSION =>"Single extension",
self::MODE_KERNEL_OVERRIDE => "Kernel overrides",
)

Definition at line 78 of file ezautoloadgenerator.php.

## ◆ $options

eZAutoloadGenerator::$options
| protected

Definition at line 26 of file ezautoloadgenerator.php.

Referenced by __construct().

## ◆ $output

eZAutoloadGenerator::$output
| protected

Definition at line 70 of file ezautoloadgenerator.php.

## ◆ $outputCallback

eZAutoloadGenerator::$outputCallback
| protected

Definition at line 63 of file ezautoloadgenerator.php.

## ◆ $warnings

eZAutoloadGenerator::$warnings
| protected

Definition at line 56 of file ezautoloadgenerator.php.

## ◆ DEFAULT_EXCLUDE_FILE

const eZAutoloadGenerator::DEFAULT_EXCLUDE_FILE = '.autoloadignore'

The name of the file which contains default exclude directories for the autoload generator.

Definition at line 146 of file ezautoloadgenerator.php.

Referenced by handleDefaultExcludeFile().

## ◆ MODE_EXTENSION

const eZAutoloadGenerator::MODE_EXTENSION = 2

Bitmask for search in extension files

Definition at line 109 of file ezautoloadgenerator.php.

Referenced by __construct(), dumpArrayStart(), fetchFiles(), and runMode().

## ◆ MODE_KERNEL

const eZAutoloadGenerator::MODE_KERNEL = 1

Bitmask for searhing in kernel files

Definition at line 104 of file ezautoloadgenerator.php.

Referenced by __construct(), dumpArrayStart(), fetchFiles(), and runMode().

## ◆ MODE_KERNEL_OVERRIDE

const eZAutoloadGenerator::MODE_KERNEL_OVERRIDE = 16

Bitmask for searching for kernel overrides.

This mode is mutually excluse from the other modes.

Definition at line 128 of file ezautoloadgenerator.php.

Referenced by dumpArrayStart(), fetchFiles(), and runMode().

## ◆ MODE_NONE

const eZAutoloadGenerator::MODE_NONE = 0

Bitmask for searching in no files.

Definition at line 99 of file ezautoloadgenerator.php.

Referenced by runMode().

## ◆ MODE_SINGLE_EXTENSION

const eZAutoloadGenerator::MODE_SINGLE_EXTENSION = 8

Bitmask for searching in a single extension only.

This mode is mutually exclusive from the other modes.

Definition at line 121 of file ezautoloadgenerator.php.

Referenced by dumpArrayStart(), fetchFiles(), and runMode().

## ◆ MODE_TESTS

const eZAutoloadGenerator::MODE_TESTS = 4

Bitmask for searching in test files

Definition at line 114 of file ezautoloadgenerator.php.

Referenced by __construct(), dumpArrayStart(), fetchFiles(), and runMode().

## ◆ OUTPUT_PROGRESS_PHASE1

const eZAutoloadGenerator::OUTPUT_PROGRESS_PHASE1 = 1

Represents the first phase of autoload generation, where the code searches for PHP source files.

Definition at line 134 of file ezautoloadgenerator.php.

Referenced by findRecursiveCallback(), ezpAutoloadCliOutput\getData(), and ezpAutoloadCliOutput\updateProgress().

## ◆ OUTPUT_PROGRESS_PHASE2

const eZAutoloadGenerator::OUTPUT_PROGRESS_PHASE2 = 2

Represents the second phase of autoload generation, where the code tokenizes the found PHP files to look for classes and interfaces.

Definition at line 140 of file ezautoloadgenerator.php.

Referenced by ezpAutoloadCliOutput\getData(), and ezpAutoloadCliOutput\updateProgress().

## ◆ UNDEFINED_TOKEN

const eZAutoloadGenerator::UNDEFINED_TOKEN = -1

Undefined token value

Definition at line 151 of file ezautoloadgenerator.php.

Referenced by getClassFileList().

The documentation for this class was generated from the following file:

- ezautoloadgenerator.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.