idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
8,800
|
public function addConstant ( ClassConstant $ constant ) { if ( isset ( $ this -> constants [ $ constant -> getName ( ) ] ) ) { throw new CompilerException ( "Constant '" . $ constant -> getName ( ) . "' was defined more than one time" ) ; } $ this -> constants [ $ constant -> getName ( ) ] = $ constant ; }
|
Adds a constant to the definition .
|
8,801
|
public function hasProperty ( $ name ) { if ( isset ( $ this -> properties [ $ name ] ) ) { return true ; } else { $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition ) { if ( $ extendsClassDefinition -> hasProperty ( $ name ) ) { return true ; } } return false ; } }
|
Checks if a class definition has a property .
|
8,802
|
public function getProperty ( $ propertyName ) { if ( isset ( $ this -> properties [ $ propertyName ] ) ) { return $ this -> properties [ $ propertyName ] ; } $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition ) { if ( $ extendsClassDefinition -> hasProperty ( $ propertyName ) ) { return $ extendsClassDefinition -> getProperty ( $ propertyName ) ; } } return false ; }
|
Returns a method definition by its name .
|
8,803
|
public function hasConstant ( $ name ) { if ( isset ( $ this -> constants [ $ name ] ) ) { return true ; } $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition ) { if ( $ extendsClassDefinition -> hasConstant ( $ name ) ) { return true ; } } return $ this -> hasConstantFromInterfaces ( $ name ) ; }
|
Checks if class definition has a property .
|
8,804
|
public function getConstant ( $ constantName ) { if ( ! \ is_string ( $ constantName ) ) { throw new InvalidArgumentException ( '$constantName must be string type' ) ; } if ( empty ( $ constantName ) ) { throw new InvalidArgumentException ( '$constantName must not be empty: ' . $ constantName ) ; } if ( isset ( $ this -> constants [ $ constantName ] ) ) { return $ this -> constants [ $ constantName ] ; } $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition ) { if ( $ extendsClassDefinition -> hasConstant ( $ constantName ) ) { return $ extendsClassDefinition -> getConstant ( $ constantName ) ; } } return $ this -> getConstantFromInterfaces ( $ constantName ) ; }
|
Returns a constant definition by its name .
|
8,805
|
public function addMethod ( ClassMethod $ method , $ statement = null ) { $ methodName = strtolower ( $ method -> getName ( ) ) ; if ( isset ( $ this -> methods [ $ methodName ] ) ) { throw new CompilerException ( "Method '" . $ method -> getName ( ) . "' was defined more than one time" , $ statement ) ; } $ this -> methods [ $ methodName ] = $ method ; }
|
Adds a method to the class definition .
|
8,806
|
public function hasMethod ( $ methodName ) { $ methodNameLower = strtolower ( $ methodName ) ; foreach ( $ this -> methods as $ name => $ method ) { if ( $ methodNameLower == $ name ) { return true ; } } $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition instanceof ClassDefinitionRuntime ) { try { $ extendsClassDefinition = $ this -> compiler -> getInternalClassDefinition ( $ extendsClassDefinition -> getName ( ) ) ; } catch ( \ ReflectionException $ e ) { return false ; } } while ( $ extendsClassDefinition instanceof self ) { if ( $ extendsClassDefinition -> hasMethod ( $ methodName ) ) { return true ; } $ extendsClassDefinition = $ extendsClassDefinition -> getExtendsClassDefinition ( ) ; } return false ; }
|
Checks if the class implements an specific name .
|
8,807
|
public function getMethod ( $ methodName , $ checkExtends = true ) { $ methodNameLower = strtolower ( $ methodName ) ; foreach ( $ this -> methods as $ name => $ method ) { if ( $ methodNameLower == $ name ) { return $ method ; } } if ( ! $ checkExtends ) { return false ; } $ extendsClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ extendsClassDefinition instanceof self ) { if ( $ extendsClassDefinition -> hasMethod ( $ methodName ) ) { return $ extendsClassDefinition -> getMethod ( $ methodName ) ; } } return false ; }
|
Returns a method by its name .
|
8,808
|
public function getPossibleMethodName ( $ methodName ) { $ methodNameLower = strtolower ( $ methodName ) ; foreach ( $ this -> methods as $ name => $ method ) { if ( metaphone ( $ methodNameLower ) == metaphone ( $ name ) ) { return $ method -> getName ( ) ; } } $ extendsClassDefinition = $ this -> extendsClassDefinition ; if ( $ extendsClassDefinition ) { return $ extendsClassDefinition -> getPossibleMethodName ( $ methodName ) ; } return false ; }
|
Tries to find the most similar name .
|
8,809
|
public function getClassEntry ( CompilationContext $ compilationContext = null ) { if ( $ this -> external ) { if ( ! \ is_object ( $ compilationContext ) ) { throw new Exception ( 'A compilation context is required' ) ; } $ this -> compiler = $ compilationContext -> compiler ; $ compilationContext -> headersManager -> add ( $ this -> getExternalHeader ( ) , HeadersManager :: POSITION_LAST ) ; } return strtolower ( str_replace ( '\\' , '_' , $ this -> namespace ) . '_' . $ this -> name ) . '_ce' ; }
|
Returns the name of the zend_class_entry according to the class name .
|
8,810
|
public function getExternalHeader ( ) { $ parts = explode ( '\\' , $ this -> namespace ) ; return 'ext/' . strtolower ( $ parts [ 0 ] . \ DIRECTORY_SEPARATOR . str_replace ( '\\' , \ DIRECTORY_SEPARATOR , $ this -> namespace ) . \ DIRECTORY_SEPARATOR . $ this -> name ) . '.zep' ; }
|
Returns an absolute location to the class header .
|
8,811
|
public function checkInterfaceImplements ( self $ classDefinition , self $ interfaceDefinition ) { foreach ( $ interfaceDefinition -> getMethods ( ) as $ method ) { if ( ! $ classDefinition -> hasMethod ( $ method -> getName ( ) ) ) { throw new CompilerException ( sprintf ( 'Class %s must implement a method called: "%s" as requirement of interface: "%s"' , $ classDefinition -> getCompleteName ( ) , $ method -> getName ( ) , $ interfaceDefinition -> getCompleteName ( ) ) ) ; } if ( ! $ method -> hasParameters ( ) ) { continue ; } $ implementedMethod = $ classDefinition -> getMethod ( $ method -> getName ( ) ) ; if ( $ implementedMethod -> getNumberOfRequiredParameters ( ) > $ method -> getNumberOfRequiredParameters ( ) || $ implementedMethod -> getNumberOfParameters ( ) < $ method -> getNumberOfParameters ( ) ) { throw new CompilerException ( sprintf ( 'Method %s::%s() does not have the same number of required parameters in interface: "%s"' , $ classDefinition -> getCompleteName ( ) , $ method -> getName ( ) , $ interfaceDefinition -> getCompleteName ( ) ) ) ; } } }
|
Checks if a class implements an interface .
|
8,812
|
public function getLocalOrParentInitMethod ( ) { $ method = $ this -> getInitMethod ( ) ; if ( $ method ) { $ parentClassDefinition = $ this -> getExtendsClassDefinition ( ) ; if ( $ parentClassDefinition instanceof self ) { $ method = $ parentClassDefinition -> getInitMethod ( ) ; if ( $ method ) { $ this -> addInitMethod ( $ method -> getStatementsBlock ( ) ) ; } } } return $ method ; }
|
Returns the initialization method if any does exist .
|
8,813
|
public function addInitMethod ( StatementsBlock $ statementsBlock ) { if ( ! $ statementsBlock -> isEmpty ( ) ) { $ initClassName = $ this -> getCNamespace ( ) . '_' . $ this -> getName ( ) ; $ classMethod = new ClassMethod ( $ this , [ 'internal' ] , 'zephir_init_properties_' . $ initClassName , null , $ statementsBlock ) ; $ classMethod -> setIsInitializer ( true ) ; $ this -> addMethod ( $ classMethod ) ; } }
|
Creates the initialization method .
|
8,814
|
public function addStaticInitMethod ( StatementsBlock $ statementsBlock ) { $ initClassName = $ this -> getCNamespace ( ) . '_' . $ this -> getName ( ) ; $ classMethod = new ClassMethod ( $ this , [ 'internal' ] , 'zephir_init_static_properties_' . $ initClassName , null , $ statementsBlock ) ; $ classMethod -> setIsInitializer ( true ) ; $ classMethod -> setIsStatic ( true ) ; $ this -> addMethod ( $ classMethod ) ; }
|
Creates the static initialization method .
|
8,815
|
public static function buildFromReflection ( \ ReflectionClass $ class ) { $ classDefinition = new self ( $ class -> getNamespaceName ( ) , $ class -> getName ( ) , $ class -> getShortName ( ) ) ; $ methods = $ class -> getMethods ( ) ; if ( \ count ( $ methods ) > 0 ) { foreach ( $ methods as $ method ) { $ parameters = [ ] ; foreach ( $ method -> getParameters ( ) as $ row ) { $ params = [ 'type' => 'parameter' , 'name' => $ row -> getName ( ) , 'const' => 0 , 'data-type' => 'variable' , 'mandatory' => ! $ row -> isOptional ( ) , ] ; if ( ! $ params [ 'mandatory' ] ) { try { $ params [ 'default' ] = $ row -> getDefaultValue ( ) ; } catch ( \ ReflectionException $ e ) { $ params [ 'default' ] = true ; } } $ parameters [ ] = $ params ; } $ classMethod = new ClassMethod ( $ classDefinition , [ ] , $ method -> getName ( ) , new ClassMethodParameters ( $ parameters ) ) ; $ classMethod -> setIsStatic ( $ method -> isStatic ( ) ) ; $ classMethod -> setIsBundled ( true ) ; $ classDefinition -> addMethod ( $ classMethod ) ; } } $ constants = $ class -> getConstants ( ) ; if ( \ count ( $ constants ) > 0 ) { foreach ( $ constants as $ constantName => $ constantValue ) { $ type = self :: _convertPhpConstantType ( \ gettype ( $ constantValue ) ) ; $ classConstant = new ClassConstant ( $ constantName , [ 'value' => $ constantValue , 'type' => $ type ] , null ) ; $ classDefinition -> addConstant ( $ classConstant ) ; } } $ properties = $ class -> getProperties ( ) ; if ( \ count ( $ properties ) > 0 ) { foreach ( $ properties as $ property ) { $ visibility = [ ] ; if ( $ property -> isPublic ( ) ) { $ visibility [ ] = 'public' ; } if ( $ property -> isPrivate ( ) ) { $ visibility [ ] = 'private' ; } if ( $ property -> isProtected ( ) ) { $ visibility [ ] = 'protected' ; } if ( $ property -> isStatic ( ) ) { $ visibility [ ] = 'static' ; } $ classProperty = new ClassProperty ( $ classDefinition , $ visibility , $ property -> getName ( ) , null , null , null ) ; $ classDefinition -> addProperty ( $ classProperty ) ; } } $ classDefinition -> setIsBundled ( true ) ; return $ classDefinition ; }
|
Builds a class definition from reflection .
|
8,816
|
public function drawFile ( AbstractFile $ file ) { $ outputFile = ltrim ( $ file -> getOutputFile ( ) , '/' ) ; $ output = pathinfo ( $ this -> outputDir . '/' . $ outputFile ) ; $ outputDirname = $ output [ 'dirname' ] ; $ outputBasename = $ output [ 'basename' ] ; $ outputFilename = $ outputDirname . '/' . $ outputBasename ; if ( ! file_exists ( $ outputDirname ) ) { mkdir ( $ outputDirname , 0777 , true ) ; } $ subDirNumber = \ count ( explode ( '/' , $ outputFile ) ) - 1 ; if ( $ subDirNumber > 0 ) { $ pathToRoot = str_repeat ( '../' , $ subDirNumber ) ; } else { $ pathToRoot = './' ; } $ template = new Template ( $ this , $ file -> getData ( ) , $ file -> getTemplateName ( ) ) ; $ template -> setPathToRoot ( $ pathToRoot ) ; $ template -> setThemeOptions ( $ this -> options ) ; $ template -> setProjectConfig ( $ this -> projectConfig ) ; touch ( $ outputFilename ) ; $ template -> write ( $ outputFilename ) ; }
|
Parse and draw the specified file .
|
8,817
|
public function getThemeInfoExtendAware ( $ name ) { if ( $ this -> extendedTheme ) { $ data = $ this -> extendedTheme -> getThemeInfoExtendAware ( $ name ) ; } else { $ data = [ ] ; } $ info = $ this -> getThemeInfo ( $ name ) ; array_unshift ( $ data , $ info ) ; return $ data ; }
|
Similar with getThemeInfo but includes the value for all extended themes and returns the results as an array .
|
8,818
|
public function buildStaticDirectory ( ) { $ outputStt = $ this -> getOutputPath ( 'asset' ) ; if ( ! file_exists ( $ outputStt ) ) { mkdir ( $ outputStt , 0777 , true ) ; } if ( $ this -> extendedTheme ) { $ this -> extendedTheme -> buildStaticDirectory ( ) ; } $ themeStt = $ this -> getThemePath ( 'static' ) ; if ( $ themeStt ) { $ files = [ ] ; $ this -> __copyDir ( $ themeStt , $ outputStt . '/static' , $ files ) ; foreach ( $ files as $ f ) { foreach ( $ this -> options as $ optName => $ opt ) { $ fcontent = file_get_contents ( $ f ) ; $ fcontent = str_replace ( '%_' . $ optName . '_%' , $ opt , $ fcontent ) ; file_put_contents ( $ f , $ fcontent ) ; } } } }
|
copy the static directory of the theme into the output directory .
|
8,819
|
public function getThemePathExtendsAware ( $ path ) { $ newPath = $ this -> getThemePath ( $ path ) ; if ( ! $ newPath ) { if ( $ this -> extendedTheme ) { return $ this -> extendedTheme -> getThemePathExtendsAware ( $ path ) ; } } return $ newPath ; }
|
find the path to a file in the theme or from the extended theme .
|
8,820
|
public function getThemePath ( $ path ) { $ path = pathinfo ( $ this -> themeDir . '/' . $ path ) ; $ pathDirname = $ path [ 'dirname' ] ; $ pathBasename = $ path [ 'basename' ] ; $ pathFilename = $ pathDirname . '/' . $ pathBasename ; if ( ! file_exists ( $ pathFilename ) ) { return null ; } return $ pathFilename ; }
|
find the path to a file in the theme .
|
8,821
|
private function throwStringException ( CodePrinter $ printer , $ class , $ message , $ expression ) { $ message = add_slashes ( $ message ) ; $ path = Compiler :: getShortUserPath ( $ expression [ 'file' ] ) ; $ printer -> output ( sprintf ( 'ZEPHIR_THROW_EXCEPTION_DEBUG_STR(%s, "%s", "%s", %s);' , $ class , $ message , $ path , $ expression [ 'line' ] ) ) ; $ printer -> output ( 'return;' ) ; }
|
Throws an exception escaping the data .
|
8,822
|
public function join ( $ caller , CompilationContext $ compilationContext , Call $ call , array $ expression ) { $ functionCall = BuilderFactory :: getInstance ( ) -> statements ( ) -> functionCall ( 'join' , $ expression [ 'parameters' ] ) -> addArgument ( $ caller ) -> setFile ( $ expression [ 'file' ] ) -> setLine ( $ expression [ 'line' ] ) -> setChar ( $ expression [ 'char' ] ) ; $ expression = new Expression ( $ functionCall -> build ( ) ) ; return $ expression -> compile ( $ compilationContext ) ; }
|
Transforms calls to method join to function calls to join .
|
8,823
|
public function setupOptimized ( CompilationContext $ compilationContext ) { if ( ! $ compilationContext -> config -> get ( 'internal-call-transformation' , 'optimizations' ) ) { return $ this ; } $ classDefinition = $ this -> getClassDefinition ( ) ; if ( '__invoke' == $ this -> getName ( ) || $ classDefinition -> isInterface ( ) ) { return $ this ; } if ( ! $ this -> isInternal ( ) && ! $ classDefinition -> isBundled ( ) ) { if ( $ this -> getNumberOfRequiredParameters ( ) != $ this -> getNumberOfParameters ( ) ) { return $ this ; } if ( $ this -> isConstructor ( ) ) { return $ this ; } $ optimizedName = $ this -> getName ( ) . '_zephir_internal_call' ; $ visibility = [ 'internal' ] ; $ statements = null ; if ( $ this -> statements ) { $ statements = new StatementsBlock ( json_decode ( json_encode ( $ this -> statements -> getStatements ( ) ) , true ) ) ; } $ optimizedMethod = new self ( $ classDefinition , $ visibility , $ optimizedName , $ this -> parameters , $ statements , $ this -> docblock , null , $ this -> expression ) ; $ optimizedMethod -> typeInference = $ this -> typeInference ; $ optimizedMethod -> setReturnTypes ( $ this -> returnTypes ) ; $ classDefinition -> addMethod ( $ optimizedMethod ) ; } return $ this ; }
|
Generate internal method s based on the equivalent PHP methods allowing bypassing php userspace for internal method calls .
|
8,824
|
public function hasReturnTypes ( ) { if ( \ count ( $ this -> returnTypes ) ) { return true ; } if ( \ count ( $ this -> returnClassTypes ) ) { return true ; } return false ; }
|
Checks if the method has return - type or cast hints .
|
8,825
|
public function areReturnTypesNullCompatible ( $ type = null ) { if ( \ count ( $ this -> returnTypes ) ) { foreach ( $ this -> returnTypes as $ returnType => $ definition ) { switch ( $ returnType ) { case 'null' : return true ; } } } return false ; }
|
Checks whether at least one return type hint is null compatible .
|
8,826
|
public function hasModifier ( $ modifier ) { foreach ( $ this -> visibility as $ visibility ) { if ( $ visibility == $ modifier ) { return true ; } } return false ; }
|
Checks whether the method has a specific modifier .
|
8,827
|
public function getModifiers ( ) { $ modifiers = [ ] ; foreach ( $ this -> visibility as $ visibility ) { switch ( $ visibility ) { case 'public' : $ modifiers [ 'ZEND_ACC_PUBLIC' ] = $ visibility ; break ; case 'protected' : $ modifiers [ 'ZEND_ACC_PROTECTED' ] = $ visibility ; break ; case 'private' : $ modifiers [ 'ZEND_ACC_PRIVATE' ] = $ visibility ; break ; case 'static' : $ modifiers [ 'ZEND_ACC_STATIC' ] = $ visibility ; break ; case 'final' : $ modifiers [ 'ZEND_ACC_FINAL' ] = $ visibility ; break ; case 'abstract' : $ modifiers [ 'ZEND_ACC_ABSTRACT' ] = $ visibility ; break ; case 'deprecated' : $ modifiers [ 'ZEND_ACC_DEPRECATED' ] = $ visibility ; break ; case 'inline' : break ; case 'scoped' : break ; case 'internal' : break ; default : throw new Exception ( 'Unknown modifier "' . $ visibility . '"' ) ; } } if ( '__construct' == $ this -> name ) { $ modifiers [ 'ZEND_ACC_CTOR' ] = true ; } else { if ( '__destruct' == $ this -> name ) { $ modifiers [ 'ZEND_ACC_DTOR' ] = true ; } } return implode ( '|' , array_keys ( $ modifiers ) ) ; }
|
Returns the C - modifier flags .
|
8,828
|
public function removeMemoryStackReferences ( SymbolTable $ symbolTable , $ containerCode ) { if ( ! $ symbolTable -> getMustGrownStack ( ) ) { $ containerCode = str_replace ( 'ZEPHIR_THROW_EXCEPTION_STR' , 'ZEPHIR_THROW_EXCEPTION_STRW' , $ containerCode ) ; $ containerCode = str_replace ( 'ZEPHIR_THROW_EXCEPTION_DEBUG_STR' , 'ZEPHIR_THROW_EXCEPTION_DEBUG_STRW' , $ containerCode ) ; $ containerCode = str_replace ( 'ZEPHIR_THROW_EXCEPTION_ZVAL' , 'ZEPHIR_THROW_EXCEPTION_ZVALW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_THIS' , 'RETURN_THISW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_LCTOR' , 'RETURN_LCTORW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_CTOR' , 'RETURN_CTORW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_NCTOR' , 'RETURN_NCTORW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_CCTOR' , 'RETURN_CCTORW' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_NULL' , 'RETURN_NULL' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_BOOL' , 'RETURN_BOOL' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_FALSE' , 'RETURN_FALSE' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_TRUE' , 'RETURN_TRUE' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_STRING' , 'RETURN_STRING' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_LONG' , 'RETURN_LONG' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_DOUBLE' , 'RETURN_DOUBLE' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_FALSE' , 'RETURN_FALSE' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_EMPTY_STRING' , 'RETURN_MM_EMPTY_STRING' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_EMPTY_ARRAY' , 'RETURN_EMPTY_ARRAY' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM_MEMBER' , 'RETURN_MEMBER' , $ containerCode ) ; $ containerCode = str_replace ( 'RETURN_MM()' , 'return' , $ containerCode ) ; $ containerCode = preg_replace ( '/[ \t]+ZEPHIR_MM_RESTORE\(\);' . PHP_EOL . '/s' , '' , $ containerCode ) ; } return $ containerCode ; }
|
Replace macros .
|
8,829
|
public function hasChildReturnStatementType ( $ statement ) { if ( ! isset ( $ statement [ 'statements' ] ) || ! \ is_array ( $ statement [ 'statements' ] ) ) { return false ; } if ( 'if' == $ statement [ 'type' ] ) { $ ret = false ; $ statements = $ statement [ 'statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { $ ret = true ; } else { $ ret = $ this -> hasChildReturnStatementType ( $ item ) ; } } if ( ! $ ret || ! isset ( $ statement [ 'else_statements' ] ) ) { return false ; } $ statements = $ statement [ 'else_statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { return true ; } else { return $ this -> hasChildReturnStatementType ( $ item ) ; } } } else { $ statements = $ statement [ 'statements' ] ; foreach ( $ statements as $ item ) { $ type = isset ( $ item [ 'type' ] ) ? $ item [ 'type' ] : null ; if ( 'return' == $ type || 'throw' == $ type ) { return true ; } else { return $ this -> hasChildReturnStatementType ( $ item ) ; } } } return false ; }
|
Simple method to check if one of the paths are returning the right expected type .
|
8,830
|
public function getArgInfoName ( ClassDefinition $ classDefinition = null ) { if ( null != $ classDefinition ) { return sprintf ( 'arginfo_%s_%s_%s' , strtolower ( $ classDefinition -> getCNamespace ( ) ) , strtolower ( $ classDefinition -> getName ( ) ) , strtolower ( $ this -> getName ( ) ) ) ; } return sprintf ( 'arginfo_%s' , strtolower ( $ this -> getInternalName ( ) ) ) ; }
|
Returns arginfo name for current method .
|
8,831
|
public function isReturnTypesHintDetermined ( ) { if ( 0 == \ count ( $ this -> returnTypes ) || $ this -> isVoid ( ) ) { return false ; } foreach ( $ this -> returnTypes as $ returnType => $ definition ) { switch ( $ returnType ) { case 'variable' : case 'callable' : case 'resource' : return false ; } if ( isset ( $ definition [ 'type' ] ) && 'return-type-annotation' === $ definition [ 'type' ] ) { if ( $ this -> areReturnTypesBoolCompatible ( ) || $ this -> areReturnTypesDoubleCompatible ( ) || $ this -> areReturnTypesIntCompatible ( ) || $ this -> areReturnTypesNullCompatible ( ) || $ this -> areReturnTypesStringCompatible ( ) || \ array_key_exists ( 'array' , $ this -> getReturnTypes ( ) ) ) { continue ; } return false ; } } return true ; }
|
Is method have determined return type hint .
|
8,832
|
public function areReturnTypesCompatible ( ) { if ( \ count ( $ this -> returnTypes ) > 2 ) { return false ; } if ( 2 == \ count ( $ this -> returnTypes ) && ! isset ( $ this -> returnTypes [ 'null' ] ) ) { return false ; } return true ; }
|
Checks if the method have compatible return types .
|
8,833
|
public function isSatisfiedBy ( ReturnType \ TypeInterface $ type ) { return $ this -> left -> isSatisfiedBy ( $ type ) && $ this -> right -> isSatisfiedBy ( $ type ) ; }
|
Checks if the composite AND of specifications passes .
|
8,834
|
protected function callParent ( $ methodName , array $ expression , $ symbolVariable , $ mustInit , $ isExpecting , ClassDefinition $ classDefinition , CompilationContext $ compilationContext , ClassMethod $ method ) { $ codePrinter = $ compilationContext -> codePrinter ; $ classCe = $ classDefinition -> getClassEntry ( $ compilationContext ) ; $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; if ( $ mustInit ) { $ symbolVariable -> setMustInitNull ( true ) ; $ symbolVariable -> trackVariant ( $ compilationContext ) ; } $ methodCache = $ compilationContext -> cacheManager -> getStaticMethodCache ( ) ; $ cachePointer = $ methodCache -> get ( $ compilationContext , isset ( $ method ) ? $ method : null ) ; if ( isset ( $ expression [ 'parameters' ] ) && \ count ( $ expression [ 'parameters' ] ) ) { $ params = $ this -> getResolvedParams ( $ expression [ 'parameters' ] , $ compilationContext , $ expression ) ; } else { $ params = [ ] ; } if ( ! \ count ( $ params ) ) { if ( $ isExpecting ) { if ( 'return_value' == $ symbolVariable -> getName ( ) ) { $ codePrinter -> output ( 'ZEPHIR_RETURN_CALL_PARENT(' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ');' ) ; } else { $ codePrinter -> output ( 'ZEPHIR_CALL_PARENT(&' . $ symbolVariable -> getName ( ) . ', ' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ');' ) ; } } else { $ codePrinter -> output ( 'ZEPHIR_CALL_PARENT(NULL, ' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ');' ) ; } } else { if ( $ isExpecting ) { if ( 'return_value' == $ symbolVariable -> getName ( ) ) { $ codePrinter -> output ( 'ZEPHIR_RETURN_CALL_PARENT(' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ', ' . implode ( ', ' , $ params ) . ');' ) ; } else { $ codePrinter -> output ( 'ZEPHIR_CALL_PARENT(&' . $ symbolVariable -> getName ( ) . ', ' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ', ' . implode ( ', ' , $ params ) . ');' ) ; } } else { $ codePrinter -> output ( 'ZEPHIR_CALL_PARENT(NULL, ' . $ classCe . ', getThis(), "' . $ methodName . '", ' . $ cachePointer . ', ' . implode ( ', ' , $ params ) . ');' ) ; } } foreach ( $ this -> getMustCheckForCopyVariables ( ) as $ checkVariable ) { $ codePrinter -> output ( 'zephir_check_temp_parameter(' . $ checkVariable . ');' ) ; } $ this -> addCallStatusOrJump ( $ compilationContext ) ; }
|
Calls static methods on the parent context .
|
8,835
|
public function getBooleanCode ( ) { if ( $ this -> code && ( 'true' == $ this -> code || true === $ this -> code ) ) { return '1' ; } else { if ( 'false' == $ this -> code || false === $ this -> code ) { return '0' ; } } return $ this -> code ; }
|
Returns a C representation for a boolean constant .
|
8,836
|
public function resolve ( $ result , CompilationContext $ compilationContext ) { if ( $ this -> code instanceof \ Closure ) { $ code = $ this -> code ; if ( ! $ result ) { $ tempVariable = $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext ) ; $ compilationContext -> codePrinter -> output ( $ code ( $ tempVariable -> getName ( ) ) ) ; $ tempVariable -> setIsInitialized ( true , $ compilationContext ) ; return $ tempVariable -> getName ( ) ; } return $ code ( $ result ) ; } return $ this -> code ; }
|
Resolves an expression Some code cannot be directly pushed into the generated source because it s missing some bound parts this method resolves the missing parts returning the generated code .
|
8,837
|
private function recursiveProcess ( $ src , $ dst , $ pattern = null , $ callback = 'copy' ) { $ success = true ; $ iterator = new \ DirectoryIterator ( $ src ) ; foreach ( $ iterator as $ item ) { $ pathName = $ item -> getPathname ( ) ; if ( ! is_readable ( $ pathName ) ) { $ this -> logger -> error ( 'File is not readable :' . $ pathName ) ; continue ; } $ fileName = $ item -> getFileName ( ) ; if ( $ item -> isDir ( ) ) { if ( '.' != $ fileName && '..' != $ fileName && '.libs' != $ fileName ) { if ( ! is_dir ( $ dst . \ DIRECTORY_SEPARATOR . $ fileName ) ) { mkdir ( $ dst . \ DIRECTORY_SEPARATOR . $ fileName , 0755 , true ) ; } $ this -> recursiveProcess ( $ pathName , $ dst . \ DIRECTORY_SEPARATOR . $ fileName , $ pattern , $ callback ) ; } } elseif ( ! $ pattern || ( $ pattern && 1 === preg_match ( $ pattern , $ fileName ) ) ) { $ path = $ dst . \ DIRECTORY_SEPARATOR . $ fileName ; $ success = $ success && \ call_user_func ( $ callback , $ pathName , $ path ) ; } } return $ success ; }
|
Copies the base kernel to the extension destination .
|
8,838
|
public function getNumberOfMethodCalls ( $ className , $ methodName ) { if ( isset ( $ this -> methodCalls [ $ className ] [ $ methodName ] ) ) { return $ this -> methodCalls [ $ className ] [ $ methodName ] ; } return 0 ; }
|
Returns the number of calls a function had .
|
8,839
|
public function getTemplateFileContents ( $ filename ) { $ templatePath = rtrim ( $ this -> config -> get ( 'templatepath' , 'backend' ) , '\\/' ) ; if ( empty ( $ templatepath ) ) { $ templatePath = $ this -> templatesPath ; } return file_get_contents ( "{$templatePath}/{$this->name}/{$filename}" ) ; }
|
Resolves the path to the source template file of the backend .
|
8,840
|
public function pass ( $ branchNumber , StatementsBlock $ block ) { $ this -> passStatementBlock ( $ branchNumber , $ block -> getStatements ( ) ) ; $ this -> branches [ $ branchNumber ] = 0 ; }
|
Do the compilation pass .
|
8,841
|
public function passLetStatement ( $ branchNumber , $ statement ) { foreach ( $ statement [ 'assignments' ] as $ assignment ) { if ( 'variable' == $ assignment [ 'assign-type' ] ) { if ( 'assign' == $ assignment [ 'operator' ] ) { switch ( $ assignment [ 'expr' ] [ 'type' ] ) { case 'variable' : case 'array-access' : case 'property-access' : case 'static-property-access' : case 'fcall' : case 'mcall' : case 'scall' : break ; default : $ this -> variablesToSkip [ $ branchNumber ] [ $ assignment [ 'variable' ] ] = 1 ; break ; } } } } }
|
Check assignment types for possible skip .
|
8,842
|
public function getVariables ( ) { $ variableStats = [ ] ; foreach ( $ this -> variablesToSkip as $ branchNumber => $ variables ) { foreach ( $ variables as $ variable => $ one ) { if ( ! isset ( $ variableStats [ $ variable ] ) ) { $ variableStats [ $ variable ] = 1 ; } else { ++ $ variableStats [ $ variable ] ; } } } $ variables = [ ] ; $ numberBranches = \ count ( $ this -> branches ) ; foreach ( $ variableStats as $ variable => $ number ) { if ( $ number == $ numberBranches ) { $ variables [ ] = $ variable ; } } return $ variables ; }
|
Returns a list of variables that are initialized in every analyzed branch .
|
8,843
|
public function setIdle ( $ idle ) { $ this -> idle = false ; if ( $ this -> reusable ) { $ this -> classTypes = [ ] ; $ this -> dynamicTypes = [ 'unknown' => true ] ; $ this -> idle = $ idle ; } }
|
Once a temporal variable is unused in a specific branch it is marked as idle .
|
8,844
|
public function setClassTypes ( $ classTypes ) { if ( $ classTypes ) { if ( \ is_string ( $ classTypes ) ) { if ( ! \ in_array ( $ classTypes , $ this -> classTypes ) ) { $ this -> classTypes [ ] = $ classTypes ; } } else { foreach ( $ classTypes as $ classType ) { if ( ! \ in_array ( $ classType , $ this -> classTypes ) ) { $ this -> classTypes [ ] = $ classType ; } } } } }
|
Sets the PHP class related to variable .
|
8,845
|
public function setDynamicTypes ( $ types ) { if ( $ types ) { unset ( $ this -> dynamicTypes [ 'unknown' ] ) ; if ( \ is_string ( $ types ) ) { if ( ! isset ( $ this -> dynamicTypes [ $ types ] ) ) { $ this -> dynamicTypes [ $ types ] = true ; } } else { foreach ( $ types as $ type => $ one ) { if ( ! isset ( $ this -> dynamicTypes [ $ one ] ) ) { $ this -> dynamicTypes [ $ one ] = true ; } } } } }
|
Sets the current dynamic type in a polymorphic variable .
|
8,846
|
public function hasAnyDynamicType ( $ types ) { if ( \ is_string ( $ types ) ) { return isset ( $ this -> dynamicTypes [ $ types ] ) ; } else { foreach ( $ types as $ type ) { if ( isset ( $ this -> dynamicTypes [ $ type ] ) ) { return true ; } } } return false ; }
|
Checks if the variable has any of the passed dynamic .
|
8,847
|
public function hasDifferentDynamicType ( $ types ) { $ number = 0 ; foreach ( $ types as $ type ) { if ( isset ( $ this -> dynamicTypes [ $ type ] ) ) { ++ $ number ; } } return 0 == $ number ; }
|
Check if the variable has at least one dynamic type to the ones passed in the list .
|
8,848
|
public function setIsInitialized ( $ initialized , CompilationContext $ compilationContext ) { $ this -> initialized = $ initialized ; if ( ! $ initialized || ! $ compilationContext -> branchManager instanceof BranchManager ) { return ; } $ currentBranch = $ compilationContext -> branchManager -> getCurrentBranch ( ) ; if ( $ currentBranch instanceof Branch ) { $ this -> initBranches [ ] = $ currentBranch ; } }
|
Sets if the variable is initialized This allow to throw an exception if the variable is being read without prior initialization .
|
8,849
|
public function enableDefaultAutoInitValue ( ) { switch ( $ this -> type ) { case 'char' : case 'boolean' : case 'bool' : case 'int' : case 'uint' : case 'long' : case 'ulong' : case 'double' : case 'zephir_ce_guard' : $ this -> defaultInitValue = 0 ; break ; case 'variable' : case 'string' : case 'array' : $ this -> defaultInitValue = null ; $ this -> setDynamicTypes ( 'null' ) ; $ this -> setMustInitNull ( true ) ; $ this -> setLocalOnly ( false ) ; break ; default : throw new CompilerException ( 'Cannot create an automatic safe default value for variable type: ' . $ this -> type ) ; } }
|
Sets an automatic safe default init value according to its type .
|
8,850
|
public function separate ( CompilationContext $ compilationContext ) { if ( 'this_ptr' != $ this -> getName ( ) && 'return_value' != $ this -> getName ( ) ) { $ compilationContext -> codePrinter -> output ( 'ZEPHIR_SEPARATE(' . $ compilationContext -> backend -> getVariableCode ( $ this ) . ');' ) ; } }
|
Separates variables before being updated .
|
8,851
|
public function initVariant ( CompilationContext $ compilationContext ) { if ( $ this -> numberSkips ) { -- $ this -> numberSkips ; return ; } if ( 'this_ptr' != $ this -> getName ( ) && 'return_value' != $ this -> getName ( ) ) { if ( false === $ this -> initBranch ) { $ this -> initBranch = $ compilationContext -> currentBranch ; } $ compilationContext -> headersManager -> add ( 'kernel/memory' ) ; if ( ! $ this -> isLocalOnly ( ) ) { $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; if ( $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; $ compilationContext -> backend -> initVar ( $ this , $ compilationContext , true , true ) ; } else { if ( $ this -> variantInits > 0 ) { if ( 0 === $ this -> initBranch ) { $ compilationContext -> codePrinter -> output ( 'ZEPHIR_INIT_BNVAR(' . $ this -> getName ( ) . ');' ) ; } else { $ this -> mustInitNull = true ; $ compilationContext -> backend -> initVar ( $ this , $ compilationContext , true , true ) ; } } else { $ compilationContext -> backend -> initVar ( $ this , $ compilationContext ) ; } } } else { if ( $ this -> variantInits > 0 || $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; $ compilationContext -> codePrinter -> output ( 'ZEPHIR_SINIT_NVAR(' . $ this -> getName ( ) . ');' ) ; } else { $ compilationContext -> codePrinter -> output ( 'ZEPHIR_SINIT_VAR(' . $ this -> getName ( ) . ');' ) ; } } ++ $ this -> variantInits ; $ this -> associatedClass = null ; } }
|
Initializes a variant variable .
|
8,852
|
public function trackVariant ( CompilationContext $ compilationContext ) { if ( $ this -> numberSkips ) { -- $ this -> numberSkips ; return ; } if ( 'this_ptr' != $ this -> getName ( ) && 'return_value' != $ this -> getName ( ) ) { if ( false === $ this -> initBranch ) { $ this -> initBranch = $ compilationContext -> currentBranch ; } if ( ! $ this -> isLocalOnly ( ) ) { $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; if ( $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; } else { if ( $ this -> variantInits > 0 ) { if ( 1 !== $ this -> initBranch ) { $ this -> mustInitNull = true ; } } } } else { if ( $ this -> variantInits > 0 || $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; } } ++ $ this -> variantInits ; } }
|
Tells the compiler a generated code will track the variable .
|
8,853
|
public function observeVariant ( CompilationContext $ compilationContext ) { if ( $ this -> numberSkips ) { -- $ this -> numberSkips ; return ; } $ name = $ this -> getName ( ) ; if ( 'this_ptr' != $ name && 'return_value' != $ name ) { if ( false === $ this -> initBranch ) { $ this -> initBranch = $ compilationContext -> currentBranch ; } $ compilationContext -> headersManager -> add ( 'kernel/memory' ) ; $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; $ symbol = $ compilationContext -> backend -> getVariableCode ( $ this ) ; if ( $ this -> variantInits > 0 || $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; $ compilationContext -> codePrinter -> output ( 'ZEPHIR_OBS_NVAR(' . $ symbol . ');' ) ; } else { $ compilationContext -> codePrinter -> output ( 'ZEPHIR_OBS_VAR(' . $ symbol . ');' ) ; } ++ $ this -> variantInits ; } }
|
Observes a variable in the memory frame without initialization .
|
8,854
|
public function observeOrNullifyVariant ( CompilationContext $ compilationContext ) { if ( $ this -> numberSkips ) { -- $ this -> numberSkips ; return ; } $ name = $ this -> getName ( ) ; if ( 'this_ptr' != $ name && 'return_value' != $ name ) { if ( false === $ this -> initBranch ) { $ this -> initBranch = $ compilationContext -> currentBranch ; } $ compilationContext -> headersManager -> add ( 'kernel/memory' ) ; $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; if ( $ this -> variantInits > 0 || $ compilationContext -> insideCycle ) { $ this -> mustInitNull = true ; } ++ $ this -> variantInits ; $ this -> setMustInitNull ( true ) ; } }
|
Observes a variable in the memory frame without initialization or nullify an existing allocated variable .
|
8,855
|
public function setPossibleValue ( CompiledExpression $ possibleValue , CompilationContext $ compilationContext ) { $ this -> possibleValue = $ possibleValue ; $ this -> possibleValueBranch = $ compilationContext -> branchManager -> getCurrentBranch ( ) ; }
|
Sets the latest CompiledExpression assigned to a variable .
|
8,856
|
public function addBranch ( Branch $ branch ) { if ( $ this -> currentBranch ) { $ branch -> setParentBranch ( $ this -> currentBranch ) ; $ this -> currentBranch = $ branch ; } else { $ this -> currentBranch = $ branch ; } $ branch -> setUniqueId ( $ this -> uniqueId ) ; $ branch -> setLevel ( $ this -> level ) ; ++ $ this -> level ; ++ $ this -> uniqueId ; if ( Branch :: TYPE_ROOT == $ branch -> getType ( ) ) { $ this -> setRootBranch ( $ branch ) ; } }
|
Sets the current active branch in the manager .
|
8,857
|
public function removeBranch ( Branch $ branch ) { $ parentBranch = $ branch -> getParentBranch ( ) ; $ this -> currentBranch = $ parentBranch ; -- $ this -> level ; }
|
Removes a branch from the branch manager .
|
8,858
|
private function resolveBackendClass ( ) { $ parser = new ArgvInput ( ) ; $ backend = $ parser -> getParameterOption ( '--backend' , null ) ; if ( null === $ backend ) { if ( getenv ( 'ZEPHIR_BACKEND' ) ) { $ backend = $ backend = getenv ( 'ZEPHIR_BACKEND' ) ; } elseif ( $ this -> container -> has ( 'ZEPHIR_BACKEND' ) ) { $ backend = $ this -> container -> get ( 'ZEPHIR_BACKEND' ) ; } } if ( null === $ backend ) { $ backend = BaseBackend :: getActiveBackend ( ) ; } $ className = "Zephir\\Backends\\{$backend}\\Backend" ; if ( ! class_exists ( $ className ) ) { throw new IllegalStateException ( sprintf ( 'Backend class "%s" doesn\'t exist.' , $ backend ) ) ; } return $ className ; }
|
Resolve backend class .
|
8,859
|
public function create ( $ className , $ filePath ) { $ compiler = new CompilerFile ( $ this -> config , new AliasManager ( ) , $ this -> filesystem ) ; $ compiler -> setClassName ( $ className ) ; $ compiler -> setFilePath ( $ filePath ) ; $ compiler -> setLogger ( $ this -> logger ) ; return $ compiler ; }
|
Creates CompilerFile instance .
|
8,860
|
public function findThemePathByName ( $ name ) { $ path = null ; foreach ( $ this -> themesDirectories as $ themeDir ) { $ path = rtrim ( $ themeDir , '\\/' ) . \ DIRECTORY_SEPARATOR . $ name ; if ( 0 !== strpos ( $ path , 'phar://' ) ) { $ path = realpath ( $ path ) ; } if ( is_dir ( $ path ) ) { break ; } } return $ path ; }
|
Search a theme by its name .
|
8,861
|
private function prepareThemeOptions ( $ themeConfig , $ options = null ) { $ parsedOptions = null ; if ( ! empty ( $ options ) ) { if ( '{' == $ options [ 0 ] ) { $ parsedOptions = json_decode ( trim ( $ options ) , true ) ; if ( ! $ parsedOptions || ! \ is_array ( $ parsedOptions ) ) { throw new Exception ( "Unable to parse json from 'theme-options' argument" ) ; } } else { if ( file_exists ( $ options ) ) { $ unparsed = file_get_contents ( $ options ) ; $ parsedOptions = json_decode ( $ unparsed , true ) ; if ( ! $ parsedOptions || ! \ is_array ( $ parsedOptions ) ) { throw new Exception ( sprintf ( "Unable to parse json from the file '%s'" , $ options ) ) ; } } else { throw new Exception ( sprintf ( "Unable to find file '%s'" , $ options ) ) ; } } } if ( \ is_array ( $ parsedOptions ) ) { $ options = array_merge ( $ themeConfig [ 'options' ] , $ parsedOptions ) ; } else { $ options = $ themeConfig [ 'options' ] ; } return $ options ; }
|
Prepare the options by merging the one in the project config with the one in the command line arg theme - options .
|
8,862
|
private function findOutputDirectory ( $ outputDir ) { $ outputDir = str_replace ( '%version%' , $ this -> config -> get ( 'version' ) , $ outputDir ) ; if ( '/' !== $ outputDir [ 0 ] ) { $ outputDir = getcwd ( ) . '/' . $ outputDir ; } return $ outputDir ; }
|
Find the directory where the doc is going to be generated depending on the command line options and the config .
|
8,863
|
private function findThemeDirectory ( $ themeConfig , $ path = null ) { $ themeDirectoriesConfig = $ this -> config -> get ( 'theme-directories' , 'api' ) ; if ( $ themeDirectoriesConfig ) { if ( \ is_array ( $ themeDirectoriesConfig ) ) { $ themesDirectories = $ themeDirectoriesConfig ; } else { throw new InvalidArgumentException ( "Invalid value for theme config 'theme-directories'" ) ; } } else { $ themesDirectories = [ ] ; } $ themesDirectories [ ] = $ this -> templatesPath . '/Api/themes' ; $ this -> themesDirectories = $ themesDirectories ; if ( ! empty ( $ path ) ) { if ( file_exists ( $ path ) && is_dir ( $ path ) ) { return $ path ; } else { throw new InvalidArgumentException ( sprintf ( "Invalid value for option 'theme-path': the theme '%s' was not found or is not a valid theme." , $ path ) ) ; } } if ( ! isset ( $ themeConfig [ 'name' ] ) || ! $ themeConfig [ 'name' ] ) { throw new ConfigException ( 'There is no theme neither in the the theme config nor as a command line argument' ) ; } return $ this -> findThemePathByName ( $ themeConfig [ 'name' ] ) ; }
|
Find the theme directory depending on the command line options and the config .
|
8,864
|
public function optimizeNot ( $ expr , CompilationContext $ compilationContext ) { if ( 'not' == $ expr [ 'type' ] ) { $ conditions = $ this -> optimize ( $ expr [ 'left' ] , $ compilationContext ) ; if ( false !== $ conditions ) { if ( null !== $ this -> unreachable ) { $ this -> unreachable = ! $ this -> unreachable ; } if ( null !== $ this -> unreachableElse ) { $ this -> unreachableElse = ! $ this -> unreachableElse ; } return '!(' . $ conditions . ')' ; } } return false ; }
|
Skips the not operator by recursively optimizing the expression at its right .
|
8,865
|
public function genIR ( Compiler $ compiler ) { $ normalizedPath = $ this -> filesystem -> normalizePath ( $ this -> filePath ) ; $ compilePath = "{$normalizedPath}.js" ; $ zepRealPath = realpath ( $ this -> filePath ) ; if ( $ this -> filesystem -> exists ( $ compilePath ) ) { $ modificationTime = $ this -> filesystem -> modificationTime ( $ compilePath ) ; if ( $ modificationTime < filemtime ( $ zepRealPath ) ) { $ this -> filesystem -> delete ( $ compilePath ) ; if ( false != $ this -> filesystem -> exists ( $ compilePath . '.php' ) ) { $ this -> filesystem -> delete ( $ compilePath . '.php' ) ; } } } $ ir = null ; if ( false == $ this -> filesystem -> exists ( $ compilePath ) ) { $ parser = $ compiler -> getParserManager ( ) -> getParser ( ) ; $ ir = $ parser -> parse ( $ zepRealPath ) ; $ this -> filesystem -> write ( $ compilePath , json_encode ( $ ir , JSON_PRETTY_PRINT ) ) ; } if ( false == $ this -> filesystem -> exists ( $ compilePath . '.php' ) ) { if ( empty ( $ ir ) ) { $ ir = json_decode ( $ this -> filesystem -> read ( $ compilePath ) , true ) ; } $ data = '<?php return ' . var_export ( $ ir , true ) . ';' ; $ this -> filesystem -> write ( $ compilePath . '.php' , $ data ) ; } $ contents = $ this -> filesystem -> requireFile ( $ compilePath . '.php' ) ; if ( false == \ is_array ( $ contents ) ) { throw new IllegalStateException ( sprintf ( 'Generating the intermediate representation for the file "%s" was failed.' , realpath ( $ this -> filePath ) ) ) ; } return $ contents ; }
|
Compiles the file generating a JSON intermediate representation .
|
8,866
|
public function preCompileInterface ( $ namespace , $ topStatement , $ docblock ) { $ classDefinition = new ClassDefinition ( $ namespace , $ topStatement [ 'name' ] ) ; $ classDefinition -> setIsExternal ( $ this -> external ) ; if ( isset ( $ topStatement [ 'extends' ] ) ) { foreach ( $ topStatement [ 'extends' ] as & $ extend ) { $ extend [ 'value' ] = $ this -> getFullName ( $ extend [ 'value' ] ) ; } $ classDefinition -> setImplementsInterfaces ( $ topStatement [ 'extends' ] ) ; } $ classDefinition -> setType ( 'interface' ) ; if ( \ is_array ( $ docblock ) ) { $ classDefinition -> setDocBlock ( $ docblock [ 'value' ] ) ; } if ( isset ( $ topStatement [ 'definition' ] ) ) { $ definition = $ topStatement [ 'definition' ] ; if ( isset ( $ definition [ 'constants' ] ) ) { foreach ( $ definition [ 'constants' ] as $ constant ) { $ classConstant = new ClassConstant ( $ constant [ 'name' ] , isset ( $ constant [ 'default' ] ) ? $ constant [ 'default' ] : null , isset ( $ constant [ 'docblock' ] ) ? $ constant [ 'docblock' ] : null ) ; $ classDefinition -> addConstant ( $ classConstant ) ; } } if ( isset ( $ definition [ 'methods' ] ) ) { foreach ( $ definition [ 'methods' ] as $ method ) { $ classMethod = new ClassMethod ( $ classDefinition , $ method [ 'visibility' ] , $ method [ 'name' ] , isset ( $ method [ 'parameters' ] ) ? new ClassMethodParameters ( $ method [ 'parameters' ] ) : null , null , isset ( $ method [ 'docblock' ] ) ? $ method [ 'docblock' ] : null , isset ( $ method [ 'return-type' ] ) ? $ method [ 'return-type' ] : null , $ method ) ; $ classDefinition -> addMethod ( $ classMethod , $ method ) ; } } } $ this -> classDefinition = $ classDefinition ; }
|
Creates a definition for an interface .
|
8,867
|
public function checkDependencies ( Compiler $ compiler ) { $ classDefinition = $ this -> classDefinition ; $ extendedClass = $ classDefinition -> getExtendsClass ( ) ; if ( $ extendedClass ) { if ( 'class' == $ classDefinition -> getType ( ) ) { if ( $ compiler -> isClass ( $ extendedClass ) ) { $ extendedDefinition = $ compiler -> getClassDefinition ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; } else { if ( $ compiler -> isBundledClass ( $ extendedClass ) ) { $ extendedDefinition = $ compiler -> getInternalClassDefinition ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; } else { $ extendedDefinition = new ClassDefinitionRuntime ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; $ this -> logger -> warning ( sprintf ( 'Cannot locate class "%s" when extending class "%s"' , $ extendedClass , $ classDefinition -> getCompleteName ( ) ) , [ 'nonexistent-class' , $ this -> originalNode ] ) ; } } } else { if ( $ compiler -> isInterface ( $ extendedClass ) ) { $ extendedDefinition = $ compiler -> getClassDefinition ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; } else { if ( $ compiler -> isBundledInterface ( $ extendedClass ) ) { $ extendedDefinition = $ compiler -> getInternalClassDefinition ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; } else { $ extendedDefinition = new ClassDefinitionRuntime ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; $ this -> logger -> warning ( sprintf ( 'Cannot locate class "%s" when extending interface "%s"' , $ extendedClass , $ classDefinition -> getCompleteName ( ) ) , [ 'nonexistent-class' , $ this -> originalNode ] ) ; } } } } $ implementedInterfaces = $ classDefinition -> getImplementedInterfaces ( ) ; if ( $ implementedInterfaces ) { $ interfaceDefinitions = [ ] ; foreach ( $ implementedInterfaces as $ interface ) { if ( $ compiler -> isInterface ( $ interface ) ) { $ interfaceDefinitions [ $ interface ] = $ compiler -> getClassDefinition ( $ interface ) ; } else { if ( $ compiler -> isBundledInterface ( $ interface ) ) { $ interfaceDefinitions [ $ interface ] = $ compiler -> getInternalClassDefinition ( $ interface ) ; } else { $ extendedDefinition = new ClassDefinitionRuntime ( $ extendedClass ) ; $ classDefinition -> setExtendsClassDefinition ( $ extendedDefinition ) ; $ this -> logger -> warning ( sprintf ( 'Cannot locate class "%s" when extending interface "%s"' , $ interface , $ classDefinition -> getCompleteName ( ) ) , [ 'nonexistent-class' , $ this -> originalNode ] ) ; } } } if ( $ interfaceDefinitions ) { $ classDefinition -> setImplementedInterfaceDefinitions ( $ interfaceDefinitions ) ; } } }
|
Check dependencies .
|
8,868
|
protected function createReturnsType ( array $ types , $ annotated = false ) { if ( ! $ types ) { return null ; } $ list = [ ] ; foreach ( $ types as $ type ) { $ list [ ] = [ 'type' => $ annotated ? 'return-type-annotation' : 'return-type-paramater' , 'data-type' => 'mixed' == $ type ? 'variable' : $ type , 'mandatory' => false , ] ; } return [ 'type' => 'return-type' , 'list' => $ list , 'void' => empty ( $ list ) , ] ; }
|
Create returns type list .
|
8,869
|
public function processExpectedReturn ( CompilationContext $ compilationContext ) { $ expr = $ this -> expression ; $ expression = $ expr -> getExpression ( ) ; $ mustInit = false ; $ symbolVariable = null ; $ isExpecting = $ expr -> isExpectingReturn ( ) ; if ( $ isExpecting ) { $ symbolVariable = $ expr -> getExpectingVariable ( ) ; if ( \ is_object ( $ symbolVariable ) ) { $ readDetector = new ReadDetector ( ) ; if ( $ readDetector -> detect ( $ symbolVariable -> getName ( ) , $ expression ) ) { $ symbolVariable = $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } else { $ mustInit = true ; } } else { $ symbolVariable = $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } } $ this -> mustInit = $ mustInit ; $ this -> symbolVariable = $ symbolVariable ; $ this -> isExpecting = $ isExpecting ; }
|
Processes the symbol variable that will be used to return the result of the symbol call .
|
8,870
|
public function processExpectedComplexLiteralReturn ( CompilationContext $ compilationContext ) { $ expr = $ this -> expression ; $ expression = $ expr -> getExpression ( ) ; $ mustInit = false ; $ isExpecting = $ expr -> isExpectingReturn ( ) ; if ( $ isExpecting ) { $ symbolVariable = $ expr -> getExpectingVariable ( ) ; if ( \ is_object ( $ symbolVariable ) ) { $ readDetector = new ReadDetector ( ) ; if ( $ readDetector -> detect ( $ symbolVariable -> getName ( ) , $ expression ) ) { $ symbolVariable = $ compilationContext -> symbolTable -> getTempComplexLiteralVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } else { $ mustInit = true ; } } else { $ symbolVariable = $ compilationContext -> symbolTable -> getTempComplexLiteralVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } } $ this -> mustInit = $ mustInit ; $ this -> symbolVariable = $ symbolVariable ; $ this -> isExpecting = $ isExpecting ; }
|
Processes the symbol variable that will be used to return the result of the symbol call . If a temporal variable is used as returned value only the body is freed between calls .
|
8,871
|
public function getSymbolVariable ( $ useTemp = false , CompilationContext $ compilationContext = null ) { $ symbolVariable = $ this -> symbolVariable ; if ( $ useTemp && ! \ is_object ( $ symbolVariable ) ) { return $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext ) ; } return $ symbolVariable ; }
|
Returns the symbol variable that must be returned by the call .
|
8,872
|
public function getResolvedParamsAsExpr ( $ parameters , CompilationContext $ compilationContext , $ expression , $ readOnly = false ) { if ( ! $ this -> resolvedParams ) { $ hasParametersByName = false ; foreach ( $ parameters as $ parameter ) { if ( isset ( $ parameter [ 'name' ] ) ) { $ hasParametersByName = true ; break ; } } if ( $ hasParametersByName ) { foreach ( $ parameters as $ parameter ) { if ( ! isset ( $ parameter [ 'name' ] ) ) { throw new CompilerException ( 'All parameters must use named' , $ parameter ) ; } } } if ( $ hasParametersByName ) { if ( $ this -> reflection ) { $ positionalParameters = [ ] ; foreach ( $ this -> reflection -> getParameters ( ) as $ position => $ reflectionParameter ) { if ( \ is_object ( $ reflectionParameter ) ) { $ positionalParameters [ $ reflectionParameter -> getName ( ) ] = $ position ; } else { $ positionalParameters [ $ reflectionParameter [ 'name' ] ] = $ position ; } } $ orderedParameters = [ ] ; foreach ( $ parameters as $ parameter ) { if ( isset ( $ positionalParameters [ $ parameter [ 'name' ] ] ) ) { $ orderedParameters [ $ positionalParameters [ $ parameter [ 'name' ] ] ] = $ parameter ; } else { throw new CompilerException ( 'Named parameter "' . $ parameter [ 'name' ] . '" is not a valid parameter name, available: ' . implode ( ', ' , array_keys ( $ positionalParameters ) ) , $ parameter [ 'parameter' ] ) ; } } $ parameters_count = \ count ( $ parameters ) ; for ( $ i = 0 ; $ i < $ parameters_count ; ++ $ i ) { if ( ! isset ( $ orderedParameters [ $ i ] ) ) { $ orderedParameters [ $ i ] = [ 'parameter' => [ 'type' => 'null' ] ] ; } } $ parameters = $ orderedParameters ; } } $ params = [ ] ; foreach ( $ parameters as $ parameter ) { if ( \ is_array ( $ parameter [ 'parameter' ] ) ) { $ paramExpr = new Expression ( $ parameter [ 'parameter' ] ) ; switch ( $ parameter [ 'parameter' ] [ 'type' ] ) { case 'property-access' : case 'array-access' : case 'static-property-access' : $ paramExpr -> setReadOnly ( true ) ; break ; default : $ paramExpr -> setReadOnly ( $ readOnly ) ; break ; } $ params [ ] = $ paramExpr -> compile ( $ compilationContext ) ; continue ; } if ( $ parameter [ 'parameter' ] instanceof CompiledExpression ) { $ params [ ] = $ parameter [ 'parameter' ] ; continue ; } throw new CompilerException ( 'Invalid expression ' , $ expression ) ; } $ this -> resolvedParams = $ params ; } return $ this -> resolvedParams ; }
|
Resolves parameters .
|
8,873
|
public function addCallStatusFlag ( CompilationContext $ compilationContext ) { if ( ! $ compilationContext -> symbolTable -> hasVariable ( 'ZEPHIR_LAST_CALL_STATUS' ) ) { $ callStatus = new Variable ( 'int' , 'ZEPHIR_LAST_CALL_STATUS' , $ compilationContext -> branchManager -> getCurrentBranch ( ) ) ; $ callStatus -> setIsInitialized ( true , $ compilationContext ) ; $ callStatus -> increaseUses ( ) ; $ callStatus -> setReadOnly ( true ) ; $ compilationContext -> symbolTable -> addRawVariable ( $ callStatus ) ; } }
|
Add the last - call - status flag to the current symbol table .
|
8,874
|
public function addCallStatusOrJump ( CompilationContext $ compilationContext ) { $ compilationContext -> headersManager -> add ( 'kernel/fcall' ) ; if ( $ compilationContext -> insideTryCatch ) { $ compilationContext -> codePrinter -> output ( 'zephir_check_call_status_or_jump(try_end_' . $ compilationContext -> currentTryCatch . ');' ) ; return ; } $ compilationContext -> codePrinter -> output ( 'zephir_check_call_status();' ) ; }
|
Checks the last call status or make a label jump to the next catch block .
|
8,875
|
public function checkTempParameters ( CompilationContext $ compilationContext ) { $ compilationContext -> headersManager -> add ( 'kernel/fcall' ) ; foreach ( $ this -> getMustCheckForCopyVariables ( ) as $ checkVariable ) { $ compilationContext -> codePrinter -> output ( 'zephir_check_temp_parameter(' . $ checkVariable . ');' ) ; } }
|
Checks if temporary parameters must be copied or not .
|
8,876
|
private function __tryRegisterAnnotation ( ) { if ( ( $ this -> annotationNameOpen || $ this -> annotationOpen ) && \ strlen ( $ this -> currentAnnotationStr ) > 0 ) { $ annotation = $ this -> __createAnnotation ( $ this -> currentAnnotationStr , $ this -> currentAnnotationContentStr ) ; $ this -> docblockObj -> addAnnotation ( $ annotation ) ; } $ this -> annotationNameOpen = false ; $ this -> annotationOpen = false ; }
|
check if there is a currently parsed annotation registers it and stops the current annotation parsing .
|
8,877
|
private function nextCharacter ( ) { ++ $ this -> currentCharIndex ; if ( $ this -> annotationLen <= $ this -> currentCharIndex ) { $ this -> currentChar = null ; } else { $ this -> currentChar = $ this -> annotation [ $ this -> currentCharIndex ] ; } return $ this -> currentChar ; }
|
moves the current cursor to the next character .
|
8,878
|
private function processOptionals ( array & $ expression , Call $ call , CompilationContext $ context ) { $ flags = null ; $ offset = null ; $ offsetParamOffset = 4 ; if ( isset ( $ expression [ 'parameters' ] [ 4 ] ) && 'int' === $ expression [ 'parameters' ] [ 4 ] [ 'parameter' ] [ 'type' ] ) { $ offset = $ expression [ 'parameters' ] [ 4 ] [ 'parameter' ] [ 'value' ] . ' ' ; unset ( $ expression [ 'parameters' ] [ 4 ] ) ; } if ( isset ( $ expression [ 'parameters' ] [ 3 ] ) && 'int' === $ expression [ 'parameters' ] [ 3 ] [ 'parameter' ] [ 'type' ] ) { $ flags = $ expression [ 'parameters' ] [ 3 ] [ 'parameter' ] [ 'value' ] . ' ' ; $ offsetParamOffset = 3 ; unset ( $ expression [ 'parameters' ] [ 3 ] ) ; } try { $ resolvedParams = $ call -> getReadOnlyResolvedParams ( $ expression [ 'parameters' ] , $ context , $ expression ) ; if ( null === $ offset && isset ( $ resolvedParams [ $ offsetParamOffset ] ) ) { $ context -> headersManager -> add ( 'kernel/operators' ) ; $ offset = 'zephir_get_intval(' . $ resolvedParams [ $ offsetParamOffset ] . ') ' ; } if ( null === $ flags && isset ( $ resolvedParams [ 3 ] ) ) { $ context -> headersManager -> add ( 'kernel/operators' ) ; $ flags = 'zephir_get_intval(' . $ resolvedParams [ 3 ] . ') ' ; } } catch ( Exception $ e ) { throw new CompilerException ( $ e -> getMessage ( ) , $ expression , $ e -> getCode ( ) , $ e ) ; } if ( null === $ flags ) { $ flags = '0 ' ; } if ( null === $ offset ) { $ offset = '0 ' ; } return [ $ flags , $ offset ] ; }
|
Process optional parameters .
|
8,879
|
private function createMatches ( array $ expression , CompilationContext $ context ) { if ( isset ( $ expression [ 'parameters' ] [ 2 ] ) ) { $ type = $ expression [ 'parameters' ] [ 2 ] [ 'parameter' ] [ 'type' ] ; if ( 'variable' !== $ type ) { throw new CompilerException ( 'Only variables can be passed by reference' , $ expression ) ; } $ name = $ expression [ 'parameters' ] [ 2 ] [ 'parameter' ] [ 'value' ] ; if ( ! $ variable = $ context -> symbolTable -> getVariable ( $ name ) ) { throw new CompilerException ( sprintf ( "Cannot mutate variable '%s' because it wasn't defined" , $ name ) , $ expression ) ; } if ( ! \ in_array ( $ variable -> getType ( ) , [ 'variable' , 'array' ] , true ) ) { throw new CompilerException ( sprintf ( "The '%s' variable must be either a variable or an array, got %s" , $ name , $ variable -> getType ( ) ) , $ expression ) ; } if ( false == $ variable -> isInitialized ( ) ) { $ variable -> initVariant ( $ context ) ; $ variable -> setIsInitialized ( true , $ context ) ; } } else { $ variable = $ context -> symbolTable -> addTemp ( 'variable' , $ context ) ; $ variable -> initVariant ( $ context ) ; } $ variable -> setDynamicTypes ( 'array' ) ; return $ variable ; }
|
Process the matches result .
|
8,880
|
private function getFileContents ( $ file ) { if ( ! isset ( $ this -> filesContent [ $ file ] ) ) { $ this -> filesContent [ $ file ] = file_exists ( $ file ) ? file ( $ file ) : [ ] ; } return $ this -> filesContent [ $ file ] ; }
|
Gets the contents of the files that are involved in the log message .
|
8,881
|
private function getRealCalledMethod ( CompilationContext $ compilationContext , Variable $ caller , $ methodName ) { $ compiler = $ compilationContext -> compiler ; $ numberPoly = 0 ; $ method = null ; if ( 'this' == $ caller -> getRealName ( ) ) { $ classDefinition = $ compilationContext -> classDefinition ; if ( $ classDefinition -> hasMethod ( $ methodName ) ) { ++ $ numberPoly ; $ method = $ classDefinition -> getMethod ( $ methodName ) ; } } else { $ classTypes = $ caller -> getClassTypes ( ) ; foreach ( $ classTypes as $ classType ) { if ( $ compiler -> isInterface ( $ classType ) ) { continue ; } if ( $ compiler -> isClass ( $ classType ) || $ compiler -> isBundledClass ( $ classType ) || $ compiler -> isBundledInterface ( $ classType ) ) { if ( $ compiler -> isClass ( $ classType ) ) { $ classDefinition = $ compiler -> getClassDefinition ( $ classType ) ; } else { $ classDefinition = $ compiler -> getInternalClassDefinition ( $ classType ) ; } if ( ! $ classDefinition ) { continue ; } if ( $ classDefinition -> hasMethod ( $ methodName ) && ! $ classDefinition -> isInterface ( ) ) { ++ $ numberPoly ; $ method = $ classDefinition -> getMethod ( $ methodName ) ; } } } } return [ $ numberPoly , $ method ] ; }
|
Examine internal class information and returns the method called .
|
8,882
|
public function getNomeDocumento ( ) { if ( ! $ this -> getDocumento ( ) ) { return $ this -> getNome ( ) ; } else { return $ this -> getNome ( ) . ' / ' . $ this -> getTipoDocumento ( ) . ': ' . $ this -> getDocumento ( ) ; } }
|
Retorna o nome e o documento formatados
|
8,883
|
public static function nFloat ( $ number , $ decimals = 2 , $ showThousands = false ) { if ( is_null ( $ number ) || empty ( self :: onlyNumbers ( $ number ) ) || floatval ( $ number ) == 0 ) { return 0 ; } $ pontuacao = preg_replace ( '/[0-9]/' , '' , $ number ) ; $ locale = ( mb_substr ( $ pontuacao , - 1 , 1 ) == ',' ) ? "pt-BR" : "en-US" ; $ formater = new \ NumberFormatter ( $ locale , \ NumberFormatter :: DECIMAL ) ; if ( $ decimals === false ) { $ decimals = 2 ; preg_match_all ( '/[0-9][^0-9]([0-9]+)/' , $ number , $ matches ) ; if ( ! empty ( $ matches [ 1 ] ) ) { $ decimals = mb_strlen ( rtrim ( $ matches [ 1 ] [ 0 ] , 0 ) ) ; } } return number_format ( $ formater -> parse ( $ number , \ NumberFormatter :: TYPE_DOUBLE ) , $ decimals , '.' , ( $ showThousands ? ',' : '' ) ) ; }
|
Mostra o Valor no float Formatado
|
8,884
|
public static function percentOf ( $ big , $ small , $ defaultOnZero = 0 ) { $ result = $ big > 0.01 ? ( ( $ small * 100 ) / $ big ) : $ defaultOnZero ; return self :: nFloat ( $ result ) ; }
|
Return percent x of y ;
|
8,885
|
protected function incrementDetalhe ( ) { $ this -> increment ++ ; $ detalhe = new Detalhe ( ) ; $ this -> detalhe [ $ this -> increment ] = $ detalhe ; }
|
Incrementa o detalhe .
|
8,886
|
public function addBoleto ( BoletoContract $ boleto ) { $ dados = $ boleto -> toArray ( ) ; $ dados [ 'codigo_barras' ] = $ this -> getImagemCodigoDeBarras ( $ dados [ 'codigo_barras' ] ) ; $ this -> boleto [ ] = $ dados ; return $ this ; }
|
Addiciona o boleto
|
8,887
|
public function toArray ( ) { $ array = [ 'header' => $ this -> header -> toArray ( ) , 'trailer' => $ this -> trailer -> toArray ( ) , 'detalhes' => new Collection ( ) ] ; foreach ( $ this -> detalhe as $ detalhe ) { $ array [ 'detalhes' ] -> push ( $ detalhe -> toArray ( ) ) ; } return $ array ; }
|
Retorna o array .
|
8,888
|
public function getCodigoCliente ( ) { if ( empty ( $ this -> codigoCliente ) ) { $ this -> codigoCliente = Util :: formatCnab ( '9' , $ this -> getCarteiraNumero ( ) , 4 ) . Util :: formatCnab ( '9' , $ this -> getAgencia ( ) , 5 ) . Util :: formatCnab ( '9' , $ this -> getConta ( ) , 7 ) . Util :: formatCnab ( '9' , $ this -> getContaDv ( ) ? : CalculoDV :: bradescoContaCorrente ( $ this -> getConta ( ) ) , 1 ) ; } return $ this -> codigoCliente ; }
|
Retorna o codigo do cliente .
|
8,889
|
public function addBoletos ( array $ boletos , $ withGroup = true ) { if ( $ withGroup ) { $ this -> StartPageGroup ( ) ; } foreach ( $ boletos as $ boleto ) { $ this -> addBoleto ( $ boleto ) ; } return $ this ; }
|
Addiciona o boletos
|
8,890
|
public function setJurosApos ( $ jurosApos ) { $ jurosApos = ( int ) $ jurosApos ; $ this -> jurosApos = $ jurosApos > 0 ? $ jurosApos : 0 ; return $ this ; }
|
Seta a quantidade de dias apos o vencimento que cobra o juros
|
8,891
|
public function getCodigoBarras ( ) { if ( ! empty ( $ this -> campoCodigoBarras ) ) { return $ this -> campoCodigoBarras ; } if ( ! $ this -> isValid ( $ messages ) ) { throw new \ Exception ( 'Campos requeridos pelo banco, aparentam estar ausentes ' . $ messages ) ; } $ codigo = Util :: numberFormatGeral ( $ this -> getCodigoBanco ( ) , 3 ) . $ this -> getMoeda ( ) . Util :: fatorVencimento ( $ this -> getDataVencimento ( ) ) . Util :: numberFormatGeral ( $ this -> getValor ( ) , 10 ) . $ this -> getCampoLivre ( ) ; $ resto = Util :: modulo11 ( $ codigo , 2 , 9 , 0 ) ; $ dv = ( in_array ( $ resto , [ 0 , 10 , 11 ] ) ) ? 1 : $ resto ; return $ this -> campoCodigoBarras = substr ( $ codigo , 0 , 4 ) . $ dv . substr ( $ codigo , 4 ) ; }
|
Retorna o codigo de barras
|
8,892
|
public function getDataRemessa ( $ format ) { if ( is_null ( $ this -> dataRemessa ) ) { return Carbon :: now ( ) -> format ( $ format ) ; } return $ this -> dataRemessa -> format ( $ format ) ; }
|
Retorna a data da remessa a ser gerada
|
8,893
|
public function download ( $ filename = null ) { if ( $ filename === null ) { $ filename = 'remessa.txt' ; } header ( 'Content-type: text/plain' ) ; header ( 'Content-Disposition: attachment; filename="' . $ filename . '"' ) ; echo $ this -> gerar ( ) ; }
|
Realiza o download da string retornada do metodo gerar
|
8,894
|
public function gerar ( ) { if ( ! $ this -> isValid ( $ messages ) ) { throw new \ Exception ( 'Campos requeridos pelo banco, aparentam estar ausentes ' . $ messages ) ; } $ stringRemessa = '' ; if ( $ this -> iRegistros < 1 ) { throw new \ Exception ( 'Nenhuma linha detalhe foi adicionada' ) ; } $ this -> header ( ) ; $ stringRemessa .= $ this -> valida ( $ this -> getHeader ( ) ) . $ this -> fimLinha ; $ this -> headerLote ( ) ; $ stringRemessa .= $ this -> valida ( $ this -> getHeaderLote ( ) ) . $ this -> fimLinha ; foreach ( $ this -> getDetalhes ( ) as $ i => $ detalhe ) { $ stringRemessa .= $ this -> valida ( $ detalhe ) . $ this -> fimLinha ; } $ this -> trailerLote ( ) ; $ stringRemessa .= $ this -> valida ( $ this -> getTrailerLote ( ) ) . $ this -> fimLinha ; $ this -> trailer ( ) ; $ stringRemessa .= $ this -> valida ( $ this -> getTrailer ( ) ) . $ this -> fimArquivo ; return Encoding :: toUTF8 ( $ stringRemessa ) ; }
|
Gera o arquivo retorna a string .
|
8,895
|
public function setCip ( $ cip ) { $ this -> cip = $ cip ; $ this -> variaveis_adicionais [ 'cip' ] = $ this -> getCip ( ) ; return $ this ; }
|
Define o campo CIP do boleto
|
8,896
|
public static function fromParser ( MangaReviewParser $ parser ) : MangaReview { $ instance = new self ( ) ; $ instance -> malId = $ parser -> getId ( ) ; $ instance -> url = $ parser -> getUrl ( ) ; $ instance -> helpfulCount = $ parser -> getHelpfulCount ( ) ; $ instance -> date = $ parser -> getDate ( ) ; $ instance -> reviewer = $ parser -> getReviewer ( ) ; $ instance -> content = $ parser -> getContent ( ) ; return $ instance ; }
|
Create an instance from an MangaReviewParser parser
|
8,897
|
public static function removeChildNodes ( Crawler $ crawler ) : Crawler { if ( ! $ crawler -> count ( ) ) { return $ crawler ; } $ crawler -> children ( ) -> each ( function ( Crawler $ crawler ) { $ node = $ crawler -> getNode ( 0 ) ; if ( $ node === null || $ node -> nodeType === 3 || \ in_array ( $ node -> nodeName , self :: ALLOWED_NODES , true ) ) { return ; } $ node -> parentNode -> removeChild ( $ node ) ; } ) ; return $ crawler ; }
|
Removes all html elements so the text is left over
|
8,898
|
public static function fromParser ( MangaParser $ parser ) : Manga { $ instance = new self ( ) ; $ instance -> title = $ parser -> getMangaTitle ( ) ; $ instance -> url = $ parser -> getMangaURL ( ) ; $ instance -> malId = $ parser -> getMangaId ( ) ; $ instance -> imageUrl = $ parser -> getMangaImageURL ( ) ; $ instance -> synopsis = $ parser -> getMangaSynopsis ( ) ; $ instance -> titleEnglish = $ parser -> getMangaTitleEnglish ( ) ; $ instance -> titleSynonyms = $ parser -> getMangaTitleSynonyms ( ) ; $ instance -> titleJapanese = $ parser -> getMangaTitleJapanese ( ) ; $ instance -> type = $ parser -> getMangaType ( ) ; $ instance -> chapters = $ parser -> getMangaChapters ( ) ; $ instance -> volumes = $ parser -> getMangaVolumes ( ) ; $ instance -> status = $ parser -> getMangaStatus ( ) ; $ instance -> publishing = $ instance -> status === 'Publishing' ; $ instance -> published = $ parser -> getPublished ( ) ; $ instance -> genres = $ parser -> getMangaGenre ( ) ; $ instance -> score = $ parser -> getMangaScore ( ) ; $ instance -> scoredBy = $ parser -> getMangaScoredBy ( ) ; $ instance -> rank = $ parser -> getMangaRank ( ) ; $ instance -> popularity = $ parser -> getMangaPopularity ( ) ; $ instance -> members = $ parser -> getMangaMembers ( ) ; $ instance -> favorites = $ parser -> getMangaFavorites ( ) ; $ instance -> related = $ parser -> getMangaRelated ( ) ; $ instance -> background = $ parser -> getMangaBackground ( ) ; $ instance -> authors = $ parser -> getMangaAuthors ( ) ; $ instance -> serializations = $ parser -> getMangaSerialization ( ) ; return $ instance ; }
|
Create an instance from an MangaParser parser
|
8,899
|
private function generateRegex ( $ stepText ) { return preg_replace ( array_keys ( self :: $ replacePatterns ) , array_values ( self :: $ replacePatterns ) , $ this -> escapeStepText ( $ stepText ) ) ; }
|
Generates regex from step text .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.