PHP Class Zephir\CompilerFile

This class represents every file compiled in a project Every file may contain a class or an interface
Show file Open project: phalcon/zephir Class Usage Examples

Protected Properties

Property Type Description
$_aliasManager zephir\AliasManager
$_classDefinition ClassDefinition
$_className
$_compiledFile
$_config zephir\Config
$_external
$_filePath
$_functionDefinitions zephir\FunctionDefinition[]
$_headerCBlocks array
$_ir Original internal representation (IR) of the file
$_logger zephir\Logger
$_namespace Namespace of the
$_originalNode

Public Methods

Method Description
__construct ( string $className, string $filePath, zephir\Config $config, zephir\Logger $logger ) CompilerFile constructor
addFunction ( Compiler $compiler, zephir\FunctionDefinition $func, array $statement = null ) Adds a function to the function definitions
applyClassHeaders ( zephir\CompilationContext $compilationContext )
checkDependencies ( Compiler $compiler ) Check dependencies
compile ( Compiler $compiler, zephir\StringsManager $stringsManager ) Compiles the file
compileClass ( zephir\CompilationContext $compilationContext, string $namespace, array $classStatement ) Compiles the class/interface contained in the file
compileComment ( zephir\CompilationContext $compilationContext, array $topStatement ) Compiles a comment as a top-level statement
compileFunction ( zephir\CompilationContext $compilationContext, zephir\FunctionDefinition $functionDefinition ) Compiles a function
genIR ( Compiler $compiler ) : array Compiles the file generating a JSON intermediate representation
getClassDefinition ( ) : ClassDefinition
getCompiledFile ( ) : string Returns the path to the compiled file
getFilePath ( ) : string Returns the path to the source file
getFunctionDefinitions ( )
isExternal ( ) : boolean
preCompile ( Compiler $compiler ) Pre-compiles a Zephir file. Generates the IR and perform basic validations
preCompileClass ( zephir\CompilationContext $compilationContext, string $namespace, array $topStatement, array $docblock ) Creates a definition for a class
preCompileInterface ( string $namespace, array $topStatement, array $docblock ) Creates a definition for an interface
setIsExternal ( boolean $external ) Sets if the class belongs to an external dependency or not

Protected Methods

Method Description
_processShorcuts ( array $property, ClassDefinition $classDefinition ) Creates the property shortcuts
createReturnsType ( array $types ) : array | null
getFullName ( string $name ) : string Transform class/interface name to FQN format

Method Details

__construct() public method

CompilerFile constructor
public __construct ( string $className, string $filePath, zephir\Config $config, zephir\Logger $logger )
$className string
$filePath string
$config zephir\Config
$logger zephir\Logger

_processShorcuts() protected method

Creates the property shortcuts
protected _processShorcuts ( array $property, ClassDefinition $classDefinition )
$property array
$classDefinition ClassDefinition

addFunction() public method

Adds a function to the function definitions
public addFunction ( Compiler $compiler, zephir\FunctionDefinition $func, array $statement = null )
$compiler Compiler
$func zephir\FunctionDefinition
$statement array

applyClassHeaders() public method

public applyClassHeaders ( zephir\CompilationContext $compilationContext )
$compilationContext zephir\CompilationContext

checkDependencies() public method

Check dependencies
public checkDependencies ( Compiler $compiler )
$compiler Compiler

compile() public method

Compiles the file
public compile ( Compiler $compiler, zephir\StringsManager $stringsManager )
$compiler Compiler
$stringsManager zephir\StringsManager

compileClass() public method

Compiles the class/interface contained in the file
public compileClass ( zephir\CompilationContext $compilationContext, string $namespace, array $classStatement )
$compilationContext zephir\CompilationContext
$namespace string
$classStatement array

compileComment() public method

Compiles a comment as a top-level statement
public compileComment ( zephir\CompilationContext $compilationContext, array $topStatement )
$compilationContext zephir\CompilationContext
$topStatement array

compileFunction() public method

Compiles a function
public compileFunction ( zephir\CompilationContext $compilationContext, zephir\FunctionDefinition $functionDefinition )
$compilationContext zephir\CompilationContext
$functionDefinition zephir\FunctionDefinition

createReturnsType() protected method

protected createReturnsType ( array $types ) : array | null
$types array
return array | null

genIR() public method

Compiles the file generating a JSON intermediate representation
public genIR ( Compiler $compiler ) : array
$compiler Compiler
return array

getClassDefinition() public method

public getClassDefinition ( ) : ClassDefinition
return ClassDefinition

getCompiledFile() public method

Returns the path to the compiled file
public getCompiledFile ( ) : string
return string

getFilePath() public method

Returns the path to the source file
public getFilePath ( ) : string
return string

getFullName() protected method

Transform class/interface name to FQN format
protected getFullName ( string $name ) : string
$name string
return string

getFunctionDefinitions() public method

isExternal() public method

public isExternal ( ) : boolean
return boolean

preCompile() public method

Pre-compiles a Zephir file. Generates the IR and perform basic validations
public preCompile ( Compiler $compiler )
$compiler Compiler

preCompileClass() public method

Creates a definition for a class
public preCompileClass ( zephir\CompilationContext $compilationContext, string $namespace, array $topStatement, array $docblock )
$compilationContext zephir\CompilationContext
$namespace string
$topStatement array
$docblock array

preCompileInterface() public method

Creates a definition for an interface
public preCompileInterface ( string $namespace, array $topStatement, array $docblock )
$namespace string
$topStatement array
$docblock array

setIsExternal() public method

Sets if the class belongs to an external dependency or not
public setIsExternal ( boolean $external )
$external boolean

Property Details

$_aliasManager protected property

protected AliasManager,zephir $_aliasManager
return zephir\AliasManager

$_classDefinition protected property

protected ClassDefinition,zephir $_classDefinition
return ClassDefinition

$_className protected property

protected $_className

$_compiledFile protected property

protected $_compiledFile

$_config protected property

protected Config,zephir $_config
return zephir\Config

$_external protected property

protected $_external

$_filePath protected property

protected $_filePath

$_functionDefinitions protected property

protected FunctionDefinition[],zephir $_functionDefinitions
return zephir\FunctionDefinition[]

$_headerCBlocks protected property

protected array $_headerCBlocks
return array

$_ir protected property

Original internal representation (IR) of the file
protected $_ir

$_logger protected property

protected Logger,zephir $_logger
return zephir\Logger

$_namespace protected property

Namespace of the
protected $_namespace

$_originalNode protected property

protected $_originalNode