repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
zordius/lightncandy | src/Compiler.php | Compiler.with | protected static function with(&$context, $vars) {
$v = isset($vars[1]) ? static::getVariableNameOrSubExpression($context, $vars[1]) : array(null, array());
$bp = Parser::getBlockParams($vars);
$bs = $bp ? ('array(' . Expression::listString($bp) . ')') : 'null';
$be = $bp ? " as |$bp[0]|... | php | protected static function with(&$context, $vars) {
$v = isset($vars[1]) ? static::getVariableNameOrSubExpression($context, $vars[1]) : array(null, array());
$bp = Parser::getBlockParams($vars);
$bs = $bp ? ('array(' . Expression::listString($bp) . ')') : 'null';
$be = $bp ? " as |$bp[0]|... | [
"protected",
"static",
"function",
"with",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"$",
"v",
"=",
"isset",
"(",
"$",
"vars",
"[",
"1",
"]",
")",
"?",
"static",
"::",
"getVariableNameOrSubExpression",
"(",
"$",
"context",
",",
"$",
"vars... | compile {{with}} token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return string|null Return compiled code segment for the token | [
"compile",
"{{",
"with",
"}}",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L558-L564 |
zordius/lightncandy | src/Compiler.php | Compiler.customHelper | protected static function customHelper(&$context, $vars, $raw, $nosep, $subExp = false) {
if (count($vars[0]) > 1) {
return;
}
if (!isset($context['helpers'][$vars[0][0]])) {
if ($subExp) {
if ($vars[0][0] == 'lookup') {
return static:... | php | protected static function customHelper(&$context, $vars, $raw, $nosep, $subExp = false) {
if (count($vars[0]) > 1) {
return;
}
if (!isset($context['helpers'][$vars[0][0]])) {
if ($subExp) {
if ($vars[0][0] == 'lookup') {
return static:... | [
"protected",
"static",
"function",
"customHelper",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
",",
"$",
"raw",
",",
"$",
"nosep",
",",
"$",
"subExp",
"=",
"false",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"vars",
"[",
"0",
"]",
")",
">",
"1",
"... | Return compiled PHP code for a handlebars custom helper token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $raw is this {{{ token or not
@param boolean $nosep true to compile without seperator
@param boo... | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"custom",
"helper",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L577-L598 |
zordius/lightncandy | src/Compiler.php | Compiler.doElse | protected static function doElse(&$context, $vars) {
$v = $context['stack'][count($context['stack']) - 2];
if ((($v === '[if]') && !isset($context['helpers']['if'])) ||
(($v === '[unless]') && !isset($context['helpers']['unless']))) {
$context['stack'][] = ':';
return "... | php | protected static function doElse(&$context, $vars) {
$v = $context['stack'][count($context['stack']) - 2];
if ((($v === '[if]') && !isset($context['helpers']['if'])) ||
(($v === '[unless]') && !isset($context['helpers']['unless']))) {
$context['stack'][] = ':';
return "... | [
"protected",
"static",
"function",
"doElse",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"$",
"v",
"=",
"$",
"context",
"[",
"'stack'",
"]",
"[",
"count",
"(",
"$",
"context",
"[",
"'stack'",
"]",
")",
"-",
"2",
"]",
";",
"if",
"(",
"... | Return compiled PHP code for a handlebars else token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return string Return compiled code segment for the token when the token is else | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"else",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L608-L618 |
zordius/lightncandy | src/Compiler.php | Compiler.compileLog | protected static function compileLog(&$context, &$vars, $raw) {
array_shift($vars);
$v = static::getVariableNames($context, $vars);
return $context['ops']['seperator'] . static::getFuncName($context, 'lo', $v[1]) . "\$cx, {$v[0]}){$context['ops']['seperator']}";
} | php | protected static function compileLog(&$context, &$vars, $raw) {
array_shift($vars);
$v = static::getVariableNames($context, $vars);
return $context['ops']['seperator'] . static::getFuncName($context, 'lo', $v[1]) . "\$cx, {$v[0]}){$context['ops']['seperator']}";
} | [
"protected",
"static",
"function",
"compileLog",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
",",
"$",
"raw",
")",
"{",
"array_shift",
"(",
"$",
"vars",
")",
";",
"$",
"v",
"=",
"static",
"::",
"getVariableNames",
"(",
"$",
"context",
",",
"$",
... | Return compiled PHP code for a handlebars log token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $raw is this {{{ token or not
@return string Return compiled code segment for the token | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"log",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L629-L633 |
zordius/lightncandy | src/Compiler.php | Compiler.compileLookup | protected static function compileLookup(&$context, &$vars, $raw, $nosep = false) {
$v2 = static::getVariableName($context, $vars[2]);
$v = static::getVariableName($context, $vars[1], $v2);
$sep = $nosep ? '' : $context['ops']['seperator'];
$ex = $nosep ? ', 1' : '';
if ($context... | php | protected static function compileLookup(&$context, &$vars, $raw, $nosep = false) {
$v2 = static::getVariableName($context, $vars[2]);
$v = static::getVariableName($context, $vars[1], $v2);
$sep = $nosep ? '' : $context['ops']['seperator'];
$ex = $nosep ? ', 1' : '';
if ($context... | [
"protected",
"static",
"function",
"compileLookup",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
",",
"$",
"raw",
",",
"$",
"nosep",
"=",
"false",
")",
"{",
"$",
"v2",
"=",
"static",
"::",
"getVariableName",
"(",
"$",
"context",
",",
"$",
"vars",... | Return compiled PHP code for a handlebars lookup token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $raw is this {{{ token or not
@param boolean $nosep true to compile without seperator
@return string R... | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"lookup",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L645-L656 |
zordius/lightncandy | src/Compiler.php | Compiler.compileOutput | protected static function compileOutput(&$context, $variable, $expression, $raw, $nosep) {
$sep = $nosep ? '' : $context['ops']['seperator'];
if ($context['flags']['hbesc'] || $context['flags']['jsobj'] || $context['flags']['jstrue'] || $context['flags']['debug'] || $nosep) {
return $sep . s... | php | protected static function compileOutput(&$context, $variable, $expression, $raw, $nosep) {
$sep = $nosep ? '' : $context['ops']['seperator'];
if ($context['flags']['hbesc'] || $context['flags']['jsobj'] || $context['flags']['jstrue'] || $context['flags']['debug'] || $nosep) {
return $sep . s... | [
"protected",
"static",
"function",
"compileOutput",
"(",
"&",
"$",
"context",
",",
"$",
"variable",
",",
"$",
"expression",
",",
"$",
"raw",
",",
"$",
"nosep",
")",
"{",
"$",
"sep",
"=",
"$",
"nosep",
"?",
"''",
":",
"$",
"context",
"[",
"'ops'",
"... | Return compiled PHP code for template output
@param array<string,array|string|integer> $context current compile context
@param string $variable PHP code for the variable
@param string $expression normalized handlebars expression
@param boolean $raw is this {{{ token or not
@param boolean $nosep true to compile without... | [
"Return",
"compiled",
"PHP",
"code",
"for",
"template",
"output"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L669-L676 |
zordius/lightncandy | src/Compiler.php | Compiler.compileVariable | protected static function compileVariable(&$context, &$vars, $raw, $nosep) {
if ($context['flags']['lambda']) {
$V = array_shift($vars);
$v = static::getVariableName($context, $V, null, count($vars) ? static::getVariableNames($context, $vars) : array('0',array('')));
} else {
... | php | protected static function compileVariable(&$context, &$vars, $raw, $nosep) {
if ($context['flags']['lambda']) {
$V = array_shift($vars);
$v = static::getVariableName($context, $V, null, count($vars) ? static::getVariableNames($context, $vars) : array('0',array('')));
} else {
... | [
"protected",
"static",
"function",
"compileVariable",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
",",
"$",
"raw",
",",
"$",
"nosep",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'lambda'",
"]",
")",
"{",
"$",
"V",
"=",
"a... | Return compiled PHP code for a handlebars variable token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $raw is this {{{ token or not
@param boolean $nosep true to compile without seperator
@return string... | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"variable",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L688-L696 |
zordius/lightncandy | src/Compiler.php | Compiler.addUsageCount | protected static function addUsageCount(&$context, $category, $name, $count = 1) {
if (!isset($context['usedCount'][$category][$name])) {
$context['usedCount'][$category][$name] = 0;
}
return ($context['usedCount'][$category][$name] += $count);
} | php | protected static function addUsageCount(&$context, $category, $name, $count = 1) {
if (!isset($context['usedCount'][$category][$name])) {
$context['usedCount'][$category][$name] = 0;
}
return ($context['usedCount'][$category][$name] += $count);
} | [
"protected",
"static",
"function",
"addUsageCount",
"(",
"&",
"$",
"context",
",",
"$",
"category",
",",
"$",
"name",
",",
"$",
"count",
"=",
"1",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"context",
"[",
"'usedCount'",
"]",
"[",
"$",
"category",
... | Add usage count to context
@param array<string,array|string|integer> $context current context
@param string $category category name, can be one of: 'var', 'helpers', 'runtime'
@param string $name used name
@param integer $count increment
@expect 1 when input array('usedCount' => array('test' => array())), 'test', 'te... | [
"Add",
"usage",
"count",
"to",
"context"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Compiler.php#L710-L715 |
zordius/lightncandy | src/Exporter.php | Exporter.closure | protected static function closure($context, $closure) {
if (is_string($closure) && preg_match('/(.+)::(.+)/', $closure, $matched)) {
$ref = new \ReflectionMethod($matched[1], $matched[2]);
} else {
$ref = new \ReflectionFunction($closure);
}
$meta = static::getMet... | php | protected static function closure($context, $closure) {
if (is_string($closure) && preg_match('/(.+)::(.+)/', $closure, $matched)) {
$ref = new \ReflectionMethod($matched[1], $matched[2]);
} else {
$ref = new \ReflectionFunction($closure);
}
$meta = static::getMet... | [
"protected",
"static",
"function",
"closure",
"(",
"$",
"context",
",",
"$",
"closure",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"closure",
")",
"&&",
"preg_match",
"(",
"'/(.+)::(.+)/'",
",",
"$",
"closure",
",",
"$",
"matched",
")",
")",
"{",
"$",... | Get PHP code string from a closure of function as string
@param array<string,array|string|integer> $context current compile context
@param object $closure Closure object
@return string
@expect 'function($a) {return;}' when input array('flags' => array('standalone' => 0)), function ($a) {return;}
@expect 'function($... | [
"Get",
"PHP",
"code",
"string",
"from",
"a",
"closure",
"of",
"function",
"as",
"string"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L38-L47 |
zordius/lightncandy | src/Exporter.php | Exporter.helpers | public static function helpers($context) {
$ret = '';
foreach ($context['helpers'] as $name => $func) {
if (!isset($context['usedCount']['helpers'][$name])) {
continue;
}
if ((is_object($func) && ($func instanceof \Closure)) || ($context['flags']['exhl... | php | public static function helpers($context) {
$ret = '';
foreach ($context['helpers'] as $name => $func) {
if (!isset($context['usedCount']['helpers'][$name])) {
continue;
}
if ((is_object($func) && ($func instanceof \Closure)) || ($context['flags']['exhl... | [
"public",
"static",
"function",
"helpers",
"(",
"$",
"context",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"foreach",
"(",
"$",
"context",
"[",
"'helpers'",
"]",
"as",
"$",
"name",
"=>",
"$",
"func",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"conte... | Export required custom helper functions
@param array<string,array|string|integer> $context current compile context
@return string | [
"Export",
"required",
"custom",
"helper",
"functions"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L56-L70 |
zordius/lightncandy | src/Exporter.php | Exporter.getClassMethods | public static function getClassMethods($context, $class) {
$methods = array();
foreach ($class->getMethods() as $method) {
$meta = static::getMeta($method);
$methods[$meta['name']] = static::scanDependency($context, preg_replace('/public static function (.+)\\(/', "function {$co... | php | public static function getClassMethods($context, $class) {
$methods = array();
foreach ($class->getMethods() as $method) {
$meta = static::getMeta($method);
$methods[$meta['name']] = static::scanDependency($context, preg_replace('/public static function (.+)\\(/', "function {$co... | [
"public",
"static",
"function",
"getClassMethods",
"(",
"$",
"context",
",",
"$",
"class",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"meta",
... | Get methods from ReflectionClass
@param array<string,array|string|integer> $context current compile context
@param \ReflectionClass $class instance of the ReflectionClass
@return array | [
"Get",
"methods",
"from",
"ReflectionClass"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L92-L101 |
zordius/lightncandy | src/Exporter.php | Exporter.getClassStatics | public static function getClassStatics($class) {
$ret = '';
foreach ($class->getStaticProperties() as $name => $value) {
$ret .= " public static \${$name} = " . var_export($value, true) . ";\n";
}
return $ret;
} | php | public static function getClassStatics($class) {
$ret = '';
foreach ($class->getStaticProperties() as $name => $value) {
$ret .= " public static \${$name} = " . var_export($value, true) . ";\n";
}
return $ret;
} | [
"public",
"static",
"function",
"getClassStatics",
"(",
"$",
"class",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"foreach",
"(",
"$",
"class",
"->",
"getStaticProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"ret",
".=",
"\" pu... | Get statics code from ReflectionClass
@param \ReflectionClass $class instance of the ReflectionClass
@return string | [
"Get",
"statics",
"code",
"from",
"ReflectionClass"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L110-L118 |
zordius/lightncandy | src/Exporter.php | Exporter.getMeta | public static function getMeta($refobj) {
$fname = $refobj->getFileName();
$lines = file_get_contents($fname);
$file = new \SplFileObject($fname);
$file->seek($refobj->getStartLine() - 2);
$spos = $file->ftell();
$file->seek($refobj->getEndLine() - 1);
$epos = $fi... | php | public static function getMeta($refobj) {
$fname = $refobj->getFileName();
$lines = file_get_contents($fname);
$file = new \SplFileObject($fname);
$file->seek($refobj->getStartLine() - 2);
$spos = $file->ftell();
$file->seek($refobj->getEndLine() - 1);
$epos = $fi... | [
"public",
"static",
"function",
"getMeta",
"(",
"$",
"refobj",
")",
"{",
"$",
"fname",
"=",
"$",
"refobj",
"->",
"getFileName",
"(",
")",
";",
"$",
"lines",
"=",
"file_get_contents",
"(",
"$",
"fname",
")",
";",
"$",
"file",
"=",
"new",
"\\",
"SplFil... | Get metadata from ReflectionObject
@param object $refobj instance of the ReflectionObject
@return array | [
"Get",
"metadata",
"from",
"ReflectionObject"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L131-L144 |
zordius/lightncandy | src/Exporter.php | Exporter.safestring | public static function safestring($context) {
$class = new \ReflectionClass($context['safestring']);
return array_reduce(static::getClassMethods($context, $class), function ($in, $cur) {
return $in . $cur[2];
}, "if (!class_exists(\"" . addslashes($context['safestringalias']) . "\")... | php | public static function safestring($context) {
$class = new \ReflectionClass($context['safestring']);
return array_reduce(static::getClassMethods($context, $class), function ($in, $cur) {
return $in . $cur[2];
}, "if (!class_exists(\"" . addslashes($context['safestringalias']) . "\")... | [
"public",
"static",
"function",
"safestring",
"(",
"$",
"context",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"context",
"[",
"'safestring'",
"]",
")",
";",
"return",
"array_reduce",
"(",
"static",
"::",
"getClassMethods",
"(",
... | Export SafeString class as string
@param array<string,array|string|integer> $context current compile context
@return string | [
"Export",
"SafeString",
"class",
"as",
"string"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L153-L159 |
zordius/lightncandy | src/Exporter.php | Exporter.runtime | public static function runtime($context) {
$class = new \ReflectionClass($context['runtime']);
$ret = '';
$methods = static::getClassMethods($context, $class);
$exports = array_keys($context['usedCount']['runtime']);
while (true) {
if (array_sum(array_map(function (... | php | public static function runtime($context) {
$class = new \ReflectionClass($context['runtime']);
$ret = '';
$methods = static::getClassMethods($context, $class);
$exports = array_keys($context['usedCount']['runtime']);
while (true) {
if (array_sum(array_map(function (... | [
"public",
"static",
"function",
"runtime",
"(",
"$",
"context",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"context",
"[",
"'runtime'",
"]",
")",
";",
"$",
"ret",
"=",
"''",
";",
"$",
"methods",
"=",
"static",
"::",
"getCl... | Export required standalone Runtime methods
@param array<string,array|string|integer> $context current compile context
@return string | [
"Export",
"required",
"standalone",
"Runtime",
"methods"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L185-L212 |
zordius/lightncandy | src/Exporter.php | Exporter.constants | public static function constants($context) {
if ($context['flags']['standalone'] == 0) {
return 'array()';
}
$class = new \ReflectionClass($context['runtime']);
$constants = $class->getConstants();
$ret = " array(\n";
foreach($constants as $name => $value) {
... | php | public static function constants($context) {
if ($context['flags']['standalone'] == 0) {
return 'array()';
}
$class = new \ReflectionClass($context['runtime']);
$constants = $class->getConstants();
$ret = " array(\n";
foreach($constants as $name => $value) {
... | [
"public",
"static",
"function",
"constants",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'standalone'",
"]",
"==",
"0",
")",
"{",
"return",
"'array()'",
";",
"}",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass... | Export Runtime constants
@param array<string,array|string|integer> $context current compile context
@return string | [
"Export",
"Runtime",
"constants"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L221-L234 |
zordius/lightncandy | src/Exporter.php | Exporter.scanDependency | protected static function scanDependency($context, $code, $ocode) {
$child = array();
$code = preg_replace_callback('/static::(\w+?)\s*\(/', function ($matches) use ($context, &$child) {
if (!isset($child[$matches[1]])) {
$child[$matches[1]] = 0;
}
$c... | php | protected static function scanDependency($context, $code, $ocode) {
$child = array();
$code = preg_replace_callback('/static::(\w+?)\s*\(/', function ($matches) use ($context, &$child) {
if (!isset($child[$matches[1]])) {
$child[$matches[1]] = 0;
}
$c... | [
"protected",
"static",
"function",
"scanDependency",
"(",
"$",
"context",
",",
"$",
"code",
",",
"$",
"ocode",
")",
"{",
"$",
"child",
"=",
"array",
"(",
")",
";",
"$",
"code",
"=",
"preg_replace_callback",
"(",
"'/static::(\\w+?)\\s*\\(/'",
",",
"function",... | Scan for required standalone functions
@param array<string,array|string|integer> $context current compile context
@param string $code patched PHP code string of the method
@param string $ocode original PHP code string of the method
@return array<string|array> list of converted code and children array | [
"Scan",
"for",
"required",
"standalone",
"functions"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Exporter.php#L245-L264 |
zordius/lightncandy | src/Partial.php | Partial.handleDynamic | public static function handleDynamic(&$context) {
if ($context['usedFeature']['dynpartial'] == 0) {
return;
}
foreach ($context['partials'] as $name => $code) {
static::read($context, $name);
}
} | php | public static function handleDynamic(&$context) {
if ($context['usedFeature']['dynpartial'] == 0) {
return;
}
foreach ($context['partials'] as $name => $code) {
static::read($context, $name);
}
} | [
"public",
"static",
"function",
"handleDynamic",
"(",
"&",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'usedFeature'",
"]",
"[",
"'dynpartial'",
"]",
"==",
"0",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"context",
"[",
"'partial... | Include all partials when using dynamic partials | [
"Include",
"all",
"partials",
"when",
"using",
"dynamic",
"partials"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L35-L43 |
zordius/lightncandy | src/Partial.php | Partial.read | public static function read(&$context, $name) {
$isPB = ($name === '@partial-block');
$context['usedFeature']['partial']++;
if (isset($context['usedPartial'][$name])) {
return;
}
$cnt = static::resolve($context, $name);
if ($cnt !== null) {
$con... | php | public static function read(&$context, $name) {
$isPB = ($name === '@partial-block');
$context['usedFeature']['partial']++;
if (isset($context['usedPartial'][$name])) {
return;
}
$cnt = static::resolve($context, $name);
if ($cnt !== null) {
$con... | [
"public",
"static",
"function",
"read",
"(",
"&",
"$",
"context",
",",
"$",
"name",
")",
"{",
"$",
"isPB",
"=",
"(",
"$",
"name",
"===",
"'@partial-block'",
")",
";",
"$",
"context",
"[",
"'usedFeature'",
"]",
"[",
"'partial'",
"]",
"++",
";",
"if",
... | Read partial file content as string and store in context
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $name partial name
@return string|null $code compiled PHP code when success | [
"Read",
"partial",
"file",
"content",
"as",
"string",
"and",
"store",
"in",
"context"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L53-L71 |
zordius/lightncandy | src/Partial.php | Partial.prePartial | protected static function prePartial(&$context, $tmpl, &$name) {
return $context['prepartial'] ? $context['prepartial']($context, $tmpl, $name) : $tmpl;
} | php | protected static function prePartial(&$context, $tmpl, &$name) {
return $context['prepartial'] ? $context['prepartial']($context, $tmpl, $name) : $tmpl;
} | [
"protected",
"static",
"function",
"prePartial",
"(",
"&",
"$",
"context",
",",
"$",
"tmpl",
",",
"&",
"$",
"name",
")",
"{",
"return",
"$",
"context",
"[",
"'prepartial'",
"]",
"?",
"$",
"context",
"[",
"'prepartial'",
"]",
"(",
"$",
"context",
",",
... | preprocess partial template before it be stored into context
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $tmpl partial template
@param string $name partial name
@return string|null $content processed partial template
@expect 'hey' when input Array('prepartia... | [
"preprocess",
"partial",
"template",
"before",
"it",
"be",
"stored",
"into",
"context"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L85-L87 |
zordius/lightncandy | src/Partial.php | Partial.resolve | public static function resolve(&$context, &$name) {
if ($name === '@partial-block') {
$name = "@partial-block{$context['usedFeature']['pblock']}";
}
if (isset($context['partials'][$name])) {
return static::prePartial($context, $context['partials'][$name], $name);
... | php | public static function resolve(&$context, &$name) {
if ($name === '@partial-block') {
$name = "@partial-block{$context['usedFeature']['pblock']}";
}
if (isset($context['partials'][$name])) {
return static::prePartial($context, $context['partials'][$name], $name);
... | [
"public",
"static",
"function",
"resolve",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'@partial-block'",
")",
"{",
"$",
"name",
"=",
"\"@partial-block{$context['usedFeature']['pblock']}\"",
";",
"}",
"if",
"(",... | resolve partial, return the partial content
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $name partial name
@return string|null $content partial content | [
"resolve",
"partial",
"return",
"the",
"partial",
"content"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L97-L106 |
zordius/lightncandy | src/Partial.php | Partial.resolver | public static function resolver(&$context, &$name) {
if ($context['partialresolver']) {
$cnt = $context['partialresolver']($context, $name);
return static::prePartial($context, $cnt, $name);
}
} | php | public static function resolver(&$context, &$name) {
if ($context['partialresolver']) {
$cnt = $context['partialresolver']($context, $name);
return static::prePartial($context, $cnt, $name);
}
} | [
"public",
"static",
"function",
"resolver",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'partialresolver'",
"]",
")",
"{",
"$",
"cnt",
"=",
"$",
"context",
"[",
"'partialresolver'",
"]",
"(",
"$",
"cont... | use partialresolver to resolve partial, return the partial content
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $name partial name
@return string|null $content partial content | [
"use",
"partialresolver",
"to",
"resolve",
"partial",
"return",
"the",
"partial",
"content"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L116-L121 |
zordius/lightncandy | src/Partial.php | Partial.compileStatic | public static function compileStatic(&$context, $name) {
// Check for recursive partial
if (!$context['flags']['runpart']) {
$context['partialStack'][] = $name;
$diff = count($context['partialStack']) - count(array_unique($context['partialStack']));
if ($diff) {
... | php | public static function compileStatic(&$context, $name) {
// Check for recursive partial
if (!$context['flags']['runpart']) {
$context['partialStack'][] = $name;
$diff = count($context['partialStack']) - count(array_unique($context['partialStack']));
if ($diff) {
... | [
"public",
"static",
"function",
"compileStatic",
"(",
"&",
"$",
"context",
",",
"$",
"name",
")",
"{",
"// Check for recursive partial",
"if",
"(",
"!",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'runpart'",
"]",
")",
"{",
"$",
"context",
"[",
"'partialSta... | compile a partial to static embed PHP code
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $name partial name
@return string|null $code PHP code string | [
"compile",
"a",
"partial",
"to",
"static",
"embed",
"PHP",
"code"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L131-L148 |
zordius/lightncandy | src/Partial.php | Partial.compileDynamic | public static function compileDynamic(&$context, $name) {
if (!$context['flags']['runpart']) {
return;
}
$func = static::compile($context, $context['usedPartial'][$name], $name);
if (!isset($context['partialCode'][$name]) && $func) {
$context['partialCode'][$nam... | php | public static function compileDynamic(&$context, $name) {
if (!$context['flags']['runpart']) {
return;
}
$func = static::compile($context, $context['usedPartial'][$name], $name);
if (!isset($context['partialCode'][$name]) && $func) {
$context['partialCode'][$nam... | [
"public",
"static",
"function",
"compileDynamic",
"(",
"&",
"$",
"context",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'runpart'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"func",
"=",
"static",
"::",
"com... | compile partial as closure, stored in context
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $name partial name
@return string|null $code compiled PHP code when success | [
"compile",
"partial",
"as",
"closure",
"stored",
"in",
"context"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L158-L170 |
zordius/lightncandy | src/Partial.php | Partial.compile | public static function compile(&$context, $template, $name = 0) {
if ((end($context['partialStack']) === $name) && (substr($name, 0, 14) === '@partial-block')) {
return;
}
$tmpContext = $context;
$tmpContext['inlinepartial'] = array();
$tmpContext['partialblock'] = a... | php | public static function compile(&$context, $template, $name = 0) {
if ((end($context['partialStack']) === $name) && (substr($name, 0, 14) === '@partial-block')) {
return;
}
$tmpContext = $context;
$tmpContext['inlinepartial'] = array();
$tmpContext['partialblock'] = a... | [
"public",
"static",
"function",
"compile",
"(",
"&",
"$",
"context",
",",
"$",
"template",
",",
"$",
"name",
"=",
"0",
")",
"{",
"if",
"(",
"(",
"end",
"(",
"$",
"context",
"[",
"'partialStack'",
"]",
")",
"===",
"$",
"name",
")",
"&&",
"(",
"sub... | compile a template into a closure function
@param array<string,array|string|integer> $context Current context of compiler progress.
@param string $template template string
@param string|integer $name partial name or 0
@return string $code compiled PHP code | [
"compile",
"a",
"template",
"into",
"a",
"closure",
"function"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Partial.php#L181-L207 |
zordius/lightncandy | src/Encoder.php | Encoder.raw | public static function raw($cx, $v, $ex = 0) {
if ($ex) {
return $v;
}
if ($v === true) {
if ($cx['flags']['jstrue']) {
return 'true';
}
}
if (($v === false)) {
if ($cx['flags']['jstrue']) {
return ... | php | public static function raw($cx, $v, $ex = 0) {
if ($ex) {
return $v;
}
if ($v === true) {
if ($cx['flags']['jstrue']) {
return 'true';
}
}
if (($v === false)) {
if ($cx['flags']['jstrue']) {
return ... | [
"public",
"static",
"function",
"raw",
"(",
"$",
"cx",
",",
"$",
"v",
",",
"$",
"ex",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"ex",
")",
"{",
"return",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"v",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"cx",
... | Get string value
@param array<string,array|string|integer> $cx render time context
@param array<array|string|integer>|string|integer|null $v value to be output
@param integer $ex 1 to return untouched value, default is 0
@return array<array|string|integer>|string|integer|null The raw value of the specified variable
... | [
"Get",
"string",
"value"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Encoder.php#L50-L84 |
zordius/lightncandy | src/Context.php | Context.create | public static function create($options) {
if (!is_array($options)) {
$options = array();
}
$flags = isset($options['flags']) ? $options['flags'] : static::FLAG_BESTPERFORMANCE;
$context = array(
'flags' => array(
'errorlog' => $flags & static::FL... | php | public static function create($options) {
if (!is_array($options)) {
$options = array();
}
$flags = isset($options['flags']) ? $options['flags'] : static::FLAG_BESTPERFORMANCE;
$context = array(
'flags' => array(
'errorlog' => $flags & static::FL... | [
"public",
"static",
"function",
"create",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"}",
"$",
"flags",
"=",
"isset",
"(",
"$",
"options",
"[",
"'fla... | Create a context from options
@param array<string,array|string|integer> $options input options
@return array<string,array|string|integer> Context from options | [
"Create",
"a",
"context",
"from",
"options"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Context.php#L36-L180 |
zordius/lightncandy | src/Context.php | Context.updateHelperTable | protected static function updateHelperTable(&$context, $options, $tname = 'helpers') {
if (isset($options[$tname]) && is_array($options[$tname])) {
foreach ($options[$tname] as $name => $func) {
$tn = is_int($name) ? $func : $name;
if (is_callable($func)) {
... | php | protected static function updateHelperTable(&$context, $options, $tname = 'helpers') {
if (isset($options[$tname]) && is_array($options[$tname])) {
foreach ($options[$tname] as $name => $func) {
$tn = is_int($name) ? $func : $name;
if (is_callable($func)) {
... | [
"protected",
"static",
"function",
"updateHelperTable",
"(",
"&",
"$",
"context",
",",
"$",
"options",
",",
"$",
"tname",
"=",
"'helpers'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"tname",
"]",
")",
"&&",
"is_array",
"(",
"$",
"o... | update specific custom helper table from options
@param array<string,array|string|integer> $context prepared context
@param array<string,array|string|integer> $options input options
@param string $tname helper table name
@return array<string,array|string|integer> context with generated helper table
@expect array() w... | [
"update",
"specific",
"custom",
"helper",
"table",
"from",
"options"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Context.php#L197-L218 |
zordius/lightncandy | src/Context.php | Context.merge | public static function merge(&$context, $tmp) {
$context['error'] = $tmp['error'];
$context['helpers'] = $tmp['helpers'];
$context['partials'] = $tmp['partials'];
$context['partialCode'] = $tmp['partialCode'];
$context['partialStack'] = $tmp['partialStack'];
$context['use... | php | public static function merge(&$context, $tmp) {
$context['error'] = $tmp['error'];
$context['helpers'] = $tmp['helpers'];
$context['partials'] = $tmp['partials'];
$context['partialCode'] = $tmp['partialCode'];
$context['partialStack'] = $tmp['partialStack'];
$context['use... | [
"public",
"static",
"function",
"merge",
"(",
"&",
"$",
"context",
",",
"$",
"tmp",
")",
"{",
"$",
"context",
"[",
"'error'",
"]",
"=",
"$",
"tmp",
"[",
"'error'",
"]",
";",
"$",
"context",
"[",
"'helpers'",
"]",
"=",
"$",
"tmp",
"[",
"'helpers'",
... | Merge a context into another
@param array<string,array|string|integer> $context master context
@param array<string,array|string|integer> $tmp another context will be overwrited into master context | [
"Merge",
"a",
"context",
"into",
"another"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Context.php#L226-L235 |
zordius/lightncandy | src/Runtime.php | Runtime.debug | public static function debug($v, $f, $cx) {
// Build array of reference for call_user_func_array
$P = func_get_args();
$params = array();
for ($i=2;$i<count($P);$i++) {
$params[] = &$P[$i];
}
$r = call_user_func_array((isset($cx['funcs'][$f]) ? $cx['funcs'][$f... | php | public static function debug($v, $f, $cx) {
// Build array of reference for call_user_func_array
$P = func_get_args();
$params = array();
for ($i=2;$i<count($P);$i++) {
$params[] = &$P[$i];
}
$r = call_user_func_array((isset($cx['funcs'][$f]) ? $cx['funcs'][$f... | [
"public",
"static",
"function",
"debug",
"(",
"$",
"v",
",",
"$",
"f",
",",
"$",
"cx",
")",
"{",
"// Build array of reference for call_user_func_array",
"$",
"P",
"=",
"func_get_args",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"for",
"("... | Output debug info.
@param string $v expression
@param string $f runtime function name
@param array<string,array|string|integer> $cx render time context for lightncandy
@expect '{{123}}' when input '123', 'miss', array('flags' => array('debug' => Runtime::DEBUG_TAGS), 'runtime' => 'LightnCandy\\Runtime'), ''
@expect '... | [
"Output",
"debug",
"info",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L60-L94 |
zordius/lightncandy | src/Runtime.php | Runtime.err | public static function err($cx, $err) {
if ($cx['flags']['debug'] & static::DEBUG_ERROR_LOG) {
error_log($err);
return;
}
if ($cx['flags']['debug'] & static::DEBUG_ERROR_EXCEPTION) {
throw new \Exception($err);
}
} | php | public static function err($cx, $err) {
if ($cx['flags']['debug'] & static::DEBUG_ERROR_LOG) {
error_log($err);
return;
}
if ($cx['flags']['debug'] & static::DEBUG_ERROR_EXCEPTION) {
throw new \Exception($err);
}
} | [
"public",
"static",
"function",
"err",
"(",
"$",
"cx",
",",
"$",
"err",
")",
"{",
"if",
"(",
"$",
"cx",
"[",
"'flags'",
"]",
"[",
"'debug'",
"]",
"&",
"static",
"::",
"DEBUG_ERROR_LOG",
")",
"{",
"error_log",
"(",
"$",
"err",
")",
";",
"return",
... | Handle error by error_log or throw exception.
@param array<string,array|string|integer> $cx render time context for lightncandy
@param string $err error message
@throws \Exception | [
"Handle",
"error",
"by",
"error_log",
"or",
"throw",
"exception",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L104-L112 |
zordius/lightncandy | src/Runtime.php | Runtime.v | public static function v($cx, $in, $base, $path, $args = null) {
$count = count($cx['scopes']);
$plen = count($path);
while ($base) {
$v = $base;
foreach ($path as $i => $name) {
if (is_array($v)) {
if (isset($v[$name])) {
... | php | public static function v($cx, $in, $base, $path, $args = null) {
$count = count($cx['scopes']);
$plen = count($path);
while ($base) {
$v = $base;
foreach ($path as $i => $name) {
if (is_array($v)) {
if (isset($v[$name])) {
... | [
"public",
"static",
"function",
"v",
"(",
"$",
"cx",
",",
"$",
"in",
",",
"$",
"base",
",",
"$",
"path",
",",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"cx",
"[",
"'scopes'",
"]",
")",
";",
"$",
"plen",
"=",
... | Resursive lookup variable and helpers. This is slow and will only be used for instance property or method detection or lambdas.
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array|string|boolean|integer|double|null $in current context
@param array<array|string|integer> $base ... | [
"Resursive",
"lookup",
"variable",
"and",
"helpers",
".",
"This",
"is",
"slow",
"and",
"will",
"only",
"be",
"used",
"for",
"instance",
"property",
"or",
"method",
"detection",
"or",
"lambdas",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L151-L210 |
zordius/lightncandy | src/Runtime.php | Runtime.ifvar | public static function ifvar($cx, $v, $zero) {
return ($v !== null) && ($v !== false) && ($zero || ($v !== 0) && ($v !== 0.0)) && ($v !== '') && (is_array($v) ? (count($v) > 0) : true);
} | php | public static function ifvar($cx, $v, $zero) {
return ($v !== null) && ($v !== false) && ($zero || ($v !== 0) && ($v !== 0.0)) && ($v !== '') && (is_array($v) ? (count($v) > 0) : true);
} | [
"public",
"static",
"function",
"ifvar",
"(",
"$",
"cx",
",",
"$",
"v",
",",
"$",
"zero",
")",
"{",
"return",
"(",
"$",
"v",
"!==",
"null",
")",
"&&",
"(",
"$",
"v",
"!==",
"false",
")",
"&&",
"(",
"$",
"zero",
"||",
"(",
"$",
"v",
"!==",
"... | For {{#if}} .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $v value to be tested
@param boolean $zero include zero as true
@return boolean Return true when the value is not null nor false.
@expect false when input array(), nu... | [
"For",
"{{",
"#if",
"}}",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L232-L234 |
zordius/lightncandy | src/Runtime.php | Runtime.isec | public static function isec($cx, $v) {
return ($v === null) || ($v === false) || (is_array($v) && (count($v) === 0));
} | php | public static function isec($cx, $v) {
return ($v === null) || ($v === false) || (is_array($v) && (count($v) === 0));
} | [
"public",
"static",
"function",
"isec",
"(",
"$",
"cx",
",",
"$",
"v",
")",
"{",
"return",
"(",
"$",
"v",
"===",
"null",
")",
"||",
"(",
"$",
"v",
"===",
"false",
")",
"||",
"(",
"is_array",
"(",
"$",
"v",
")",
"&&",
"(",
"count",
"(",
"$",
... | For {{^var}} .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $v value to be tested
@return boolean Return true when the value is not null nor false.
@expect true when input array(), null
@expect false when input array(), 0
@ex... | [
"For",
"{{",
"^var",
"}}",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L251-L253 |
zordius/lightncandy | src/Runtime.php | Runtime.encq | public static function encq($cx, $var) {
if ($var instanceof \LightnCandy\SafeString) {
return (string)$var;
}
return str_replace(array('=', '`', '''), array('=', '`', '''), htmlspecialchars(static::raw($cx, $var), ENT_QUOTES, 'UTF-8'));
} | php | public static function encq($cx, $var) {
if ($var instanceof \LightnCandy\SafeString) {
return (string)$var;
}
return str_replace(array('=', '`', '''), array('=', '`', '''), htmlspecialchars(static::raw($cx, $var), ENT_QUOTES, 'UTF-8'));
} | [
"public",
"static",
"function",
"encq",
"(",
"$",
"cx",
",",
"$",
"var",
")",
"{",
"if",
"(",
"$",
"var",
"instanceof",
"\\",
"LightnCandy",
"\\",
"SafeString",
")",
"{",
"return",
"(",
"string",
")",
"$",
"var",
";",
"}",
"return",
"str_replace",
"(... | For {{var}} , do html encode just like handlebars.js .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $var value to be htmlencoded
@return string The htmlencoded value of the specified variable
@expect 'a' when input array('fla... | [
"For",
"{{",
"var",
"}}",
"do",
"html",
"encode",
"just",
"like",
"handlebars",
".",
"js",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L289-L295 |
zordius/lightncandy | src/Runtime.php | Runtime.sec | public static function sec($cx, $v, $bp, $in, $each, $cb, $else = null) {
$push = ($in !== $v) || $each;
$isAry = is_array($v) || ($v instanceof \ArrayObject);
$isTrav = $v instanceof \Traversable;
$loop = $each;
$keys = null;
$last = null;
$isObj = false;
... | php | public static function sec($cx, $v, $bp, $in, $each, $cb, $else = null) {
$push = ($in !== $v) || $each;
$isAry = is_array($v) || ($v instanceof \ArrayObject);
$isTrav = $v instanceof \Traversable;
$loop = $each;
$keys = null;
$last = null;
$isObj = false;
... | [
"public",
"static",
"function",
"sec",
"(",
"$",
"cx",
",",
"$",
"v",
",",
"$",
"bp",
",",
"$",
"in",
",",
"$",
"each",
",",
"$",
"cb",
",",
"$",
"else",
"=",
"null",
")",
"{",
"$",
"push",
"=",
"(",
"$",
"in",
"!==",
"$",
"v",
")",
"||",... | For {{#var}} or {{#each}} .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $v value for the section
@param array<string>|null $bp block parameters
@param array<array|string|integer>|string|integer|null $in input data with current... | [
"For",
"{{",
"#var",
"}}",
"or",
"{{",
"#each",
"}}",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L335-L446 |
zordius/lightncandy | src/Runtime.php | Runtime.wi | public static function wi($cx, $v, $bp, $in, $cb, $else = null) {
if (isset($bp[0])) {
$v = static::m($cx, $v, array($bp[0] => $v));
}
if (($v === false) || ($v === null) || (is_array($v) && (count($v) === 0))) {
return $else ? $else($cx, $in) : '';
}
if (... | php | public static function wi($cx, $v, $bp, $in, $cb, $else = null) {
if (isset($bp[0])) {
$v = static::m($cx, $v, array($bp[0] => $v));
}
if (($v === false) || ($v === null) || (is_array($v) && (count($v) === 0))) {
return $else ? $else($cx, $in) : '';
}
if (... | [
"public",
"static",
"function",
"wi",
"(",
"$",
"cx",
",",
"$",
"v",
",",
"$",
"bp",
",",
"$",
"in",
",",
"$",
"cb",
",",
"$",
"else",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"bp",
"[",
"0",
"]",
")",
")",
"{",
"$",
"v",
"=... | For {{#with}} .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $v value to be the new context
@param array<array|string|integer>|string|integer|null $in input data with current scope
@param array<string>|null $bp block parameters... | [
"For",
"{{",
"#with",
"}}",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L465-L480 |
zordius/lightncandy | src/Runtime.php | Runtime.m | public static function m($cx, $a, $b) {
if (is_array($b)) {
if ($a === null) {
return $b;
} else if (is_array($a)) {
return array_merge($a, $b);
} else if ($cx['flags']['method'] || $cx['flags']['prop']) {
if (!is_object($a)) {
... | php | public static function m($cx, $a, $b) {
if (is_array($b)) {
if ($a === null) {
return $b;
} else if (is_array($a)) {
return array_merge($a, $b);
} else if ($cx['flags']['method'] || $cx['flags']['prop']) {
if (!is_object($a)) {
... | [
"public",
"static",
"function",
"m",
"(",
"$",
"cx",
",",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"b",
")",
")",
"{",
"if",
"(",
"$",
"a",
"===",
"null",
")",
"{",
"return",
"$",
"b",
";",
"}",
"else",
"if",
"(... | Get merged context.
@param array<string,array|string|integer> $cx render time context for lightncandy
@param array<array|string|integer>|string|integer|null $a the context to be merged
@param array<array|string|integer>|string|integer|null $b the new context to overwrite
@return array<array|string|integer>|string|int... | [
"Get",
"merged",
"context",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L492-L508 |
zordius/lightncandy | src/Runtime.php | Runtime.p | public static function p($cx, $p, $v, $pid, $sp = '') {
$pp = ($p === '@partial-block') ? "$p" . ($pid > 0 ? $pid : $cx['partialid']) : $p;
if (!isset($cx['partials'][$pp])) {
static::err($cx, "Can not find partial named as '$p' !!");
return '';
}
$cx['partialid... | php | public static function p($cx, $p, $v, $pid, $sp = '') {
$pp = ($p === '@partial-block') ? "$p" . ($pid > 0 ? $pid : $cx['partialid']) : $p;
if (!isset($cx['partials'][$pp])) {
static::err($cx, "Can not find partial named as '$p' !!");
return '';
}
$cx['partialid... | [
"public",
"static",
"function",
"p",
"(",
"$",
"cx",
",",
"$",
"p",
",",
"$",
"v",
",",
"$",
"pid",
",",
"$",
"sp",
"=",
"''",
")",
"{",
"$",
"pp",
"=",
"(",
"$",
"p",
"===",
"'@partial-block'",
")",
"?",
"\"$p\"",
".",
"(",
"$",
"pid",
">"... | For {{> partial}} .
@param array<string,array|string|integer> $cx render time context for lightncandy
@param string $p partial name
@param array<array|string|integer>|string|integer|null $v value to be the new context
@return string The rendered string of the partial | [
"For",
"{{",
">",
"partial",
"}}",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L520-L531 |
zordius/lightncandy | src/Runtime.php | Runtime.hbch | public static function hbch($cx, $ch, $vars, $op, &$_this) {
if (isset($cx['blparam'][0][$ch])) {
return $cx['blparam'][0][$ch];
}
$options = array(
'name' => $ch,
'hash' => $vars[1],
'contexts' => count($cx['scopes']) ? $cx['scopes'] : array(null... | php | public static function hbch($cx, $ch, $vars, $op, &$_this) {
if (isset($cx['blparam'][0][$ch])) {
return $cx['blparam'][0][$ch];
}
$options = array(
'name' => $ch,
'hash' => $vars[1],
'contexts' => count($cx['scopes']) ? $cx['scopes'] : array(null... | [
"public",
"static",
"function",
"hbch",
"(",
"$",
"cx",
",",
"$",
"ch",
",",
"$",
"vars",
",",
"$",
"op",
",",
"&",
"$",
"_this",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cx",
"[",
"'blparam'",
"]",
"[",
"0",
"]",
"[",
"$",
"ch",
"]",
")",
... | /* For single custom helpers.
@param array<string,array|string|integer> $cx render time context for lightncandy
@param string $ch the name of custom helper to be executed
@param array<array|string|integer>|string|integer|null $vars variables for the helper
@param string $op the name of variable resolver. should be one... | [
"/",
"*",
"For",
"single",
"custom",
"helpers",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L555-L573 |
zordius/lightncandy | src/Runtime.php | Runtime.hbbch | public static function hbbch($cx, $ch, $vars, &$_this, $inverted, $cb, $else = null) {
$options = array(
'name' => $ch,
'hash' => $vars[1],
'contexts' => count($cx['scopes']) ? $cx['scopes'] : array(null),
'fn.blockParams' => 0,
'_this' => &$_this,
... | php | public static function hbbch($cx, $ch, $vars, &$_this, $inverted, $cb, $else = null) {
$options = array(
'name' => $ch,
'hash' => $vars[1],
'contexts' => count($cx['scopes']) ? $cx['scopes'] : array(null),
'fn.blockParams' => 0,
'_this' => &$_this,
... | [
"public",
"static",
"function",
"hbbch",
"(",
"$",
"cx",
",",
"$",
"ch",
",",
"$",
"vars",
",",
"&",
"$",
"_this",
",",
"$",
"inverted",
",",
"$",
"cb",
",",
"$",
"else",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'name'",
"=>",... | For block custom helpers.
@param array<string,array|string|integer> $cx render time context for lightncandy
@param string $ch the name of custom helper to be executed
@param array<array|string|integer>|string|integer|null $vars variables for the helper
@param array<string,array|string|integer> $_this current rendering... | [
"For",
"block",
"custom",
"helpers",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L588-L661 |
zordius/lightncandy | src/Runtime.php | Runtime.exch | public static function exch($cx, $ch, $vars, &$options) {
$args = $vars[0];
$args[] = $options;
$e = null;
$r = true;
try {
$r = call_user_func_array($cx['helpers'][$ch], $args);
} catch (\Exception $E) {
$e = "Runtime: call custom helper '$ch' er... | php | public static function exch($cx, $ch, $vars, &$options) {
$args = $vars[0];
$args[] = $options;
$e = null;
$r = true;
try {
$r = call_user_func_array($cx['helpers'][$ch], $args);
} catch (\Exception $E) {
$e = "Runtime: call custom helper '$ch' er... | [
"public",
"static",
"function",
"exch",
"(",
"$",
"cx",
",",
"$",
"ch",
",",
"$",
"vars",
",",
"&",
"$",
"options",
")",
"{",
"$",
"args",
"=",
"$",
"vars",
"[",
"0",
"]",
";",
"$",
"args",
"[",
"]",
"=",
"$",
"options",
";",
"$",
"e",
"=",... | Execute custom helper with prepared options
@param array<string,array|string|integer> $cx render time context for lightncandy
@param string $ch the name of custom helper to be executed
@param array<array|string|integer>|string|integer|null $vars variables for the helper
@param array<string,array|string|integer> $optio... | [
"Execute",
"custom",
"helper",
"with",
"prepared",
"options"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Runtime.php#L673-L690 |
zordius/lightncandy | src/LightnCandy.php | LightnCandy.compile | public static function compile($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) {
$context = Context::create($options);
if (static::handleError($context)) {
return false;
}
$code = Compiler::compileTemplate($context, SafeString::escapeTemplate($template))... | php | public static function compile($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) {
$context = Context::create($options);
if (static::handleError($context)) {
return false;
}
$code = Compiler::compileTemplate($context, SafeString::escapeTemplate($template))... | [
"public",
"static",
"function",
"compile",
"(",
"$",
"template",
",",
"$",
"options",
"=",
"array",
"(",
"'flags'",
"=>",
"self",
"::",
"FLAG_BESTPERFORMANCE",
")",
")",
"{",
"$",
"context",
"=",
"Context",
"::",
"create",
"(",
"$",
"options",
")",
";",
... | Compile handlebars template into PHP code.
@param string $template handlebars template string
@param array<string,array|string|integer> $options LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE)
@return string|false Compiled PHP code when successed. If error... | [
"Compile",
"handlebars",
"template",
"into",
"PHP",
"code",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/LightnCandy.php#L43-L60 |
zordius/lightncandy | src/LightnCandy.php | LightnCandy.compilePartial | public static function compilePartial($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) {
$context = Context::create($options);
if (static::handleError($context)) {
return false;
}
$code = Partial::compile($context, SafeString::escapeTemplate($template));
... | php | public static function compilePartial($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) {
$context = Context::create($options);
if (static::handleError($context)) {
return false;
}
$code = Partial::compile($context, SafeString::escapeTemplate($template));
... | [
"public",
"static",
"function",
"compilePartial",
"(",
"$",
"template",
",",
"$",
"options",
"=",
"array",
"(",
"'flags'",
"=>",
"self",
"::",
"FLAG_BESTPERFORMANCE",
")",
")",
"{",
"$",
"context",
"=",
"Context",
"::",
"create",
"(",
"$",
"options",
")",
... | Compile handlebars partial into PHP function code.
@param string $template handlebars template string
@param array<string,array|string|integer> $options LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE)
@return string|false Compiled PHP code when successed. ... | [
"Compile",
"handlebars",
"partial",
"into",
"PHP",
"function",
"code",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/LightnCandy.php#L72-L89 |
zordius/lightncandy | src/LightnCandy.php | LightnCandy.handleError | protected static function handleError(&$context) {
static::$lastContext = $context;
if (count($context['error'])) {
if ($context['flags']['errorlog']) {
error_log(implode("\n", $context['error']));
}
if ($context['flags']['exception']) {
... | php | protected static function handleError(&$context) {
static::$lastContext = $context;
if (count($context['error'])) {
if ($context['flags']['errorlog']) {
error_log(implode("\n", $context['error']));
}
if ($context['flags']['exception']) {
... | [
"protected",
"static",
"function",
"handleError",
"(",
"&",
"$",
"context",
")",
"{",
"static",
"::",
"$",
"lastContext",
"=",
"$",
"context",
";",
"if",
"(",
"count",
"(",
"$",
"context",
"[",
"'error'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"context"... | Handle exists error and return error status.
@param array<string,array|string|integer> $context Current context of compiler progress.
@throws \Exception
@return boolean True when error detected
@expect false when input array('error' => array())
@expect true when input array('error' => array('some error'), 'flags' =>... | [
"Handle",
"exists",
"error",
"and",
"return",
"error",
"status",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/LightnCandy.php#L102-L115 |
zordius/lightncandy | src/LightnCandy.php | LightnCandy.prepare | public static function prepare($php, $tmpDir = null, $delete = true) {
$php = "<?php $php ?>";
if (!ini_get('allow_url_include') || !ini_get('allow_url_fopen')) {
if (!is_string($tmpDir) || !is_dir($tmpDir)) {
$tmpDir = sys_get_temp_dir();
}
}
if... | php | public static function prepare($php, $tmpDir = null, $delete = true) {
$php = "<?php $php ?>";
if (!ini_get('allow_url_include') || !ini_get('allow_url_fopen')) {
if (!is_string($tmpDir) || !is_dir($tmpDir)) {
$tmpDir = sys_get_temp_dir();
}
}
if... | [
"public",
"static",
"function",
"prepare",
"(",
"$",
"php",
",",
"$",
"tmpDir",
"=",
"null",
",",
"$",
"delete",
"=",
"true",
")",
"{",
"$",
"php",
"=",
"\"<?php $php ?>\"",
";",
"if",
"(",
"!",
"ini_get",
"(",
"'allow_url_include'",
")",
"||",
"!",
... | Get a working render function by a string of PHP code. This method may requires php setting allow_url_include=1 and allow_url_fopen=1 , or access right to tmp file system.
@param string $php PHP code
@param string|null $tmpDir Optional, change temp directory for php include file saved by prepare() when cannot inc... | [
"Get",
"a",
"working",
"render",
"function",
"by",
"a",
"string",
"of",
"PHP",
"code",
".",
"This",
"method",
"may",
"requires",
"php",
"setting",
"allow_url_include",
"=",
"1",
"and",
"allow_url_fopen",
"=",
"1",
"or",
"access",
"right",
"to",
"tmp",
"fil... | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/LightnCandy.php#L137-L167 |
zordius/lightncandy | src/Validator.php | Validator.verify | public static function verify(&$context, $template) {
$template = SafeString::stripExtendedComments($template);
$context['level'] = 0;
Parser::setDelimiter($context);
while (preg_match($context['tokens']['search'], $template, $matches)) {
// Skip a token when it is slash esc... | php | public static function verify(&$context, $template) {
$template = SafeString::stripExtendedComments($template);
$context['level'] = 0;
Parser::setDelimiter($context);
while (preg_match($context['tokens']['search'], $template, $matches)) {
// Skip a token when it is slash esc... | [
"public",
"static",
"function",
"verify",
"(",
"&",
"$",
"context",
",",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"SafeString",
"::",
"stripExtendedComments",
"(",
"$",
"template",
")",
";",
"$",
"context",
"[",
"'level'",
"]",
"=",
"0",
";",
"... | Verify template
@param array<string,array|string|integer> $context Current context
@param string $template handlebars template | [
"Verify",
"template"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L37-L73 |
zordius/lightncandy | src/Validator.php | Validator.pushLeft | protected static function pushLeft(&$context) {
$L = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
if ($context['currentToken'][Token::POS_OP] === '!') {
$appender = function (&$pb) use ($L) {
$pb .= $L;
};
... | php | protected static function pushLeft(&$context) {
$L = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
if ($context['currentToken'][Token::POS_OP] === '!') {
$appender = function (&$pb) use ($L) {
$pb .= $L;
};
... | [
"protected",
"static",
"function",
"pushLeft",
"(",
"&",
"$",
"context",
")",
"{",
"$",
"L",
"=",
"$",
"context",
"[",
"'currentToken'",
"]",
"[",
"Token",
"::",
"POS_LOTHER",
"]",
".",
"$",
"context",
"[",
"'currentToken'",
"]",
"[",
"Token",
"::",
"P... | push left string of current token and clear it
@param array<string,array|string|integer> $context Current context | [
"push",
"left",
"string",
"of",
"current",
"token",
"and",
"clear",
"it"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L80-L97 |
zordius/lightncandy | src/Validator.php | Validator.pushToken | protected static function pushToken(&$context, $token) {
if ($token === '') {
return;
}
if (is_string($token)) {
if (is_string(end($context['parsed'][0]))) {
$context['parsed'][0][key($context['parsed'][0])] .= $token;
return;
}... | php | protected static function pushToken(&$context, $token) {
if ($token === '') {
return;
}
if (is_string($token)) {
if (is_string(end($context['parsed'][0]))) {
$context['parsed'][0][key($context['parsed'][0])] .= $token;
return;
}... | [
"protected",
"static",
"function",
"pushToken",
"(",
"&",
"$",
"context",
",",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"===",
"''",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"token",
")",
")",
"{",
"if",
"(",
"is_st... | push a token into the stack when it is not empty string
@param array<string,array|string|integer> $context Current context
@param string|array $token a parsed token or a string | [
"push",
"a",
"token",
"into",
"the",
"stack",
"when",
"it",
"is",
"not",
"empty",
"string"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L105-L116 |
zordius/lightncandy | src/Validator.php | Validator.pushStack | protected static function pushStack(&$context, $operation, $vars) {
list($levels, $spvar, $var) = Expression::analyze($context, $vars[0]);
$context['stack'][] = $context['currentToken'][Token::POS_INNERTAG];
$context['stack'][] = Expression::toString($levels, $spvar, $var);
$context['sta... | php | protected static function pushStack(&$context, $operation, $vars) {
list($levels, $spvar, $var) = Expression::analyze($context, $vars[0]);
$context['stack'][] = $context['currentToken'][Token::POS_INNERTAG];
$context['stack'][] = Expression::toString($levels, $spvar, $var);
$context['sta... | [
"protected",
"static",
"function",
"pushStack",
"(",
"&",
"$",
"context",
",",
"$",
"operation",
",",
"$",
"vars",
")",
"{",
"list",
"(",
"$",
"levels",
",",
"$",
"spvar",
",",
"$",
"var",
")",
"=",
"Expression",
"::",
"analyze",
"(",
"$",
"context",... | push current token into the section stack
@param array<string,array|string|integer> $context Current context
@param string $operation operation string
@param array<boolean|integer|string|array> $vars parsed arguments list | [
"push",
"current",
"token",
"into",
"the",
"section",
"stack"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L125-L131 |
zordius/lightncandy | src/Validator.php | Validator.delimiter | protected static function delimiter($token, &$context) {
// {{ }}} or {{{ }} are invalid
if (strlen($token[Token::POS_BEGINRAW]) !== strlen($token[Token::POS_ENDRAW])) {
$context['error'][] = 'Bad token ' . Token::toString($token) . ' ! Do you mean ' . Token::toString($token, array(Token::PO... | php | protected static function delimiter($token, &$context) {
// {{ }}} or {{{ }} are invalid
if (strlen($token[Token::POS_BEGINRAW]) !== strlen($token[Token::POS_ENDRAW])) {
$context['error'][] = 'Bad token ' . Token::toString($token) . ' ! Do you mean ' . Token::toString($token, array(Token::PO... | [
"protected",
"static",
"function",
"delimiter",
"(",
"$",
"token",
",",
"&",
"$",
"context",
")",
"{",
"// {{ }}} or {{{ }} are invalid",
"if",
"(",
"strlen",
"(",
"$",
"token",
"[",
"Token",
"::",
"POS_BEGINRAW",
"]",
")",
"!==",
"strlen",
"(",
"$",
"toke... | Verify delimiters and operators
@param string[] $token detected handlebars {{ }} token
@param array<string,array|string|integer> $context current compile context
@return boolean|null Return true when invalid
@expect null when input array_fill(0, 11, ''), array()
@expect null when input array(0, 0, 0, 0, 0, '{{', '#'... | [
"Verify",
"delimiters",
"and",
"operators"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L145-L156 |
zordius/lightncandy | src/Validator.php | Validator.operator | protected static function operator($operator, &$context, &$vars) {
switch ($operator) {
case '#*':
if (!$context['compile']) {
static::pushLeft($context);
$context['stack'][] = count($context['parsed'][0]);
static::pushStack... | php | protected static function operator($operator, &$context, &$vars) {
switch ($operator) {
case '#*':
if (!$context['compile']) {
static::pushLeft($context);
$context['stack'][] = count($context['parsed'][0]);
static::pushStack... | [
"protected",
"static",
"function",
"operator",
"(",
"$",
"operator",
",",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
")",
"{",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"'#*'",
":",
"if",
"(",
"!",
"$",
"context",
"[",
"'compile'",
"]",
")... | Verify operators
@param string $operator the operator string
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean|integer|null Return true when invalid or detected
@expect null when input '', array(), array()... | [
"Verify",
"operators"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L179-L242 |
zordius/lightncandy | src/Validator.php | Validator.inlinePartial | protected static function inlinePartial(&$context, $vars) {
if (count($context['inlinepartial']) > 0) {
$ended = false;
$append = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
array_walk($context['inlinepartial'], function (&$pb) u... | php | protected static function inlinePartial(&$context, $vars) {
if (count($context['inlinepartial']) > 0) {
$ended = false;
$append = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
array_walk($context['inlinepartial'], function (&$pb) u... | [
"protected",
"static",
"function",
"inlinePartial",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"context",
"[",
"'inlinepartial'",
"]",
")",
">",
"0",
")",
"{",
"$",
"ended",
"=",
"false",
";",
"$",
"append",
... | validate inline partial begin token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean|null Return true when inline partial ends | [
"validate",
"inline",
"partial",
"begin",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L252-L279 |
zordius/lightncandy | src/Validator.php | Validator.partialBlock | protected static function partialBlock(&$context, $vars) {
if (count($context['partialblock']) > 0) {
$ended = false;
$append = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
array_walk($context['partialblock'], function (&$pb) use ... | php | protected static function partialBlock(&$context, $vars) {
if (count($context['partialblock']) > 0) {
$ended = false;
$append = $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
array_walk($context['partialblock'], function (&$pb) use ... | [
"protected",
"static",
"function",
"partialBlock",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"context",
"[",
"'partialblock'",
"]",
")",
">",
"0",
")",
"{",
"$",
"ended",
"=",
"false",
";",
"$",
"append",
"... | validate partial block token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean|null Return true when partial block ends | [
"validate",
"partial",
"block",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L289-L322 |
zordius/lightncandy | src/Validator.php | Validator.blockBegin | protected static function blockBegin(&$context, $vars) {
switch ((isset($vars[0][0]) && is_string($vars[0][0])) ? $vars[0][0] : null) {
case 'with':
return static::with($context, $vars);
case 'each':
return static::section($context, $vars, true);
... | php | protected static function blockBegin(&$context, $vars) {
switch ((isset($vars[0][0]) && is_string($vars[0][0])) ? $vars[0][0] : null) {
case 'with':
return static::with($context, $vars);
case 'each':
return static::section($context, $vars, true);
... | [
"protected",
"static",
"function",
"blockBegin",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"switch",
"(",
"(",
"isset",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"&&",
"is_string",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0... | validate block begin token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean Return true always | [
"validate",
"block",
"begin",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L345-L358 |
zordius/lightncandy | src/Validator.php | Validator.builtin | protected static function builtin(&$context, $vars) {
if ($context['flags']['nohbh']) {
if (isset($vars[1][0])) {
$context['error'][] = "Do not support {{#{$vars[0][0]} var}} because you compile with LightnCandy::FLAG_NOHBHELPERS flag";
}
} else {
if (... | php | protected static function builtin(&$context, $vars) {
if ($context['flags']['nohbh']) {
if (isset($vars[1][0])) {
$context['error'][] = "Do not support {{#{$vars[0][0]} var}} because you compile with LightnCandy::FLAG_NOHBHELPERS flag";
}
} else {
if (... | [
"protected",
"static",
"function",
"builtin",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'nohbh'",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"1",
"]",
"[",
"0",
"]... | validate builtin helpers
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list | [
"validate",
"builtin",
"helpers"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L366-L377 |
zordius/lightncandy | src/Validator.php | Validator.section | protected static function section(&$context, $vars, $isEach = false) {
if ($isEach) {
static::builtin($context, $vars);
} else {
if ((count($vars) > 1) && !$context['flags']['lambda']) {
$context['error'][] = "Custom helper not found: {$vars[0][0]} in " . Token::t... | php | protected static function section(&$context, $vars, $isEach = false) {
if ($isEach) {
static::builtin($context, $vars);
} else {
if ((count($vars) > 1) && !$context['flags']['lambda']) {
$context['error'][] = "Custom helper not found: {$vars[0][0]} in " . Token::t... | [
"protected",
"static",
"function",
"section",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
",",
"$",
"isEach",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isEach",
")",
"{",
"static",
"::",
"builtin",
"(",
"$",
"context",
",",
"$",
"vars",
")",
";",
... | validate section token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $isEach the section is #each
@return boolean Return true always | [
"validate",
"section",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L388-L398 |
zordius/lightncandy | src/Validator.php | Validator.blockCustomHelper | protected static function blockCustomHelper(&$context, $vars, $inverted = false) {
if (is_string($vars[0][0])) {
if (static::resolveHelper($context, $vars)) {
return ++$context['usedFeature']['helper'];
}
}
} | php | protected static function blockCustomHelper(&$context, $vars, $inverted = false) {
if (is_string($vars[0][0])) {
if (static::resolveHelper($context, $vars)) {
return ++$context['usedFeature']['helper'];
}
}
} | [
"protected",
"static",
"function",
"blockCustomHelper",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
",",
"$",
"inverted",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
")",
")",
"{",
"if",
"(",
"s... | validate block custom helper token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $inverted the logic will be inverted
@return integer|null Return number of used custom helpers | [
"validate",
"block",
"custom",
"helper",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L448-L454 |
zordius/lightncandy | src/Validator.php | Validator.blockEnd | protected static function blockEnd(&$context, &$vars, $match = null) {
$c = count($context['stack']) - 2;
$pop = ($c >= 0) ? $context['stack'][$c + 1] : '';
if (($match !== null) && ($match !== $pop)) {
return;
}
// if we didn't match our $pop, we didn't actually do a... | php | protected static function blockEnd(&$context, &$vars, $match = null) {
$c = count($context['stack']) - 2;
$pop = ($c >= 0) ? $context['stack'][$c + 1] : '';
if (($match !== null) && ($match !== $pop)) {
return;
}
// if we didn't match our $pop, we didn't actually do a... | [
"protected",
"static",
"function",
"blockEnd",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
",",
"$",
"match",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"count",
"(",
"$",
"context",
"[",
"'stack'",
"]",
")",
"-",
"2",
";",
"$",
"pop",
"=",
"("... | Return compiled PHP code for a handlebars block end token
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param string|null $match should also match to this operator
@return boolean Return true | [
"Return",
"compiled",
"PHP",
"code",
"for",
"a",
"handlebars",
"block",
"end",
"token"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L477-L520 |
zordius/lightncandy | src/Validator.php | Validator.isDelimiter | protected static function isDelimiter(&$context) {
if (preg_match('/^=\s*([^ ]+)\s+([^ ]+)\s*=$/', $context['currentToken'][Token::POS_INNERTAG], $matched)) {
$context['usedFeature']['delimiter']++;
Parser::setDelimiter($context, $matched[1], $matched[2]);
return true;
... | php | protected static function isDelimiter(&$context) {
if (preg_match('/^=\s*([^ ]+)\s+([^ ]+)\s*=$/', $context['currentToken'][Token::POS_INNERTAG], $matched)) {
$context['usedFeature']['delimiter']++;
Parser::setDelimiter($context, $matched[1], $matched[2]);
return true;
... | [
"protected",
"static",
"function",
"isDelimiter",
"(",
"&",
"$",
"context",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^=\\s*([^ ]+)\\s+([^ ]+)\\s*=$/'",
",",
"$",
"context",
"[",
"'currentToken'",
"]",
"[",
"Token",
"::",
"POS_INNERTAG",
"]",
",",
"$",
"match... | handle delimiter change
@param array<string,array|string|integer> $context current compile context
@return boolean|null Return true when delimiter changed | [
"handle",
"delimiter",
"change"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L529-L535 |
zordius/lightncandy | src/Validator.php | Validator.rawblock | protected static function rawblock(&$token, &$context) {
$inner = $token[Token::POS_INNERTAG];
trim($inner);
// skip parse when inside raw block
if ($context['rawblock'] && !(($token[Token::POS_BEGINRAW] === '{{') && ($token[Token::POS_OP] === '/') && ($context['rawblock'] === $inner)))... | php | protected static function rawblock(&$token, &$context) {
$inner = $token[Token::POS_INNERTAG];
trim($inner);
// skip parse when inside raw block
if ($context['rawblock'] && !(($token[Token::POS_BEGINRAW] === '{{') && ($token[Token::POS_OP] === '/') && ($context['rawblock'] === $inner)))... | [
"protected",
"static",
"function",
"rawblock",
"(",
"&",
"$",
"token",
",",
"&",
"$",
"context",
")",
"{",
"$",
"inner",
"=",
"$",
"token",
"[",
"Token",
"::",
"POS_INNERTAG",
"]",
";",
"trim",
"(",
"$",
"inner",
")",
";",
"// skip parse when inside raw ... | handle raw block
@param string[] $token detected handlebars {{ }} token
@param array<string,array|string|integer> $context current compile context
@return boolean|null Return true when in rawblock mode | [
"handle",
"raw",
"block"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L545-L574 |
zordius/lightncandy | src/Validator.php | Validator.token | protected static function token(&$token, &$context) {
$context['currentToken'] = &$token;
if (static::rawblock($token, $context)) {
return Token::toString($token);
}
if (static::delimiter($token, $context)) {
return;
}
if (static::isDelimiter($c... | php | protected static function token(&$token, &$context) {
$context['currentToken'] = &$token;
if (static::rawblock($token, $context)) {
return Token::toString($token);
}
if (static::delimiter($token, $context)) {
return;
}
if (static::isDelimiter($c... | [
"protected",
"static",
"function",
"token",
"(",
"&",
"$",
"token",
",",
"&",
"$",
"context",
")",
"{",
"$",
"context",
"[",
"'currentToken'",
"]",
"=",
"&",
"$",
"token",
";",
"if",
"(",
"static",
"::",
"rawblock",
"(",
"$",
"token",
",",
"$",
"co... | Collect handlebars usage information, detect template error.
@param string[] $token detected handlebars {{ }} token
@param array<string,array|string|integer> $context current compile context | [
"Collect",
"handlebars",
"usage",
"information",
"detect",
"template",
"error",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L597-L671 |
zordius/lightncandy | src/Validator.php | Validator.doElse | protected static function doElse(&$context, $vars) {
if ($context['level'] == 0) {
$context['error'][] = '{{else}} only valid in if, unless, each, and #section context';
}
if (isset($vars[1][0])) {
$token = $context['currentToken'];
$context['currentToken'][T... | php | protected static function doElse(&$context, $vars) {
if ($context['level'] == 0) {
$context['error'][] = '{{else}} only valid in if, unless, each, and #section context';
}
if (isset($vars[1][0])) {
$token = $context['currentToken'];
$context['currentToken'][T... | [
"protected",
"static",
"function",
"doElse",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'level'",
"]",
"==",
"0",
")",
"{",
"$",
"context",
"[",
"'error'",
"]",
"[",
"]",
"=",
"'{{else}} only valid in if, unl... | Return 1 or larger number when else token detected
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return integer Return 1 or larger number when else token detected | [
"Return",
"1",
"or",
"larger",
"number",
"when",
"else",
"token",
"detected"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L681-L694 |
zordius/lightncandy | src/Validator.php | Validator.log | public static function log(&$context, $vars) {
if (isset($vars[0][0]) && ($vars[0][0] === 'log')) {
if (!$context['flags']['nohbh']) {
if (count($vars) < 2) {
$context['error'][] = "No argument after {{log}} !";
}
$context['usedFeat... | php | public static function log(&$context, $vars) {
if (isset($vars[0][0]) && ($vars[0][0] === 'log')) {
if (!$context['flags']['nohbh']) {
if (count($vars) < 2) {
$context['error'][] = "No argument after {{log}} !";
}
$context['usedFeat... | [
"public",
"static",
"function",
"log",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"&&",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
"===",
"'log'",
")",... | Return true when this is {{log ...}}
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean|null Return true when it is custom helper | [
"Return",
"true",
"when",
"this",
"is",
"{{",
"log",
"...",
"}}"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L704-L714 |
zordius/lightncandy | src/Validator.php | Validator.lookup | public static function lookup(&$context, $vars) {
if (isset($vars[0][0]) && ($vars[0][0] === 'lookup')) {
if (!$context['flags']['nohbh']) {
if (count($vars) < 2) {
$context['error'][] = "No argument after {{lookup}} !";
} else if (count($vars) < 3... | php | public static function lookup(&$context, $vars) {
if (isset($vars[0][0]) && ($vars[0][0] === 'lookup')) {
if (!$context['flags']['nohbh']) {
if (count($vars) < 2) {
$context['error'][] = "No argument after {{lookup}} !";
} else if (count($vars) < 3... | [
"public",
"static",
"function",
"lookup",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"&&",
"(",
"$",
"vars",
"[",
"0",
"]",
"[",
"0",
"]",
"===",
"'lookup'",
... | Return true when this is {{lookup ...}}
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean|null Return true when it is custom helper | [
"Return",
"true",
"when",
"this",
"is",
"{{",
"lookup",
"...",
"}}"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L724-L736 |
zordius/lightncandy | src/Validator.php | Validator.helper | public static function helper(&$context, $vars, $checkSubexp = false) {
if (static::resolveHelper($context, $vars)) {
$context['usedFeature']['helper']++;
return true;
}
if ($checkSubexp) {
switch ($vars[0][0]) {
case 'if':
cas... | php | public static function helper(&$context, $vars, $checkSubexp = false) {
if (static::resolveHelper($context, $vars)) {
$context['usedFeature']['helper']++;
return true;
}
if ($checkSubexp) {
switch ($vars[0][0]) {
case 'if':
cas... | [
"public",
"static",
"function",
"helper",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
",",
"$",
"checkSubexp",
"=",
"false",
")",
"{",
"if",
"(",
"static",
"::",
"resolveHelper",
"(",
"$",
"context",
",",
"$",
"vars",
")",
")",
"{",
"$",
"context",
... | Return true when the name is listed in helper table
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@param boolean $checkSubexp true when check for subexpression
@return boolean Return true when it is custom helper | [
"Return",
"true",
"when",
"the",
"name",
"is",
"listed",
"in",
"helper",
"table"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L747-L765 |
zordius/lightncandy | src/Validator.php | Validator.resolveHelper | public static function resolveHelper(&$context, &$vars) {
if (count($vars[0]) !== 1) {
return false;
}
if (isset($context['helpers'][$vars[0][0]])) {
return true;
}
if ($context['helperresolver']) {
$helper = $context['helperresolver']($contex... | php | public static function resolveHelper(&$context, &$vars) {
if (count($vars[0]) !== 1) {
return false;
}
if (isset($context['helpers'][$vars[0][0]])) {
return true;
}
if ($context['helperresolver']) {
$helper = $context['helperresolver']($contex... | [
"public",
"static",
"function",
"resolveHelper",
"(",
"&",
"$",
"context",
",",
"&",
"$",
"vars",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"vars",
"[",
"0",
"]",
")",
"!==",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$... | use helperresolver to resolve helper, return true when helper founded
@param array<string,array|string|integer> $context Current context of compiler progress.
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean $found helper exists or not | [
"use",
"helperresolver",
"to",
"resolve",
"helper",
"return",
"true",
"when",
"helper",
"founded"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L775-L792 |
zordius/lightncandy | src/Validator.php | Validator.inline | protected static function inline(&$context, $vars) {
if (!$context['flags']['runpart']) {
$context['error'][] = "Do not support {{#*{$context['currentToken'][Token::POS_INNERTAG]}}}, you should do compile with LightnCandy::FLAG_RUNTIMEPARTIAL flag";
}
if (!isset($vars[0][0]) || ($var... | php | protected static function inline(&$context, $vars) {
if (!$context['flags']['runpart']) {
$context['error'][] = "Do not support {{#*{$context['currentToken'][Token::POS_INNERTAG]}}}, you should do compile with LightnCandy::FLAG_RUNTIMEPARTIAL flag";
}
if (!isset($vars[0][0]) || ($var... | [
"protected",
"static",
"function",
"inline",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'runpart'",
"]",
")",
"{",
"$",
"context",
"[",
"'error'",
"]",
"[",
"]",
"=",
"\"Do not s... | validate inline partial
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return boolean Return true always | [
"validate",
"inline",
"partial"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L822-L833 |
zordius/lightncandy | src/Validator.php | Validator.partial | protected static function partial(&$context, $vars) {
if (Parser::isSubExp($vars[0])) {
if ($context['flags']['runpart']) {
return $context['usedFeature']['dynpartial']++;
} else {
$context['error'][] = "You use dynamic partial name as '{$vars[0][2]}', thi... | php | protected static function partial(&$context, $vars) {
if (Parser::isSubExp($vars[0])) {
if ($context['flags']['runpart']) {
return $context['usedFeature']['dynpartial']++;
} else {
$context['error'][] = "You use dynamic partial name as '{$vars[0][2]}', thi... | [
"protected",
"static",
"function",
"partial",
"(",
"&",
"$",
"context",
",",
"$",
"vars",
")",
"{",
"if",
"(",
"Parser",
"::",
"isSubExp",
"(",
"$",
"vars",
"[",
"0",
"]",
")",
")",
"{",
"if",
"(",
"$",
"context",
"[",
"'flags'",
"]",
"[",
"'runp... | validate partial
@param array<string,array|string|integer> $context current compile context
@param array<boolean|integer|string|array> $vars parsed arguments list
@return integer|boolean Return 1 or larger number for runtime partial, return true for other case | [
"validate",
"partial"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L843-L864 |
zordius/lightncandy | src/Validator.php | Validator.spacing | protected static function spacing(&$token, &$context, $nost = false) {
// left line change detection
$lsp = preg_match('/^(.*)(\\r?\\n)([ \\t]*?)$/s', $token[Token::POS_LSPACE], $lmatch);
$ind = $lsp ? $lmatch[3] : $token[Token::POS_LSPACE];
// right line change detection
$rsp = ... | php | protected static function spacing(&$token, &$context, $nost = false) {
// left line change detection
$lsp = preg_match('/^(.*)(\\r?\\n)([ \\t]*?)$/s', $token[Token::POS_LSPACE], $lmatch);
$ind = $lsp ? $lmatch[3] : $token[Token::POS_LSPACE];
// right line change detection
$rsp = ... | [
"protected",
"static",
"function",
"spacing",
"(",
"&",
"$",
"token",
",",
"&",
"$",
"context",
",",
"$",
"nost",
"=",
"false",
")",
"{",
"// left line change detection",
"$",
"lsp",
"=",
"preg_match",
"(",
"'/^(.*)(\\\\r?\\\\n)([ \\\\t]*?)$/s'",
",",
"$",
"to... | Modify $token when spacing rules matched.
@param array<string> $token detected handlebars {{ }} token
@param array<string,array|string|integer> $context current compile context
@param boolean $nost do not do stand alone logic
@return string|null Return compiled code segment for the token | [
"Modify",
"$token",
"when",
"spacing",
"rules",
"matched",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Validator.php#L875-L925 |
zordius/lightncandy | src/Expression.php | Expression.analyze | public static function analyze($context, $var) {
$levels = 0;
$spvar = false;
if (isset($var[0])) {
// trace to parent
if (!is_string($var[0]) && is_int($var[0])) {
$levels = array_shift($var);
}
}
if (isset($var[0])) {
... | php | public static function analyze($context, $var) {
$levels = 0;
$spvar = false;
if (isset($var[0])) {
// trace to parent
if (!is_string($var[0]) && is_int($var[0])) {
$levels = array_shift($var);
}
}
if (isset($var[0])) {
... | [
"public",
"static",
"function",
"analyze",
"(",
"$",
"context",
",",
"$",
"var",
")",
"{",
"$",
"levels",
"=",
"0",
";",
"$",
"spvar",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"var",
"[",
"0",
"]",
")",
")",
"{",
"// trace to parent",
"if... | Analyze an expression
@param array<string,array|string|integer> $context Current context
@param array<array|string|integer> $var variable parsed path
@return array<integer|boolean|array> analyzed result
@expect array(0, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(0, 'foo')
@expect ar... | [
"Analyze",
"an",
"expression"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Expression.php#L91-L113 |
zordius/lightncandy | src/Expression.php | Expression.toString | public static function toString($levels, $spvar, $var) {
return ($spvar ? '@' : '') . str_repeat('../', $levels) . ((is_array($var) && count($var)) ? implode('.', array_map(function($v) {
return ($v === null) ? 'this' : "[$v]";
}, $var)) : 'this');
} | php | public static function toString($levels, $spvar, $var) {
return ($spvar ? '@' : '') . str_repeat('../', $levels) . ((is_array($var) && count($var)) ? implode('.', array_map(function($v) {
return ($v === null) ? 'this' : "[$v]";
}, $var)) : 'this');
} | [
"public",
"static",
"function",
"toString",
"(",
"$",
"levels",
",",
"$",
"spvar",
",",
"$",
"var",
")",
"{",
"return",
"(",
"$",
"spvar",
"?",
"'@'",
":",
"''",
")",
".",
"str_repeat",
"(",
"'../'",
",",
"$",
"levels",
")",
".",
"(",
"(",
"is_ar... | get normalized handlebars expression for a variable
@param integer $levels trace N levels top parent scope
@param boolean $spvar is the path start with @ or not
@param array<string|integer> $var variable parsed path
@return string normalized expression for debug display
@expect '[a].[b]' when input 0, false, array('... | [
"get",
"normalized",
"handlebars",
"expression",
"for",
"a",
"variable"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Expression.php#L132-L136 |
zordius/lightncandy | src/Token.php | Token.setDelimiter | public static function setDelimiter(&$context, $left = null, $right = null) {
if ($left === null) {
$left = $context['delimiters'][0];
}
if ($right === null) {
$right = $context['delimiters'][1];
}
if (preg_match('/=/', "$left$right")) {
$conte... | php | public static function setDelimiter(&$context, $left = null, $right = null) {
if ($left === null) {
$left = $context['delimiters'][0];
}
if ($right === null) {
$right = $context['delimiters'][1];
}
if (preg_match('/=/', "$left$right")) {
$conte... | [
"public",
"static",
"function",
"setDelimiter",
"(",
"&",
"$",
"context",
",",
"$",
"left",
"=",
"null",
",",
"$",
"right",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"left",
"===",
"null",
")",
"{",
"$",
"left",
"=",
"$",
"context",
"[",
"'delimiters'... | Setup delimiter by default or provided string
@param array<string,array|string|integer> $context Current context
@param string|null $left left string of a token
@param string|null $right right string of a token | [
"Setup",
"delimiter",
"by",
"default",
"or",
"provided",
"string"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Token.php#L52-L72 |
zordius/lightncandy | src/Token.php | Token.toString | public static function toString($token, $merge = null) {
if (is_array($merge)) {
$token = array_replace($token, $merge);
}
return implode('', array_slice($token, 3, -2));
} | php | public static function toString($token, $merge = null) {
if (is_array($merge)) {
$token = array_replace($token, $merge);
}
return implode('', array_slice($token, 3, -2));
} | [
"public",
"static",
"function",
"toString",
"(",
"$",
"token",
",",
"$",
"merge",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"merge",
")",
")",
"{",
"$",
"token",
"=",
"array_replace",
"(",
"$",
"token",
",",
"$",
"merge",
")",
";",
... | return token string
@param string[] $token detected handlebars {{ }} token
@param string[]|null $merge list of token strings to be merged
@return string Return whole token
@expect 'c' when input array(0, 'a', 'b', 'c', 'd', 'e')
@expect 'cd' when input array(0, 'a', 'b', 'c', 'd', 'e', 'f')
@expect 'qd' when input a... | [
"return",
"token",
"string"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Token.php#L86-L91 |
zordius/lightncandy | src/Parser.php | Parser.getPartialBlock | public static function getPartialBlock(&$vars) {
if (isset($vars[static::PARTIALBLOCK])) {
$id = $vars[static::PARTIALBLOCK];
unset($vars[static::PARTIALBLOCK]);
return $id;
}
return 0;
} | php | public static function getPartialBlock(&$vars) {
if (isset($vars[static::PARTIALBLOCK])) {
$id = $vars[static::PARTIALBLOCK];
unset($vars[static::PARTIALBLOCK]);
return $id;
}
return 0;
} | [
"public",
"static",
"function",
"getPartialBlock",
"(",
"&",
"$",
"vars",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"static",
"::",
"PARTIALBLOCK",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"vars",
"[",
"static",
"::",
"PARTIALBLOCK",
"]",
... | Get partial block id and fix the variable list
@param array<boolean|integer|string|array> $vars parsed token
@return integer Return partial block id | [
"Get",
"partial",
"block",
"id",
"and",
"fix",
"the",
"variable",
"list"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L44-L51 |
zordius/lightncandy | src/Parser.php | Parser.getBlockParams | public static function getBlockParams(&$vars) {
if (isset($vars[static::BLOCKPARAM])) {
$list = $vars[static::BLOCKPARAM];
unset($vars[static::BLOCKPARAM]);
return $list;
}
} | php | public static function getBlockParams(&$vars) {
if (isset($vars[static::BLOCKPARAM])) {
$list = $vars[static::BLOCKPARAM];
unset($vars[static::BLOCKPARAM]);
return $list;
}
} | [
"public",
"static",
"function",
"getBlockParams",
"(",
"&",
"$",
"vars",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"static",
"::",
"BLOCKPARAM",
"]",
")",
")",
"{",
"$",
"list",
"=",
"$",
"vars",
"[",
"static",
"::",
"BLOCKPARAM",
"]",
"... | Get block params and fix the variable list
@param array<boolean|integer|string|array> $vars parsed token
@return array<string>|null Return list of block params or null | [
"Get",
"block",
"params",
"and",
"fix",
"the",
"variable",
"list"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L61-L67 |
zordius/lightncandy | src/Parser.php | Parser.getLiteral | protected static function getLiteral($name, $asis, $quote = false) {
return $asis ? array($name) : array(static::LITERAL, $quote ? "'$name'" : $name);
} | php | protected static function getLiteral($name, $asis, $quote = false) {
return $asis ? array($name) : array(static::LITERAL, $quote ? "'$name'" : $name);
} | [
"protected",
"static",
"function",
"getLiteral",
"(",
"$",
"name",
",",
"$",
"asis",
",",
"$",
"quote",
"=",
"false",
")",
"{",
"return",
"$",
"asis",
"?",
"array",
"(",
"$",
"name",
")",
":",
"array",
"(",
"static",
"::",
"LITERAL",
",",
"$",
"quo... | Return array presentation for a literal
@param string $name variable name.
@param boolean $asis keep the name as is or not
@param boolean $quote add single quote or not
@return array<integer|string> Return variable name array | [
"Return",
"array",
"presentation",
"for",
"a",
"literal"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L79-L81 |
zordius/lightncandy | src/Parser.php | Parser.getExpression | protected static function getExpression($v, &$context, $pos) {
$asis = ($pos === 0);
// handle number
if (is_numeric($v)) {
return static::getLiteral(strval(1 * $v), $asis);
}
// handle double quoted string
if (preg_match('/^"(.*)"$/', $v, $matched)) {
... | php | protected static function getExpression($v, &$context, $pos) {
$asis = ($pos === 0);
// handle number
if (is_numeric($v)) {
return static::getLiteral(strval(1 * $v), $asis);
}
// handle double quoted string
if (preg_match('/^"(.*)"$/', $v, $matched)) {
... | [
"protected",
"static",
"function",
"getExpression",
"(",
"$",
"v",
",",
"&",
"$",
"context",
",",
"$",
"pos",
")",
"{",
"$",
"asis",
"=",
"(",
"$",
"pos",
"===",
"0",
")",
";",
"// handle number",
"if",
"(",
"is_numeric",
"(",
"$",
"v",
")",
")",
... | Return array presentation for an expression
@param string $v analyzed expression names.
@param array<string,array|string|integer> $context Current compile content.
@param integer $pos expression position
@return array<integer,string> Return variable name array
@expect array('this') when input 'this', array('flags' =... | [
"Return",
"array",
"presentation",
"for",
"an",
"expression"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L109-L190 |
zordius/lightncandy | src/Parser.php | Parser.parse | public static function parse(&$token, &$context) {
$vars = static::analyze($token[static::POS_INNERTAG], $context);
if ($token[static::POS_OP] === '>') {
$fn = static::getPartialName($vars);
} else if ($token[static::POS_OP] === '#*') {
$fn = static::getPartialName($vars,... | php | public static function parse(&$token, &$context) {
$vars = static::analyze($token[static::POS_INNERTAG], $context);
if ($token[static::POS_OP] === '>') {
$fn = static::getPartialName($vars);
} else if ($token[static::POS_OP] === '#*') {
$fn = static::getPartialName($vars,... | [
"public",
"static",
"function",
"parse",
"(",
"&",
"$",
"token",
",",
"&",
"$",
"context",
")",
"{",
"$",
"vars",
"=",
"static",
"::",
"analyze",
"(",
"$",
"token",
"[",
"static",
"::",
"POS_INNERTAG",
"]",
",",
"$",
"context",
")",
";",
"if",
"(",... | Parse the token and return parsed result.
@param array<string> $token preg_match results
@param array<string,array|string|integer> $context current compile context
@return array<boolean|integer|array> Return parsed result
@expect array(false, array(array())) when input array(0,0,0,0,0,0,0,''), array('flags' => array... | [
"Parse",
"the",
"token",
"and",
"return",
"parsed",
"result",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L230-L249 |
zordius/lightncandy | src/Parser.php | Parser.getPartialName | public static function getPartialName(&$vars, $pos = 0) {
if (!isset($vars[$pos])) {
return;
}
return preg_match(SafeString::IS_SUBEXP_SEARCH, $vars[$pos]) ? null : array(preg_replace('/^("(.+)")|(\\[(.+)\\])|(\\\\\'(.+)\\\\\')$/', '$2$4$6', $vars[$pos]));
} | php | public static function getPartialName(&$vars, $pos = 0) {
if (!isset($vars[$pos])) {
return;
}
return preg_match(SafeString::IS_SUBEXP_SEARCH, $vars[$pos]) ? null : array(preg_replace('/^("(.+)")|(\\[(.+)\\])|(\\\\\'(.+)\\\\\')$/', '$2$4$6', $vars[$pos]));
} | [
"public",
"static",
"function",
"getPartialName",
"(",
"&",
"$",
"vars",
",",
"$",
"pos",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"vars",
"[",
"$",
"pos",
"]",
")",
")",
"{",
"return",
";",
"}",
"return",
"preg_match",
"(",
"SafeSt... | Get partial name from "foo" or [foo] or \'foo\'
@param array<boolean|integer|array> $vars parsed token
@param integer $pos position of partial name
@return array<string>|null Return one element partial name array
@expect null when input array()
@expect array('foo') when input array('foo')
@expect array('foo') when i... | [
"Get",
"partial",
"name",
"from",
"foo",
"or",
"[",
"foo",
"]",
"or",
"\\",
"foo",
"\\"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L266-L271 |
zordius/lightncandy | src/Parser.php | Parser.subexpression | public static function subexpression($expression, &$context) {
$context['usedFeature']['subexp']++;
$vars = static::analyze(substr($expression, 1, -1), $context);
$avars = static::advancedVariable($vars, $context, $expression);
if (isset($avars[0][0]) && !$context['flags']['exhlp']) {
... | php | public static function subexpression($expression, &$context) {
$context['usedFeature']['subexp']++;
$vars = static::analyze(substr($expression, 1, -1), $context);
$avars = static::advancedVariable($vars, $context, $expression);
if (isset($avars[0][0]) && !$context['flags']['exhlp']) {
... | [
"public",
"static",
"function",
"subexpression",
"(",
"$",
"expression",
",",
"&",
"$",
"context",
")",
"{",
"$",
"context",
"[",
"'usedFeature'",
"]",
"[",
"'subexp'",
"]",
"++",
";",
"$",
"vars",
"=",
"static",
"::",
"analyze",
"(",
"substr",
"(",
"$... | Parse a subexpression then return parsed result.
@param string $expression the full string of a sub expression
@param array<string,array|string|integer> $context current compile context
@return array<boolean|integer|array> Return parsed result
@expect array(\LightnCandy\Parser::SUBEXP, array(array('a'), array('b')),... | [
"Parse",
"a",
"subexpression",
"then",
"return",
"parsed",
"result",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L283-L293 |
zordius/lightncandy | src/Parser.php | Parser.advancedVariable | protected static function advancedVariable($vars, &$context, $token) {
$ret = array();
$i = 0;
foreach ($vars as $idx => $var) {
// handle (...)
if (preg_match(SafeString::IS_SUBEXP_SEARCH, $var)) {
$ret[$i] = static::subexpression($var, $context);
... | php | protected static function advancedVariable($vars, &$context, $token) {
$ret = array();
$i = 0;
foreach ($vars as $idx => $var) {
// handle (...)
if (preg_match(SafeString::IS_SUBEXP_SEARCH, $var)) {
$ret[$i] = static::subexpression($var, $context);
... | [
"protected",
"static",
"function",
"advancedVariable",
"(",
"$",
"vars",
",",
"&",
"$",
"context",
",",
"$",
"token",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"idx",
"=>",... | Analyze parsed token for advanved variables.
@param array<boolean|integer|array> $vars parsed token
@param array<string,array|string|integer> $context current compile context
@param string $token original token
@return array<boolean|integer|array> Return parsed result
@expect array(array('this')) when input array('t... | [
"Analyze",
"parsed",
"token",
"for",
"advanved",
"variables",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L330-L397 |
zordius/lightncandy | src/Parser.php | Parser.detectQuote | protected static function detectQuote($string) {
// begin with '(' without ending ')'
if (preg_match('/^\([^\)]*$/', $string)) {
return array(')', 1);
}
// begin with '"' without ending '"'
if (preg_match('/^"[^"]*$/', $string)) {
return array('"', 0);
... | php | protected static function detectQuote($string) {
// begin with '(' without ending ')'
if (preg_match('/^\([^\)]*$/', $string)) {
return array(')', 1);
}
// begin with '"' without ending '"'
if (preg_match('/^"[^"]*$/', $string)) {
return array('"', 0);
... | [
"protected",
"static",
"function",
"detectQuote",
"(",
"$",
"string",
")",
"{",
"// begin with '(' without ending ')'",
"if",
"(",
"preg_match",
"(",
"'/^\\([^\\)]*$/'",
",",
"$",
"string",
")",
")",
"{",
"return",
"array",
"(",
"')'",
",",
"1",
")",
";",
"}... | Detect quote charactors
@param string $string the string to be detect the quote charactors
@return array<string,integer>|null Expected ending string when quote charactor be detected | [
"Detect",
"quote",
"charactors"
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L406-L441 |
zordius/lightncandy | src/Parser.php | Parser.analyze | protected static function analyze($token, &$context) {
$count = preg_match_all('/(\s*)([^\s]+)/', $token, $matchedall);
// Parse arguments and deal with "..." or [...] or (...) or \'...\' or |...|
if (($count > 0) && $context['flags']['advar']) {
$vars = array();
$prev = ... | php | protected static function analyze($token, &$context) {
$count = preg_match_all('/(\s*)([^\s]+)/', $token, $matchedall);
// Parse arguments and deal with "..." or [...] or (...) or \'...\' or |...|
if (($count > 0) && $context['flags']['advar']) {
$vars = array();
$prev = ... | [
"protected",
"static",
"function",
"analyze",
"(",
"$",
"token",
",",
"&",
"$",
"context",
")",
"{",
"$",
"count",
"=",
"preg_match_all",
"(",
"'/(\\s*)([^\\s]+)/'",
",",
"$",
"token",
",",
"$",
"matchedall",
")",
";",
"// Parse arguments and deal with \"...\" o... | Analyze a token string and return parsed result.
@param string $token preg_match results
@param array<string,array|string|integer> $context current compile context
@return array<boolean|integer|array> Return parsed result
@expect array('foo', 'bar') when input 'foo bar', array('flags' => array('advar' => 1))
@expect... | [
"Analyze",
"a",
"token",
"string",
"and",
"return",
"parsed",
"result",
"."
] | train | https://github.com/zordius/lightncandy/blob/67b91587f8e133439dc1096fe19489a800b7a27e/src/Parser.php#L462-L543 |
Setasign/FPDI | src/Fpdi.php | Fpdi.useTemplate | public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
{
if (isset($this->importedPages[$tpl])) {
$size = $this->useImportedPage($tpl, $x, $y, $width, $height, $adjustPageSize);
if ($this->currentTemplateId !== null) {
... | php | public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
{
if (isset($this->importedPages[$tpl])) {
$size = $this->useImportedPage($tpl, $x, $y, $width, $height, $adjustPageSize);
if ($this->currentTemplateId !== null) {
... | [
"public",
"function",
"useTemplate",
"(",
"$",
"tpl",
",",
"$",
"x",
"=",
"0",
",",
"$",
"y",
"=",
"0",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
",",
"$",
"adjustPageSize",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"("... | Draws an imported page or a template onto the page or another template.
Give only one of the size parameters (width, height) to calculate the other one automatically in view to the
aspect ratio.
@param mixed $tpl The template id
@param float|int|array $x The abscissa of upper-left corner. Alternatively you could use ... | [
"Draws",
"an",
"imported",
"page",
"or",
"a",
"template",
"onto",
"the",
"page",
"or",
"another",
"template",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/Fpdi.php#L57-L68 |
Setasign/FPDI | src/Fpdi.php | Fpdi.getTemplateSize | public function getTemplateSize($tpl, $width = null, $height = null)
{
$size = parent::getTemplateSize($tpl, $width, $height);
if ($size === false) {
return $this->getImportedPageSize($tpl, $width, $height);
}
return $size;
} | php | public function getTemplateSize($tpl, $width = null, $height = null)
{
$size = parent::getTemplateSize($tpl, $width, $height);
if ($size === false) {
return $this->getImportedPageSize($tpl, $width, $height);
}
return $size;
} | [
"public",
"function",
"getTemplateSize",
"(",
"$",
"tpl",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"$",
"size",
"=",
"parent",
"::",
"getTemplateSize",
"(",
"$",
"tpl",
",",
"$",
"width",
",",
"$",
"height",
")",
"... | Get the size of an imported page or template.
Give only one of the size parameters (width, height) to calculate the other one automatically in view to the
aspect ratio.
@param mixed $tpl The template id
@param float|int|null $width The width.
@param float|int|null $height The height.
@return array|bool An array with ... | [
"Get",
"the",
"size",
"of",
"an",
"imported",
"page",
"or",
"template",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/Fpdi.php#L81-L89 |
Setasign/FPDI | src/PdfParser/Filter/Flate.php | Flate.decode | public function decode($data)
{
if ($this->extensionLoaded()) {
$oData = $data;
$data = @((\strlen($data) > 0) ? \gzuncompress($data) : '');
if ($data === false) {
// Try this fallback
$tries = 1;
while ($tries < 10 && ($dat... | php | public function decode($data)
{
if ($this->extensionLoaded()) {
$oData = $data;
$data = @((\strlen($data) > 0) ? \gzuncompress($data) : '');
if ($data === false) {
// Try this fallback
$tries = 1;
while ($tries < 10 && ($dat... | [
"public",
"function",
"decode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"extensionLoaded",
"(",
")",
")",
"{",
"$",
"oData",
"=",
"$",
"data",
";",
"$",
"data",
"=",
"@",
"(",
"(",
"\\",
"strlen",
"(",
"$",
"data",
")",
">",
... | Decodes a flate compressed string.
@param string $data The input string
@return string
@throws FlateException | [
"Decodes",
"a",
"flate",
"compressed",
"string",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/Filter/Flate.php#L39-L77 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.cleanUp | public function cleanUp($allReaders = false)
{
$readers = $allReaders ? array_keys($this->readers) : $this->createdReaders;
foreach ($readers as $id) {
$this->readers[$id]->getParser()->getStreamReader()->cleanUp();
unset($this->readers[$id]);
}
$this->create... | php | public function cleanUp($allReaders = false)
{
$readers = $allReaders ? array_keys($this->readers) : $this->createdReaders;
foreach ($readers as $id) {
$this->readers[$id]->getParser()->getStreamReader()->cleanUp();
unset($this->readers[$id]);
}
$this->create... | [
"public",
"function",
"cleanUp",
"(",
"$",
"allReaders",
"=",
"false",
")",
"{",
"$",
"readers",
"=",
"$",
"allReaders",
"?",
"array_keys",
"(",
"$",
"this",
"->",
"readers",
")",
":",
"$",
"this",
"->",
"createdReaders",
";",
"foreach",
"(",
"$",
"rea... | Release resources and file handles.
This method is called internally when the document is created successfully. By default it only cleans up
stream reader instances which were created internally.
@param bool $allReaders | [
"Release",
"resources",
"and",
"file",
"handles",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L99-L108 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.getPdfReaderId | protected function getPdfReaderId($file)
{
if (\is_resource($file)) {
$id = (string) $file;
} elseif (\is_string($file)) {
$id = \realpath($file);
if ($id === false) {
$id = $file;
}
} elseif (\is_object($file)) {
$i... | php | protected function getPdfReaderId($file)
{
if (\is_resource($file)) {
$id = (string) $file;
} elseif (\is_string($file)) {
$id = \realpath($file);
if ($id === false) {
$id = $file;
}
} elseif (\is_object($file)) {
$i... | [
"protected",
"function",
"getPdfReaderId",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"\\",
"is_resource",
"(",
"$",
"file",
")",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"file",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"file",
... | Get an unique reader id by the $file parameter.
@param string|resource|PdfReader|StreamReader $file An open file descriptor, a path to a file, a PdfReader
instance or a StreamReader instance.
@return string | [
"Get",
"an",
"unique",
"reader",
"id",
"by",
"the",
"$file",
"parameter",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L147-L183 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.getPdfReader | protected function getPdfReader($id)
{
if (isset($this->readers[$id])) {
return $this->readers[$id];
}
throw new \InvalidArgumentException(
\sprintf('No pdf reader with the given id (%s) exists.', $id)
);
} | php | protected function getPdfReader($id)
{
if (isset($this->readers[$id])) {
return $this->readers[$id];
}
throw new \InvalidArgumentException(
\sprintf('No pdf reader with the given id (%s) exists.', $id)
);
} | [
"protected",
"function",
"getPdfReader",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"readers",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"readers",
"[",
"$",
"id",
"]",
";",
"}",
"throw",
"new",
... | Get a pdf reader instance by its id.
@param string $id
@return PdfReader | [
"Get",
"a",
"pdf",
"reader",
"instance",
"by",
"its",
"id",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L191-L200 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.setSourceFile | public function setSourceFile($file)
{
$this->currentReaderId = $this->getPdfReaderId($file);
$this->objectsToCopy[$this->currentReaderId] = [];
$reader = $this->getPdfReader($this->currentReaderId);
$this->setMinPdfVersion($reader->getPdfVersion());
return $reader->getPage... | php | public function setSourceFile($file)
{
$this->currentReaderId = $this->getPdfReaderId($file);
$this->objectsToCopy[$this->currentReaderId] = [];
$reader = $this->getPdfReader($this->currentReaderId);
$this->setMinPdfVersion($reader->getPdfVersion());
return $reader->getPage... | [
"public",
"function",
"setSourceFile",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"currentReaderId",
"=",
"$",
"this",
"->",
"getPdfReaderId",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"objectsToCopy",
"[",
"$",
"this",
"->",
"currentReaderId",
... | Set the source PDF file.
@param string|resource|StreamReader $file Path to the file or a stream resource or a StreamReader instance.
@return int The page count of the PDF document.
@throws PdfParserException | [
"Set",
"the",
"source",
"PDF",
"file",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L209-L218 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.importPage | public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true)
{
if (null === $this->currentReaderId) {
throw new \BadMethodCallException('No reader initiated. Call setSourceFile() first.');
}
$pageId = $this->currentReaderId;
$pageNumber... | php | public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true)
{
if (null === $this->currentReaderId) {
throw new \BadMethodCallException('No reader initiated. Call setSourceFile() first.');
}
$pageId = $this->currentReaderId;
$pageNumber... | [
"public",
"function",
"importPage",
"(",
"$",
"pageNumber",
",",
"$",
"box",
"=",
"PageBoundaries",
"::",
"CROP_BOX",
",",
"$",
"groupXObject",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"currentReaderId",
")",
"{",
"throw",
"new... | Imports a page.
@param int $pageNumber The page number.
@param string $box The page boundary to import. Default set to PageBoundaries::CROP_BOX.
@param bool $groupXObject Define the form XObject as a group XObject to support transparency (if used).
@return string A unique string identifying the imported page.
@throws ... | [
"Imports",
"a",
"page",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L234-L383 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.useImportedPage | public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
{
if (\is_array($x)) {
/** @noinspection OffsetOperationsInspection */
unset($x['pageId']);
\extract($x, EXTR_IF_EXISTS);
/** @noinspection NotOpti... | php | public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
{
if (\is_array($x)) {
/** @noinspection OffsetOperationsInspection */
unset($x['pageId']);
\extract($x, EXTR_IF_EXISTS);
/** @noinspection NotOpti... | [
"public",
"function",
"useImportedPage",
"(",
"$",
"pageId",
",",
"$",
"x",
"=",
"0",
",",
"$",
"y",
"=",
"0",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
",",
"$",
"adjustPageSize",
"=",
"false",
")",
"{",
"if",
"(",
"\\",
... | Draws an imported page onto the page.
Give only one of the size parameters (width, height) to calculate the other one automatically in view to the
aspect ratio.
@param mixed $pageId The page id
@param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array
with the keys "x", "... | [
"Draws",
"an",
"imported",
"page",
"onto",
"the",
"page",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L401-L438 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.getImportedPageSize | public function getImportedPageSize($tpl, $width = null, $height = null)
{
if (isset($this->importedPages[$tpl])) {
$importedPage = $this->importedPages[$tpl];
if ($width === null && $height === null) {
$width = $importedPage['width'];
$height = $impo... | php | public function getImportedPageSize($tpl, $width = null, $height = null)
{
if (isset($this->importedPages[$tpl])) {
$importedPage = $this->importedPages[$tpl];
if ($width === null && $height === null) {
$width = $importedPage['width'];
$height = $impo... | [
"public",
"function",
"getImportedPageSize",
"(",
"$",
"tpl",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"importedPages",
"[",
"$",
"tpl",
"]",
")",
")",
"{",
"$",
"importe... | Get the size of an imported page.
Give only one of the size parameters (width, height) to calculate the other one automatically in view to the
aspect ratio.
@param mixed $tpl The template id
@param float|int|null $width The width.
@param float|int|null $height The height.
@return array|bool An array with following ke... | [
"Get",
"the",
"size",
"of",
"an",
"imported",
"page",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L451-L481 |
Setasign/FPDI | src/FpdiTrait.php | FpdiTrait.writePdfType | protected function writePdfType(PdfType $value)
{
if ($value instanceof PdfNumeric) {
if (\is_int($value->value)) {
$this->_put($value->value . ' ', false);
} else {
$this->_put(\rtrim(\rtrim(\sprintf('%.5F', $value->value), '0'), '.') . ' ', false);
... | php | protected function writePdfType(PdfType $value)
{
if ($value instanceof PdfNumeric) {
if (\is_int($value->value)) {
$this->_put($value->value . ' ', false);
} else {
$this->_put(\rtrim(\rtrim(\sprintf('%.5F', $value->value), '0'), '.') . ' ', false);
... | [
"protected",
"function",
"writePdfType",
"(",
"PdfType",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"PdfNumeric",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"value",
"->",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_put",
"("... | Writes a PdfType object to the resulting buffer.
@param PdfType $value
@throws PdfTypeException | [
"Writes",
"a",
"PdfType",
"object",
"to",
"the",
"resulting",
"buffer",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/FpdiTrait.php#L489-L561 |
Setasign/FPDI | src/PdfParser/CrossReference/CrossReference.php | CrossReference.getOffsetFor | public function getOffsetFor($objectNumber)
{
foreach ($this->getReaders() as $reader) {
$offset = $reader->getOffsetFor($objectNumber);
if ($offset !== false) {
return $offset;
}
}
return false;
} | php | public function getOffsetFor($objectNumber)
{
foreach ($this->getReaders() as $reader) {
$offset = $reader->getOffsetFor($objectNumber);
if ($offset !== false) {
return $offset;
}
}
return false;
} | [
"public",
"function",
"getOffsetFor",
"(",
"$",
"objectNumber",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getReaders",
"(",
")",
"as",
"$",
"reader",
")",
"{",
"$",
"offset",
"=",
"$",
"reader",
"->",
"getOffsetFor",
"(",
"$",
"objectNumber",
")",
... | Get the offset by an object number.
@param int $objectNumber
@return integer|bool | [
"Get",
"the",
"offset",
"by",
"an",
"object",
"number",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/CrossReference/CrossReference.php#L139-L149 |
Setasign/FPDI | src/PdfParser/CrossReference/CrossReference.php | CrossReference.getIndirectObject | public function getIndirectObject($objectNumber)
{
$offset = $this->getOffsetFor($objectNumber);
if ($offset === false) {
throw new CrossReferenceException(
\sprintf('Object (id:%s) not found.', $objectNumber),
CrossReferenceException::OBJECT_NOT_FOUND
... | php | public function getIndirectObject($objectNumber)
{
$offset = $this->getOffsetFor($objectNumber);
if ($offset === false) {
throw new CrossReferenceException(
\sprintf('Object (id:%s) not found.', $objectNumber),
CrossReferenceException::OBJECT_NOT_FOUND
... | [
"public",
"function",
"getIndirectObject",
"(",
"$",
"objectNumber",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"getOffsetFor",
"(",
"$",
"objectNumber",
")",
";",
"if",
"(",
"$",
"offset",
"===",
"false",
")",
"{",
"throw",
"new",
"CrossReferenceExc... | Get an indirect object by its object number.
@param int $objectNumber
@return PdfIndirectObject
@throws CrossReferenceException | [
"Get",
"an",
"indirect",
"object",
"by",
"its",
"object",
"number",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/CrossReference/CrossReference.php#L158-L192 |
Setasign/FPDI | src/PdfParser/CrossReference/CrossReference.php | CrossReference.readXref | protected function readXref($offset)
{
$this->parser->getStreamReader()->reset($offset);
$this->parser->getTokenizer()->clearStack();
$initValue = $this->parser->readValue();
return $this->initReaderInstance($initValue);
} | php | protected function readXref($offset)
{
$this->parser->getStreamReader()->reset($offset);
$this->parser->getTokenizer()->clearStack();
$initValue = $this->parser->readValue();
return $this->initReaderInstance($initValue);
} | [
"protected",
"function",
"readXref",
"(",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"getStreamReader",
"(",
")",
"->",
"reset",
"(",
"$",
"offset",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"getTokenizer",
"(",
")",
"->",
"clearSta... | Read the cross-reference table at a given offset.
Internally the method will try to evaluate the best reader for this cross-reference.
@param int $offset
@return ReaderInterface
@throws CrossReferenceException
@throws PdfTypeException | [
"Read",
"the",
"cross",
"-",
"reference",
"table",
"at",
"a",
"given",
"offset",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/CrossReference/CrossReference.php#L204-L211 |
Setasign/FPDI | src/PdfParser/CrossReference/CrossReference.php | CrossReference.initReaderInstance | protected function initReaderInstance($initValue)
{
$position = $this->parser->getStreamReader()->getPosition()
+ $this->parser->getStreamReader()->getOffset() + $this->fileHeaderOffset;
if ($initValue instanceof PdfToken && $initValue->value === 'xref') {
try {
... | php | protected function initReaderInstance($initValue)
{
$position = $this->parser->getStreamReader()->getPosition()
+ $this->parser->getStreamReader()->getOffset() + $this->fileHeaderOffset;
if ($initValue instanceof PdfToken && $initValue->value === 'xref') {
try {
... | [
"protected",
"function",
"initReaderInstance",
"(",
"$",
"initValue",
")",
"{",
"$",
"position",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStreamReader",
"(",
")",
"->",
"getPosition",
"(",
")",
"+",
"$",
"this",
"->",
"parser",
"->",
"getStreamReader",
... | Get a cross-reference reader instance.
@param PdfToken|PdfIndirectObject $initValue
@return ReaderInterface|bool
@throws CrossReferenceException
@throws PdfTypeException | [
"Get",
"a",
"cross",
"-",
"reference",
"reader",
"instance",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/CrossReference/CrossReference.php#L221-L262 |
Setasign/FPDI | src/PdfParser/CrossReference/CrossReference.php | CrossReference.findStartXref | protected function findStartXref()
{
$reader = $this->parser->getStreamReader();
$reader->reset(-self::$trailerSearchLength, self::$trailerSearchLength);
$buffer = $reader->getBuffer(false);
$pos = \strrpos($buffer, 'startxref');
$addOffset = 9;
if ($pos === false) {... | php | protected function findStartXref()
{
$reader = $this->parser->getStreamReader();
$reader->reset(-self::$trailerSearchLength, self::$trailerSearchLength);
$buffer = $reader->getBuffer(false);
$pos = \strrpos($buffer, 'startxref');
$addOffset = 9;
if ($pos === false) {... | [
"protected",
"function",
"findStartXref",
"(",
")",
"{",
"$",
"reader",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStreamReader",
"(",
")",
";",
"$",
"reader",
"->",
"reset",
"(",
"-",
"self",
"::",
"$",
"trailerSearchLength",
",",
"self",
"::",
"$",
... | Find the start position for the first cross-reference.
@return int The byte-offset position of the first cross-reference.
@throws CrossReferenceException | [
"Find",
"the",
"start",
"position",
"for",
"the",
"first",
"cross",
"-",
"reference",
"."
] | train | https://github.com/Setasign/FPDI/blob/3c266002f8044f61b17329f7cd702d44d73f0f7f/src/PdfParser/CrossReference/CrossReference.php#L286-L319 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.