Overview

Namespaces

  • None
  • Peg
    • Cli
      • Commands
    • Config
    • Custom
      • Command
        • Action
          • Generate
          • Parse
      • CommandLine
      • Config
      • Localization
      • Utilities
    • Lib
      • Definitions
        • Element
      • Generator
      • Lexers
      • Plugins
      • Signals
        • Data
          • Definitions
          • Lexers
        • Type
  • PHP

Classes

  • Exporter
  • Importer
  • StandardType
  • Symbols
  • Type
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

Class Symbols

Represents a symbols table with all the definitions required to generate a PHP extension.

Namespace: Peg\Lib\Definitions
Located at src/Definitions/Symbols.php
Methods summary
public
# __construct( )

Default constructor.

Default constructor.

public
# Clear( )

Removes all the symbols stored on the container.

Removes all the symbols stored on the container.

public
# AddHeader( string $name, boolean $enabled = true )

Add a header file.

Add a header file.

Parameters

$name
string
$name Name of header file.
$enabled
boolean
$enabled Flag to inidicate if the header should be included as part of the code generation.
public
# AddConstant( Peg\Lib\Definitions\Element\Constant $constant, string $header, string $namespace = "\\" )

Adds a constant to the symbols table.

Adds a constant to the symbols table.

Parameters

$constant
Peg\Lib\Definitions\Element\Constant
$constant
$header
string
$header Name of header file where the constant resides.
$namespace
string
$namespace If omitted the constant is added at a global scope.
public
# AddEnumeration( Peg\Lib\Definitions\Element\Enumeration $enumeration, string $header, string $namespace = "\\" )

Adds an enumeration to the symbols table.

Adds an enumeration to the symbols table.

Parameters

$enumeration
Peg\Lib\Definitions\Element\Enumeration
$enumeration
$header
string
$header Name of header file where the constant resides.
$namespace
string
$namespace If omitted the constant is added at a global scope.
public
# AddTypeDef( Peg\Lib\Definitions\Element\TypeDef $typedef, string $header, string $namespace = "\\" )

Adds a type definition to the symbols table.

Adds a type definition to the symbols table.

Parameters

$typedef
Peg\Lib\Definitions\Element\TypeDef
$typedef
$header
string
$header Name of header file where the constant resides.
$namespace
string
$namespace If omitted the constant is added at a global scope.
public
# AddGlobalVar( Peg\Lib\Definitions\Element\GlobalVariable $global_variable, string $header, string $namespace = "\\" )

Adds a global variable to the symbols table.

Adds a global variable to the symbols table.

Parameters

$global_variable
Peg\Lib\Definitions\Element\GlobalVariable
$global_variable
$header
string
$header Name of header file where the constant resides.
$namespace
string
$namespace If omitted the constant is added at a global scope.
public
# AddFunction( Peg\Lib\Definitions\Element\FunctionElement $function, string $header, string $namespace = "\\" )

Adds a function to the symbols table.

Adds a function to the symbols table.

Parameters

$function
Peg\Lib\Definitions\Element\FunctionElement
$function
$header
string
$header Name of header file where the constant resides.
$namespace
string
$namespace If omitted the constant is added at a global scope.
public
# AddClass( Peg\Lib\Definitions\Element\ClassElement $class, string $header, string $namespace = "\\" )

Adds a class to the symbols table.

Adds a class to the symbols table.

Parameters

$class
Peg\Lib\Definitions\Element\ClassElement
$class
$header
string
$header Name of header file where the class resides.
$namespace
string
$namespace If omitted the class is added at a global scope.
public boolean
# ClassHasProperties( string $class_name )

Checks if a class has properties.

Checks if a class has properties.

Parameters

$class_name
string
$class_name

Returns

boolean
True if has properties, otherwise false.
public
# GetStandardType( Peg\Lib\Definitions\Element\VariableType $type )

Gets a standard type identifier for a variable type.

Gets a standard type identifier for a variable type.

Parameters

$type
Peg\Lib\Definitions\Element\VariableType
$type

Todo

Add hook|signal so a plugin can modify the returned type.
public
# GetPHPStandardType( Peg\Lib\Definitions\Element\VariableType $type )

Gets the php standard type identifier for a variable type.

Gets the php standard type identifier for a variable type.

Parameters

$type
Peg\Lib\Definitions\Element\VariableType
$type

Todo

Add hook|signal so a plugin can modify the returned type.
public Peg\Lib\Definitions\Element\TypeComponents
# GetComponents( string $type )

Get the components of a variable type as namespace and class by checking the whole symbols object for matches.

Get the components of a variable type as namespace and class by checking the whole symbols object for matches.

Parameters

$type
string
$type A plain variable type eg: somens::sometype, somens::someclass::sometype.

Returns

Peg\Lib\Definitions\Element\TypeComponents
public Peg\Lib\Definitions\Element\ClassElement[]
# GetClassChilds( string $class_name, mixed $namespace = "" )

Gets a list of child classes that inherit from the given class.

Gets a list of child classes that inherit from the given class.

Parameters

$class_name
string
$class_name
$namespace

Returns

Peg\Lib\Definitions\Element\ClassElement[]
public Peg\Lib\Definitions\Element\NamespaceElement
# HasNamespace( string $namespace, string $header = "" )

Check if the symbols object has a given namespace.

Check if the symbols object has a given namespace.

Parameters

$namespace
string
$namespace
$header
string
$header A specific header to search in.

Returns

Peg\Lib\Definitions\Element\NamespaceElement
or null if nothing found.
public Peg\Lib\Definitions\Element\Constant
# HasConstant( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has a constant.

Check if the symbols object has a constant.

Parameters

$name
string
$name Name of the constant can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\Constant
or null if nothing found.
public Peg\Lib\Definitions\Element\Enumeration
# HasEnumeration( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has an enumeration.

Check if the symbols object has an enumeration.

Parameters

$name
string
$name Name of the enumeration can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\Enumeration
or null if nothing found.
public Peg\Lib\Definitions\Element\TypeDef
# HasTypeDef( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has a typedef.

Check if the symbols object has a typedef.

Parameters

$name
string
$name Name of the typedef can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\TypeDef
or null if nothing found.

Todo

Resolve classes that are part of the name.
public Peg\Lib\Definitions\Element\GlobalVariable
# HasGlobalVariable( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has a global variable.

Check if the symbols object has a global variable.

Parameters

$name
string
$name Name of the global variable can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\GlobalVariable
or null if nothing found.
public Peg\Lib\Definitions\Element\FunctionElement
# HasFunction( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has a function.

Check if the symbols object has a function.

Parameters

$name
string
$name Name of the function can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\FunctionElement
or null if nothing found.
public Peg\Lib\Definitions\Element\ClassElement
# HasClass( string $name, string $header = "", string $namespace = "" )

Check if the symbols object has a class.

Check if the symbols object has a class.

Parameters

$name
string
$name Name of the class can include namespace separated by the :: operator or \.
$header
string
$header A specific header to search in.
$namespace
string
$namespace A specific namespace to search in.

Returns

Peg\Lib\Definitions\Element\ClassElement
or null if nothing found.

Todo

Resolve classes that are part of the name.
public Peg\Lib\Definitions\Element\Enumeration
# HasClassEnum( string $type )

Checks if a given type is a class enumeration. and class names separated by the :: operator or \.

Checks if a given type is a class enumeration. and class names separated by the :: operator or \.

Parameters

$type
string
$type

Returns

Peg\Lib\Definitions\Element\Enumeration
or null if nothing found.
public
# RemoveHeader( string $name )

Removes a header from the symbols object.

Removes a header from the symbols object.

Parameters

$name
string
$name
public
# RemoveNamespace( string $name, string $header = "" )

Removes a namespace from the symbols object.

Removes a namespace from the symbols object.

Parameters

$name
string
$name
$header
string
$header A specific header.
public
# RemoveConstant( string $name, string $namespace = "", string $header = "" )

Removes a constant from the symbols object.

Removes a constant from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
public
# RemoveEnumeration( string $name, string $namespace = "", string $header = "" )

Removes an enumeration from the symbols object.

Removes an enumeration from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
public
# RemoveTypeDef( string $name, string $namespace = "", string $header = "" )

Removes a typedef from the symbols object.

Removes a typedef from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
public
# RemoveGlobalVariable( string $name, string $namespace = "", string $header = "" )

Removes a global variable from the symbols object.

Removes a global variable from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
public
# RemoveFunction( string $name, string $namespace = "", string $header = "" )

Removes a function from the symbols object.

Removes a function from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
public
# RemoveClass( string $name, string $namespace = "", string $header = "" )

Removes a class from the symbols object.

Removes a class from the symbols object.

Parameters

$name
string
$name
$namespace
string
$namespace A specific namespace.
$header
string
$header A specific header.
Properties summary
public Peg\Lib\Definitions\Element\Header[] $headers
#

List of header files (#include)

List of header files (#include)

PEG Api API documentation generated by ApiGen 2.8.0