repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.addConstant
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; }
php
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; }
[ "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. @param ClassConstant $constant @throws CompilerException
[ "Adds", "a", "constant", "to", "the", "definition", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L500-L507
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.hasProperty
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; } }
php
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; } }
[ "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. @param string $name @return bool
[ "Checks", "if", "a", "class", "definition", "has", "a", "property", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L516-L530
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getProperty
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; }
php
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; }
[ "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. @param string $propertyName @return bool|ClassProperty
[ "Returns", "a", "method", "definition", "by", "its", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L539-L553
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.hasConstant
public function hasConstant($name) { if (isset($this->constants[$name])) { return true; } $extendsClassDefinition = $this->getExtendsClassDefinition(); if ($extendsClassDefinition) { if ($extendsClassDefinition->hasConstant($name)) { return true; } } /* * Check if constant is defined in interfaces */ return $this->hasConstantFromInterfaces($name); }
php
public function hasConstant($name) { if (isset($this->constants[$name])) { return true; } $extendsClassDefinition = $this->getExtendsClassDefinition(); if ($extendsClassDefinition) { if ($extendsClassDefinition->hasConstant($name)) { return true; } } /* * Check if constant is defined in interfaces */ return $this->hasConstantFromInterfaces($name); }
[ "public", "function", "hasConstant", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "constants", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "$", "extendsClassDefinition", "=", "$", "this", "->", "getExtendsClassDefinition", "(", ")", ";", "if", "(", "$", "extendsClassDefinition", ")", "{", "if", "(", "$", "extendsClassDefinition", "->", "hasConstant", "(", "$", "name", ")", ")", "{", "return", "true", ";", "}", "}", "/*\n * Check if constant is defined in interfaces\n */", "return", "$", "this", "->", "hasConstantFromInterfaces", "(", "$", "name", ")", ";", "}" ]
Checks if class definition has a property. @param string $name @return bool
[ "Checks", "if", "class", "definition", "has", "a", "property", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L562-L579
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getConstant
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); } } /* * Gets constant from interfaces */ return $this->getConstantFromInterfaces($constantName); }
php
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); } } /* * Gets constant from interfaces */ return $this->getConstantFromInterfaces($constantName); }
[ "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", ")", ";", "}", "}", "/*\n * Gets constant from interfaces\n */", "return", "$", "this", "->", "getConstantFromInterfaces", "(", "$", "constantName", ")", ";", "}" ]
Returns a constant definition by its name. @param string $constantName @return bool|ClassConstant @throws InvalidArgumentException
[ "Returns", "a", "constant", "definition", "by", "its", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L590-L615
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.addMethod
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; }
php
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; }
[ "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. @param ClassMethod $method @param array $statement @throws CompilerException
[ "Adds", "a", "method", "to", "the", "class", "definition", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L625-L633
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.hasMethod
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) { // Do nothing return false; } } while ($extendsClassDefinition instanceof self) { if ($extendsClassDefinition->hasMethod($methodName)) { return true; } $extendsClassDefinition = $extendsClassDefinition->getExtendsClassDefinition(); } return false; }
php
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) { // Do nothing return false; } } while ($extendsClassDefinition instanceof self) { if ($extendsClassDefinition->hasMethod($methodName)) { return true; } $extendsClassDefinition = $extendsClassDefinition->getExtendsClassDefinition(); } return false; }
[ "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", ")", "{", "// Do nothing", "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. @param string $methodName @return bool
[ "Checks", "if", "the", "class", "implements", "an", "specific", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L690-L720
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getMethod
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; }
php
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; }
[ "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. @param string $methodName @param bool $checkExtends @return bool|ClassMethod
[ "Returns", "a", "method", "by", "its", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L730-L751
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getPossibleMethodName
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; }
php
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; }
[ "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. @param string $methodName @return bool|string
[ "Tries", "to", "find", "the", "most", "similar", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L781-L797
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getClassEntry
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; /* * Automatically add the external header */ $compilationContext->headersManager->add($this->getExternalHeader(), HeadersManager::POSITION_LAST); } return strtolower(str_replace('\\', '_', $this->namespace).'_'.$this->name).'_ce'; }
php
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; /* * Automatically add the external header */ $compilationContext->headersManager->add($this->getExternalHeader(), HeadersManager::POSITION_LAST); } return strtolower(str_replace('\\', '_', $this->namespace).'_'.$this->name).'_ce'; }
[ "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", ";", "/*\n * Automatically add the external header\n */", "$", "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. @param CompilationContext $compilationContext @throws Exception @return string
[ "Returns", "the", "name", "of", "the", "zend_class_entry", "according", "to", "the", "class", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L808-L824
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getExternalHeader
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'; }
php
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'; }
[ "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. @return string
[ "Returns", "an", "absolute", "location", "to", "the", "class", "header", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L863-L868
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.checkInterfaceImplements
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() ) ); } } }
php
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() ) ); } } }
[ "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. @param ClassDefinition $classDefinition @param ClassDefinition $interfaceDefinition @throws CompilerException
[ "Checks", "if", "a", "class", "implements", "an", "interface", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L878-L910
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.getLocalOrParentInitMethod
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; }
php
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; }
[ "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. @return ClassMethod
[ "Returns", "the", "initialization", "method", "if", "any", "does", "exist", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L962-L976
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.addInitMethod
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); } }
php
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); } }
[ "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. @param StatementsBlock $statementsBlock
[ "Creates", "the", "initialization", "method", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L983-L999
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.addStaticInitMethod
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); }
php
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); }
[ "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. @param StatementsBlock $statementsBlock
[ "Creates", "the", "static", "initialization", "method", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L1006-L1021
train
phalcon/zephir
Library/ClassDefinition.php
ClassDefinition.buildFromReflection
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) { // TODO: dummy default value $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; }
php
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) { // TODO: dummy default value $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; }
[ "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", ")", "{", "// TODO: dummy default value", "$", "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. @param \ReflectionClass $class @return ClassDefinition
[ "Builds", "a", "class", "definition", "from", "reflection", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassDefinition.php#L1828-L1913
train
phalcon/zephir
Library/Documentation/Theme.php
Theme.drawFile
public function drawFile(AbstractFile $file) { $outputFile = ltrim($file->getOutputFile(), '/'); $output = pathinfo($this->outputDir.'/'.$outputFile); $outputDirname = $output['dirname']; $outputBasename = $output['basename']; $outputFilename = $outputDirname.'/'.$outputBasename; // todo : check if writable 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); }
php
public function drawFile(AbstractFile $file) { $outputFile = ltrim($file->getOutputFile(), '/'); $output = pathinfo($this->outputDir.'/'.$outputFile); $outputDirname = $output['dirname']; $outputBasename = $output['basename']; $outputFilename = $outputDirname.'/'.$outputBasename; // todo : check if writable 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); }
[ "public", "function", "drawFile", "(", "AbstractFile", "$", "file", ")", "{", "$", "outputFile", "=", "ltrim", "(", "$", "file", "->", "getOutputFile", "(", ")", ",", "'/'", ")", ";", "$", "output", "=", "pathinfo", "(", "$", "this", "->", "outputDir", ".", "'/'", ".", "$", "outputFile", ")", ";", "$", "outputDirname", "=", "$", "output", "[", "'dirname'", "]", ";", "$", "outputBasename", "=", "$", "output", "[", "'basename'", "]", ";", "$", "outputFilename", "=", "$", "outputDirname", ".", "'/'", ".", "$", "outputBasename", ";", "// todo : check if writable", "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. @param AbstractFile $file @throws Exception
[ "Parse", "and", "draw", "the", "specified", "file", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/Theme.php#L118-L147
train
phalcon/zephir
Library/Documentation/Theme.php
Theme.getThemeInfoExtendAware
public function getThemeInfoExtendAware($name) { if ($this->extendedTheme) { $data = $this->extendedTheme->getThemeInfoExtendAware($name); } else { $data = []; } $info = $this->getThemeInfo($name); array_unshift($data, $info); return $data; }
php
public function getThemeInfoExtendAware($name) { if ($this->extendedTheme) { $data = $this->extendedTheme->getThemeInfoExtendAware($name); } else { $data = []; } $info = $this->getThemeInfo($name); array_unshift($data, $info); return $data; }
[ "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. @param string $name @return array
[ "Similar", "with", "getThemeInfo", "but", "includes", "the", "value", "for", "all", "extended", "themes", "and", "returns", "the", "results", "as", "an", "array", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/Theme.php#L172-L183
train
phalcon/zephir
Library/Documentation/Theme.php
Theme.buildStaticDirectory
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); } } } }
php
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); } } } }
[ "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.
[ "copy", "the", "static", "directory", "of", "the", "theme", "into", "the", "output", "directory", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/Theme.php#L188-L216
train
phalcon/zephir
Library/Documentation/Theme.php
Theme.getThemePathExtendsAware
public function getThemePathExtendsAware($path) { $newPath = $this->getThemePath($path); if (!$newPath) { if ($this->extendedTheme) { return $this->extendedTheme->getThemePathExtendsAware($path); } } return $newPath; }
php
public function getThemePathExtendsAware($path) { $newPath = $this->getThemePath($path); if (!$newPath) { if ($this->extendedTheme) { return $this->extendedTheme->getThemePathExtendsAware($path); } } return $newPath; }
[ "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. @param $path @return string
[ "find", "the", "path", "to", "a", "file", "in", "the", "theme", "or", "from", "the", "extended", "theme", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/Theme.php#L286-L296
train
phalcon/zephir
Library/Documentation/Theme.php
Theme.getThemePath
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; }
php
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; }
[ "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. @param $path @return string
[ "find", "the", "path", "to", "a", "file", "in", "the", "theme", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/Theme.php#L305-L317
train
phalcon/zephir
Library/Statements/ThrowStatement.php
ThrowStatement.throwStringException
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;'); }
php
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;'); }
[ "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. @param CodePrinter $printer @param string $class @param string $message @param array $expression
[ "Throws", "an", "exception", "escaping", "the", "data", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Statements/ThrowStatement.php#L154-L168
train
phalcon/zephir
Library/Types/ArrayType.php
ArrayType.join
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); }
php
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); }
[ "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". @param object $caller @param CompilationContext $compilationContext @param Call $call @param array $expression @return bool|\Zephir\CompiledExpression
[ "Transforms", "calls", "to", "method", "join", "to", "function", "calls", "to", "join", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Types/ArrayType.php#L94-L106
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.setupOptimized
public function setupOptimized(CompilationContext $compilationContext) { if (!$compilationContext->config->get('internal-call-transformation', 'optimizations')) { return $this; } $classDefinition = $this->getClassDefinition(); /* Skip for closures */ if ('__invoke' == $this->getName() || $classDefinition->isInterface()) { return $this; } if (!$this->isInternal() && !$classDefinition->isBundled()) { /* Not supported for now */ 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; }
php
public function setupOptimized(CompilationContext $compilationContext) { if (!$compilationContext->config->get('internal-call-transformation', 'optimizations')) { return $this; } $classDefinition = $this->getClassDefinition(); /* Skip for closures */ if ('__invoke' == $this->getName() || $classDefinition->isInterface()) { return $this; } if (!$this->isInternal() && !$classDefinition->isBundled()) { /* Not supported for now */ 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; }
[ "public", "function", "setupOptimized", "(", "CompilationContext", "$", "compilationContext", ")", "{", "if", "(", "!", "$", "compilationContext", "->", "config", "->", "get", "(", "'internal-call-transformation'", ",", "'optimizations'", ")", ")", "{", "return", "$", "this", ";", "}", "$", "classDefinition", "=", "$", "this", "->", "getClassDefinition", "(", ")", ";", "/* Skip for closures */", "if", "(", "'__invoke'", "==", "$", "this", "->", "getName", "(", ")", "||", "$", "classDefinition", "->", "isInterface", "(", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "$", "this", "->", "isInternal", "(", ")", "&&", "!", "$", "classDefinition", "->", "isBundled", "(", ")", ")", "{", "/* Not supported for now */", "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. @param CompilationContext $compilationContext @return $this
[ "Generate", "internal", "method", "s", "based", "on", "the", "equivalent", "PHP", "methods", "allowing", "bypassing", "php", "userspace", "for", "internal", "method", "calls", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L421-L464
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.hasReturnTypes
public function hasReturnTypes() { if (\count($this->returnTypes)) { return true; } if (\count($this->returnClassTypes)) { return true; } return false; }
php
public function hasReturnTypes() { if (\count($this->returnTypes)) { return true; } if (\count($this->returnClassTypes)) { return true; } return false; }
[ "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. @return bool
[ "Checks", "if", "the", "method", "has", "return", "-", "type", "or", "cast", "hints", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L561-L572
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.areReturnTypesNullCompatible
public function areReturnTypesNullCompatible($type = null) { if (\count($this->returnTypes)) { foreach ($this->returnTypes as $returnType => $definition) { switch ($returnType) { case 'null': return true; } } } return false; }
php
public function areReturnTypesNullCompatible($type = null) { if (\count($this->returnTypes)) { foreach ($this->returnTypes as $returnType => $definition) { switch ($returnType) { case 'null': return true; } } } return false; }
[ "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. @param string $type @return bool
[ "Checks", "whether", "at", "least", "one", "return", "type", "hint", "is", "null", "compatible", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L581-L593
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.hasModifier
public function hasModifier($modifier) { foreach ($this->visibility as $visibility) { if ($visibility == $modifier) { return true; } } return false; }
php
public function hasModifier($modifier) { foreach ($this->visibility as $visibility) { if ($visibility == $modifier) { return true; } } return false; }
[ "public", "function", "hasModifier", "(", "$", "modifier", ")", "{", "foreach", "(", "$", "this", "->", "visibility", "as", "$", "visibility", ")", "{", "if", "(", "$", "visibility", "==", "$", "modifier", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks whether the method has a specific modifier. @param string $modifier @return bool
[ "Checks", "whether", "the", "method", "has", "a", "specific", "modifier", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L780-L789
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.getModifiers
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)); }
php
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)); }
[ "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. @throws Exception @return string
[ "Returns", "the", "C", "-", "modifier", "flags", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L813-L869
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.removeMemoryStackReferences
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; }
php
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; }
[ "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. @param SymbolTable $symbolTable @param string $containerCode @return mixed
[ "Replace", "macros", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L1061-L1088
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.hasChildReturnStatementType
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; }
php
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; }
[ "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. @param array $statement @return bool
[ "Simple", "method", "to", "check", "if", "one", "of", "the", "paths", "are", "returning", "the", "right", "expected", "type", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L2228-L2273
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.getArgInfoName
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())); }
php
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())); }
[ "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. @param ClassDefinition|null $classDefinition @return string
[ "Returns", "arginfo", "name", "for", "current", "method", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L2292-L2304
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.isReturnTypesHintDetermined
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; } /* * @todo Probable we should detect return type more more carefully. * It is hard to process return type from the annotations at this time. * Thus we just return false here. */ return false; } } return true; }
php
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; } /* * @todo Probable we should detect return type more more carefully. * It is hard to process return type from the annotations at this time. * Thus we just return false here. */ return false; } } return true; }
[ "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", ";", "}", "/*\n * @todo Probable we should detect return type more more carefully.\n * It is hard to process return type from the annotations at this time.\n * Thus we just return false here.\n */", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Is method have determined return type hint. This method is used to generate: - ZEND_BEGIN_ARG_INFO_EX - ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX Examples: - FALSE: function foo() -> void; - TRUE: function foo() -> null; - TRUE: function foo() -> bool|string|..; - TRUE: function foo() -> <\stdClass>; - FALSE: function foo(); - FALSE: function foo() -> var; - FALSE: function foo() -> resource|callable; @return bool
[ "Is", "method", "have", "determined", "return", "type", "hint", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L2326-L2361
train
phalcon/zephir
Library/ClassMethod.php
ClassMethod.areReturnTypesCompatible
public function areReturnTypesCompatible() { // null | T1 | T2 if (\count($this->returnTypes) > 2) { return false; } // T1 | T2 if (2 == \count($this->returnTypes) && !isset($this->returnTypes['null'])) { return false; } return true; }
php
public function areReturnTypesCompatible() { // null | T1 | T2 if (\count($this->returnTypes) > 2) { return false; } // T1 | T2 if (2 == \count($this->returnTypes) && !isset($this->returnTypes['null'])) { return false; } return true; }
[ "public", "function", "areReturnTypesCompatible", "(", ")", "{", "// null | T1 | T2", "if", "(", "\\", "count", "(", "$", "this", "->", "returnTypes", ")", ">", "2", ")", "{", "return", "false", ";", "}", "// T1 | T2", "if", "(", "2", "==", "\\", "count", "(", "$", "this", "->", "returnTypes", ")", "&&", "!", "isset", "(", "$", "this", "->", "returnTypes", "[", "'null'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if the method have compatible return types. @return bool
[ "Checks", "if", "the", "method", "have", "compatible", "return", "types", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/ClassMethod.php#L2368-L2381
train
phalcon/zephir
Library/FunctionLike/ReturnType/Plus.php
Plus.isSatisfiedBy
public function isSatisfiedBy(ReturnType\TypeInterface $type) { return $this->left->isSatisfiedBy($type) && $this->right->isSatisfiedBy($type); }
php
public function isSatisfiedBy(ReturnType\TypeInterface $type) { return $this->left->isSatisfiedBy($type) && $this->right->isSatisfiedBy($type); }
[ "public", "function", "isSatisfiedBy", "(", "ReturnType", "\\", "TypeInterface", "$", "type", ")", "{", "return", "$", "this", "->", "left", "->", "isSatisfiedBy", "(", "$", "type", ")", "&&", "$", "this", "->", "right", "->", "isSatisfiedBy", "(", "$", "type", ")", ";", "}" ]
Checks if the composite AND of specifications passes. @param ReturnType\TypeInterface $type @return bool
[ "Checks", "if", "the", "composite", "AND", "of", "specifications", "passes", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/FunctionLike/ReturnType/Plus.php#L51-L54
train
phalcon/zephir
Library/StaticCall.php
StaticCall.callParent
protected function callParent($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, ClassMethod $method) { $codePrinter = $compilationContext->codePrinter; $classCe = $classDefinition->getClassEntry($compilationContext); //$className = str_replace('\\', '\\\\', $classDefinition->getCompleteName()); /* * Call static methods must grown the stack */ $compilationContext->symbolTable->mustGrownStack(true); if ($mustInit) { $symbolVariable->setMustInitNull(true); $symbolVariable->trackVariant($compilationContext); } /** * Check if the method call can have an inline cache. */ $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).');'); } } /* * Temporary variables must be copied if they have more than one reference */ foreach ($this->getMustCheckForCopyVariables() as $checkVariable) { $codePrinter->output('zephir_check_temp_parameter('.$checkVariable.');'); } $this->addCallStatusOrJump($compilationContext); }
php
protected function callParent($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, ClassMethod $method) { $codePrinter = $compilationContext->codePrinter; $classCe = $classDefinition->getClassEntry($compilationContext); //$className = str_replace('\\', '\\\\', $classDefinition->getCompleteName()); /* * Call static methods must grown the stack */ $compilationContext->symbolTable->mustGrownStack(true); if ($mustInit) { $symbolVariable->setMustInitNull(true); $symbolVariable->trackVariant($compilationContext); } /** * Check if the method call can have an inline cache. */ $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).');'); } } /* * Temporary variables must be copied if they have more than one reference */ foreach ($this->getMustCheckForCopyVariables() as $checkVariable) { $codePrinter->output('zephir_check_temp_parameter('.$checkVariable.');'); } $this->addCallStatusOrJump($compilationContext); }
[ "protected", "function", "callParent", "(", "$", "methodName", ",", "array", "$", "expression", ",", "$", "symbolVariable", ",", "$", "mustInit", ",", "$", "isExpecting", ",", "ClassDefinition", "$", "classDefinition", ",", "CompilationContext", "$", "compilationContext", ",", "ClassMethod", "$", "method", ")", "{", "$", "codePrinter", "=", "$", "compilationContext", "->", "codePrinter", ";", "$", "classCe", "=", "$", "classDefinition", "->", "getClassEntry", "(", "$", "compilationContext", ")", ";", "//$className = str_replace('\\\\', '\\\\\\\\', $classDefinition->getCompleteName());", "/*\n * Call static methods must grown the stack\n */", "$", "compilationContext", "->", "symbolTable", "->", "mustGrownStack", "(", "true", ")", ";", "if", "(", "$", "mustInit", ")", "{", "$", "symbolVariable", "->", "setMustInitNull", "(", "true", ")", ";", "$", "symbolVariable", "->", "trackVariant", "(", "$", "compilationContext", ")", ";", "}", "/**\n * Check if the method call can have an inline cache.\n */", "$", "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", ")", ".", "');'", ")", ";", "}", "}", "/*\n * Temporary variables must be copied if they have more than one reference\n */", "foreach", "(", "$", "this", "->", "getMustCheckForCopyVariables", "(", ")", "as", "$", "checkVariable", ")", "{", "$", "codePrinter", "->", "output", "(", "'zephir_check_temp_parameter('", ".", "$", "checkVariable", ".", "');'", ")", ";", "}", "$", "this", "->", "addCallStatusOrJump", "(", "$", "compilationContext", ")", ";", "}" ]
Calls static methods on the 'parent' context. @param string $methodName @param array $expression @param Variable $symbolVariable @param bool $mustInit @param bool $isExpecting @param ClassDefinition $classDefinition @param CompilationContext $compilationContext @param ClassMethod $method
[ "Calls", "static", "methods", "on", "the", "parent", "context", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/StaticCall.php#L373-L431
train
phalcon/zephir
Library/CompiledExpression.php
CompiledExpression.getBooleanCode
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; }
php
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; }
[ "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. @return string
[ "Returns", "a", "C", "representation", "for", "a", "boolean", "constant", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompiledExpression.php#L75-L86
train
phalcon/zephir
Library/CompiledExpression.php
CompiledExpression.resolve
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; }
php
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; }
[ "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. @param string $result @param CompilationContext $compilationContext @return string
[ "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", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompiledExpression.php#L135-L154
train
phalcon/zephir
Library/Console/Command/InitCommand.php
InitCommand.recursiveProcess
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; }
php
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; }
[ "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. @param $src @param $dst @param string $pattern @param mixed $callback @return bool
[ "Copies", "the", "base", "kernel", "to", "the", "extension", "destination", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Console/Command/InitCommand.php#L135-L163
train
phalcon/zephir
Library/Passes/CallGathererPass.php
CallGathererPass.getNumberOfMethodCalls
public function getNumberOfMethodCalls($className, $methodName) { if (isset($this->methodCalls[$className][$methodName])) { return $this->methodCalls[$className][$methodName]; } return 0; }
php
public function getNumberOfMethodCalls($className, $methodName) { if (isset($this->methodCalls[$className][$methodName])) { return $this->methodCalls[$className][$methodName]; } return 0; }
[ "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. @param string $className @param string $methodName @return int
[ "Returns", "the", "number", "of", "calls", "a", "function", "had", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Passes/CallGathererPass.php#L80-L87
train
phalcon/zephir
Library/BaseBackend.php
BaseBackend.getTemplateFileContents
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}" ); }
php
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}" ); }
[ "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. @param string $filename @return string
[ "Resolves", "the", "path", "to", "the", "source", "template", "file", "of", "the", "backend", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/BaseBackend.php#L91-L101
train
phalcon/zephir
Library/Passes/SkipVariantInit.php
SkipVariantInit.pass
public function pass($branchNumber, StatementsBlock $block) { $this->passStatementBlock($branchNumber, $block->getStatements()); $this->branches[$branchNumber] = 0; }
php
public function pass($branchNumber, StatementsBlock $block) { $this->passStatementBlock($branchNumber, $block->getStatements()); $this->branches[$branchNumber] = 0; }
[ "public", "function", "pass", "(", "$", "branchNumber", ",", "StatementsBlock", "$", "block", ")", "{", "$", "this", "->", "passStatementBlock", "(", "$", "branchNumber", ",", "$", "block", "->", "getStatements", "(", ")", ")", ";", "$", "this", "->", "branches", "[", "$", "branchNumber", "]", "=", "0", ";", "}" ]
Do the compilation pass. @param int $branchNumber @param StatementsBlock $block
[ "Do", "the", "compilation", "pass", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Passes/SkipVariantInit.php#L36-L40
train
phalcon/zephir
Library/Passes/SkipVariantInit.php
SkipVariantInit.passLetStatement
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; } } } } }
php
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; } } } } }
[ "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. @param int $branchNumber @param array $statement
[ "Check", "assignment", "types", "for", "possible", "skip", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Passes/SkipVariantInit.php#L48-L69
train
phalcon/zephir
Library/Passes/SkipVariantInit.php
SkipVariantInit.getVariables
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; }
php
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; }
[ "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. @return array
[ "Returns", "a", "list", "of", "variables", "that", "are", "initialized", "in", "every", "analyzed", "branch", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Passes/SkipVariantInit.php#L91-L114
train
phalcon/zephir
Library/Variable.php
Variable.setIdle
public function setIdle($idle) { $this->idle = false; if ($this->reusable) { $this->classTypes = []; $this->dynamicTypes = ['unknown' => true]; $this->idle = $idle; } }
php
public function setIdle($idle) { $this->idle = false; if ($this->reusable) { $this->classTypes = []; $this->dynamicTypes = ['unknown' => true]; $this->idle = $idle; } }
[ "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. @param bool $idle
[ "Once", "a", "temporal", "variable", "is", "unused", "in", "a", "specific", "branch", "it", "is", "marked", "as", "idle", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L343-L352
train
phalcon/zephir
Library/Variable.php
Variable.setClassTypes
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; } } } } }
php
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; } } } } }
[ "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. @param array|string $classTypes
[ "Sets", "the", "PHP", "class", "related", "to", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L477-L492
train
phalcon/zephir
Library/Variable.php
Variable.setDynamicTypes
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; } } } } }
php
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; } } } } }
[ "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. @param array|string $types
[ "Sets", "the", "current", "dynamic", "type", "in", "a", "polymorphic", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L529-L546
train
phalcon/zephir
Library/Variable.php
Variable.hasAnyDynamicType
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; }
php
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; }
[ "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. @param mixed $types @return bool
[ "Checks", "if", "the", "variable", "has", "any", "of", "the", "passed", "dynamic", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L565-L578
train
phalcon/zephir
Library/Variable.php
Variable.hasDifferentDynamicType
public function hasDifferentDynamicType($types) { $number = 0; foreach ($types as $type) { if (isset($this->dynamicTypes[$type])) { ++$number; } } return 0 == $number; }
php
public function hasDifferentDynamicType($types) { $number = 0; foreach ($types as $type) { if (isset($this->dynamicTypes[$type])) { ++$number; } } return 0 == $number; }
[ "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. @param array|string $types @return bool
[ "Check", "if", "the", "variable", "has", "at", "least", "one", "dynamic", "type", "to", "the", "ones", "passed", "in", "the", "list", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L587-L597
train
phalcon/zephir
Library/Variable.php
Variable.setIsInitialized
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; } }
php
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; } }
[ "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. @param bool $initialized @param CompilationContext $compilationContext
[ "Sets", "if", "the", "variable", "is", "initialized", "This", "allow", "to", "throw", "an", "exception", "if", "the", "variable", "is", "being", "read", "without", "prior", "initialization", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L642-L655
train
phalcon/zephir
Library/Variable.php
Variable.enableDefaultAutoInitValue
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); } }
php
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); } }
[ "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.
[ "Sets", "an", "automatic", "safe", "default", "init", "value", "according", "to", "its", "type", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L721-L748
train
phalcon/zephir
Library/Variable.php
Variable.separate
public function separate(CompilationContext $compilationContext) { if ('this_ptr' != $this->getName() && 'return_value' != $this->getName()) { $compilationContext->codePrinter->output('ZEPHIR_SEPARATE('.$compilationContext->backend->getVariableCode($this).');'); } }
php
public function separate(CompilationContext $compilationContext) { if ('this_ptr' != $this->getName() && 'return_value' != $this->getName()) { $compilationContext->codePrinter->output('ZEPHIR_SEPARATE('.$compilationContext->backend->getVariableCode($this).');'); } }
[ "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. @param CompilationContext $compilationContext
[ "Separates", "variables", "before", "being", "updated", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L765-L770
train
phalcon/zephir
Library/Variable.php
Variable.initVariant
public function initVariant(CompilationContext $compilationContext) { if ($this->numberSkips) { --$this->numberSkips; return; } /* * Variables are allocated for the first time using ZEPHIR_INIT_VAR * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR */ 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; } }
php
public function initVariant(CompilationContext $compilationContext) { if ($this->numberSkips) { --$this->numberSkips; return; } /* * Variables are allocated for the first time using ZEPHIR_INIT_VAR * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR */ 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; } }
[ "public", "function", "initVariant", "(", "CompilationContext", "$", "compilationContext", ")", "{", "if", "(", "$", "this", "->", "numberSkips", ")", "{", "--", "$", "this", "->", "numberSkips", ";", "return", ";", "}", "/*\n * Variables are allocated for the first time using ZEPHIR_INIT_VAR\n * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR\n * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR\n */", "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. @param CompilationContext $compilationContext
[ "Initializes", "a", "variant", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L826-L875
train
phalcon/zephir
Library/Variable.php
Variable.trackVariant
public function trackVariant(CompilationContext $compilationContext) { if ($this->numberSkips) { --$this->numberSkips; return; } /* * Variables are allocated for the first time using ZEPHIR_INIT_VAR * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR */ 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; } }
php
public function trackVariant(CompilationContext $compilationContext) { if ($this->numberSkips) { --$this->numberSkips; return; } /* * Variables are allocated for the first time using ZEPHIR_INIT_VAR * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR */ 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; } }
[ "public", "function", "trackVariant", "(", "CompilationContext", "$", "compilationContext", ")", "{", "if", "(", "$", "this", "->", "numberSkips", ")", "{", "--", "$", "this", "->", "numberSkips", ";", "return", ";", "}", "/*\n * Variables are allocated for the first time using ZEPHIR_INIT_VAR\n * the second, third, etc times are allocated using ZEPHIR_INIT_NVAR\n * Variables initialized for the first time in a cycle are always initialized using ZEPHIR_INIT_NVAR\n */", "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. @param CompilationContext $compilationContext
[ "Tells", "the", "compiler", "a", "generated", "code", "will", "track", "the", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L882-L919
train
phalcon/zephir
Library/Variable.php
Variable.observeVariant
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; } }
php
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; } }
[ "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. @param CompilationContext $compilationContext
[ "Observes", "a", "variable", "in", "the", "memory", "frame", "without", "initialization", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L966-L993
train
phalcon/zephir
Library/Variable.php
Variable.observeOrNullifyVariant
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); /** * TODO: Do we need this? * $compilationContext->codePrinter->output('ZEPHIR_OBS_NVAR(' . $this->getName() . ');');. * * TODO: What about else? * $compilationContext->codePrinter->output('ZEPHIR_OBS_VAR(' . $this->getName() . ');'); */ if ($this->variantInits > 0 || $compilationContext->insideCycle) { $this->mustInitNull = true; } ++$this->variantInits; $this->setMustInitNull(true); } }
php
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); /** * TODO: Do we need this? * $compilationContext->codePrinter->output('ZEPHIR_OBS_NVAR(' . $this->getName() . ');');. * * TODO: What about else? * $compilationContext->codePrinter->output('ZEPHIR_OBS_VAR(' . $this->getName() . ');'); */ if ($this->variantInits > 0 || $compilationContext->insideCycle) { $this->mustInitNull = true; } ++$this->variantInits; $this->setMustInitNull(true); } }
[ "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", ")", ";", "/**\n * TODO: Do we need this?\n * $compilationContext->codePrinter->output('ZEPHIR_OBS_NVAR(' . $this->getName() . ');');.\n *\n * TODO: What about else?\n * $compilationContext->codePrinter->output('ZEPHIR_OBS_VAR(' . $this->getName() . ');');\n */", "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. @param CompilationContext $compilationContext
[ "Observes", "a", "variable", "in", "the", "memory", "frame", "without", "initialization", "or", "nullify", "an", "existing", "allocated", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L1001-L1032
train
phalcon/zephir
Library/Variable.php
Variable.setPossibleValue
public function setPossibleValue(CompiledExpression $possibleValue, CompilationContext $compilationContext) { $this->possibleValue = $possibleValue; $this->possibleValueBranch = $compilationContext->branchManager->getCurrentBranch(); }
php
public function setPossibleValue(CompiledExpression $possibleValue, CompilationContext $compilationContext) { $this->possibleValue = $possibleValue; $this->possibleValueBranch = $compilationContext->branchManager->getCurrentBranch(); }
[ "public", "function", "setPossibleValue", "(", "CompiledExpression", "$", "possibleValue", ",", "CompilationContext", "$", "compilationContext", ")", "{", "$", "this", "->", "possibleValue", "=", "$", "possibleValue", ";", "$", "this", "->", "possibleValueBranch", "=", "$", "compilationContext", "->", "branchManager", "->", "getCurrentBranch", "(", ")", ";", "}" ]
Sets the latest CompiledExpression assigned to a variable. @param CompiledExpression $possibleValue @param CompilationContext $compilationContext
[ "Sets", "the", "latest", "CompiledExpression", "assigned", "to", "a", "variable", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Variable.php#L1160-L1164
train
phalcon/zephir
Library/BranchManager.php
BranchManager.addBranch
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); } }
php
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); } }
[ "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. @param Branch $branch
[ "Sets", "the", "current", "active", "branch", "in", "the", "manager", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/BranchManager.php#L36-L54
train
phalcon/zephir
Library/BranchManager.php
BranchManager.removeBranch
public function removeBranch(Branch $branch) { $parentBranch = $branch->getParentBranch(); $this->currentBranch = $parentBranch; --$this->level; }
php
public function removeBranch(Branch $branch) { $parentBranch = $branch->getParentBranch(); $this->currentBranch = $parentBranch; --$this->level; }
[ "public", "function", "removeBranch", "(", "Branch", "$", "branch", ")", "{", "$", "parentBranch", "=", "$", "branch", "->", "getParentBranch", "(", ")", ";", "$", "this", "->", "currentBranch", "=", "$", "parentBranch", ";", "--", "$", "this", "->", "level", ";", "}" ]
Removes a branch from the branch manager. @param Branch $branch
[ "Removes", "a", "branch", "from", "the", "branch", "manager", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/BranchManager.php#L61-L66
train
phalcon/zephir
Library/Backends/BackendFactory.php
BackendFactory.resolveBackendClass
private function resolveBackendClass() { $parser = new ArgvInput(); $backend = $parser->getParameterOption('--backend', null); if (null === $backend) { // Do not use this feature for typical use case. // Overriding backend using env var provided only for // testing purposes and may be removed in the future. // You SHOULD NOT rely on this possibility. 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; }
php
private function resolveBackendClass() { $parser = new ArgvInput(); $backend = $parser->getParameterOption('--backend', null); if (null === $backend) { // Do not use this feature for typical use case. // Overriding backend using env var provided only for // testing purposes and may be removed in the future. // You SHOULD NOT rely on this possibility. 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; }
[ "private", "function", "resolveBackendClass", "(", ")", "{", "$", "parser", "=", "new", "ArgvInput", "(", ")", ";", "$", "backend", "=", "$", "parser", "->", "getParameterOption", "(", "'--backend'", ",", "null", ")", ";", "if", "(", "null", "===", "$", "backend", ")", "{", "// Do not use this feature for typical use case.", "// Overriding backend using env var provided only for", "// testing purposes and may be removed in the future.", "// You SHOULD NOT rely on this possibility.", "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. @throws IllegalStateException @return string
[ "Resolve", "backend", "class", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Backends/BackendFactory.php#L51-L79
train
phalcon/zephir
Library/Compiler/CompilerFileFactory.php
CompilerFileFactory.create
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; }
php
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; }
[ "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. NOTE: Each instance of CompilerFile must have its own AliasManager instance. @param string $className @param string $filePath @return FileInterface
[ "Creates", "CompilerFile", "instance", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Compiler/CompilerFileFactory.php#L46-L55
train
phalcon/zephir
Library/Documentation.php
Documentation.findThemePathByName
public function findThemePathByName($name) { // check the theme from the config $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; }
php
public function findThemePathByName($name) { // check the theme from the config $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; }
[ "public", "function", "findThemePathByName", "(", "$", "name", ")", "{", "// check the theme from the config", "$", "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. Return the path to it if it exists. Otherwise NULL. @param string $name @return string|null
[ "Search", "a", "theme", "by", "its", "name", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation.php#L128-L145
train
phalcon/zephir
Library/Documentation.php
Documentation.prepareThemeOptions
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; }
php
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; }
[ "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". command line arg "theme-options" can be either a path to a json file containing the options or a raw json string @param array $themeConfig @param string|null $options @throws Exception @return array
[ "Prepare", "the", "options", "by", "merging", "the", "one", "in", "the", "project", "config", "with", "the", "one", "in", "the", "command", "line", "arg", "theme", "-", "options", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation.php#L240-L271
train
phalcon/zephir
Library/Documentation.php
Documentation.findOutputDirectory
private function findOutputDirectory($outputDir) { $outputDir = str_replace('%version%', $this->config->get('version'), $outputDir); if ('/' !== $outputDir[0]) { $outputDir = getcwd().'/'.$outputDir; } return $outputDir; }
php
private function findOutputDirectory($outputDir) { $outputDir = str_replace('%version%', $this->config->get('version'), $outputDir); if ('/' !== $outputDir[0]) { $outputDir = getcwd().'/'.$outputDir; } return $outputDir; }
[ "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. output directory is checked in this order : => check if the command line argument --output-directory was given => if not ; check if config config[api][path] was given @param string $outputDir @return string|null
[ "Find", "the", "directory", "where", "the", "doc", "is", "going", "to", "be", "generated", "depending", "on", "the", "command", "line", "options", "and", "the", "config", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation.php#L285-L294
train
phalcon/zephir
Library/Documentation.php
Documentation.findThemeDirectory
private function findThemeDirectory($themeConfig, $path = null) { // check if there are additional theme paths in the config $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; // check if the path was set from the command 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']); }
php
private function findThemeDirectory($themeConfig, $path = null) { // check if there are additional theme paths in the config $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; // check if the path was set from the command 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']); }
[ "private", "function", "findThemeDirectory", "(", "$", "themeConfig", ",", "$", "path", "=", "null", ")", "{", "// check if there are additional theme paths in the config", "$", "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", ";", "// check if the path was set from the command", "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. theme directory is checked in this order : => check if the command line argument --theme-path was given => if not ; find the different theme directories on the config $config['api']['theme-directories'] search the theme from the name ($config['api']['theme']['name'] in the theme directories, if nothing was found, we look in the zephir install dir default themes (templates/Api/themes) @param array $themeConfig @param string|null $path @throws InvalidArgumentException @throws ConfigException @return string|null
[ "Find", "the", "theme", "directory", "depending", "on", "the", "command", "line", "options", "and", "the", "config", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation.php#L313-L351
train
phalcon/zephir
Library/Optimizers/EvalExpression.php
EvalExpression.optimizeNot
public function optimizeNot($expr, CompilationContext $compilationContext) { /* * Compile the expression negating the evaluated expression */ 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; }
php
public function optimizeNot($expr, CompilationContext $compilationContext) { /* * Compile the expression negating the evaluated expression */ 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; }
[ "public", "function", "optimizeNot", "(", "$", "expr", ",", "CompilationContext", "$", "compilationContext", ")", "{", "/*\n * Compile the expression negating the evaluated expression\n */", "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. @param array $expr @param CompilationContext $compilationContext @return bool|string
[ "Skips", "the", "not", "operator", "by", "recursively", "optimizing", "the", "expression", "at", "its", "right", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Optimizers/EvalExpression.php#L42-L62
train
phalcon/zephir
Library/CompilerFile.php
CompilerFile.genIR
public function genIR(Compiler $compiler) { $normalizedPath = $this->filesystem->normalizePath($this->filePath); // TODO: JS => JSON $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; }
php
public function genIR(Compiler $compiler) { $normalizedPath = $this->filesystem->normalizePath($this->filePath); // TODO: JS => JSON $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; }
[ "public", "function", "genIR", "(", "Compiler", "$", "compiler", ")", "{", "$", "normalizedPath", "=", "$", "this", "->", "filesystem", "->", "normalizePath", "(", "$", "this", "->", "filePath", ")", ";", "// TODO: JS => JSON", "$", "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. @param Compiler $compiler @throws ParseException @throws IllegalStateException if the intermediate representation is not of type 'array' @return array
[ "Compiles", "the", "file", "generating", "a", "JSON", "intermediate", "representation", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompilerFile.php#L201-L247
train
phalcon/zephir
Library/CompilerFile.php
CompilerFile.preCompileInterface
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']; /* * Register constants */ 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); } } /* * Register methods */ 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; }
php
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']; /* * Register constants */ 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); } } /* * Register methods */ 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; }
[ "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'", "]", ";", "/*\n * Register constants\n */", "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", ")", ";", "}", "}", "/*\n * Register methods\n */", "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. @param string $namespace @param array $topStatement @param array $docblock
[ "Creates", "a", "definition", "for", "an", "interface", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompilerFile.php#L308-L364
train
phalcon/zephir
Library/CompilerFile.php
CompilerFile.checkDependencies
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 { // Whether the $extendedClass is part of the compiled extension 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); } } }
php
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 { // Whether the $extendedClass is part of the compiled extension 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); } } }
[ "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", "{", "// Whether the $extendedClass is part of the compiled extension", "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. @param Compiler $compiler
[ "Check", "dependencies", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompilerFile.php#L693-L777
train
phalcon/zephir
Library/CompilerFile.php
CompilerFile.createReturnsType
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), ]; }
php
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), ]; }
[ "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. @param array $types @param bool $annotated @return array
[ "Create", "returns", "type", "list", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/CompilerFile.php#L1173-L1194
train
phalcon/zephir
Library/Call.php
Call.processExpectedReturn
public function processExpectedReturn(CompilationContext $compilationContext) { $expr = $this->expression; $expression = $expr->getExpression(); /** * Create temporary variable if needed. */ $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; }
php
public function processExpectedReturn(CompilationContext $compilationContext) { $expr = $this->expression; $expression = $expr->getExpression(); /** * Create temporary variable if needed. */ $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; }
[ "public", "function", "processExpectedReturn", "(", "CompilationContext", "$", "compilationContext", ")", "{", "$", "expr", "=", "$", "this", "->", "expression", ";", "$", "expression", "=", "$", "expr", "->", "getExpression", "(", ")", ";", "/**\n * Create temporary variable if needed.\n */", "$", "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. @param CompilationContext $compilationContext
[ "Processes", "the", "symbol", "variable", "that", "will", "be", "used", "to", "return", "the", "result", "of", "the", "symbol", "call", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L55-L87
train
phalcon/zephir
Library/Call.php
Call.processExpectedComplexLiteralReturn
public function processExpectedComplexLiteralReturn(CompilationContext $compilationContext) { $expr = $this->expression; $expression = $expr->getExpression(); /** * Create temporary variable if needed. */ $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; }
php
public function processExpectedComplexLiteralReturn(CompilationContext $compilationContext) { $expr = $this->expression; $expression = $expr->getExpression(); /** * Create temporary variable if needed. */ $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; }
[ "public", "function", "processExpectedComplexLiteralReturn", "(", "CompilationContext", "$", "compilationContext", ")", "{", "$", "expr", "=", "$", "this", "->", "expression", ";", "$", "expression", "=", "$", "expr", "->", "getExpression", "(", ")", ";", "/**\n * Create temporary variable if needed.\n */", "$", "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. @param CompilationContext $compilationContext
[ "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", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L132-L159
train
phalcon/zephir
Library/Call.php
Call.getSymbolVariable
public function getSymbolVariable($useTemp = false, CompilationContext $compilationContext = null) { $symbolVariable = $this->symbolVariable; if ($useTemp && !\is_object($symbolVariable)) { return $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext); } return $symbolVariable; }
php
public function getSymbolVariable($useTemp = false, CompilationContext $compilationContext = null) { $symbolVariable = $this->symbolVariable; if ($useTemp && !\is_object($symbolVariable)) { return $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext); } return $symbolVariable; }
[ "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. @param bool $useTemp @param CompilationContext|null $compilationContext @return Variable
[ "Returns", "the", "symbol", "variable", "that", "must", "be", "returned", "by", "the", "call", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L189-L198
train
phalcon/zephir
Library/Call.php
Call.getResolvedParamsAsExpr
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; } } /* * All parameters must be passed by name */ 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; }
php
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; } } /* * All parameters must be passed by name */ 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; }
[ "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", ";", "}", "}", "/*\n * All parameters must be passed by name\n */", "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. @param array $parameters @param CompilationContext $compilationContext @param array $expression @param bool $readOnly @throws CompilerException @return array|CompiledExpression[]|null @return array
[ "Resolves", "parameters", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L213-L295
train
phalcon/zephir
Library/Call.php
Call.addCallStatusFlag
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); } }
php
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); } }
[ "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. @param CompilationContext $compilationContext
[ "Add", "the", "last", "-", "call", "-", "status", "flag", "to", "the", "current", "symbol", "table", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L701-L710
train
phalcon/zephir
Library/Call.php
Call.addCallStatusOrJump
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();'); }
php
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();'); }
[ "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. @param CompilationContext $compilationContext
[ "Checks", "the", "last", "call", "status", "or", "make", "a", "label", "jump", "to", "the", "next", "catch", "block", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L717-L729
train
phalcon/zephir
Library/Call.php
Call.checkTempParameters
public function checkTempParameters(CompilationContext $compilationContext) { $compilationContext->headersManager->add('kernel/fcall'); foreach ($this->getMustCheckForCopyVariables() as $checkVariable) { $compilationContext->codePrinter->output('zephir_check_temp_parameter('.$checkVariable.');'); } }
php
public function checkTempParameters(CompilationContext $compilationContext) { $compilationContext->headersManager->add('kernel/fcall'); foreach ($this->getMustCheckForCopyVariables() as $checkVariable) { $compilationContext->codePrinter->output('zephir_check_temp_parameter('.$checkVariable.');'); } }
[ "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. @param CompilationContext $compilationContext
[ "Checks", "if", "temporary", "parameters", "must", "be", "copied", "or", "not", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Call.php#L736-L742
train
phalcon/zephir
Library/Documentation/DocblockParser.php
DocblockParser.__tryRegisterAnnotation
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; }
php
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; }
[ "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.
[ "check", "if", "there", "is", "a", "currently", "parsed", "annotation", "registers", "it", "and", "stops", "the", "current", "annotation", "parsing", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/DocblockParser.php#L58-L67
train
phalcon/zephir
Library/Documentation/DocblockParser.php
DocblockParser.nextCharacter
private function nextCharacter() { ++$this->currentCharIndex; if ($this->annotationLen <= $this->currentCharIndex) { $this->currentChar = null; } else { $this->currentChar = $this->annotation[$this->currentCharIndex]; } return $this->currentChar; }
php
private function nextCharacter() { ++$this->currentCharIndex; if ($this->annotationLen <= $this->currentCharIndex) { $this->currentChar = null; } else { $this->currentChar = $this->annotation[$this->currentCharIndex]; } return $this->currentChar; }
[ "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. @return string the new current character
[ "moves", "the", "current", "cursor", "to", "the", "next", "character", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Documentation/DocblockParser.php#L229-L240
train
phalcon/zephir
Library/Optimizers/FunctionCall/PregMatchOptimizer.php
PregMatchOptimizer.processOptionals
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]; }
php
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]; }
[ "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. preg_match(pattern, subject, matches, flags, offset) @param array $expression @param Call $call @param CompilationContext $context @throws CompilerException @return array
[ "Process", "optional", "parameters", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Optimizers/FunctionCall/PregMatchOptimizer.php#L125-L167
train
phalcon/zephir
Library/Optimizers/FunctionCall/PregMatchOptimizer.php
PregMatchOptimizer.createMatches
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; }
php
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; }
[ "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. preg_match(pattern, subject, matches) @param array $expression @param CompilationContext $context @return Variable
[ "Process", "the", "matches", "result", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Optimizers/FunctionCall/PregMatchOptimizer.php#L179-L220
train
phalcon/zephir
Library/Logger/Formatter/CompilerFormatter.php
CompilerFormatter.getFileContents
private function getFileContents($file) { if (!isset($this->filesContent[$file])) { $this->filesContent[$file] = file_exists($file) ? file($file) : []; } return $this->filesContent[$file]; }
php
private function getFileContents($file) { if (!isset($this->filesContent[$file])) { $this->filesContent[$file] = file_exists($file) ? file($file) : []; } return $this->filesContent[$file]; }
[ "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. @param string $file File path @return array
[ "Gets", "the", "contents", "of", "the", "files", "that", "are", "involved", "in", "the", "log", "message", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/Logger/Formatter/CompilerFormatter.php#L161-L168
train
phalcon/zephir
Library/MethodCall.php
MethodCall.getRealCalledMethod
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]; }
php
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]; }
[ "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. @param CompilationContext $compilationContext @param Variable $caller @param string $methodName @return array
[ "Examine", "internal", "class", "information", "and", "returns", "the", "method", "called", "." ]
2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773
https://github.com/phalcon/zephir/blob/2a5b0f3c9d936a0a7d8477adda6cb8aa0fe28773/Library/MethodCall.php#L833-L876
train
eduardokum/laravel-boleto
src/Pessoa.php
Pessoa.getNomeDocumento
public function getNomeDocumento() { if (!$this->getDocumento()) { return $this->getNome(); } else { return $this->getNome() . ' / ' . $this->getTipoDocumento() . ': ' . $this->getDocumento(); } }
php
public function getNomeDocumento() { if (!$this->getDocumento()) { return $this->getNome(); } else { return $this->getNome() . ' / ' . $this->getTipoDocumento() . ': ' . $this->getDocumento(); } }
[ "public", "function", "getNomeDocumento", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getDocumento", "(", ")", ")", "{", "return", "$", "this", "->", "getNome", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getNome", "(", ")", ".", "' / '", ".", "$", "this", "->", "getTipoDocumento", "(", ")", ".", "': '", ".", "$", "this", "->", "getDocumento", "(", ")", ";", "}", "}" ]
Retorna o nome e o documento formatados @return string
[ "Retorna", "o", "nome", "e", "o", "documento", "formatados" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Pessoa.php#L250-L257
train
eduardokum/laravel-boleto
src/Util.php
Util.nFloat
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 ? ',' : '')); }
php
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 ? ',' : '')); }
[ "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 @param string $number @param integer $decimals @param boolean $showThousands @return string
[ "Mostra", "o", "Valor", "no", "float", "Formatado" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Util.php#L331-L349
train
eduardokum/laravel-boleto
src/Util.php
Util.percentOf
public static function percentOf($big, $small, $defaultOnZero = 0) { $result = $big > 0.01 ? (($small*100)/$big) : $defaultOnZero; return self::nFloat($result); }
php
public static function percentOf($big, $small, $defaultOnZero = 0) { $result = $big > 0.01 ? (($small*100)/$big) : $defaultOnZero; return self::nFloat($result); }
[ "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; @param $big @param $small @param int $defaultOnZero @return string
[ "Return", "percent", "x", "of", "y", ";" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Util.php#L395-L399
train
eduardokum/laravel-boleto
src/Cnab/Retorno/Cnab240/AbstractRetorno.php
AbstractRetorno.incrementDetalhe
protected function incrementDetalhe() { $this->increment++; $detalhe = new Detalhe(); $this->detalhe[$this->increment] = $detalhe; }
php
protected function incrementDetalhe() { $this->increment++; $detalhe = new Detalhe(); $this->detalhe[$this->increment] = $detalhe; }
[ "protected", "function", "incrementDetalhe", "(", ")", "{", "$", "this", "->", "increment", "++", ";", "$", "detalhe", "=", "new", "Detalhe", "(", ")", ";", "$", "this", "->", "detalhe", "[", "$", "this", "->", "increment", "]", "=", "$", "detalhe", ";", "}" ]
Incrementa o detalhe.
[ "Incrementa", "o", "detalhe", "." ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Retorno/Cnab240/AbstractRetorno.php#L98-L103
train
eduardokum/laravel-boleto
src/Boleto/Render/Html.php
Html.addBoleto
public function addBoleto(BoletoContract $boleto) { $dados = $boleto->toArray(); $dados['codigo_barras'] = $this->getImagemCodigoDeBarras($dados['codigo_barras']); $this->boleto[] = $dados; return $this; }
php
public function addBoleto(BoletoContract $boleto) { $dados = $boleto->toArray(); $dados['codigo_barras'] = $this->getImagemCodigoDeBarras($dados['codigo_barras']); $this->boleto[] = $dados; return $this; }
[ "public", "function", "addBoleto", "(", "BoletoContract", "$", "boleto", ")", "{", "$", "dados", "=", "$", "boleto", "->", "toArray", "(", ")", ";", "$", "dados", "[", "'codigo_barras'", "]", "=", "$", "this", "->", "getImagemCodigoDeBarras", "(", "$", "dados", "[", "'codigo_barras'", "]", ")", ";", "$", "this", "->", "boleto", "[", "]", "=", "$", "dados", ";", "return", "$", "this", ";", "}" ]
Addiciona o boleto @param BoletoContract $boleto @return $this
[ "Addiciona", "o", "boleto" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Boleto/Render/Html.php#L79-L85
train
eduardokum/laravel-boleto
src/Cnab/Retorno/Cnab400/AbstractRetorno.php
AbstractRetorno.toArray
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; }
php
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; }
[ "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. @return array
[ "Retorna", "o", "array", "." ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Retorno/Cnab400/AbstractRetorno.php#L107-L118
train
eduardokum/laravel-boleto
src/Cnab/Remessa/Cnab240/Banco/Bradesco.php
Bradesco.getCodigoCliente
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; }
php
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; }
[ "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. @return mixed @throws \Exception
[ "Retorna", "o", "codigo", "do", "cliente", "." ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Remessa/Cnab240/Banco/Bradesco.php#L102-L112
train
eduardokum/laravel-boleto
src/Boleto/Render/Pdf.php
Pdf.addBoletos
public function addBoletos(array $boletos, $withGroup = true) { if ($withGroup) { $this->StartPageGroup(); } foreach ($boletos as $boleto) { $this->addBoleto($boleto); } return $this; }
php
public function addBoletos(array $boletos, $withGroup = true) { if ($withGroup) { $this->StartPageGroup(); } foreach ($boletos as $boleto) { $this->addBoleto($boleto); } return $this; }
[ "public", "function", "addBoletos", "(", "array", "$", "boletos", ",", "$", "withGroup", "=", "true", ")", "{", "if", "(", "$", "withGroup", ")", "{", "$", "this", "->", "StartPageGroup", "(", ")", ";", "}", "foreach", "(", "$", "boletos", "as", "$", "boleto", ")", "{", "$", "this", "->", "addBoleto", "(", "$", "boleto", ")", ";", "}", "return", "$", "this", ";", "}" ]
Addiciona o boletos @param array $boletos @param bool $withGroup @return $this
[ "Addiciona", "o", "boletos" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Boleto/Render/Pdf.php#L407-L418
train
eduardokum/laravel-boleto
src/Boleto/AbstractBoleto.php
AbstractBoleto.setJurosApos
public function setJurosApos($jurosApos) { $jurosApos = (int)$jurosApos; $this->jurosApos = $jurosApos > 0 ? $jurosApos : 0; return $this; }
php
public function setJurosApos($jurosApos) { $jurosApos = (int)$jurosApos; $this->jurosApos = $jurosApos > 0 ? $jurosApos : 0; return $this; }
[ "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 @param int $jurosApos @return AbstractBoleto
[ "Seta", "a", "quantidade", "de", "dias", "apos", "o", "vencimento", "que", "cobra", "o", "juros" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Boleto/AbstractBoleto.php#L1119-L1125
train
eduardokum/laravel-boleto
src/Boleto/AbstractBoleto.php
AbstractBoleto.getCodigoBarras
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); }
php
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); }
[ "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 @return string @throws \Exception
[ "Retorna", "o", "codigo", "de", "barras" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Boleto/AbstractBoleto.php#L1413-L1433
train
eduardokum/laravel-boleto
src/Cnab/Remessa/AbstractRemessa.php
AbstractRemessa.getDataRemessa
public function getDataRemessa($format){ if(is_null($this->dataRemessa)){ return Carbon::now()->format($format); } return $this->dataRemessa->format($format); }
php
public function getDataRemessa($format){ if(is_null($this->dataRemessa)){ return Carbon::now()->format($format); } return $this->dataRemessa->format($format); }
[ "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 @param $format @return string;
[ "Retorna", "a", "data", "da", "remessa", "a", "ser", "gerada" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Remessa/AbstractRemessa.php#L159-L164
train
eduardokum/laravel-boleto
src/Cnab/Remessa/AbstractRemessa.php
AbstractRemessa.download
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(); }
php
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(); }
[ "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 @param null $filename @throws \Exception
[ "Realiza", "o", "download", "da", "string", "retornada", "do", "metodo", "gerar" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Remessa/AbstractRemessa.php#L534-L542
train
eduardokum/laravel-boleto
src/Cnab/Remessa/Cnab240/AbstractRemessa.php
AbstractRemessa.gerar
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); }
php
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); }
[ "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. @return string @throws \Exception
[ "Gera", "o", "arquivo", "retorna", "a", "string", "." ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Cnab/Remessa/Cnab240/AbstractRemessa.php#L152-L180
train
eduardokum/laravel-boleto
src/Boleto/Banco/Bradesco.php
Bradesco.setCip
public function setCip($cip) { $this->cip = $cip; $this->variaveis_adicionais['cip'] = $this->getCip(); return $this; }
php
public function setCip($cip) { $this->cip = $cip; $this->variaveis_adicionais['cip'] = $this->getCip(); return $this; }
[ "public", "function", "setCip", "(", "$", "cip", ")", "{", "$", "this", "->", "cip", "=", "$", "cip", ";", "$", "this", "->", "variaveis_adicionais", "[", "'cip'", "]", "=", "$", "this", "->", "getCip", "(", ")", ";", "return", "$", "this", ";", "}" ]
Define o campo CIP do boleto @param int $cip @return Bradesco
[ "Define", "o", "campo", "CIP", "do", "boleto" ]
b435e23340e5290d4a4206519e02cea2bdbecb01
https://github.com/eduardokum/laravel-boleto/blob/b435e23340e5290d4a4206519e02cea2bdbecb01/src/Boleto/Banco/Bradesco.php#L173-L178
train
jikan-me/jikan
src/Model/Manga/MangaReview.php
MangaReview.fromParser
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; }
php
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; }
[ "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 @param MangaReviewParser $parser @return MangaReview @throws \Exception @throws \RuntimeException @throws \InvalidArgumentException
[ "Create", "an", "instance", "from", "an", "MangaReviewParser", "parser" ]
a169ceec85889b144b1aab6f1b4950271bf27369
https://github.com/jikan-me/jikan/blob/a169ceec85889b144b1aab6f1b4950271bf27369/src/Model/Manga/MangaReview.php#L55-L67
train
jikan-me/jikan
src/Helper/Parser.php
Parser.removeChildNodes
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; }
php
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; }
[ "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 @param Crawler $crawler @return Crawler @throws \InvalidArgumentException
[ "Removes", "all", "html", "elements", "so", "the", "text", "is", "left", "over" ]
a169ceec85889b144b1aab6f1b4950271bf27369
https://github.com/jikan-me/jikan/blob/a169ceec85889b144b1aab6f1b4950271bf27369/src/Helper/Parser.php#L24-L40
train
jikan-me/jikan
src/Model/Manga/Manga.php
Manga.fromParser
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; }
php
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; }
[ "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 @param MangaParser $parser @return Manga @throws \RuntimeException @throws \InvalidArgumentException
[ "Create", "an", "instance", "from", "an", "MangaParser", "parser" ]
a169ceec85889b144b1aab6f1b4950271bf27369
https://github.com/jikan-me/jikan/blob/a169ceec85889b144b1aab6f1b4950271bf27369/src/Model/Manga/Manga.php#L158-L189
train
Behat/Behat
src/Behat/Behat/Definition/Pattern/Policy/RegexPatternPolicy.php
RegexPatternPolicy.generateRegex
private function generateRegex($stepText) { return preg_replace( array_keys(self::$replacePatterns), array_values(self::$replacePatterns), $this->escapeStepText($stepText) ); }
php
private function generateRegex($stepText) { return preg_replace( array_keys(self::$replacePatterns), array_values(self::$replacePatterns), $this->escapeStepText($stepText) ); }
[ "private", "function", "generateRegex", "(", "$", "stepText", ")", "{", "return", "preg_replace", "(", "array_keys", "(", "self", "::", "$", "replacePatterns", ")", ",", "array_values", "(", "self", "::", "$", "replacePatterns", ")", ",", "$", "this", "->", "escapeStepText", "(", "$", "stepText", ")", ")", ";", "}" ]
Generates regex from step text. @param string $stepText @return string
[ "Generates", "regex", "from", "step", "text", "." ]
eb6c5d39420a47c08344598b58ec5f8d26a75b9b
https://github.com/Behat/Behat/blob/eb6c5d39420a47c08344598b58ec5f8d26a75b9b/src/Behat/Behat/Definition/Pattern/Policy/RegexPatternPolicy.php#L83-L90
train