repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.fetchContext
private function fetchContext(int $invocationTID, int $argumentsTID): array { $class = $operator = ''; $name = trim($this->getSource($invocationTID, $argumentsTID), '( '); //Let's try to fetch all information we need if (strpos($name, '->') !== false) { $operator = '->'; } elseif (strpos($name, '::') !== false) { $operator = '::'; } if (!empty($operator)) { list($class, $name) = explode($operator, $name); //We now have to clarify class name if (in_array($class, ['self', 'static', '$this'])) { $class = $this->activeDeclaration($invocationTID); } } return [$class, $operator, $name]; }
php
private function fetchContext(int $invocationTID, int $argumentsTID): array { $class = $operator = ''; $name = trim($this->getSource($invocationTID, $argumentsTID), '( '); //Let's try to fetch all information we need if (strpos($name, '->') !== false) { $operator = '->'; } elseif (strpos($name, '::') !== false) { $operator = '::'; } if (!empty($operator)) { list($class, $name) = explode($operator, $name); //We now have to clarify class name if (in_array($class, ['self', 'static', '$this'])) { $class = $this->activeDeclaration($invocationTID); } } return [$class, $operator, $name]; }
[ "private", "function", "fetchContext", "(", "int", "$", "invocationTID", ",", "int", "$", "argumentsTID", ")", ":", "array", "{", "$", "class", "=", "$", "operator", "=", "''", ";", "$", "name", "=", "trim", "(", "$", "this", "->", "getSource", "(", ...
Fetching invocation context. @param int $invocationTID @param int $argumentsTID @return array
[ "Fetching", "invocation", "context", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L628-L650
train
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.activeDeclaration
private function activeDeclaration(int $tokenID): string { foreach ($this->declarations as $declarations) { foreach ($declarations as $name => $position) { if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { return $name; } } } //Can not be detected return ''; }
php
private function activeDeclaration(int $tokenID): string { foreach ($this->declarations as $declarations) { foreach ($declarations as $name => $position) { if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { return $name; } } } //Can not be detected return ''; }
[ "private", "function", "activeDeclaration", "(", "int", "$", "tokenID", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "declarations", "as", "$", "declarations", ")", "{", "foreach", "(", "$", "declarations", "as", "$", "name", "=>", "$", "p...
Get declaration which is active in given token position. @param int $tokenID @return string|null
[ "Get", "declaration", "which", "is", "active", "in", "given", "token", "position", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L659-L671
train
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.activeNamespace
private function activeNamespace(int $tokenID): string { foreach ($this->namespaces as $namespace => $position) { if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { return $namespace; } } //Seems like no namespace declaration $this->namespaces[''] = [ self::O_TOKEN => 0, self::C_TOKEN => count($this->tokens), self::N_USES => [], ]; return ''; }
php
private function activeNamespace(int $tokenID): string { foreach ($this->namespaces as $namespace => $position) { if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { return $namespace; } } //Seems like no namespace declaration $this->namespaces[''] = [ self::O_TOKEN => 0, self::C_TOKEN => count($this->tokens), self::N_USES => [], ]; return ''; }
[ "private", "function", "activeNamespace", "(", "int", "$", "tokenID", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "namespace", "=>", "$", "position", ")", "{", "if", "(", "$", "tokenID", ">=", "$", "position", "...
Get namespace name active at specified token position. @param int $tokenID @return string
[ "Get", "namespace", "name", "active", "at", "specified", "token", "position", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L680-L696
train
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.endingToken
private function endingToken(int $tokenID): int { $level = null; for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) { $token = $this->tokens[$localID]; if ($token[self::TOKEN_CODE] == '{') { ++$level; continue; } if ($token[self::TOKEN_CODE] == '}') { --$level; } if ($level === 0) { break; } } return $localID; }
php
private function endingToken(int $tokenID): int { $level = null; for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) { $token = $this->tokens[$localID]; if ($token[self::TOKEN_CODE] == '{') { ++$level; continue; } if ($token[self::TOKEN_CODE] == '}') { --$level; } if ($level === 0) { break; } } return $localID; }
[ "private", "function", "endingToken", "(", "int", "$", "tokenID", ")", ":", "int", "{", "$", "level", "=", "null", ";", "for", "(", "$", "localID", "=", "$", "tokenID", ";", "$", "localID", "<", "$", "this", "->", "countTokens", ";", "++", "$", "lo...
Find token ID of ending brace. @param int $tokenID @return int
[ "Find", "token", "ID", "of", "ending", "brace", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L705-L725
train
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.lineNumber
private function lineNumber(int $tokenID): int { while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) { --$tokenID; } return $this->tokens[$tokenID][self::TOKEN_LINE]; }
php
private function lineNumber(int $tokenID): int { while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) { --$tokenID; } return $this->tokens[$tokenID][self::TOKEN_LINE]; }
[ "private", "function", "lineNumber", "(", "int", "$", "tokenID", ")", ":", "int", "{", "while", "(", "empty", "(", "$", "this", "->", "tokens", "[", "$", "tokenID", "]", "[", "self", "::", "TOKEN_LINE", "]", ")", ")", "{", "--", "$", "tokenID", ";"...
Get line number associated with token. @param int $tokenID @return int
[ "Get", "line", "number", "associated", "with", "token", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L734-L741
train
spiral/tokenizer
src/Reflection/ReflectionFile.php
ReflectionFile.getSource
private function getSource(int $startID, int $endID): string { $result = ''; for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) { //Collecting function usage src $result .= $this->tokens[$tokenID][self::TOKEN_CODE]; } return $result; }
php
private function getSource(int $startID, int $endID): string { $result = ''; for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) { //Collecting function usage src $result .= $this->tokens[$tokenID][self::TOKEN_CODE]; } return $result; }
[ "private", "function", "getSource", "(", "int", "$", "startID", ",", "int", "$", "endID", ")", ":", "string", "{", "$", "result", "=", "''", ";", "for", "(", "$", "tokenID", "=", "$", "startID", ";", "$", "tokenID", "<=", "$", "endID", ";", "++", ...
Get src located between two tokens. @param int $startID @param int $endID @return string
[ "Get", "src", "located", "between", "two", "tokens", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionFile.php#L751-L760
train
spiral/tokenizer
src/Reflection/ReflectionArgument.php
ReflectionArgument.createArgument
private static function createArgument(array $definition): ReflectionArgument { $result = new static(self::EXPRESSION, $definition['value']); if (count($definition['tokens']) == 1) { //If argument represent by one token we can try to resolve it's type more precisely switch ($definition['tokens'][0][0]) { case T_VARIABLE: $result->type = self::VARIABLE; break; case T_LNUMBER: case T_DNUMBER: $result->type = self::CONSTANT; break; case T_CONSTANT_ENCAPSED_STRING: $result->type = self::STRING; break; } } return $result; }
php
private static function createArgument(array $definition): ReflectionArgument { $result = new static(self::EXPRESSION, $definition['value']); if (count($definition['tokens']) == 1) { //If argument represent by one token we can try to resolve it's type more precisely switch ($definition['tokens'][0][0]) { case T_VARIABLE: $result->type = self::VARIABLE; break; case T_LNUMBER: case T_DNUMBER: $result->type = self::CONSTANT; break; case T_CONSTANT_ENCAPSED_STRING: $result->type = self::STRING; break; } } return $result; }
[ "private", "static", "function", "createArgument", "(", "array", "$", "definition", ")", ":", "ReflectionArgument", "{", "$", "result", "=", "new", "static", "(", "self", "::", "EXPRESSION", ",", "$", "definition", "[", "'value'", "]", ")", ";", "if", "(",...
Create Argument reflection using token definition. Internal method. @see locateArguments @param array $definition @return self
[ "Create", "Argument", "reflection", "using", "token", "definition", ".", "Internal", "method", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionArgument.php#L152-L173
train
spiral/tokenizer
src/AbstractLocator.php
AbstractLocator.availableReflections
protected function availableReflections(): \Generator { /** * @var SplFileInfo */ foreach ($this->finder->getIterator() as $file) { $reflection = new ReflectionFile((string)$file); if ($reflection->hasIncludes()) { //We are not analyzing files which has includes, it's not safe to require such reflections $this->getLogger()->warning( sprintf("File `%s` has includes and excluded from analysis", $file), compact('file') ); continue; } /* * @var ReflectionFile $reflection */ yield $reflection; } }
php
protected function availableReflections(): \Generator { /** * @var SplFileInfo */ foreach ($this->finder->getIterator() as $file) { $reflection = new ReflectionFile((string)$file); if ($reflection->hasIncludes()) { //We are not analyzing files which has includes, it's not safe to require such reflections $this->getLogger()->warning( sprintf("File `%s` has includes and excluded from analysis", $file), compact('file') ); continue; } /* * @var ReflectionFile $reflection */ yield $reflection; } }
[ "protected", "function", "availableReflections", "(", ")", ":", "\\", "Generator", "{", "/**\n * @var SplFileInfo\n */", "foreach", "(", "$", "this", "->", "finder", "->", "getIterator", "(", ")", "as", "$", "file", ")", "{", "$", "reflection", "...
Available file reflections. Generator. @return ReflectionFile[]|\Generator
[ "Available", "file", "reflections", ".", "Generator", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/AbstractLocator.php#L44-L67
train
spiral/tokenizer
src/AbstractLocator.php
AbstractLocator.classReflection
protected function classReflection(string $class): \ReflectionClass { $loader = function ($class) { if ($class == LocatorException::class) { return; } throw new LocatorException("Class '{$class}' can not be loaded"); }; //To suspend class dependency exception spl_autoload_register($loader); try { //In some cases reflection can thrown an exception if class invalid or can not be loaded, //we are going to handle such exception and convert it soft exception return new \ReflectionClass($class); } catch (\Throwable $e) { if ($e instanceof LocatorException && $e->getPrevious() != null) { $e = $e->getPrevious(); } $this->getLogger()->error( sprintf( "%s: %s in %s:%s", $class, $e->getMessage(), $e->getFile(), $e->getLine() ), ['error' => $e] ); throw new LocatorException($e->getMessage(), $e->getCode(), $e); } finally { spl_autoload_unregister($loader); } }
php
protected function classReflection(string $class): \ReflectionClass { $loader = function ($class) { if ($class == LocatorException::class) { return; } throw new LocatorException("Class '{$class}' can not be loaded"); }; //To suspend class dependency exception spl_autoload_register($loader); try { //In some cases reflection can thrown an exception if class invalid or can not be loaded, //we are going to handle such exception and convert it soft exception return new \ReflectionClass($class); } catch (\Throwable $e) { if ($e instanceof LocatorException && $e->getPrevious() != null) { $e = $e->getPrevious(); } $this->getLogger()->error( sprintf( "%s: %s in %s:%s", $class, $e->getMessage(), $e->getFile(), $e->getLine() ), ['error' => $e] ); throw new LocatorException($e->getMessage(), $e->getCode(), $e); } finally { spl_autoload_unregister($loader); } }
[ "protected", "function", "classReflection", "(", "string", "$", "class", ")", ":", "\\", "ReflectionClass", "{", "$", "loader", "=", "function", "(", "$", "class", ")", "{", "if", "(", "$", "class", "==", "LocatorException", "::", "class", ")", "{", "ret...
Safely get class reflection, class loading errors will be blocked and reflection will be excluded from analysis. @param string $class @return \ReflectionClass
[ "Safely", "get", "class", "reflection", "class", "loading", "errors", "will", "be", "blocked", "and", "reflection", "will", "be", "excluded", "from", "analysis", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/AbstractLocator.php#L77-L114
train
spiral/tokenizer
src/InvocationLocator.php
InvocationLocator.availableInvocations
protected function availableInvocations(string $signature = ''): \Generator { $signature = strtolower(trim($signature, '\\')); foreach ($this->availableReflections() as $reflection) { foreach ($reflection->getInvocations() as $invocation) { if ( !empty($signature) && strtolower(trim($invocation->getName(), '\\')) != $signature ) { continue; } yield $invocation; } } }
php
protected function availableInvocations(string $signature = ''): \Generator { $signature = strtolower(trim($signature, '\\')); foreach ($this->availableReflections() as $reflection) { foreach ($reflection->getInvocations() as $invocation) { if ( !empty($signature) && strtolower(trim($invocation->getName(), '\\')) != $signature ) { continue; } yield $invocation; } } }
[ "protected", "function", "availableInvocations", "(", "string", "$", "signature", "=", "''", ")", ":", "\\", "Generator", "{", "$", "signature", "=", "strtolower", "(", "trim", "(", "$", "signature", ",", "'\\\\'", ")", ")", ";", "foreach", "(", "$", "th...
Invocations available in finder scope. @param string $signature Method or function signature (name), for pre-filtering. @return ReflectionInvocation[]|\Generator
[ "Invocations", "available", "in", "finder", "scope", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/InvocationLocator.php#L43-L58
train
spiral/tokenizer
src/ClassLocator.php
ClassLocator.availableClasses
protected function availableClasses(): array { $classes = []; foreach ($this->availableReflections() as $reflection) { $classes = array_merge($classes, $reflection->getClasses()); } return $classes; }
php
protected function availableClasses(): array { $classes = []; foreach ($this->availableReflections() as $reflection) { $classes = array_merge($classes, $reflection->getClasses()); } return $classes; }
[ "protected", "function", "availableClasses", "(", ")", ":", "array", "{", "$", "classes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "availableReflections", "(", ")", "as", "$", "reflection", ")", "{", "$", "classes", "=", "array_merge", "(",...
Classes available in finder scope. @return array
[ "Classes", "available", "in", "finder", "scope", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/ClassLocator.php#L51-L60
train
spiral/tokenizer
src/ClassLocator.php
ClassLocator.isTargeted
protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool { if (empty($target)) { return true; } if (!$target->isTrait()) { //Target is interface or class return $class->isSubclassOf($target) || $class->getName() == $target->getName(); } //Checking using traits return in_array($target->getName(), $this->fetchTraits($class->getName())); }
php
protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool { if (empty($target)) { return true; } if (!$target->isTrait()) { //Target is interface or class return $class->isSubclassOf($target) || $class->getName() == $target->getName(); } //Checking using traits return in_array($target->getName(), $this->fetchTraits($class->getName())); }
[ "protected", "function", "isTargeted", "(", "\\", "ReflectionClass", "$", "class", ",", "\\", "ReflectionClass", "$", "target", "=", "null", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "target", ")", ")", "{", "return", "true", ";", "}", "if",...
Check if given class targeted by locator. @param \ReflectionClass $class @param \ReflectionClass|null $target @return bool
[ "Check", "if", "given", "class", "targeted", "by", "locator", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/ClassLocator.php#L69-L82
train
spiral/tokenizer
src/Isolator.php
Isolator.isolatePHP
public function isolatePHP(string $source): string { $phpBlock = false; $isolated = ''; foreach (token_get_all($source) as $token) { if ($this->isOpenTag($token)) { $phpBlock = $token[1]; continue; } if ($this->isCloseTag($token)) { $blockID = $this->uniqueID(); $this->phpBlocks[$blockID] = $phpBlock . $token[1]; $isolated .= $this->placeholder($blockID); $phpBlock = ''; continue; } $tokenContent = is_array($token) ? $token[1] : $token; if (!empty($phpBlock)) { $phpBlock .= $tokenContent; } else { $isolated .= $tokenContent; } } return $isolated; }
php
public function isolatePHP(string $source): string { $phpBlock = false; $isolated = ''; foreach (token_get_all($source) as $token) { if ($this->isOpenTag($token)) { $phpBlock = $token[1]; continue; } if ($this->isCloseTag($token)) { $blockID = $this->uniqueID(); $this->phpBlocks[$blockID] = $phpBlock . $token[1]; $isolated .= $this->placeholder($blockID); $phpBlock = ''; continue; } $tokenContent = is_array($token) ? $token[1] : $token; if (!empty($phpBlock)) { $phpBlock .= $tokenContent; } else { $isolated .= $tokenContent; } } return $isolated; }
[ "public", "function", "isolatePHP", "(", "string", "$", "source", ")", ":", "string", "{", "$", "phpBlock", "=", "false", ";", "$", "isolated", "=", "''", ";", "foreach", "(", "token_get_all", "(", "$", "source", ")", "as", "$", "token", ")", "{", "i...
Isolates all returned PHP blocks with a defined pattern. Method uses token_get_all function. Resulted src have all php blocks replaced with non executable placeholder. @param string $source @return string
[ "Isolates", "all", "returned", "PHP", "blocks", "with", "a", "defined", "pattern", ".", "Method", "uses", "token_get_all", "function", ".", "Resulted", "src", "have", "all", "php", "blocks", "replaced", "with", "non", "executable", "placeholder", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Isolator.php#L64-L97
train
spiral/tokenizer
src/Isolator.php
Isolator.setBlock
public function setBlock(string $blockID, string $source): Isolator { if (!isset($this->phpBlocks[$blockID])) { throw new IsolatorException("Undefined block {$blockID}"); } $this->phpBlocks[$blockID] = $source; return $this; }
php
public function setBlock(string $blockID, string $source): Isolator { if (!isset($this->phpBlocks[$blockID])) { throw new IsolatorException("Undefined block {$blockID}"); } $this->phpBlocks[$blockID] = $source; return $this; }
[ "public", "function", "setBlock", "(", "string", "$", "blockID", ",", "string", "$", "source", ")", ":", "Isolator", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "phpBlocks", "[", "$", "blockID", "]", ")", ")", "{", "throw", "new", "Isolator...
Set block content by id. @param string $blockID @param string $source @return self @throws IsolatorException
[ "Set", "block", "content", "by", "id", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Isolator.php#L109-L118
train
spiral/tokenizer
src/Reflection/ReflectionInvocation.php
ReflectionInvocation.getArgument
public function getArgument(int $index): ReflectionArgument { if (!isset($this->arguments[$index])) { throw new ReflectionException("No such argument with index '{$index}'"); } return $this->arguments[$index]; }
php
public function getArgument(int $index): ReflectionArgument { if (!isset($this->arguments[$index])) { throw new ReflectionException("No such argument with index '{$index}'"); } return $this->arguments[$index]; }
[ "public", "function", "getArgument", "(", "int", "$", "index", ")", ":", "ReflectionArgument", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "arguments", "[", "$", "index", "]", ")", ")", "{", "throw", "new", "ReflectionException", "(", "\"No suc...
Get call argument by it's position. @param int $index @return ReflectionArgument|null
[ "Get", "call", "argument", "by", "it", "s", "position", "." ]
aca11410e183d4c4a6c0f858ba87bf072c4eb925
https://github.com/spiral/tokenizer/blob/aca11410e183d4c4a6c0f858ba87bf072c4eb925/src/Reflection/ReflectionInvocation.php#L178-L185
train
prologuephp/alerts
src/AlertsMessageBag.php
AlertsMessageBag.flush
public function flush($withSession = true) { $this->messages = []; if($withSession) { $this->session->forget($this->getSessionKey()); } return $this; }
php
public function flush($withSession = true) { $this->messages = []; if($withSession) { $this->session->forget($this->getSessionKey()); } return $this; }
[ "public", "function", "flush", "(", "$", "withSession", "=", "true", ")", "{", "$", "this", "->", "messages", "=", "[", "]", ";", "if", "(", "$", "withSession", ")", "{", "$", "this", "->", "session", "->", "forget", "(", "$", "this", "->", "getSes...
Deletes all messages. @param bool $withSession @return \Prologue\Alerts\AlertsMessageBag
[ "Deletes", "all", "messages", "." ]
d88244729b0109308136cbafe45f11095c7ee0b0
https://github.com/prologuephp/alerts/blob/d88244729b0109308136cbafe45f11095c7ee0b0/src/AlertsMessageBag.php#L95-L104
train
timble/kodekit
code/controller/behavior/persistable.php
ControllerBehaviorPersistable._getStateKey
protected function _getStateKey(ControllerContext $context) { $view = $this->getView()->getIdentifier(); $layout = $this->getView()->getLayout(); $model = $this->getModel()->getIdentifier(); return $view.'.'.$layout.'.'.$model.'.'.$context->action; }
php
protected function _getStateKey(ControllerContext $context) { $view = $this->getView()->getIdentifier(); $layout = $this->getView()->getLayout(); $model = $this->getModel()->getIdentifier(); return $view.'.'.$layout.'.'.$model.'.'.$context->action; }
[ "protected", "function", "_getStateKey", "(", "ControllerContext", "$", "context", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", "->", "getIdentifier", "(", ")", ";", "$", "layout", "=", "$", "this", "->", "getView", "(", ")", "->...
Returns a key based on the context to persist state values @param ControllerContext $context The active controller context @return string
[ "Returns", "a", "key", "based", "on", "the", "context", "to", "persist", "state", "values" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/persistable.php#L46-L53
train
timble/kodekit
code/controller/behavior/persistable.php
ControllerBehaviorPersistable._beforeBrowse
protected function _beforeBrowse(ControllerContextModel $context) { $query = $context->getRequest()->query; $query->add((array) $context->user->get($this->_getStateKey($context))); $this->getModel()->getState()->setValues($query->toArray()); }
php
protected function _beforeBrowse(ControllerContextModel $context) { $query = $context->getRequest()->query; $query->add((array) $context->user->get($this->_getStateKey($context))); $this->getModel()->getState()->setValues($query->toArray()); }
[ "protected", "function", "_beforeBrowse", "(", "ControllerContextModel", "$", "context", ")", "{", "$", "query", "=", "$", "context", "->", "getRequest", "(", ")", "->", "query", ";", "$", "query", "->", "add", "(", "(", "array", ")", "$", "context", "->...
Load the model state from the request This functions merges the request information with any model state information that was saved in the session and returns the result. @param ControllerContextModel $context The active controller context @return void
[ "Load", "the", "model", "state", "from", "the", "request" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/persistable.php#L64-L71
train
timble/kodekit
code/class/registry/registry.php
ClassRegistry.getLocator
public function getLocator($class) { $result = false; if(!false == $pos = strrpos($class, '\\')) { $namespace = substr($class, 0, $pos); if(isset($this->_namespaces[$namespace])) { $result = $this->_namespaces[$namespace]; } } return $result; }
php
public function getLocator($class) { $result = false; if(!false == $pos = strrpos($class, '\\')) { $namespace = substr($class, 0, $pos); if(isset($this->_namespaces[$namespace])) { $result = $this->_namespaces[$namespace]; } } return $result; }
[ "public", "function", "getLocator", "(", "$", "class", ")", "{", "$", "result", "=", "false", ";", "if", "(", "!", "false", "==", "$", "pos", "=", "strrpos", "(", "$", "class", ",", "'\\\\'", ")", ")", "{", "$", "namespace", "=", "substr", "(", "...
Get a specific locator from the class namespace @return string|false The name of the locator or FALSE if no locator could be found
[ "Get", "a", "specific", "locator", "from", "the", "class", "namespace" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/registry.php#L143-L157
train
timble/kodekit
code/class/registry/registry.php
ClassRegistry.setLocator
public function setLocator($class, $locator) { if(!false == $pos = strrpos($class, '\\')) { $namespace = substr($class, 0, $pos); $this->_namespaces[$namespace] = $locator; } return $this; }
php
public function setLocator($class, $locator) { if(!false == $pos = strrpos($class, '\\')) { $namespace = substr($class, 0, $pos); $this->_namespaces[$namespace] = $locator; } return $this; }
[ "public", "function", "setLocator", "(", "$", "class", ",", "$", "locator", ")", "{", "if", "(", "!", "false", "==", "$", "pos", "=", "strrpos", "(", "$", "class", ",", "'\\\\'", ")", ")", "{", "$", "namespace", "=", "substr", "(", "$", "class", ...
Set a specific locator based on a class namespace @return ClassRegistry
[ "Set", "a", "specific", "locator", "based", "on", "a", "class", "namespace" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/registry.php#L164-L173
train
timble/kodekit
code/filesystem/stream/iterator/chunked.php
FilesystemStreamIteratorChunked.seek
public function seek($position) { if ($position > $this->count()) { throw new \OutOfBoundsException('Invalid seek position ('.$position.')'); } $chunk_size = $this->getChunkSize(); $position = $chunk_size * $position; $this->getInnerIterator()->seek($position); }
php
public function seek($position) { if ($position > $this->count()) { throw new \OutOfBoundsException('Invalid seek position ('.$position.')'); } $chunk_size = $this->getChunkSize(); $position = $chunk_size * $position; $this->getInnerIterator()->seek($position); }
[ "public", "function", "seek", "(", "$", "position", ")", "{", "if", "(", "$", "position", ">", "$", "this", "->", "count", "(", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Invalid seek position ('", ".", "$", "position", ".", "')'...
Seeks to a given chunk position in the stream @param int $position @throws \OutOfBoundsException If the position is not seekable. @return void
[ "Seeks", "to", "a", "given", "chunk", "position", "in", "the", "stream" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/stream/iterator/chunked.php#L46-L56
train
timble/kodekit
code/template/helper/grid.php
TemplateHelperGrid.checkbox
public function checkbox($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null, 'attribs' => array() ))->append(array( 'column' => $config->entity->getIdentityKey() )); if($config->entity->isLockable() && $config->entity->isLocked()) { $html = $this->createHelper('behavior')->tooltip(); $html .= '<span class="k-icon-lock-locked" data-k-tooltip title="'.$this->createHelper('grid')->lock_message(array('entity' => $config->entity)).'"> </span>'; } else { $column = $config->column; $value = StringEscaper::attr($config->entity->{$column}); $attribs = $this->buildAttributes($config->attribs); $html = '<input type="checkbox" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />'; $html = sprintf($html, $column, $value, $attribs); } return $html; }
php
public function checkbox($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null, 'attribs' => array() ))->append(array( 'column' => $config->entity->getIdentityKey() )); if($config->entity->isLockable() && $config->entity->isLocked()) { $html = $this->createHelper('behavior')->tooltip(); $html .= '<span class="k-icon-lock-locked" data-k-tooltip title="'.$this->createHelper('grid')->lock_message(array('entity' => $config->entity)).'"> </span>'; } else { $column = $config->column; $value = StringEscaper::attr($config->entity->{$column}); $attribs = $this->buildAttributes($config->attribs); $html = '<input type="checkbox" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />'; $html = sprintf($html, $column, $value, $attribs); } return $html; }
[ "public", "function", "checkbox", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'entity'", "=>", "null", ",", "'at...
Render a checkbox field @param array $config An optional array with configuration options @return string Html
[ "Render", "a", "checkbox", "field" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L61-L91
train
timble/kodekit
code/template/helper/grid.php
TemplateHelperGrid.enable
public function enable($config = array()) { $translator = $this->getObject('translator'); $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null, 'field' => 'enabled', 'clickable' => true ))->append(array( 'enabled' => (bool) $config->entity->{$config->field}, 'data' => array($config->field => $config->entity->{$config->field} ? 0 : 1), ))->append(array( 'alt' => $config->enabled ? $translator->translate('Enabled') : $translator->translate('Disabled'), 'tooltip' => $config->enabled ? $translator->translate('Disable Item') : $translator->translate('Enable Item'), 'color' => $config->enabled ? '#468847' : '#b94a48', 'icon' => $config->enabled ? 'enabled' : 'disabled', )); $class = $config->enabled ? 'k-table__item--state-published' : 'k-table__item--state-unpublished'; $tooltip = ''; if ($config->clickable) { $data = htmlentities(json_encode($config->data->toArray())); $tooltip = 'data-k-tooltip=\'{"container":".k-ui-container","delay":{"show":500,"hide":50}}\' style="cursor: pointer" data-action="edit" data-data="'.$data.'" data-original-title="'.$config->tooltip.'"'; } $html = '<span class="k-table__item--state '.$class.'" '.$tooltip.'>'.$config->alt.'</span>'; $html .= $this->createHelper('behavior')->tooltip(); return $html; }
php
public function enable($config = array()) { $translator = $this->getObject('translator'); $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null, 'field' => 'enabled', 'clickable' => true ))->append(array( 'enabled' => (bool) $config->entity->{$config->field}, 'data' => array($config->field => $config->entity->{$config->field} ? 0 : 1), ))->append(array( 'alt' => $config->enabled ? $translator->translate('Enabled') : $translator->translate('Disabled'), 'tooltip' => $config->enabled ? $translator->translate('Disable Item') : $translator->translate('Enable Item'), 'color' => $config->enabled ? '#468847' : '#b94a48', 'icon' => $config->enabled ? 'enabled' : 'disabled', )); $class = $config->enabled ? 'k-table__item--state-published' : 'k-table__item--state-unpublished'; $tooltip = ''; if ($config->clickable) { $data = htmlentities(json_encode($config->data->toArray())); $tooltip = 'data-k-tooltip=\'{"container":".k-ui-container","delay":{"show":500,"hide":50}}\' style="cursor: pointer" data-action="edit" data-data="'.$data.'" data-original-title="'.$config->tooltip.'"'; } $html = '<span class="k-table__item--state '.$class.'" '.$tooltip.'>'.$config->alt.'</span>'; $html .= $this->createHelper('behavior')->tooltip(); return $html; }
[ "public", "function", "enable", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ";", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", ...
Render an enable field @param array $config An optional array with configuration options @return string Html
[ "Render", "an", "enable", "field" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L265-L302
train
timble/kodekit
code/template/helper/grid.php
TemplateHelperGrid.lock_message
public function lock_message($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null )); if (!($config->entity instanceof ModelEntityInterface)) { throw new \UnexpectedValueException('$config->entity should be a ModelEntityInterface instance'); } $entity = $config->entity; $message = ''; if($entity->isLockable() && $entity->isLocked()) { $user = $entity->getLocker(); $date = $this->getObject('date', array('date' => $entity->locked_on)); $message = $this->getObject('translator')->translate( 'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize()) ); } return $message; }
php
public function lock_message($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'entity' => null )); if (!($config->entity instanceof ModelEntityInterface)) { throw new \UnexpectedValueException('$config->entity should be a ModelEntityInterface instance'); } $entity = $config->entity; $message = ''; if($entity->isLockable() && $entity->isLocked()) { $user = $entity->getLocker(); $date = $this->getObject('date', array('date' => $entity->locked_on)); $message = $this->getObject('translator')->translate( 'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize()) ); } return $message; }
[ "public", "function", "lock_message", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'entity'", "=>", "null", ")", ...
Get the locked information @param array|ObjectConfig $config An optional configuration array. @throws \UnexpectedValueException @return string The locked by "name" "date" message
[ "Get", "the", "locked", "information" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/grid.php#L338-L363
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.isValidIsbn
public function isValidIsbn(string $isbn) : bool { return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn); }
php
public function isValidIsbn(string $isbn) : bool { return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn); }
[ "public", "function", "isValidIsbn", "(", "string", "$", "isbn", ")", ":", "bool", "{", "return", "$", "this", "->", "isValidIsbn10", "(", "$", "isbn", ")", "||", "$", "this", "->", "isValidIsbn13", "(", "$", "isbn", ")", ";", "}" ]
Returns whether the given ISBN is a valid ISBN-10 or ISBN-13. @param string $isbn The unformatted ISBN. @return bool
[ "Returns", "whether", "the", "given", "ISBN", "is", "a", "valid", "ISBN", "-", "10", "or", "ISBN", "-", "13", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L39-L42
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.isValidIsbn10
public function isValidIsbn10(string $isbn) : bool { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { return false; } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) { return false; } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { return false; } } return true; }
php
public function isValidIsbn10(string $isbn) : bool { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { return false; } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) { return false; } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { return false; } } return true; }
[ "public", "function", "isValidIsbn10", "(", "string", "$", "isbn", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "cleanupBeforeValidate", ")", "{", "if", "(", "preg_match", "(", "Internal", "\\", "Regexp", "::", "ASCII", ",", "$", "isbn", ")", "...
Returns whether the given ISBN is a valid ISBN-10. @param string $isbn The unformatted ISBN. @return bool
[ "Returns", "whether", "the", "given", "ISBN", "is", "a", "valid", "ISBN", "-", "10", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L51-L74
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.isValidIsbn13
public function isValidIsbn13(string $isbn) : bool { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { return false; } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) { return false; } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { return false; } } return true; }
php
public function isValidIsbn13(string $isbn) : bool { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { return false; } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) { return false; } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { return false; } } return true; }
[ "public", "function", "isValidIsbn13", "(", "string", "$", "isbn", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "cleanupBeforeValidate", ")", "{", "if", "(", "preg_match", "(", "Internal", "\\", "Regexp", "::", "ASCII", ",", "$", "isbn", ")", "...
Returns whether the given ISBN is a valid ISBN-13. @param string $isbn The unformatted ISBN. @return bool
[ "Returns", "whether", "the", "given", "ISBN", "is", "a", "valid", "ISBN", "-", "13", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L83-L104
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.convertIsbn10to13
public function convertIsbn10to13(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\Converter::convertIsbn10to13($isbn); }
php
public function convertIsbn10to13(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\Converter::convertIsbn10to13($isbn); }
[ "public", "function", "convertIsbn10to13", "(", "string", "$", "isbn", ")", ":", "string", "{", "if", "(", "$", "this", "->", "cleanupBeforeValidate", ")", "{", "if", "(", "preg_match", "(", "Internal", "\\", "Regexp", "::", "ASCII", ",", "$", "isbn", ")...
Converts an ISBN-10 to an ISBN-13. @param string $isbn The ISBN-10 to convert. @return string The converted, unformatted ISBN-13. @throws Exception\InvalidIsbnException If the ISBN is not a valid ISBN-10.
[ "Converts", "an", "ISBN", "-", "10", "to", "an", "ISBN", "-", "13", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L115-L138
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.convertIsbn13to10
public function convertIsbn13to10(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\Converter::convertIsbn13to10($isbn); }
php
public function convertIsbn13to10(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\Converter::convertIsbn13to10($isbn); }
[ "public", "function", "convertIsbn13to10", "(", "string", "$", "isbn", ")", ":", "string", "{", "if", "(", "$", "this", "->", "cleanupBeforeValidate", ")", "{", "if", "(", "preg_match", "(", "Internal", "\\", "Regexp", "::", "ASCII", ",", "$", "isbn", ")...
Converts an ISBN-13 to an ISBN-10. Only ISBN-13 numbers starting with 978 can be converted to an ISBN-10. If the input ISBN is a valid ISBN-13 but does not start with 978, an exception is thrown. @param string $isbn The ISBN-13 to convert. @return string The converted, unformatted ISBN-10. @throws Exception\InvalidIsbnException If the ISBN is not a valid ISBN-13. @throws Exception\IsbnNotConvertibleException If the ISBN cannot be converted.
[ "Converts", "an", "ISBN", "-", "13", "to", "an", "ISBN", "-", "10", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L153-L174
train
nicebooks-com/isbn
src/IsbnTools.php
IsbnTools.format
public function format(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 1) { if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\RangeService::format($isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 1) { if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\RangeService::format($isbn); } throw Exception\InvalidIsbnException::forIsbn($isbn); }
php
public function format(string $isbn) : string { if ($this->cleanupBeforeValidate) { if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) { throw Exception\InvalidIsbnException::forIsbn($isbn); } $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn); } if (preg_match(Internal\Regexp::ISBN13, $isbn) === 1) { if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit13($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\RangeService::format($isbn); } $isbn = strtoupper($isbn); if (preg_match(Internal\Regexp::ISBN10, $isbn) === 1) { if ($this->validateCheckDigit) { if (! Internal\CheckDigit::validateCheckDigit10($isbn)) { throw Exception\InvalidIsbnException::forIsbn($isbn); } } return Internal\RangeService::format($isbn); } throw Exception\InvalidIsbnException::forIsbn($isbn); }
[ "public", "function", "format", "(", "string", "$", "isbn", ")", ":", "string", "{", "if", "(", "$", "this", "->", "cleanupBeforeValidate", ")", "{", "if", "(", "preg_match", "(", "Internal", "\\", "Regexp", "::", "ASCII", ",", "$", "isbn", ")", "===",...
Formats an ISBN number. @param string $isbn The ISBN-10 or ISBN-13 number. @return string The formatted ISBN number. @throws Exception\InvalidIsbnException If the ISBN is not valid.
[ "Formats", "an", "ISBN", "number", "." ]
f5ceb662e517b21e30c9dfa53c4d74823849232d
https://github.com/nicebooks-com/isbn/blob/f5ceb662e517b21e30c9dfa53c4d74823849232d/src/IsbnTools.php#L185-L218
train
timble/kodekit
code/model/behavior/paginatable.php
ModelBehaviorPaginatable.getPaginator
public function getPaginator() { $paginator = new ModelPaginator(array( 'offset' => (int)$this->getState()->offset, 'limit' => (int)$this->getState()->limit, 'total' => (int)$this->count(), )); return $paginator; }
php
public function getPaginator() { $paginator = new ModelPaginator(array( 'offset' => (int)$this->getState()->offset, 'limit' => (int)$this->getState()->limit, 'total' => (int)$this->count(), )); return $paginator; }
[ "public", "function", "getPaginator", "(", ")", "{", "$", "paginator", "=", "new", "ModelPaginator", "(", "array", "(", "'offset'", "=>", "(", "int", ")", "$", "this", "->", "getState", "(", ")", "->", "offset", ",", "'limit'", "=>", "(", "int", ")", ...
Get the model paginator object @return ModelPaginator The model paginator object
[ "Get", "the", "model", "paginator", "object" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/model/behavior/paginatable.php#L39-L48
train
timble/kodekit
code/filter/factory.php
FilterFactory.createFilter
public function createFilter($filter, $config = array()) { if(is_string($filter) && strpos($filter, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['name'] = $filter; } else $identifier = $filter; $filter = $this->getObject($identifier, $config); //Check the filter interface if(!($filter instanceof FilterInterface)) { throw new \UnexpectedValueException('Filter:'.get_class($filter).' does not implement FilterInterface'); } return $filter; }
php
public function createFilter($filter, $config = array()) { if(is_string($filter) && strpos($filter, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['name'] = $filter; } else $identifier = $filter; $filter = $this->getObject($identifier, $config); //Check the filter interface if(!($filter instanceof FilterInterface)) { throw new \UnexpectedValueException('Filter:'.get_class($filter).' does not implement FilterInterface'); } return $filter; }
[ "public", "function", "createFilter", "(", "$", "filter", ",", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "filter", ")", "&&", "strpos", "(", "$", "filter", ",", "'.'", ")", "===", "false", ")", "{", "$", "...
Factory method for Filter classes. If the filter is not an identifier this function will create it directly instead of going through the Object identification process. @param string $filter Filter identifier @param object|array $config An optional ObjectConfig object with configuration options @throws \UnexpectedValueException When the filter does not implement FilterInterface @return FilterInterface
[ "Factory", "method", "for", "Filter", "classes", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filter/factory.php#L56-L73
train
rosasurfer/ministruts
src/monitor/ChainedDependency.php
ChainedDependency.isValid
public function isValid() { if ($this->type == 'AND') { foreach ($this->dependencies as $dependency) { if (!$dependency->isValid()) return false; } return true; } if ($this->type == 'OR' ) { foreach ($this->dependencies as $dependency) { if ($dependency->isValid()) return true; } return false; } throw new RuntimeException('Unreachable code reached'); }
php
public function isValid() { if ($this->type == 'AND') { foreach ($this->dependencies as $dependency) { if (!$dependency->isValid()) return false; } return true; } if ($this->type == 'OR' ) { foreach ($this->dependencies as $dependency) { if ($dependency->isValid()) return true; } return false; } throw new RuntimeException('Unreachable code reached'); }
[ "public", "function", "isValid", "(", ")", "{", "if", "(", "$", "this", "->", "type", "==", "'AND'", ")", "{", "foreach", "(", "$", "this", "->", "dependencies", "as", "$", "dependency", ")", "{", "if", "(", "!", "$", "dependency", "->", "isValid", ...
Ob das zu ueberwachende Ereignis oder der Zustandswechsel eingetreten sind oder nicht. @return bool - TRUE, wenn die Abhaengigkeit weiterhin erfuellt ist. FALSE, wenn der Zustandswechsel eingetreten ist und die Abhaengigkeit nicht mehr erfuellt ist.
[ "Ob", "das", "zu", "ueberwachende", "Ereignis", "oder", "der", "Zustandswechsel", "eingetreten", "sind", "oder", "nicht", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/monitor/ChainedDependency.php#L93-L111
train
timble/kodekit
code/filesystem/locator/factory.php
FilesystemLocatorFactory.createLocator
public function createLocator($path, array $config = array()) { $scheme = parse_url($path, PHP_URL_SCHEME); //If no scheme is specified fall back to file:// locator $name = !empty($scheme) ? $scheme : 'file'; //If a windows drive letter is passed use file:// locator if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if(preg_match('#^[a-z]{1}$#i', $name)) { $name = 'file'; } } //Locator not supported if(!in_array($name, $this->getLocators())) { throw new \RuntimeException(sprintf( 'Unable to find the filesystem locator "%s" - did you forget to register it ?', $name )); } //Create the locator $identifier = $this->getLocator($name); $locator = $this->getObject($identifier, $config); if(!$locator instanceof FilesystemLocatorInterface) { throw new \UnexpectedValueException( 'Locator: '.get_class($locator).' does not implement FilesystemLocatorInterface' ); } return $locator; }
php
public function createLocator($path, array $config = array()) { $scheme = parse_url($path, PHP_URL_SCHEME); //If no scheme is specified fall back to file:// locator $name = !empty($scheme) ? $scheme : 'file'; //If a windows drive letter is passed use file:// locator if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if(preg_match('#^[a-z]{1}$#i', $name)) { $name = 'file'; } } //Locator not supported if(!in_array($name, $this->getLocators())) { throw new \RuntimeException(sprintf( 'Unable to find the filesystem locator "%s" - did you forget to register it ?', $name )); } //Create the locator $identifier = $this->getLocator($name); $locator = $this->getObject($identifier, $config); if(!$locator instanceof FilesystemLocatorInterface) { throw new \UnexpectedValueException( 'Locator: '.get_class($locator).' does not implement FilesystemLocatorInterface' ); } return $locator; }
[ "public", "function", "createLocator", "(", "$", "path", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "scheme", "=", "parse_url", "(", "$", "path", ",", "PHP_URL_SCHEME", ")", ";", "//If no scheme is specified fall back to file:// locator"...
Create a locator Note that only URLs delimited by "://"" and ":" are supported, ":/" while technically valid URLs, are not. If no locator is registered for the specific scheme a exception will be thrown. @param string $path The locator path @param array $config An optional associative array of configuration options @throws \InvalidArgumentException If the path is not valid @throws \RuntimeException If the locator isn't registered @throws \UnexpectedValueException If the locator object doesn't implement the FilesystemLocatorInterface @return FilesystemLocatorInterface
[ "Create", "a", "locator" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/factory.php#L74-L109
train
timble/kodekit
code/object/abstract.php
ObjectAbstract.inherits
public function inherits($class) { if ($this instanceof $class) { return true; } $objects = array_values($this->__mixed_methods); foreach($objects as $object) { if($object instanceof $class) { return true; } } return false; }
php
public function inherits($class) { if ($this instanceof $class) { return true; } $objects = array_values($this->__mixed_methods); foreach($objects as $object) { if($object instanceof $class) { return true; } } return false; }
[ "public", "function", "inherits", "(", "$", "class", ")", "{", "if", "(", "$", "this", "instanceof", "$", "class", ")", "{", "return", "true", ";", "}", "$", "objects", "=", "array_values", "(", "$", "this", "->", "__mixed_methods", ")", ";", "foreach"...
Checks if the object or one of its mixins inherits from a class. @param string|object The class to check @return boolean Returns TRUE if the object inherits from the class
[ "Checks", "if", "the", "object", "or", "one", "of", "its", "mixins", "inherits", "from", "a", "class", "." ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/abstract.php#L234-L250
train
timble/kodekit
code/controller/toolbar/iterator/recursive.php
ControllerToolbarIteratorRecursive._createInnerIterator
protected static function _createInnerIterator(ControllerToolbarInterface $toolbar) { $iterator = new \RecursiveArrayIterator($toolbar->getIterator()); $iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY); return $iterator; }
php
protected static function _createInnerIterator(ControllerToolbarInterface $toolbar) { $iterator = new \RecursiveArrayIterator($toolbar->getIterator()); $iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY); return $iterator; }
[ "protected", "static", "function", "_createInnerIterator", "(", "ControllerToolbarInterface", "$", "toolbar", ")", "{", "$", "iterator", "=", "new", "\\", "RecursiveArrayIterator", "(", "$", "toolbar", "->", "getIterator", "(", ")", ")", ";", "$", "iterator", "=...
Create a recursive iterator from a toolbar @param ControllerToolbarInterface $toolbar @return \RecursiveIterator
[ "Create", "a", "recursive", "iterator", "from", "a", "toolbar" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/toolbar/iterator/recursive.php#L86-L92
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.getImplementation
final public static function getImplementation($class) { if (!is_a($class, __CLASS__, $allowString=true)) { if (!is_class($class)) throw new ClassNotFoundException('Class not found: '.$class ); throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class); } /** @var self $dao */ $dao = self::getInstance($class); return $dao; }
php
final public static function getImplementation($class) { if (!is_a($class, __CLASS__, $allowString=true)) { if (!is_class($class)) throw new ClassNotFoundException('Class not found: '.$class ); throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class); } /** @var self $dao */ $dao = self::getInstance($class); return $dao; }
[ "final", "public", "static", "function", "getImplementation", "(", "$", "class", ")", "{", "if", "(", "!", "is_a", "(", "$", "class", ",", "__CLASS__", ",", "$", "allowString", "=", "true", ")", ")", "{", "if", "(", "!", "is_class", "(", "$", "class"...
Get the specified DAO implementation. @param string $class - DAO class name @return self
[ "Get", "the", "specified", "DAO", "implementation", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L44-L52
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.findAll
public function findAll($query = null) { if ($query === null) { $mapping = $this->getMapping(); $table = $this->escapeIdentifier($mapping['table']); $query = 'select * from '.$table; } return $this->getWorker()->findAll($query); }
php
public function findAll($query = null) { if ($query === null) { $mapping = $this->getMapping(); $table = $this->escapeIdentifier($mapping['table']); $query = 'select * from '.$table; } return $this->getWorker()->findAll($query); }
[ "public", "function", "findAll", "(", "$", "query", "=", "null", ")", "{", "if", "(", "$", "query", "===", "null", ")", "{", "$", "mapping", "=", "$", "this", "->", "getMapping", "(", ")", ";", "$", "table", "=", "$", "this", "->", "escapeIdentifie...
Find all matching records and convert them to instances of the entity class. @param string $query [optional] - SQL query with optional ORM syntax; without a query all instances are returned @return PersistableObject[]
[ "Find", "all", "matching", "records", "and", "convert", "them", "to", "instances", "of", "the", "entity", "class", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L88-L95
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.get
public function get($query, $allowMany = false) { $result = $this->find($query, $allowMany); if (!$result) throw new NoSuchRecordException($query); return $result; }
php
public function get($query, $allowMany = false) { $result = $this->find($query, $allowMany); if (!$result) throw new NoSuchRecordException($query); return $result; }
[ "public", "function", "get", "(", "$", "query", ",", "$", "allowMany", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "find", "(", "$", "query", ",", "$", "allowMany", ")", ";", "if", "(", "!", "$", "result", ")", "throw", "new", ...
Get a single matching record and convert it to an instance of the entity class. @param string $query - SQL query with optional ORM syntax @param bool $allowMany [optional] - whether the query is allowed to return a multi-row result (default: no) @return PersistableObject @throws NoSuchRecordException if the query returned no rows @throws MultipleRecordsException if the query returned multiple rows and $allowMany was not set to TRUE
[ "Get", "a", "single", "matching", "record", "and", "convert", "it", "to", "an", "instance", "of", "the", "entity", "class", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L109-L114
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.transaction
public function transaction(\Closure $task) { try { $this->db()->begin(); $result = $task(); $this->db()->commit(); return $result; } catch (\Exception $ex) { $this->db()->rollback(); throw $ex; } }
php
public function transaction(\Closure $task) { try { $this->db()->begin(); $result = $task(); $this->db()->commit(); return $result; } catch (\Exception $ex) { $this->db()->rollback(); throw $ex; } }
[ "public", "function", "transaction", "(", "\\", "Closure", "$", "task", ")", "{", "try", "{", "$", "this", "->", "db", "(", ")", "->", "begin", "(", ")", ";", "$", "result", "=", "$", "task", "(", ")", ";", "$", "this", "->", "db", "(", ")", ...
Execute a task in a transactional way. The transaction is automatically committed or rolled back. A nested transaction is executed in the context of the nesting transaction. @param \Closure $task - task to execute (an anonymous function is implicitly casted) @return mixed - the task's return value (if any)
[ "Execute", "a", "task", "in", "a", "transactional", "way", ".", "The", "transaction", "is", "automatically", "committed", "or", "rolled", "back", ".", "A", "nested", "transaction", "is", "executed", "in", "the", "context", "of", "the", "nesting", "transaction"...
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L168-L179
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.getEntityMapping
public function getEntityMapping() { if (!$this->entityMapping) { $this->entityMapping = new EntityMapping($this->getMapping()); } return $this->entityMapping; }
php
public function getEntityMapping() { if (!$this->entityMapping) { $this->entityMapping = new EntityMapping($this->getMapping()); } return $this->entityMapping; }
[ "public", "function", "getEntityMapping", "(", ")", "{", "if", "(", "!", "$", "this", "->", "entityMapping", ")", "{", "$", "this", "->", "entityMapping", "=", "new", "EntityMapping", "(", "$", "this", "->", "getMapping", "(", ")", ")", ";", "}", "retu...
Return the object-oriented data mapping of the DAO's entity. @return EntityMapping
[ "Return", "the", "object", "-", "oriented", "data", "mapping", "of", "the", "DAO", "s", "entity", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L286-L291
train
rosasurfer/ministruts
src/db/orm/DAO.php
DAO.db
final public function db() { if (!$this->connector) { $this->connector = $this->getWorker()->getConnector(); } return $this->connector; }
php
final public function db() { if (!$this->connector) { $this->connector = $this->getWorker()->getConnector(); } return $this->connector; }
[ "final", "public", "function", "db", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connector", ")", "{", "$", "this", "->", "connector", "=", "$", "this", "->", "getWorker", "(", ")", "->", "getConnector", "(", ")", ";", "}", "return", "$", ...
Return the database adapter used for the DAO's entity. @return IConnector
[ "Return", "the", "database", "adapter", "used", "for", "the", "DAO", "s", "entity", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/DAO.php#L309-L314
train
hakito/PHP-Stuzza-EPS-BankTransfer
src/TransferInitiatorDetails.php
TransferInitiatorDetails.SetExpirationMinutes
public function SetExpirationMinutes($minutes) { if ($minutes < 5 || $minutes > 60) throw new \InvalidArgumentException('Expiration minutes value of "' . $minutes . '" is not between 5 and 60.'); $expires = new \DateTime(); $expires->add(new \DateInterval('PT' . $minutes . 'M')); $this->ExpirationTime = $expires->format(DATE_RFC3339); }
php
public function SetExpirationMinutes($minutes) { if ($minutes < 5 || $minutes > 60) throw new \InvalidArgumentException('Expiration minutes value of "' . $minutes . '" is not between 5 and 60.'); $expires = new \DateTime(); $expires->add(new \DateInterval('PT' . $minutes . 'M')); $this->ExpirationTime = $expires->format(DATE_RFC3339); }
[ "public", "function", "SetExpirationMinutes", "(", "$", "minutes", ")", "{", "if", "(", "$", "minutes", "<", "5", "||", "$", "minutes", ">", "60", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expiration minutes value of \"'", ".", "$", "minute...
Sets ExpirationTime by adding given amount of minutes to the current timestamp. @param int $minutes Must be between 5 and 60 @throws \InvalidArgumentException if minutes not between 5 and 60
[ "Sets", "ExpirationTime", "by", "adding", "given", "amount", "of", "minutes", "to", "the", "current", "timestamp", "." ]
c2af496ecf4b9f095447a7b9f5c02d20924252bd
https://github.com/hakito/PHP-Stuzza-EPS-BankTransfer/blob/c2af496ecf4b9f095447a7b9f5c02d20924252bd/src/TransferInitiatorDetails.php#L135-L143
train
timble/kodekit
code/dispatcher/behavior/decoratable.php
DispatcherBehaviorDecoratable.addDecorator
public function addDecorator($identifier, $prepend = false) { if($prepend) { array_unshift($this->__decorators, $identifier); } else { array_push($this->__decorators, $identifier); } return $this; }
php
public function addDecorator($identifier, $prepend = false) { if($prepend) { array_unshift($this->__decorators, $identifier); } else { array_push($this->__decorators, $identifier); } return $this; }
[ "public", "function", "addDecorator", "(", "$", "identifier", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "$", "prepend", ")", "{", "array_unshift", "(", "$", "this", "->", "__decorators", ",", "$", "identifier", ")", ";", "}", "else", "{",...
Add a decorator @param string $identifier The decorator identifier @param bool $prepend If true, the decorator will be prepended instead of appended. @return DispatcherBehaviorDecoratable
[ "Add", "a", "decorator" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/decoratable.php#L89-L98
train
timble/kodekit
code/dispatcher/behavior/decoratable.php
DispatcherBehaviorDecoratable._beforeSend
protected function _beforeSend(DispatcherContext $context) { $response = $context->getResponse(); if(!$response->isDownloadable()) { foreach ($this->getDecorators() as $decorator) { //Get the decorator $config = array('response' => array('content' => $response->getContent())); $controller = $this->getObject($decorator, $config); if(!$controller instanceof ControllerViewable) { throw new \UnexpectedValueException( 'Decorator '.get_class($controller).' does not implement ControllerViewable' ); } //Set the view $parameters = array( 'language' => $this->getLanguage(), ); if($response->isError()) { $parameters['status'] = $response->getStatusCode(); } else { $parameters['component'] = $this->getController()->getIdentifier()->package; } $controller->getView() ->setParameters($parameters) ->getTemplate()->addFilter('decorator'); //Set the response $response->setContent($controller->render()); } } }
php
protected function _beforeSend(DispatcherContext $context) { $response = $context->getResponse(); if(!$response->isDownloadable()) { foreach ($this->getDecorators() as $decorator) { //Get the decorator $config = array('response' => array('content' => $response->getContent())); $controller = $this->getObject($decorator, $config); if(!$controller instanceof ControllerViewable) { throw new \UnexpectedValueException( 'Decorator '.get_class($controller).' does not implement ControllerViewable' ); } //Set the view $parameters = array( 'language' => $this->getLanguage(), ); if($response->isError()) { $parameters['status'] = $response->getStatusCode(); } else { $parameters['component'] = $this->getController()->getIdentifier()->package; } $controller->getView() ->setParameters($parameters) ->getTemplate()->addFilter('decorator'); //Set the response $response->setContent($controller->render()); } } }
[ "protected", "function", "_beforeSend", "(", "DispatcherContext", "$", "context", ")", "{", "$", "response", "=", "$", "context", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "response", "->", "isDownloadable", "(", ")", ")", "{", "foreach", ...
Render the decorators This method will also add the 'decorator' filter to the view and add following default parameters - component: The name of the component being dispatched - language: The language of the response - status: The status code of the response @param DispatcherContext $context The active command context @return void
[ "Render", "the", "decorators" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/decoratable.php#L122-L160
train
timble/kodekit
code/filesystem/locator/component.php
FilesystemLocatorComponent.getPathTemplates
public function getPathTemplates($url) { $templates = parent::getPathTemplates($url); foreach($templates as $key => $template) { //Qualify relative path if(substr($template, 0, 1) !== '/') { $bootstrapper = $this->getObject('object.bootstrapper'); unset($templates[$key]); $info = $this->parseUrl($url); $paths = $bootstrapper->getComponentPaths($info['package'], $info['domain']); $inserts = array(); foreach ($paths as $path) { $inserts[] = $path . '/'. $template; } //Insert the paths at the right position in the array array_splice( $templates, $key, 0, $inserts); } } return $templates; }
php
public function getPathTemplates($url) { $templates = parent::getPathTemplates($url); foreach($templates as $key => $template) { //Qualify relative path if(substr($template, 0, 1) !== '/') { $bootstrapper = $this->getObject('object.bootstrapper'); unset($templates[$key]); $info = $this->parseUrl($url); $paths = $bootstrapper->getComponentPaths($info['package'], $info['domain']); $inserts = array(); foreach ($paths as $path) { $inserts[] = $path . '/'. $template; } //Insert the paths at the right position in the array array_splice( $templates, $key, 0, $inserts); } } return $templates; }
[ "public", "function", "getPathTemplates", "(", "$", "url", ")", "{", "$", "templates", "=", "parent", "::", "getPathTemplates", "(", "$", "url", ")", ";", "foreach", "(", "$", "templates", "as", "$", "key", "=>", "$", "template", ")", "{", "//Qualify rel...
Get the list of path templates This method will qualify relative url's (url not starting with '/') by prepending the component base path to the url. If the component has additional paths a template path for each will be inserted in FIFO order. @param string $url The language url @return array The path templates
[ "Get", "the", "list", "of", "path", "templates" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/component.php#L74-L101
train
rosasurfer/ministruts
src/monitor/Dependency.php
Dependency.setMinValidity
public function setMinValidity($time) { if (!is_int($time)) throw new IllegalTypeException('Illegal type of parameter $time: '.gettype($time)); if ($time < 0) throw new InvalidArgumentException('Invalid argument $time: '.$time); $this->minValidity = $time; return $this; }
php
public function setMinValidity($time) { if (!is_int($time)) throw new IllegalTypeException('Illegal type of parameter $time: '.gettype($time)); if ($time < 0) throw new InvalidArgumentException('Invalid argument $time: '.$time); $this->minValidity = $time; return $this; }
[ "public", "function", "setMinValidity", "(", "$", "time", ")", "{", "if", "(", "!", "is_int", "(", "$", "time", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $time: '", ".", "gettype", "(", "$", "time", ")", ")", ";", "...
Setzt die Mindestgueltigkeit dieser Abhaengigkeit. @param int $time - Mindestgueltigkeit in Sekunden @return Dependency
[ "Setzt", "die", "Mindestgueltigkeit", "dieser", "Abhaengigkeit", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/monitor/Dependency.php#L103-L110
train
timble/kodekit
code/command/callback/abstract.php
CommandCallbackAbstract.removeCommandCallback
public function removeCommandCallback($command, $method) { $command = strtolower($command); if (isset($this->__command_callbacks[$command]) ) { if($method instanceof \Closure) { $index = spl_object_hash($method); } else { $index = $method; } unset($this->__command_callbacks[$command][$index]); } return $this; }
php
public function removeCommandCallback($command, $method) { $command = strtolower($command); if (isset($this->__command_callbacks[$command]) ) { if($method instanceof \Closure) { $index = spl_object_hash($method); } else { $index = $method; } unset($this->__command_callbacks[$command][$index]); } return $this; }
[ "public", "function", "removeCommandCallback", "(", "$", "command", ",", "$", "method", ")", "{", "$", "command", "=", "strtolower", "(", "$", "command", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "__command_callbacks", "[", "$", "command", "]...
Remove a callback @param string $command The command to unregister the handler from @param string|\Closure $method The name of the method or a Closure object to unregister @return CommandCallbackAbstract
[ "Remove", "a", "callback" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/callback/abstract.php#L167-L183
train
locomotivemtl/charcoal-core
src/Charcoal/Model/DescribableTrait.php
DescribableTrait.loadMetadata
public function loadMetadata($metadataIdent = null) { if ($metadataIdent === null) { $metadataIdent = $this->metadataIdent(); } $metadata = $this->metadataLoader()->load($metadataIdent, $this->metadataClass()); $this->setMetadata($metadata); return $metadata; }
php
public function loadMetadata($metadataIdent = null) { if ($metadataIdent === null) { $metadataIdent = $this->metadataIdent(); } $metadata = $this->metadataLoader()->load($metadataIdent, $this->metadataClass()); $this->setMetadata($metadata); return $metadata; }
[ "public", "function", "loadMetadata", "(", "$", "metadataIdent", "=", "null", ")", "{", "if", "(", "$", "metadataIdent", "===", "null", ")", "{", "$", "metadataIdent", "=", "$", "this", "->", "metadataIdent", "(", ")", ";", "}", "$", "metadata", "=", "...
Load a metadata file and store it as a static var. Use a `MetadataLoader` object and the object's metadataIdent to load the metadata content (typically from the filesystem, as json). @param string $metadataIdent Optional ident. If none is provided then it will use the auto-genereated one. @return MetadataInterface
[ "Load", "a", "metadata", "file", "and", "store", "it", "as", "a", "static", "var", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/DescribableTrait.php#L85-L95
train
locomotivemtl/charcoal-core
src/Charcoal/Model/DescribableTrait.php
DescribableTrait.metadataIdent
public function metadataIdent() { if ($this->metadataIdent === null) { $this->metadataIdent = $this->generateMetadataIdent(); } return $this->metadataIdent; }
php
public function metadataIdent() { if ($this->metadataIdent === null) { $this->metadataIdent = $this->generateMetadataIdent(); } return $this->metadataIdent; }
[ "public", "function", "metadataIdent", "(", ")", "{", "if", "(", "$", "this", "->", "metadataIdent", "===", "null", ")", "{", "$", "this", "->", "metadataIdent", "=", "$", "this", "->", "generateMetadataIdent", "(", ")", ";", "}", "return", "$", "this", ...
Get the metadata ident, or generate it from class name if it was not set explicitly. @return string
[ "Get", "the", "metadata", "ident", "or", "generate", "it", "from", "class", "name", "if", "it", "was", "not", "set", "explicitly", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/DescribableTrait.php#L112-L118
train
rosasurfer/ministruts
src/net/NetTools.php
NetTools.getHostByAddress
public static function getHostByAddress($ipAddress) { if (!is_string($ipAddress)) throw new IllegalTypeException('Illegal type of parameter $ipAddress: '.gettype($ipAddress)); if ($ipAddress == '') throw new InvalidArgumentException('Invalid argument $ipAddress: "'.$ipAddress.'"'); $result = gethostbyaddr($ipAddress); if ($result==='localhost' && !strStartsWith($ipAddress, '127.')) $result = $ipAddress; return $result; }
php
public static function getHostByAddress($ipAddress) { if (!is_string($ipAddress)) throw new IllegalTypeException('Illegal type of parameter $ipAddress: '.gettype($ipAddress)); if ($ipAddress == '') throw new InvalidArgumentException('Invalid argument $ipAddress: "'.$ipAddress.'"'); $result = gethostbyaddr($ipAddress); if ($result==='localhost' && !strStartsWith($ipAddress, '127.')) $result = $ipAddress; return $result; }
[ "public", "static", "function", "getHostByAddress", "(", "$", "ipAddress", ")", "{", "if", "(", "!", "is_string", "(", "$", "ipAddress", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $ipAddress: '", ".", "gettype", "(", "$", ...
Return the host name of the Internet host specified by a given IP address. Additionally checks the result returned by the built-in PHP function for plausibility. @param string $ipAddress - the host IP address @return string|bool - the host name on success, the unmodified IP address on failure, or FALSE on malformed input
[ "Return", "the", "host", "name", "of", "the", "Internet", "host", "specified", "by", "a", "given", "IP", "address", ".", "Additionally", "checks", "the", "result", "returned", "by", "the", "built", "-", "in", "PHP", "function", "for", "plausibility", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/NetTools.php#L27-L37
train
rosasurfer/ministruts
src/net/NetTools.php
NetTools.getHostByName
public static function getHostByName($name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if ($name == '') throw new InvalidArgumentException('Invalid argument $name: "'.$name.'"'); return \gethostbyname($name); }
php
public static function getHostByName($name) { if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name)); if ($name == '') throw new InvalidArgumentException('Invalid argument $name: "'.$name.'"'); return \gethostbyname($name); }
[ "public", "static", "function", "getHostByName", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $name: '", ".", "gettype", "(", "$", "name", ")", "...
Gibt die IP-Adresse eines Hostnamens zurueck. @param string $name - Hostname @return string - IP-Adresse oder der originale Hostname, wenn dieser nicht aufgeloest werden kann
[ "Gibt", "die", "IP", "-", "Adresse", "eines", "Hostnamens", "zurueck", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/NetTools.php#L47-L52
train
rosasurfer/ministruts
etc/phpstan/DynamicReturnType.php
DynamicReturnType.isMethodSupported
public function isMethodSupported(MethodReflection $methodReflection) : bool { if (!static::$methodNames) throw new RuntimeException('The class property '.static::class.'::$methodNames must be defined.'); return in_array($methodReflection->getName(), static::$methodNames); }
php
public function isMethodSupported(MethodReflection $methodReflection) : bool { if (!static::$methodNames) throw new RuntimeException('The class property '.static::class.'::$methodNames must be defined.'); return in_array($methodReflection->getName(), static::$methodNames); }
[ "public", "function", "isMethodSupported", "(", "MethodReflection", "$", "methodReflection", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "$", "methodNames", ")", "throw", "new", "RuntimeException", "(", "'The class property '", ".", "static", "::", "c...
Whether the named instance method returns dynamic types. @return bool
[ "Whether", "the", "named", "instance", "method", "returns", "dynamic", "types", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L45-L48
train
rosasurfer/ministruts
etc/phpstan/DynamicReturnType.php
DynamicReturnType.isStaticMethodSupported
public function isStaticMethodSupported(MethodReflection $methodReflection) : bool { if (!static::$methodNames) throw new RuntimeException('The class constant '.static::class.'::$methodNames must be defined.'); return in_array($methodReflection->getName(), static::$methodNames); }
php
public function isStaticMethodSupported(MethodReflection $methodReflection) : bool { if (!static::$methodNames) throw new RuntimeException('The class constant '.static::class.'::$methodNames must be defined.'); return in_array($methodReflection->getName(), static::$methodNames); }
[ "public", "function", "isStaticMethodSupported", "(", "MethodReflection", "$", "methodReflection", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "$", "methodNames", ")", "throw", "new", "RuntimeException", "(", "'The class constant '", ".", "static", "::"...
Whether the named static method returns dynamic types. @return bool
[ "Whether", "the", "named", "static", "method", "returns", "dynamic", "types", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L56-L59
train
rosasurfer/ministruts
etc/phpstan/DynamicReturnType.php
DynamicReturnType.getScopeDescription
protected function getScopeDescription(Scope $scope) : string { if ($scope->isInClass()) { $description = $scope->getClassReflection()->getName(); if ($scope->getFunctionName()) $description .= '::'.$scope->getFunctionName().'()'; if ($scope->isInAnonymousFunction()) $description .= '{closure}'; return $description; } if ($scope->getFunctionName()) { $description = $scope->getFunctionName().'()'; if ($scope->isInAnonymousFunction()) $description .= '{closure}'; return $description; } $description = $scope->isInAnonymousFunction() ? '{closure}' : '{main}'; $description = trim($scope->getNamespace().'\\'.$description, '\\'); return $description; }
php
protected function getScopeDescription(Scope $scope) : string { if ($scope->isInClass()) { $description = $scope->getClassReflection()->getName(); if ($scope->getFunctionName()) $description .= '::'.$scope->getFunctionName().'()'; if ($scope->isInAnonymousFunction()) $description .= '{closure}'; return $description; } if ($scope->getFunctionName()) { $description = $scope->getFunctionName().'()'; if ($scope->isInAnonymousFunction()) $description .= '{closure}'; return $description; } $description = $scope->isInAnonymousFunction() ? '{closure}' : '{main}'; $description = trim($scope->getNamespace().'\\'.$description, '\\'); return $description; }
[ "protected", "function", "getScopeDescription", "(", "Scope", "$", "scope", ")", ":", "string", "{", "if", "(", "$", "scope", "->", "isInClass", "(", ")", ")", "{", "$", "description", "=", "$", "scope", "->", "getClassReflection", "(", ")", "->", "getNa...
Return a description of the passed scope. @param Scope $scope @return string - scope description
[ "Return", "a", "description", "of", "the", "passed", "scope", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/etc/phpstan/DynamicReturnType.php#L69-L86
train
rosasurfer/ministruts
src/ministruts/FrontController.php
FrontController.me
public static function me() { if (CLI) throw new IllegalStateException('Can not use '.static::class.' in this context.'); $cache = Cache::me(); // cache hit? $controller = $cache->get(static::class); if (!$controller) { // synchronize parsing of the struts-config.xml // TODO: Don't lock on the config file because it can block // $lock = new FileLock($configFile); // concurrent reads, see Todo-File at locking. // // // $controller = $cache->get($class); // re-check after the lock is aquired if (!$controller) { $controller = self::getInstance(static::class); $configDir = self::di('config')['app.dir.config']; $configFile = str_replace('\\', '/', $configDir.'/struts-config.xml'); $dependency = FileDependency::create($configFile); if (!WINDOWS && !LOCALHOST) // distinction dev/production? TODO: non-sense $dependency->setMinValidity(1 * MINUTE); // ...and cache it with a FileDependency $cache->set(static::class, $controller, Cache::EXPIRES_NEVER, $dependency); } //$lock->release(); } return $controller; }
php
public static function me() { if (CLI) throw new IllegalStateException('Can not use '.static::class.' in this context.'); $cache = Cache::me(); // cache hit? $controller = $cache->get(static::class); if (!$controller) { // synchronize parsing of the struts-config.xml // TODO: Don't lock on the config file because it can block // $lock = new FileLock($configFile); // concurrent reads, see Todo-File at locking. // // // $controller = $cache->get($class); // re-check after the lock is aquired if (!$controller) { $controller = self::getInstance(static::class); $configDir = self::di('config')['app.dir.config']; $configFile = str_replace('\\', '/', $configDir.'/struts-config.xml'); $dependency = FileDependency::create($configFile); if (!WINDOWS && !LOCALHOST) // distinction dev/production? TODO: non-sense $dependency->setMinValidity(1 * MINUTE); // ...and cache it with a FileDependency $cache->set(static::class, $controller, Cache::EXPIRES_NEVER, $dependency); } //$lock->release(); } return $controller; }
[ "public", "static", "function", "me", "(", ")", "{", "if", "(", "CLI", ")", "throw", "new", "IllegalStateException", "(", "'Can not use '", ".", "static", "::", "class", ".", "' in this context.'", ")", ";", "$", "cache", "=", "Cache", "::", "me", "(", "...
Return the singleton instance of this class. The instance might be loaded from a cache. @return static
[ "Return", "the", "singleton", "instance", "of", "this", "class", ".", "The", "instance", "might", "be", "loaded", "from", "a", "cache", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/FrontController.php#L41-L69
train
rosasurfer/ministruts
src/ministruts/FrontController.php
FrontController.processRequest
public static function processRequest(array $options = []) { $controller = self::me(); $request = Request::me(); $response = Response::me(); // select Module $prefix = $controller->getModulePrefix($request); $module = $controller->modules[$prefix]; $request->setAttribute(MODULE_KEY, $module); // get RequestProcessor $processor = $controller->getRequestProcessor($module, $options); // process Request $processor->process($request, $response); return $response; }
php
public static function processRequest(array $options = []) { $controller = self::me(); $request = Request::me(); $response = Response::me(); // select Module $prefix = $controller->getModulePrefix($request); $module = $controller->modules[$prefix]; $request->setAttribute(MODULE_KEY, $module); // get RequestProcessor $processor = $controller->getRequestProcessor($module, $options); // process Request $processor->process($request, $response); return $response; }
[ "public", "static", "function", "processRequest", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "controller", "=", "self", "::", "me", "(", ")", ";", "$", "request", "=", "Request", "::", "me", "(", ")", ";", "$", "response", "=", "Re...
Process the current HTTP request. @param array $options [optional] - runtime options (default: none) @return Response - respone wrapper
[ "Process", "the", "current", "HTTP", "request", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/FrontController.php#L124-L141
train
deArcane/framework
src/Debugger/Blueprints/File/File.php
File.offsetGet
public function offsetGet($i){ $j = $i - 1; // becouse we counting lines form 0 not 1. if( !isIndex($this->lines,$j) ){ (new Report('Blueprints/File/CantFindLine'))->stop(); } // Add mark and sort all marks. $this->marks[] = $j; sort($this->marks); return $this->lines[$j]; }
php
public function offsetGet($i){ $j = $i - 1; // becouse we counting lines form 0 not 1. if( !isIndex($this->lines,$j) ){ (new Report('Blueprints/File/CantFindLine'))->stop(); } // Add mark and sort all marks. $this->marks[] = $j; sort($this->marks); return $this->lines[$j]; }
[ "public", "function", "offsetGet", "(", "$", "i", ")", "{", "$", "j", "=", "$", "i", "-", "1", ";", "// becouse we counting lines form 0 not 1.", "if", "(", "!", "isIndex", "(", "$", "this", "->", "lines", ",", "$", "j", ")", ")", "{", "(", "new", ...
ArrayAccess interface.
[ "ArrayAccess", "interface", "." ]
468da43678119f8c9e3f67183b5bec727c436404
https://github.com/deArcane/framework/blob/468da43678119f8c9e3f67183b5bec727c436404/src/Debugger/Blueprints/File/File.php#L143-L152
train
rosasurfer/ministruts
src/Application.php
Application.configurePhp
protected function configurePhp() { $memoryWarnLimit = php_byte_value(self::$defaultConfig->get('log.warn.memory_limit', 0)); if ($memoryWarnLimit > 0) { register_shutdown_function(function() use ($memoryWarnLimit) { $usedBytes = memory_get_peak_usage($real=true); if ($usedBytes > $memoryWarnLimit) { Logger::log('Memory consumption exceeded '.prettyBytes($memoryWarnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]); } }); } /* ini_set('arg_separator.output' , '&amp;' ); ini_set('auto_detect_line_endings', 1 ); ini_set('default_mimetype' , 'text/html' ); ini_set('default_charset' , 'UTF-8' ); ini_set('ignore_repeated_errors' , 0 ); ini_set('ignore_repeated_source' , 0 ); ini_set('ignore_user_abort' , 1 ); ini_set('display_errors' , (int)(CLI || LOCALHOST)); ini_set('display_startup_errors' , (int)(CLI || LOCALHOST)); ini_set('log_errors' , 1 ); ini_set('log_errors_max_len' , 0 ); ini_set('track_errors' , 1 ); ini_set('html_errors' , 0 ); ini_set('session.use_cookies' , 1 ); ini_set('session.use_trans_sid' , 0 ); ini_set('session.cookie_httponly' , 1 ); ini_set('session.referer_check' , '' ); ini_set('zend.detect_unicode' , 1 ); // BOM header recognition */ }
php
protected function configurePhp() { $memoryWarnLimit = php_byte_value(self::$defaultConfig->get('log.warn.memory_limit', 0)); if ($memoryWarnLimit > 0) { register_shutdown_function(function() use ($memoryWarnLimit) { $usedBytes = memory_get_peak_usage($real=true); if ($usedBytes > $memoryWarnLimit) { Logger::log('Memory consumption exceeded '.prettyBytes($memoryWarnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]); } }); } /* ini_set('arg_separator.output' , '&amp;' ); ini_set('auto_detect_line_endings', 1 ); ini_set('default_mimetype' , 'text/html' ); ini_set('default_charset' , 'UTF-8' ); ini_set('ignore_repeated_errors' , 0 ); ini_set('ignore_repeated_source' , 0 ); ini_set('ignore_user_abort' , 1 ); ini_set('display_errors' , (int)(CLI || LOCALHOST)); ini_set('display_startup_errors' , (int)(CLI || LOCALHOST)); ini_set('log_errors' , 1 ); ini_set('log_errors_max_len' , 0 ); ini_set('track_errors' , 1 ); ini_set('html_errors' , 0 ); ini_set('session.use_cookies' , 1 ); ini_set('session.use_trans_sid' , 0 ); ini_set('session.cookie_httponly' , 1 ); ini_set('session.referer_check' , '' ); ini_set('zend.detect_unicode' , 1 ); // BOM header recognition */ }
[ "protected", "function", "configurePhp", "(", ")", "{", "$", "memoryWarnLimit", "=", "php_byte_value", "(", "self", "::", "$", "defaultConfig", "->", "get", "(", "'log.warn.memory_limit'", ",", "0", ")", ")", ";", "if", "(", "$", "memoryWarnLimit", ">", "0",...
Update the PHP configuration with user defined settings.
[ "Update", "the", "PHP", "configuration", "with", "user", "defined", "settings", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L216-L246
train
rosasurfer/ministruts
src/Application.php
Application.setupErrorHandling
protected function setupErrorHandling($value) { $mode = ErrorHandler::THROW_EXCEPTIONS; // default if (is_string($value)) { $value = strtolower($value); if ($value == 'weak' ) $mode = ErrorHandler::LOG_ERRORS; else if ($value == 'ignore') $mode = 0; } $mode && ErrorHandler::setupErrorHandling($mode); }
php
protected function setupErrorHandling($value) { $mode = ErrorHandler::THROW_EXCEPTIONS; // default if (is_string($value)) { $value = strtolower($value); if ($value == 'weak' ) $mode = ErrorHandler::LOG_ERRORS; else if ($value == 'ignore') $mode = 0; } $mode && ErrorHandler::setupErrorHandling($mode); }
[ "protected", "function", "setupErrorHandling", "(", "$", "value", ")", "{", "$", "mode", "=", "ErrorHandler", "::", "THROW_EXCEPTIONS", ";", "// default", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "strtolower", "(", "$", ...
Setup the application's error handling. @param string $value - configuration value as passed to the framework loader
[ "Setup", "the", "application", "s", "error", "handling", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L331-L340
train
rosasurfer/ministruts
src/Application.php
Application.setupExceptionHandling
protected function setupExceptionHandling($value) { $enabled = true; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='0' || $value=='off' || $value=='false'); } $enabled && ErrorHandler::setupExceptionHandling(); }
php
protected function setupExceptionHandling($value) { $enabled = true; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='0' || $value=='off' || $value=='false'); } $enabled && ErrorHandler::setupExceptionHandling(); }
[ "protected", "function", "setupExceptionHandling", "(", "$", "value", ")", "{", "$", "enabled", "=", "true", ";", "// default", "if", "(", "is_bool", "(", "$", "value", ")", "||", "is_int", "(", "$", "value", ")", ")", "{", "$", "enabled", "=", "(", ...
Setup the application's exception handling. @param bool|int|string $value - configuration value as passed to the framework loader
[ "Setup", "the", "application", "s", "exception", "handling", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L348-L358
train
rosasurfer/ministruts
src/Application.php
Application.loadGlobals
protected function loadGlobals($value) { $enabled = false; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='1' || $value=='on' || $value=='true'); } if ($enabled && !function_exists('booltostr')) { // prevent multiple includes include(MINISTRUTS_ROOT.'/src/globals.php'); } }
php
protected function loadGlobals($value) { $enabled = false; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='1' || $value=='on' || $value=='true'); } if ($enabled && !function_exists('booltostr')) { // prevent multiple includes include(MINISTRUTS_ROOT.'/src/globals.php'); } }
[ "protected", "function", "loadGlobals", "(", "$", "value", ")", "{", "$", "enabled", "=", "false", ";", "// default", "if", "(", "is_bool", "(", "$", "value", ")", "||", "is_int", "(", "$", "value", ")", ")", "{", "$", "enabled", "=", "(", "bool", ...
Map common definitions in namespace "\rosasurfer" to the global namespace. @param mixed $value - configuration value as passed to the framework loader
[ "Map", "common", "definitions", "in", "namespace", "\\", "rosasurfer", "to", "the", "global", "namespace", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L366-L378
train
rosasurfer/ministruts
src/Application.php
Application.replaceComposer
protected function replaceComposer($value) { $enabled = false; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='1' || $value=='on' || $value=='true'); } if ($enabled) { // replace Composer } }
php
protected function replaceComposer($value) { $enabled = false; // default if (is_bool($value) || is_int($value)) { $enabled = (bool) $value; } elseif (is_string($value)) { $value = trim(strtolower($value)); $enabled = ($value=='1' || $value=='on' || $value=='true'); } if ($enabled) { // replace Composer } }
[ "protected", "function", "replaceComposer", "(", "$", "value", ")", "{", "$", "enabled", "=", "false", ";", "// default", "if", "(", "is_bool", "(", "$", "value", ")", "||", "is_int", "(", "$", "value", ")", ")", "{", "$", "enabled", "=", "(", "bool"...
Replace an existing Composer class loader. @param mixed $value - configuration value as passed to the framework loader
[ "Replace", "an", "existing", "Composer", "class", "loader", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/Application.php#L386-L398
train
rosasurfer/ministruts
src/ministruts/HttpSession.php
HttpSession.init
protected function init($suppressHeadersAlreadySentError = false) { /** * PHP laesst sich ohne weiteres manipulierte Session-IDs unterschieben, solange diese keine ungueltigen Zeichen * enthalten (IDs wie PHPSESSID=111 werden anstandslos akzeptiert). Wenn session_start() zurueckkehrt, gibt es mit * den vorhandenen PHP-Mitteln keine vernuenftige Moeglichkeit mehr, festzustellen, ob die Session-ID von PHP oder * (kuenstlich?) vom User generiert wurde. Daher wird in dieser Methode jede neue Session mit einer zusaetzliche * Markierung versehen. Fehlt diese Markierung nach Rueckkehr von session_start(), wurde die ID nicht von PHP * generiert. Aus Sicherheitsgruenden wird eine solche Session verworfen und eine neue ID erzeugt. */ $request = $this->request; // Session-Cookie auf Application beschraenken, um mehrere Projekte je Domain zu ermoeglichen $params = session_get_cookie_params(); session_set_cookie_params($params['lifetime'], $request->getApplicationBaseUri(), $params['domain' ], $params['secure' ], $params['httponly']); // Session starten bzw. fortsetzen try { session_start(); // TODO: Handle the case when a session was already started elsewhere? } catch (PHPError $error) { if (preg_match('/The session id contains illegal characters/', $error->getMessage())) { session_regenerate_id(); // neue ID generieren } else if (preg_match('/- headers already sent (by )?\(output started at /', $error->getMessage())) { if (!$suppressHeadersAlreadySentError) throw $error; } else { throw $error; } } // Inhalt der Session pruefen // TODO: Session verwerfen, wenn der User zwischen Cookie- und URL-Uebertragung wechselt if (sizeof($_SESSION) == 0) { // 0 bedeutet, die Session ist (fuer diese Methode) neu $sessionName = session_name(); $sessionId = session_id(); // pruefen, woher die ID kommt ... // TODO: Verwendung von $_COOKIE und $_REQUEST ist unsicher if (isset($_COOKIE [$sessionName]) && $_COOKIE [$sessionName] == $sessionId) $fromUser = true; // ID kommt vom Cookie elseif (isset($_REQUEST[$sessionName]) && $_REQUEST[$sessionName] == $sessionId) $fromUser = true; // ID kommt aus GET/POST else $fromUser = false; $this->reset($fromUser); // if $fromUser=TRUE: generate new session id } else { // vorhandene Session fortgesetzt $this->new = false; } }
php
protected function init($suppressHeadersAlreadySentError = false) { /** * PHP laesst sich ohne weiteres manipulierte Session-IDs unterschieben, solange diese keine ungueltigen Zeichen * enthalten (IDs wie PHPSESSID=111 werden anstandslos akzeptiert). Wenn session_start() zurueckkehrt, gibt es mit * den vorhandenen PHP-Mitteln keine vernuenftige Moeglichkeit mehr, festzustellen, ob die Session-ID von PHP oder * (kuenstlich?) vom User generiert wurde. Daher wird in dieser Methode jede neue Session mit einer zusaetzliche * Markierung versehen. Fehlt diese Markierung nach Rueckkehr von session_start(), wurde die ID nicht von PHP * generiert. Aus Sicherheitsgruenden wird eine solche Session verworfen und eine neue ID erzeugt. */ $request = $this->request; // Session-Cookie auf Application beschraenken, um mehrere Projekte je Domain zu ermoeglichen $params = session_get_cookie_params(); session_set_cookie_params($params['lifetime'], $request->getApplicationBaseUri(), $params['domain' ], $params['secure' ], $params['httponly']); // Session starten bzw. fortsetzen try { session_start(); // TODO: Handle the case when a session was already started elsewhere? } catch (PHPError $error) { if (preg_match('/The session id contains illegal characters/', $error->getMessage())) { session_regenerate_id(); // neue ID generieren } else if (preg_match('/- headers already sent (by )?\(output started at /', $error->getMessage())) { if (!$suppressHeadersAlreadySentError) throw $error; } else { throw $error; } } // Inhalt der Session pruefen // TODO: Session verwerfen, wenn der User zwischen Cookie- und URL-Uebertragung wechselt if (sizeof($_SESSION) == 0) { // 0 bedeutet, die Session ist (fuer diese Methode) neu $sessionName = session_name(); $sessionId = session_id(); // pruefen, woher die ID kommt ... // TODO: Verwendung von $_COOKIE und $_REQUEST ist unsicher if (isset($_COOKIE [$sessionName]) && $_COOKIE [$sessionName] == $sessionId) $fromUser = true; // ID kommt vom Cookie elseif (isset($_REQUEST[$sessionName]) && $_REQUEST[$sessionName] == $sessionId) $fromUser = true; // ID kommt aus GET/POST else $fromUser = false; $this->reset($fromUser); // if $fromUser=TRUE: generate new session id } else { // vorhandene Session fortgesetzt $this->new = false; } }
[ "protected", "function", "init", "(", "$", "suppressHeadersAlreadySentError", "=", "false", ")", "{", "/**\n * PHP laesst sich ohne weiteres manipulierte Session-IDs unterschieben, solange diese keine ungueltigen Zeichen\n * enthalten (IDs wie PHPSESSID=111 werden anstandslos akz...
Start and initialize the session. @param bool $suppressHeadersAlreadySentError [optional] - whether to suppress "headers already sent" errors (default: no)
[ "Start", "and", "initialize", "the", "session", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/HttpSession.php#L60-L113
train
rosasurfer/ministruts
src/ministruts/HttpSession.php
HttpSession.reset
public function reset($regenerateId) { if (!is_bool($regenerateId)) throw new IllegalTypeException('Illegal type of parameter $regenerateId: '.gettype($regenerateId)); if ($regenerateId) { // assign new id, delete old file session_regenerate_id(true); } // empty the session $this->removeAttribute(\array_keys($_SESSION)); // initialize the session $request = $this->request; // TODO: $request->getHeader() einbauen $_SESSION['__SESSION_CREATED__' ] = microtime(true); $_SESSION['__SESSION_IP__' ] = $request->getRemoteAddress(); // TODO: forwarded remote IP einbauen $_SESSION['__SESSION_USERAGENT__'] = $request->getHeaderValue('User-Agent'); $this->new = true; }
php
public function reset($regenerateId) { if (!is_bool($regenerateId)) throw new IllegalTypeException('Illegal type of parameter $regenerateId: '.gettype($regenerateId)); if ($regenerateId) { // assign new id, delete old file session_regenerate_id(true); } // empty the session $this->removeAttribute(\array_keys($_SESSION)); // initialize the session $request = $this->request; // TODO: $request->getHeader() einbauen $_SESSION['__SESSION_CREATED__' ] = microtime(true); $_SESSION['__SESSION_IP__' ] = $request->getRemoteAddress(); // TODO: forwarded remote IP einbauen $_SESSION['__SESSION_USERAGENT__'] = $request->getHeaderValue('User-Agent'); $this->new = true; }
[ "public", "function", "reset", "(", "$", "regenerateId", ")", "{", "if", "(", "!", "is_bool", "(", "$", "regenerateId", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $regenerateId: '", ".", "gettype", "(", "$", "regenerateId", ...
Reset this session to a clean and new state. @param bool $regenerateId - whether to generate a new session id and to delete an old session file
[ "Reset", "this", "session", "to", "a", "clean", "and", "new", "state", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/HttpSession.php#L121-L139
train
rosasurfer/ministruts
src/ministruts/HttpSession.php
HttpSession.setAttribute
public function setAttribute($key, $value) { if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key)); if ($value !== null) { $_SESSION[$key] = $value; } else { $this->removeAttribute($key); } }
php
public function setAttribute($key, $value) { if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key)); if ($value !== null) { $_SESSION[$key] = $value; } else { $this->removeAttribute($key); } }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $key: '", ".", "gettype", "(", "$", "key", ...
Speichert in der Session unter dem angegebenen Schluessel einen Wert. Ein unter dem selben Schluessel schon vorhandener Wert wird ersetzt. Ist der uebergebene Wert NULL, hat dies den selben Effekt wie der Aufruf von HttpSession::removeAttribute($key) @param string $key - Schluessel, unter dem der Wert gespeichert wird @param mixed $value - der zu speichernde Wert
[ "Speichert", "in", "der", "Session", "unter", "dem", "angegebenen", "Schluessel", "einen", "Wert", ".", "Ein", "unter", "dem", "selben", "Schluessel", "schon", "vorhandener", "Wert", "wird", "ersetzt", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/HttpSession.php#L198-L207
train
locomotivemtl/charcoal-core
src/Charcoal/Source/Expression.php
Expression.setCondition
public function setCondition($condition) { if ($condition === null) { $this->condition = $condition; return $this; } if (!is_string($condition)) { throw new InvalidArgumentException( 'Custom expression must be a string.' ); } $condition = trim($condition); if ($condition === '') { $condition = null; } $this->condition = $condition; return $this; }
php
public function setCondition($condition) { if ($condition === null) { $this->condition = $condition; return $this; } if (!is_string($condition)) { throw new InvalidArgumentException( 'Custom expression must be a string.' ); } $condition = trim($condition); if ($condition === '') { $condition = null; } $this->condition = $condition; return $this; }
[ "public", "function", "setCondition", "(", "$", "condition", ")", "{", "if", "(", "$", "condition", "===", "null", ")", "{", "$", "this", "->", "condition", "=", "$", "condition", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "("...
Set the custom query expression. @param string|null $condition The custom query expression. @throws InvalidArgumentException If the parameter is not a valid string expression. @return self
[ "Set", "the", "custom", "query", "expression", "." ]
db3a7af547ccf96efe2d9be028b252bc8646f5d5
https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Expression.php#L78-L98
train
dereuromark/cakephp-feedback
src/Store/FilesystemStore.php
FilesystemStore.saveFile
protected function saveFile(array $object, $location) { //Serialize and save the object to a store in the Cake's tmp dir. if (!file_exists($location)) { if (!mkdir($location, 0770, true)) { //Throw error, directory is requird throw new NotFoundException('Could not create directory to save feedbacks in. Please provide write rights to webserver user on directory: ' . $location); } } if (file_put_contents($location . $object['filename'], serialize($object))) { //Add filename to data return true; } return false; }
php
protected function saveFile(array $object, $location) { //Serialize and save the object to a store in the Cake's tmp dir. if (!file_exists($location)) { if (!mkdir($location, 0770, true)) { //Throw error, directory is requird throw new NotFoundException('Could not create directory to save feedbacks in. Please provide write rights to webserver user on directory: ' . $location); } } if (file_put_contents($location . $object['filename'], serialize($object))) { //Add filename to data return true; } return false; }
[ "protected", "function", "saveFile", "(", "array", "$", "object", ",", "$", "location", ")", "{", "//Serialize and save the object to a store in the Cake's tmp dir.", "if", "(", "!", "file_exists", "(", "$", "location", ")", ")", "{", "if", "(", "!", "mkdir", "(...
Auxiliary function that saves the file @param array $object @param string $location @return bool
[ "Auxiliary", "function", "that", "saves", "the", "file" ]
0bd774fda38b3cdd05db8c07a06a526d3ba81879
https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Store/FilesystemStore.php#L56-L70
train
rosasurfer/ministruts
src/net/http/CurlHttpClient.php
CurlHttpClient.send
public function send(HttpRequest $request) { if (!is_resource($this->hCurl)) $this->hCurl = curl_init(); $response = new CurlHttpResponse(); $options = $this->prepareCurlOptions($request, $response); // CURLOPT_FOLLOWLOCATION funktioniert nur bei deaktiviertem "open_basedir"-Setting if (!ini_get('open_basedir')) { if ($this->isFollowRedirects()) { $options[CURLOPT_FOLLOWLOCATION] = true; } elseif (isset($options[CURLOPT_FOLLOWLOCATION]) && $options[CURLOPT_FOLLOWLOCATION]) { $this->setFollowRedirects(true); } if ($this->isFollowRedirects()) { !isset($options[CURLOPT_MAXREDIRS]) && $options[CURLOPT_MAXREDIRS]=$this->maxRedirects; } } if ($request->getMethod() == 'POST') { $options[CURLOPT_POST ] = true; $options[CURLOPT_URL ] = substr($request->getUrl(), 0, strpos($request->getUrl(), '?')); $options[CURLOPT_POSTFIELDS] = strstr($request->getUrl(), '?'); } curl_setopt_array($this->hCurl, $options); // Request ausfuehren if (curl_exec($this->hCurl) === false) throw new IOException('cURL error '.self::getError($this->hCurl).','.NL.'URL: '.$request->getUrl()); $status = curl_getinfo($this->hCurl, CURLINFO_HTTP_CODE); $response->setStatus($status); // ggf. manuellen Redirect ausfuehren (falls "open_basedir" aktiviert ist) if (($status==301 || $status==302) && $this->isFollowRedirects() && ini_get('open_basedir')) { if ($this->manualRedirects >= $this->maxRedirects) throw new IOException('CURL error: maxRedirects limit exceeded - '.$this->maxRedirects.', URL: '.$request->getUrl()); $this->manualRedirects++; /** @var string $location */ $location = $response->getHeader('Location'); // TODO: relative Redirects abfangen Logger::log('Performing manual redirect to: '.$location, L_INFO); // TODO: verschachtelte IOExceptions abfangen $request = new HttpRequest($location); $response = $this->send($request); } return $response; }
php
public function send(HttpRequest $request) { if (!is_resource($this->hCurl)) $this->hCurl = curl_init(); $response = new CurlHttpResponse(); $options = $this->prepareCurlOptions($request, $response); // CURLOPT_FOLLOWLOCATION funktioniert nur bei deaktiviertem "open_basedir"-Setting if (!ini_get('open_basedir')) { if ($this->isFollowRedirects()) { $options[CURLOPT_FOLLOWLOCATION] = true; } elseif (isset($options[CURLOPT_FOLLOWLOCATION]) && $options[CURLOPT_FOLLOWLOCATION]) { $this->setFollowRedirects(true); } if ($this->isFollowRedirects()) { !isset($options[CURLOPT_MAXREDIRS]) && $options[CURLOPT_MAXREDIRS]=$this->maxRedirects; } } if ($request->getMethod() == 'POST') { $options[CURLOPT_POST ] = true; $options[CURLOPT_URL ] = substr($request->getUrl(), 0, strpos($request->getUrl(), '?')); $options[CURLOPT_POSTFIELDS] = strstr($request->getUrl(), '?'); } curl_setopt_array($this->hCurl, $options); // Request ausfuehren if (curl_exec($this->hCurl) === false) throw new IOException('cURL error '.self::getError($this->hCurl).','.NL.'URL: '.$request->getUrl()); $status = curl_getinfo($this->hCurl, CURLINFO_HTTP_CODE); $response->setStatus($status); // ggf. manuellen Redirect ausfuehren (falls "open_basedir" aktiviert ist) if (($status==301 || $status==302) && $this->isFollowRedirects() && ini_get('open_basedir')) { if ($this->manualRedirects >= $this->maxRedirects) throw new IOException('CURL error: maxRedirects limit exceeded - '.$this->maxRedirects.', URL: '.$request->getUrl()); $this->manualRedirects++; /** @var string $location */ $location = $response->getHeader('Location'); // TODO: relative Redirects abfangen Logger::log('Performing manual redirect to: '.$location, L_INFO); // TODO: verschachtelte IOExceptions abfangen $request = new HttpRequest($location); $response = $this->send($request); } return $response; }
[ "public", "function", "send", "(", "HttpRequest", "$", "request", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "hCurl", ")", ")", "$", "this", "->", "hCurl", "=", "curl_init", "(", ")", ";", "$", "response", "=", "new", "CurlHttpR...
Fuehrt den uebergebenen Request aus und gibt die empfangene Antwort zurueck. @param HttpRequest $request @return HttpResponse @throws IOException wenn ein Fehler auftritt
[ "Fuehrt", "den", "uebergebenen", "Request", "aus", "und", "gibt", "die", "empfangene", "Antwort", "zurueck", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/CurlHttpClient.php#L181-L226
train
rosasurfer/ministruts
src/net/http/CurlHttpClient.php
CurlHttpClient.prepareCurlOptions
protected function prepareCurlOptions(HttpRequest $request, CurlHttpResponse $response) { $options = [CURLOPT_URL => $request->getUrl()] + $this->options; $options += [CURLOPT_TIMEOUT => $this->timeout ]; $options += [CURLOPT_USERAGENT => $this->userAgent ]; $options += [CURLOPT_ENCODING => '' ]; // empty string activates all supported encodings if (!isset($options[CURLOPT_WRITEHEADER])) $options += [CURLOPT_HEADERFUNCTION => [$response, 'writeHeader']]; if (!isset($options[CURLOPT_FILE])) // overrides CURLOPT_RETURNTRANSFER $options += [CURLOPT_WRITEFUNCTION => [$response, 'writeContent']]; foreach ($request->getHeaders() as $key => $value) { // add all specified request headers $options[CURLOPT_HTTPHEADER][] = $key.': '.$value; } return $options; }
php
protected function prepareCurlOptions(HttpRequest $request, CurlHttpResponse $response) { $options = [CURLOPT_URL => $request->getUrl()] + $this->options; $options += [CURLOPT_TIMEOUT => $this->timeout ]; $options += [CURLOPT_USERAGENT => $this->userAgent ]; $options += [CURLOPT_ENCODING => '' ]; // empty string activates all supported encodings if (!isset($options[CURLOPT_WRITEHEADER])) $options += [CURLOPT_HEADERFUNCTION => [$response, 'writeHeader']]; if (!isset($options[CURLOPT_FILE])) // overrides CURLOPT_RETURNTRANSFER $options += [CURLOPT_WRITEFUNCTION => [$response, 'writeContent']]; foreach ($request->getHeaders() as $key => $value) { // add all specified request headers $options[CURLOPT_HTTPHEADER][] = $key.': '.$value; } return $options; }
[ "protected", "function", "prepareCurlOptions", "(", "HttpRequest", "$", "request", ",", "CurlHttpResponse", "$", "response", ")", "{", "$", "options", "=", "[", "CURLOPT_URL", "=>", "$", "request", "->", "getUrl", "(", ")", "]", "+", "$", "this", "->", "op...
Create a cUrl options array for the current request. @param HttpRequest $request @param CurlHttpResponse $response @return array - resulting options
[ "Create", "a", "cUrl", "options", "array", "for", "the", "current", "request", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/CurlHttpClient.php#L237-L253
train
rosasurfer/ministruts
src/net/http/CurlHttpClient.php
CurlHttpClient.getError
protected static function getError($hCurl) { $errorNo = curl_errno($hCurl); $errorStr = curl_error($hCurl); if (isset(self::$errors[$errorNo])) { $errorNo = self::$errors[$errorNo]; } else { Logger::log('Unknown CURL error code: '.$errorNo, L_WARN); } return $errorNo.' ('.$errorStr.')'; }
php
protected static function getError($hCurl) { $errorNo = curl_errno($hCurl); $errorStr = curl_error($hCurl); if (isset(self::$errors[$errorNo])) { $errorNo = self::$errors[$errorNo]; } else { Logger::log('Unknown CURL error code: '.$errorNo, L_WARN); } return $errorNo.' ('.$errorStr.')'; }
[ "protected", "static", "function", "getError", "(", "$", "hCurl", ")", "{", "$", "errorNo", "=", "curl_errno", "(", "$", "hCurl", ")", ";", "$", "errorStr", "=", "curl_error", "(", "$", "hCurl", ")", ";", "if", "(", "isset", "(", "self", "::", "$", ...
Gibt eine Beschreibung des letzten CURL-Fehlers zurueck. @param resource $hCurl - CURL-Handle @return string
[ "Gibt", "eine", "Beschreibung", "des", "letzten", "CURL", "-", "Fehlers", "zurueck", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/CurlHttpClient.php#L263-L275
train
timble/kodekit
code/template/helper/behavior.php
TemplateHelperBehavior.validator
public function validator($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'debug' => \Kodekit::getInstance()->isDebug(), 'selector' => '.k-js-form-controller', 'options_callback' => null, 'options' => array( 'ignoreTitle' => true, 'onsubmit' => false // We run the validation ourselves ) )); $html = ''; if(!static::isLoaded('validator')) { $html .= $this->kodekit(); $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'jquery.validate.js" />'; static::setLoaded('validator'); } $options = (string) $config->options; $signature = md5('validator-'.$config->selector.$config->options_callback.$options); if (!static::isLoaded($signature)) { if ($config->options_callback) { $options = $config->options_callback.'('.$options.')'; } $html .= "<script> kQuery(function($){ $('$config->selector').on('k:validate', function(event){ if(!$(this).valid() || $(this).validate().pendingRequest !== 0) { event.preventDefault(); } }).validate($options); }); </script>"; static::setLoaded($signature); } return $html; }
php
public function validator($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'debug' => \Kodekit::getInstance()->isDebug(), 'selector' => '.k-js-form-controller', 'options_callback' => null, 'options' => array( 'ignoreTitle' => true, 'onsubmit' => false // We run the validation ourselves ) )); $html = ''; if(!static::isLoaded('validator')) { $html .= $this->kodekit(); $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'jquery.validate.js" />'; static::setLoaded('validator'); } $options = (string) $config->options; $signature = md5('validator-'.$config->selector.$config->options_callback.$options); if (!static::isLoaded($signature)) { if ($config->options_callback) { $options = $config->options_callback.'('.$options.')'; } $html .= "<script> kQuery(function($){ $('$config->selector').on('k:validate', function(event){ if(!$(this).valid() || $(this).validate().pendingRequest !== 0) { event.preventDefault(); } }).validate($options); }); </script>"; static::setLoaded($signature); } return $html; }
[ "public", "function", "validator", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "\\", "Kodekit", ...
Loads the Forms.Validator class and connects it to Kodekit.Controller.Form @param array|ObjectConfig $config @return string The html output
[ "Loads", "the", "Forms", ".", "Validator", "class", "and", "connects", "it", "to", "Kodekit", ".", "Controller", ".", "Form" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/behavior.php#L398-L444
train
timble/kodekit
code/template/helper/behavior.php
TemplateHelperBehavior.tree
public function tree($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'debug' => false, 'element' => '', 'selected' => '', 'list' => array() ))->append(array( 'options_callback' => null, 'options' => array( 'selected' => $config->selected ) )); $html = ''; /** * Loading the assets, if not already loaded */ if (!static::isLoaded('tree')) { $html .= $this->kodekit(); $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'kodekit.tree.js" />'; static::setLoaded('tree'); } /** * Parse and validate list data, if any. And load the inline js that initiates the tree on specified html element */ $signature = md5('tree-'.$config->element); if($config->element && !static::isLoaded($signature)) { /** * If there's a list set, but no 'data' in the js options, parse it */ if(isset($config->list) && !isset($config->options->data)) { $data = array(); foreach($config->list as $item) { $parts = explode('/', $item->path); array_pop($parts); // remove current id $data[] = array( 'label' => $item->title, 'id' => (int)$item->id, 'level' => (int)$item->level, 'path' => $item->path, 'parent' => (int)array_pop($parts) ); } $config->options->append(array('data' => $data)); } /** * Validate that the data is the right format */ elseif(isset($config->options->data, $config->options->data[0])) { $data = $config->options->data[0]; $required = array('label', 'id', 'level', 'path', 'parent'); foreach($required as $key) { if(!isset($data[$key])) { throw new \InvalidArgumentException('Data must contain required param: '.$key); } } } $options = (string) $config->options; if ($config->options_callback) { $options = $config->options_callback.'('.$options.')'; } $html .= '<script> kQuery(function($){ new Kodekit.Tree('.json_encode($config->element).', '.$options.'); });</script>'; static::setLoaded($signature); } return $html; }
php
public function tree($config = array()) { $config = new ObjectConfigJson($config); $config->append(array( 'debug' => false, 'element' => '', 'selected' => '', 'list' => array() ))->append(array( 'options_callback' => null, 'options' => array( 'selected' => $config->selected ) )); $html = ''; /** * Loading the assets, if not already loaded */ if (!static::isLoaded('tree')) { $html .= $this->kodekit(); $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'kodekit.tree.js" />'; static::setLoaded('tree'); } /** * Parse and validate list data, if any. And load the inline js that initiates the tree on specified html element */ $signature = md5('tree-'.$config->element); if($config->element && !static::isLoaded($signature)) { /** * If there's a list set, but no 'data' in the js options, parse it */ if(isset($config->list) && !isset($config->options->data)) { $data = array(); foreach($config->list as $item) { $parts = explode('/', $item->path); array_pop($parts); // remove current id $data[] = array( 'label' => $item->title, 'id' => (int)$item->id, 'level' => (int)$item->level, 'path' => $item->path, 'parent' => (int)array_pop($parts) ); } $config->options->append(array('data' => $data)); } /** * Validate that the data is the right format */ elseif(isset($config->options->data, $config->options->data[0])) { $data = $config->options->data[0]; $required = array('label', 'id', 'level', 'path', 'parent'); foreach($required as $key) { if(!isset($data[$key])) { throw new \InvalidArgumentException('Data must contain required param: '.$key); } } } $options = (string) $config->options; if ($config->options_callback) { $options = $config->options_callback.'('.$options.')'; } $html .= '<script> kQuery(function($){ new Kodekit.Tree('.json_encode($config->element).', '.$options.'); });</script>'; static::setLoaded($signature); } return $html; }
[ "public", "function", "tree", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "ObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "false", ",", "'elemen...
Loads the Kodekit customized jQtree behavior and renders a sidebar-nav list useful in split views @see http://mbraak.github.io/jqTree/ @note If no 'element' option is passed, then only assets will be loaded. @param array|ObjectConfig $config @throws \InvalidArgumentException @return string The html output
[ "Loads", "the", "Kodekit", "customized", "jQtree", "behavior", "and", "renders", "a", "sidebar", "-", "nav", "list", "useful", "in", "split", "views" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/behavior.php#L631-L715
train
rosasurfer/ministruts
src/console/io/Output.php
Output.out
public function out($message) { $message = printPretty($message, $return=true); $hStream = CLI ? \STDOUT : fopen('php://stdout', 'a'); fwrite($hStream, $message); if (!CLI) fclose($hStream); }
php
public function out($message) { $message = printPretty($message, $return=true); $hStream = CLI ? \STDOUT : fopen('php://stdout', 'a'); fwrite($hStream, $message); if (!CLI) fclose($hStream); }
[ "public", "function", "out", "(", "$", "message", ")", "{", "$", "message", "=", "printPretty", "(", "$", "message", ",", "$", "return", "=", "true", ")", ";", "$", "hStream", "=", "CLI", "?", "\\", "STDOUT", ":", "fopen", "(", "'php://stdout'", ",",...
Write a message to STDOUT. @param mixed $message
[ "Write", "a", "message", "to", "STDOUT", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/console/io/Output.php#L22-L28
train
rosasurfer/ministruts
src/console/io/Output.php
Output.error
public function error($message) { $message = printPretty($message, $return=true); $hStream = CLI ? \STDERR : fopen('php://stderr', 'a'); fwrite($hStream, $message); if (!CLI) fclose($hStream); }
php
public function error($message) { $message = printPretty($message, $return=true); $hStream = CLI ? \STDERR : fopen('php://stderr', 'a'); fwrite($hStream, $message); if (!CLI) fclose($hStream); }
[ "public", "function", "error", "(", "$", "message", ")", "{", "$", "message", "=", "printPretty", "(", "$", "message", ",", "$", "return", "=", "true", ")", ";", "$", "hStream", "=", "CLI", "?", "\\", "STDERR", ":", "fopen", "(", "'php://stderr'", ",...
Write a message to STDERR. @param mixed $message
[ "Write", "a", "message", "to", "STDERR", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/console/io/Output.php#L36-L42
train
rosasurfer/ministruts
src/net/http/HeaderParser.php
HeaderParser.parseLines
public function parseLines($data) { $lines = explode("\n", $data); foreach ($lines as $line) $this->parseLine($line); return $this; }
php
public function parseLines($data) { $lines = explode("\n", $data); foreach ($lines as $line) $this->parseLine($line); return $this; }
[ "public", "function", "parseLines", "(", "$", "data", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "data", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "$", "this", "->", "parseLine", "(", "$", "line", ")", ...
Parst einen uebergebenen Headerblock. @param string $data - rohe Headerdaten @return $this
[ "Parst", "einen", "uebergebenen", "Headerblock", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HeaderParser.php#L27-L34
train
rosasurfer/ministruts
src/net/http/HeaderParser.php
HeaderParser.parseLine
public function parseLine($line) { $line = trim($line, "\r\n"); if (preg_match('/^([\w-]+):\s+(.+)/', $line, $matches)) { $name = strtolower($matches[1]); $value = $matches[2]; $this->currentHeader = $name; if (isset($this->headers[$name])) { if (!is_array($this->headers[$name])) { $this->headers[$name] = [$this->headers[$name]]; } $this->headers[$name][] = $value; } else { $this->headers[$name] = $value; } } elseif (preg_match('/^\s+(.+)$/', $line, $matches) && $this->currentHeader !== null) { if (is_array($this->headers[$this->currentHeader])) { $lastKey = sizeof($this->headers[$this->currentHeader]) - 1; $this->headers[$this->currentHeader][$lastKey] .= $matches[1]; } else { $this->headers[$this->currentHeader] .= $matches[1]; } } return $this; }
php
public function parseLine($line) { $line = trim($line, "\r\n"); if (preg_match('/^([\w-]+):\s+(.+)/', $line, $matches)) { $name = strtolower($matches[1]); $value = $matches[2]; $this->currentHeader = $name; if (isset($this->headers[$name])) { if (!is_array($this->headers[$name])) { $this->headers[$name] = [$this->headers[$name]]; } $this->headers[$name][] = $value; } else { $this->headers[$name] = $value; } } elseif (preg_match('/^\s+(.+)$/', $line, $matches) && $this->currentHeader !== null) { if (is_array($this->headers[$this->currentHeader])) { $lastKey = sizeof($this->headers[$this->currentHeader]) - 1; $this->headers[$this->currentHeader][$lastKey] .= $matches[1]; } else { $this->headers[$this->currentHeader] .= $matches[1]; } } return $this; }
[ "public", "function", "parseLine", "(", "$", "line", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ",", "\"\\r\\n\"", ")", ";", "if", "(", "preg_match", "(", "'/^([\\w-]+):\\s+(.+)/'", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "$"...
Parst eine einzelne Headerzeile. @param string $line - Headerzeile @return $this
[ "Parst", "eine", "einzelne", "Headerzeile", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HeaderParser.php#L44-L73
train
timble/kodekit
code/dispatcher/authenticator/cookie.php
DispatcherAuthenticatorCookie.authenticateRequest
public function authenticateRequest(DispatcherContext $context) { $session = $context->getUser()->getSession(); $request = $context->getRequest(); if(!$session->isActive()) { if ($request->getCookies()->has($this->getConfig()->cookie_name)) { //Logging the user by auto-start the session $this->loginUser(); //Perform CSRF authentication parent::authenticateRequest($context); return true; } } }
php
public function authenticateRequest(DispatcherContext $context) { $session = $context->getUser()->getSession(); $request = $context->getRequest(); if(!$session->isActive()) { if ($request->getCookies()->has($this->getConfig()->cookie_name)) { //Logging the user by auto-start the session $this->loginUser(); //Perform CSRF authentication parent::authenticateRequest($context); return true; } } }
[ "public", "function", "authenticateRequest", "(", "DispatcherContext", "$", "context", ")", "{", "$", "session", "=", "$", "context", "->", "getUser", "(", ")", "->", "getSession", "(", ")", ";", "$", "request", "=", "$", "context", "->", "getRequest", "("...
Authenticate using the cookie session id If a session cookie is found and the session session is not active it will be auto-started. @param DispatcherContext $context A dispatcher context object @return boolean Returns TRUE if the authentication explicitly succeeded.
[ "Authenticate", "using", "the", "cookie", "session", "id" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/authenticator/cookie.php#L70-L88
train
rinvex/cortex-tenants
src/Http/Controllers/Adminarea/TenantsController.php
TenantsController.import
public function import(Tenant $tenant, ImportRecordsDataTable $importRecordsDataTable) { return $importRecordsDataTable->with([ 'resource' => $tenant, 'tabs' => 'adminarea.tenants.tabs', 'url' => route('adminarea.tenants.stash'), 'id' => "adminarea-tenants-{$tenant->getRouteKey()}-import-table", ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
php
public function import(Tenant $tenant, ImportRecordsDataTable $importRecordsDataTable) { return $importRecordsDataTable->with([ 'resource' => $tenant, 'tabs' => 'adminarea.tenants.tabs', 'url' => route('adminarea.tenants.stash'), 'id' => "adminarea-tenants-{$tenant->getRouteKey()}-import-table", ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
[ "public", "function", "import", "(", "Tenant", "$", "tenant", ",", "ImportRecordsDataTable", "$", "importRecordsDataTable", ")", "{", "return", "$", "importRecordsDataTable", "->", "with", "(", "[", "'resource'", "=>", "$", "tenant", ",", "'tabs'", "=>", "'admin...
Import tenants. @param \Cortex\Tenants\Models\Tenant $tenant @param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable @return \Illuminate\View\View
[ "Import", "tenants", "." ]
b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a
https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsController.php#L65-L73
train
rinvex/cortex-tenants
src/Http/Controllers/Adminarea/TenantsController.php
TenantsController.destroy
public function destroy(Tenant $tenant) { $tenant->delete(); return intend([ 'url' => route('adminarea.tenants.index'), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/tenants::common.tenant'), 'identifier' => $tenant->name])], ]); }
php
public function destroy(Tenant $tenant) { $tenant->delete(); return intend([ 'url' => route('adminarea.tenants.index'), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/tenants::common.tenant'), 'identifier' => $tenant->name])], ]); }
[ "public", "function", "destroy", "(", "Tenant", "$", "tenant", ")", "{", "$", "tenant", "->", "delete", "(", ")", ";", "return", "intend", "(", "[", "'url'", "=>", "route", "(", "'adminarea.tenants.index'", ")", ",", "'with'", "=>", "[", "'warning'", "=>...
Destroy given tenant. @param \Cortex\Tenants\Models\Tenant $tenant @throws \Exception @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "Destroy", "given", "tenant", "." ]
b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a
https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsController.php#L231-L239
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.fixTrace
public static function fixTrace(array $trace, $file='unknown', $line=0) { // check if the stacktrace is already fixed if ($trace && isset($trace[0]['fixed'])) return $trace; // Fix an incomplete frame[0][line] if parameters are provided and $file matches (e.g. with SimpleXMLElement). if ($file!='unknown' && $line) { if (isset($trace[0]['file']) && $trace[0]['file']==$file) { if (isset($trace[0]['line']) && $trace[0]['line']===0) { $trace[0]['line'] = $line; } } } // Add a frame for the main script to the bottom (end of array). $trace[] = ['function' => '{main}']; // Move FILE and LINE fields down (to the end) by one position. for ($i=sizeof($trace); $i--;) { if (isset($trace[$i-1]['file'])) $trace[$i]['file'] = $trace[$i-1]['file']; else unset($trace[$i]['file']); if (isset($trace[$i-1]['line'])) $trace[$i]['line'] = $trace[$i-1]['line']; else unset($trace[$i]['line']); $trace[$i]['fixed'] = true; } // Add location details from parameters to frame[0] only if they differ from the old values (now in frame[1]) if (!isset($trace[1]['file']) || !isset($trace[1]['line']) || $trace[1]['file']!=$file || $trace[1]['line']!=$line) { $trace[0]['file'] = $file; // test with: $trace[0]['line'] = $line; // \SQLite3::enableExceptions(true|false); } // \SQLite3::exec($invalid_sql); else { unset($trace[0]['file'], $trace[0]['line']); // otherwise delete them } // Remove the last frame (the one we added for the main script) if it now points to an unknown location (PHP core). $size = sizeof($trace); if (!isset($trace[$size-1]['file'])) { \array_pop($trace); } return $trace; /** * TODO: fix wrong stack frames originating from calls to virtual static functions * * phalcon\mvc\Model::__callStatic() [php-phalcon] * vokuro\models\Users::findFirstByEmail() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php * vokuro\auth\Auth->check() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php */ }
php
public static function fixTrace(array $trace, $file='unknown', $line=0) { // check if the stacktrace is already fixed if ($trace && isset($trace[0]['fixed'])) return $trace; // Fix an incomplete frame[0][line] if parameters are provided and $file matches (e.g. with SimpleXMLElement). if ($file!='unknown' && $line) { if (isset($trace[0]['file']) && $trace[0]['file']==$file) { if (isset($trace[0]['line']) && $trace[0]['line']===0) { $trace[0]['line'] = $line; } } } // Add a frame for the main script to the bottom (end of array). $trace[] = ['function' => '{main}']; // Move FILE and LINE fields down (to the end) by one position. for ($i=sizeof($trace); $i--;) { if (isset($trace[$i-1]['file'])) $trace[$i]['file'] = $trace[$i-1]['file']; else unset($trace[$i]['file']); if (isset($trace[$i-1]['line'])) $trace[$i]['line'] = $trace[$i-1]['line']; else unset($trace[$i]['line']); $trace[$i]['fixed'] = true; } // Add location details from parameters to frame[0] only if they differ from the old values (now in frame[1]) if (!isset($trace[1]['file']) || !isset($trace[1]['line']) || $trace[1]['file']!=$file || $trace[1]['line']!=$line) { $trace[0]['file'] = $file; // test with: $trace[0]['line'] = $line; // \SQLite3::enableExceptions(true|false); } // \SQLite3::exec($invalid_sql); else { unset($trace[0]['file'], $trace[0]['line']); // otherwise delete them } // Remove the last frame (the one we added for the main script) if it now points to an unknown location (PHP core). $size = sizeof($trace); if (!isset($trace[$size-1]['file'])) { \array_pop($trace); } return $trace; /** * TODO: fix wrong stack frames originating from calls to virtual static functions * * phalcon\mvc\Model::__callStatic() [php-phalcon] * vokuro\models\Users::findFirstByEmail() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php * vokuro\auth\Auth->check() # line 27, file: F:\Projekte\phalcon\sample-apps\vokuro\app\library\Auth\Auth.php */ }
[ "public", "static", "function", "fixTrace", "(", "array", "$", "trace", ",", "$", "file", "=", "'unknown'", ",", "$", "line", "=", "0", ")", "{", "// check if the stacktrace is already fixed", "if", "(", "$", "trace", "&&", "isset", "(", "$", "trace", "[",...
Take a regular PHP stacktrace and create a fixed and more readable Java-like one. @param array $trace - regular PHP stacktrace @param string $file [optional] - name of the file where the stacktrace was generated @param int $line [optional] - line of the file where the stacktrace was generated @return array - new fixed stacktrace @example original stacktrace: <pre> require_once() # line 5, file: /var/www/phalcon/vokuro/vendor/autoload.php include_once() # line 21, file: /var/www/phalcon/vokuro/app/config/loader.php include() # line 26, file: /var/www/phalcon/vokuro/public/index.php {main} </pre> new stacktrace: <pre> require_once() [php] include_once() # line 5, file: /var/www/phalcon/vokuro/vendor/autoload.php include() # line 21, file: /var/www/phalcon/vokuro/app/config/loader.php {main} # line 26, file: /var/www/phalcon/vokuro/public/index.php </pre>
[ "Take", "a", "regular", "PHP", "stacktrace", "and", "create", "a", "fixed", "and", "more", "readable", "Java", "-", "like", "one", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L51-L102
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.formatTrace
public static function formatTrace(array $trace, $indent = '') { $appRoot = self::di('config')['app.dir.root']; $result = ''; $size = sizeof($trace); $callLen = $lineLen = 0; for ($i=0; $i < $size; $i++) { // align FILE and LINE $frame = &$trace[$i]; $call = self::getFQFunctionName($frame, $nsLowerCase=true); if ($call!='{main}' && !strEndsWith($call, '{closure}')) $call.='()'; $callLen = max($callLen, strlen($call)); $frame['call'] = $call; $frame['line'] = isset($frame['line']) ? ' # line '.$frame['line'].',' : ''; $lineLen = max($lineLen, strlen($frame['line'])); if (isset($frame['file'])) $frame['file'] = ' file: '.(!$appRoot ? $frame['file'] : strRightFrom($frame['file'], $appRoot.DIRECTORY_SEPARATOR, 1, false, $frame['file'])); elseif (strStartsWith($call, 'phalcon\\')) $frame['file'] = ' [php-phalcon]'; else $frame['file'] = ' [php]'; } if ($appRoot) { $trace[] = ['call'=>'', 'line'=>'', 'file'=>' file base: '.$appRoot]; $i++; } for ($i=0; $i < $size; $i++) { $result .= $indent.str_pad($trace[$i]['call'], $callLen).' '.str_pad($trace[$i]['line'], $lineLen).$trace[$i]['file'].NL; } return $result; }
php
public static function formatTrace(array $trace, $indent = '') { $appRoot = self::di('config')['app.dir.root']; $result = ''; $size = sizeof($trace); $callLen = $lineLen = 0; for ($i=0; $i < $size; $i++) { // align FILE and LINE $frame = &$trace[$i]; $call = self::getFQFunctionName($frame, $nsLowerCase=true); if ($call!='{main}' && !strEndsWith($call, '{closure}')) $call.='()'; $callLen = max($callLen, strlen($call)); $frame['call'] = $call; $frame['line'] = isset($frame['line']) ? ' # line '.$frame['line'].',' : ''; $lineLen = max($lineLen, strlen($frame['line'])); if (isset($frame['file'])) $frame['file'] = ' file: '.(!$appRoot ? $frame['file'] : strRightFrom($frame['file'], $appRoot.DIRECTORY_SEPARATOR, 1, false, $frame['file'])); elseif (strStartsWith($call, 'phalcon\\')) $frame['file'] = ' [php-phalcon]'; else $frame['file'] = ' [php]'; } if ($appRoot) { $trace[] = ['call'=>'', 'line'=>'', 'file'=>' file base: '.$appRoot]; $i++; } for ($i=0; $i < $size; $i++) { $result .= $indent.str_pad($trace[$i]['call'], $callLen).' '.str_pad($trace[$i]['line'], $lineLen).$trace[$i]['file'].NL; } return $result; }
[ "public", "static", "function", "formatTrace", "(", "array", "$", "trace", ",", "$", "indent", "=", "''", ")", "{", "$", "appRoot", "=", "self", "::", "di", "(", "'config'", ")", "[", "'app.dir.root'", "]", ";", "$", "result", "=", "''", ";", "$", ...
Return a formatted and human-readable version of a stacktrace. @param array $trace - stacktrace @param string $indent [optional] - indent the formatted lines by this value (default: empty string) @return string
[ "Return", "a", "formatted", "and", "human", "-", "readable", "version", "of", "a", "stacktrace", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L113-L147
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.getFQFunctionName
public static function getFQFunctionName(array $frame, $nsLowerCase = false) { $class = $function = ''; if (isset($frame['function'])) { $function = $frame['function']; if (isset($frame['class'])) { $class = $frame['class']; if ($nsLowerCase && is_int($pos=strrpos($class, '\\'))) $class = strtolower(substr($class, 0, $pos)).substr($class, $pos); $class = $class.$frame['type']; } elseif ($nsLowerCase && is_int($pos=strrpos($function, '\\'))) { $function = strtolower(substr($function, 0, $pos)).substr($function, $pos); } } return $class.$function; }
php
public static function getFQFunctionName(array $frame, $nsLowerCase = false) { $class = $function = ''; if (isset($frame['function'])) { $function = $frame['function']; if (isset($frame['class'])) { $class = $frame['class']; if ($nsLowerCase && is_int($pos=strrpos($class, '\\'))) $class = strtolower(substr($class, 0, $pos)).substr($class, $pos); $class = $class.$frame['type']; } elseif ($nsLowerCase && is_int($pos=strrpos($function, '\\'))) { $function = strtolower(substr($function, 0, $pos)).substr($function, $pos); } } return $class.$function; }
[ "public", "static", "function", "getFQFunctionName", "(", "array", "$", "frame", ",", "$", "nsLowerCase", "=", "false", ")", "{", "$", "class", "=", "$", "function", "=", "''", ";", "if", "(", "isset", "(", "$", "frame", "[", "'function'", "]", ")", ...
Return the fully qualified function or method name of a stacktrace's frame. @param array $frame - frame @param bool $nsLowerCase [optional] - whether the namespace part of the name to return in lower case (default: no) @return string - fully qualified name (without trailing parentheses)
[ "Return", "the", "fully", "qualified", "function", "or", "method", "name", "of", "a", "stacktrace", "s", "frame", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L158-L175
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.composeBetterMessage
public static function composeBetterMessage(\Exception $exception, $indent = '') { if ($exception instanceof PHPError) { $result = $exception->getSimpleType(); } else { $class = get_class($exception); $namespace = strtolower(strLeftTo($class, '\\', -1, true, '')); $basename = simpleClassName($class); $result = $indent.$namespace.$basename; if ($exception instanceof \ErrorException) // A PHP error exception not created $result .= '('.self::errorLevelToStr($exception->getSeverity()).')'; // by the framework. } $message = $exception->getMessage(); if (strlen($indent)) { $lines = explode(NL, normalizeEOL($message)); // indent multiline messages $eom = ''; if (strEndsWith($message, NL)) { \array_pop($lines); $eom = NL; } $message = join(NL.$indent, $lines).$eom; } $result .= (strlen($message) ? ': ':'').$message; return $result; }
php
public static function composeBetterMessage(\Exception $exception, $indent = '') { if ($exception instanceof PHPError) { $result = $exception->getSimpleType(); } else { $class = get_class($exception); $namespace = strtolower(strLeftTo($class, '\\', -1, true, '')); $basename = simpleClassName($class); $result = $indent.$namespace.$basename; if ($exception instanceof \ErrorException) // A PHP error exception not created $result .= '('.self::errorLevelToStr($exception->getSeverity()).')'; // by the framework. } $message = $exception->getMessage(); if (strlen($indent)) { $lines = explode(NL, normalizeEOL($message)); // indent multiline messages $eom = ''; if (strEndsWith($message, NL)) { \array_pop($lines); $eom = NL; } $message = join(NL.$indent, $lines).$eom; } $result .= (strlen($message) ? ': ':'').$message; return $result; }
[ "public", "static", "function", "composeBetterMessage", "(", "\\", "Exception", "$", "exception", ",", "$", "indent", "=", "''", ")", "{", "if", "(", "$", "exception", "instanceof", "PHPError", ")", "{", "$", "result", "=", "$", "exception", "->", "getSimp...
Return a more readable version of an exception's message. @param \Exception $exception - any exception (not only RosasurferExceptions) @param string $indent [optional] - indent lines by this value (default: empty string) @return string - message
[ "Return", "a", "more", "readable", "version", "of", "an", "exception", "s", "message", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L186-L213
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.getBetterTraceAsString
public static function getBetterTraceAsString(\Exception $exception, $indent = '') { if ($exception instanceof IRosasurferException) $trace = $exception->getBetterTrace(); else $trace = self::fixTrace($exception->getTrace(), $exception->getFile(), $exception->getLine()); $result = self::formatTrace($trace, $indent); if ($cause=$exception->getPrevious()) { // recursively add stacktraces of nested exceptions $message = trim(self::composeBetterMessage($cause, $indent)); $result .= NL.$indent.'caused by'.NL.$indent.$message.NL.NL; $result .= self::{__FUNCTION__}($cause, $indent); // recursion } return $result; }
php
public static function getBetterTraceAsString(\Exception $exception, $indent = '') { if ($exception instanceof IRosasurferException) $trace = $exception->getBetterTrace(); else $trace = self::fixTrace($exception->getTrace(), $exception->getFile(), $exception->getLine()); $result = self::formatTrace($trace, $indent); if ($cause=$exception->getPrevious()) { // recursively add stacktraces of nested exceptions $message = trim(self::composeBetterMessage($cause, $indent)); $result .= NL.$indent.'caused by'.NL.$indent.$message.NL.NL; $result .= self::{__FUNCTION__}($cause, $indent); // recursion } return $result; }
[ "public", "static", "function", "getBetterTraceAsString", "(", "\\", "Exception", "$", "exception", ",", "$", "indent", "=", "''", ")", "{", "if", "(", "$", "exception", "instanceof", "IRosasurferException", ")", "$", "trace", "=", "$", "exception", "->", "g...
Return a more readable version of an exception's stacktrace. The representation also contains information about nested exceptions. @param \Exception $exception - any exception (not only RosasurferExceptions) @param string $indent [optional] - indent the resulting lines by this value (default: empty string) @return string - readable stacktrace
[ "Return", "a", "more", "readable", "version", "of", "an", "exception", "s", "stacktrace", ".", "The", "representation", "also", "contains", "information", "about", "nested", "exceptions", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L225-L237
train
rosasurfer/ministruts
src/debug/DebugHelper.php
DebugHelper.errorLevelToStr
public static function errorLevelToStr($level) { if (!is_int($level)) throw new IllegalTypeException('Illegal type of parameter $level: '.gettype($level)); $levels = [ E_ERROR => 'E_ERROR', // 1 E_WARNING => 'E_WARNING', // 2 E_PARSE => 'E_PARSE', // 4 E_NOTICE => 'E_NOTICE', // 8 E_CORE_ERROR => 'E_CORE_ERROR', // 16 E_CORE_WARNING => 'E_CORE_WARNING', // 32 E_COMPILE_ERROR => 'E_COMPILE_ERROR', // 64 E_COMPILE_WARNING => 'E_COMPILE_WARNING', // 128 E_USER_ERROR => 'E_USER_ERROR', // 256 E_USER_WARNING => 'E_USER_WARNING', // 512 E_USER_NOTICE => 'E_USER_NOTICE', // 1024 E_STRICT => 'E_STRICT', // 2048 E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', // 4096 E_DEPRECATED => 'E_DEPRECATED', // 8192 E_USER_DEPRECATED => 'E_USER_DEPRECATED', // 16384 ]; if (!$level) $levels = ['0']; // 0 else if (($level & E_ALL) == E_ALL) $levels = ['E_ALL']; // 32767 else if (($level & (E_ALL & ~E_DEPRECATED)) == (E_ALL & ~E_DEPRECATED)) $levels = ['E_ALL & ~E_DEPRECATED']; // 24575 else { foreach ($levels as $key => $value) { if ($level & $key) continue; unset($levels[$key]); } } return join('|', $levels); }
php
public static function errorLevelToStr($level) { if (!is_int($level)) throw new IllegalTypeException('Illegal type of parameter $level: '.gettype($level)); $levels = [ E_ERROR => 'E_ERROR', // 1 E_WARNING => 'E_WARNING', // 2 E_PARSE => 'E_PARSE', // 4 E_NOTICE => 'E_NOTICE', // 8 E_CORE_ERROR => 'E_CORE_ERROR', // 16 E_CORE_WARNING => 'E_CORE_WARNING', // 32 E_COMPILE_ERROR => 'E_COMPILE_ERROR', // 64 E_COMPILE_WARNING => 'E_COMPILE_WARNING', // 128 E_USER_ERROR => 'E_USER_ERROR', // 256 E_USER_WARNING => 'E_USER_WARNING', // 512 E_USER_NOTICE => 'E_USER_NOTICE', // 1024 E_STRICT => 'E_STRICT', // 2048 E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', // 4096 E_DEPRECATED => 'E_DEPRECATED', // 8192 E_USER_DEPRECATED => 'E_USER_DEPRECATED', // 16384 ]; if (!$level) $levels = ['0']; // 0 else if (($level & E_ALL) == E_ALL) $levels = ['E_ALL']; // 32767 else if (($level & (E_ALL & ~E_DEPRECATED)) == (E_ALL & ~E_DEPRECATED)) $levels = ['E_ALL & ~E_DEPRECATED']; // 24575 else { foreach ($levels as $key => $value) { if ($level & $key) continue; unset($levels[$key]); } } return join('|', $levels); }
[ "public", "static", "function", "errorLevelToStr", "(", "$", "level", ")", "{", "if", "(", "!", "is_int", "(", "$", "level", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Illegal type of parameter $level: '", ".", "gettype", "(", "$", "level", ")", ...
Return a human-readable form of the specified error reporting level. @param int $level - error reporting level @return string
[ "Return", "a", "human", "-", "readable", "form", "of", "the", "specified", "error", "reporting", "level", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/debug/DebugHelper.php#L247-L278
train
timble/kodekit
code/object/bootstrapper/bootstrapper.php
ObjectBootstrapper.registerFile
public function registerFile($path) { $hash = md5($path); if(!isset($this->_files[$hash])) { $this->_files[$hash] = $path; } return $this; }
php
public function registerFile($path) { $hash = md5($path); if(!isset($this->_files[$hash])) { $this->_files[$hash] = $path; } return $this; }
[ "public", "function", "registerFile", "(", "$", "path", ")", "{", "$", "hash", "=", "md5", "(", "$", "path", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_files", "[", "$", "hash", "]", ")", ")", "{", "$", "this", "->", "_files",...
Register a configuration file to be bootstrapped @param string $path The absolute path to the file @return ObjectBootstrapper
[ "Register", "a", "configuration", "file", "to", "be", "bootstrapped" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/bootstrapper/bootstrapper.php#L415-L424
train
timble/kodekit
code/object/bootstrapper/bootstrapper.php
ObjectBootstrapper.getComponents
public function getComponents($domain = null) { $components = $result = array_keys($this->_components); if($domain) { foreach($components as $key => $component) { if(strpos($component, 'com://'.$domain) === false) { unset($components[$key]); } } } return $components; }
php
public function getComponents($domain = null) { $components = $result = array_keys($this->_components); if($domain) { foreach($components as $key => $component) { if(strpos($component, 'com://'.$domain) === false) { unset($components[$key]); } } } return $components; }
[ "public", "function", "getComponents", "(", "$", "domain", "=", "null", ")", "{", "$", "components", "=", "$", "result", "=", "array_keys", "(", "$", "this", "->", "_components", ")", ";", "if", "(", "$", "domain", ")", "{", "foreach", "(", "$", "com...
Get the registered components @param string $domain The component domain. Domain is optional and can be NULL @return array
[ "Get", "the", "registered", "components" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/bootstrapper/bootstrapper.php#L432-L447
train
timble/kodekit
code/object/bootstrapper/bootstrapper.php
ObjectBootstrapper.getComponentManifest
public function getComponentManifest($name, $domain = null) { $result = false; $paths = $this->getComponentPaths($name, $domain); if(!empty($paths)) { $path = $paths[0]; if(!isset($this->_manifests[$path]) || is_array($this->_manifests[$path])) { if($paths = $this->getComponentPaths($name, $domain)) { $info = $this->getObject('object.config.factory')->fromFile($path . '/component.json'); $this->_manifests[$path] = $info; } else $this->_manifests[$path] = false; } $result = $this->_manifests[$path]; } return $result; }
php
public function getComponentManifest($name, $domain = null) { $result = false; $paths = $this->getComponentPaths($name, $domain); if(!empty($paths)) { $path = $paths[0]; if(!isset($this->_manifests[$path]) || is_array($this->_manifests[$path])) { if($paths = $this->getComponentPaths($name, $domain)) { $info = $this->getObject('object.config.factory')->fromFile($path . '/component.json'); $this->_manifests[$path] = $info; } else $this->_manifests[$path] = false; } $result = $this->_manifests[$path]; } return $result; }
[ "public", "function", "getComponentManifest", "(", "$", "name", ",", "$", "domain", "=", "null", ")", "{", "$", "result", "=", "false", ";", "$", "paths", "=", "$", "this", "->", "getComponentPaths", "(", "$", "name", ",", "$", "domain", ")", ";", "i...
Get manifest for a registered component @link https://en.wikipedia.org/wiki/Manifest_file @param string $name The component name @param string $domain The component domain. Domain is optional and can be NULL @return ObjectConfigJson|false Returns the component manifest or FALSE if the component couldn't be found.
[ "Get", "manifest", "for", "a", "registered", "component" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/bootstrapper/bootstrapper.php#L495-L518
train
timble/kodekit
code/event/subscriber/factory.php
EventSubscriberFactory.registerSubscriber
public function registerSubscriber($identifier, array $config = array()) { $result = false; //Create the complete identifier if a partial identifier was passed if (is_string($identifier) && strpos($identifier, '.') === false) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('event', 'subscriber'); $identifier['name'] = $identifier; } $identifier = $this->getIdentifier($identifier); $class = $this->getObject('manager')->getClass($identifier); if(!$class || !array_key_exists('Kodekit\Library\EventSubscriberInterface', class_implements($class))) { throw new \UnexpectedValueException( 'Event Subscriber: '.$identifier.' does not implement Kodekit\Library\EventSubscriberInterface' ); } if (!isset($this->__subscribers[(string)$identifier])) { $listeners = call_user_func(array($class, 'getEventListeners'));/*$class::getEventListeners();*/ if (!empty($listeners)) { $identifier->getConfig()->merge($config); foreach($listeners as $listener) { $this->__listeners[$listener][] = $identifier; } } $this->__subscribers[(string)$identifier] = true; } return $result; }
php
public function registerSubscriber($identifier, array $config = array()) { $result = false; //Create the complete identifier if a partial identifier was passed if (is_string($identifier) && strpos($identifier, '.') === false) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('event', 'subscriber'); $identifier['name'] = $identifier; } $identifier = $this->getIdentifier($identifier); $class = $this->getObject('manager')->getClass($identifier); if(!$class || !array_key_exists('Kodekit\Library\EventSubscriberInterface', class_implements($class))) { throw new \UnexpectedValueException( 'Event Subscriber: '.$identifier.' does not implement Kodekit\Library\EventSubscriberInterface' ); } if (!isset($this->__subscribers[(string)$identifier])) { $listeners = call_user_func(array($class, 'getEventListeners'));/*$class::getEventListeners();*/ if (!empty($listeners)) { $identifier->getConfig()->merge($config); foreach($listeners as $listener) { $this->__listeners[$listener][] = $identifier; } } $this->__subscribers[(string)$identifier] = true; } return $result; }
[ "public", "function", "registerSubscriber", "(", "$", "identifier", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "result", "=", "false", ";", "//Create the complete identifier if a partial identifier was passed", "if", "(", "is_string", "(", ...
Register an subscriber @param string $identifier A subscriber identifier string @param array $config An optional associative array of configuration options @throws \UnexpectedValueException @return bool Returns TRUE on success, FALSE on failure.
[ "Register", "an", "subscriber" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/event/subscriber/factory.php#L88-L127
train
timble/kodekit
code/dispatcher/behavior/limitable.php
DispatcherBehaviorLimitable._beforeGet
protected function _beforeGet(DispatcherContext $context) { $controller = $this->getController(); if($controller instanceof ControllerModellable) { $controller->getModel()->getState()->setProperty('limit', 'default', $this->getConfig()->default); $limit = $this->getRequest()->query->get('limit', 'int'); // Set to default if there is no limit. This is done for both unique and non-unique states // so that limit can be transparently used on unique state requests rendering lists. if(empty($limit)) { $limit = $this->getConfig()->default; } if($this->getConfig()->max && $limit > $this->getConfig()->max) { $limit = $this->getConfig()->max; } $this->getRequest()->query->limit = $limit; $controller->getModel()->getState()->limit = $limit; } }
php
protected function _beforeGet(DispatcherContext $context) { $controller = $this->getController(); if($controller instanceof ControllerModellable) { $controller->getModel()->getState()->setProperty('limit', 'default', $this->getConfig()->default); $limit = $this->getRequest()->query->get('limit', 'int'); // Set to default if there is no limit. This is done for both unique and non-unique states // so that limit can be transparently used on unique state requests rendering lists. if(empty($limit)) { $limit = $this->getConfig()->default; } if($this->getConfig()->max && $limit > $this->getConfig()->max) { $limit = $this->getConfig()->max; } $this->getRequest()->query->limit = $limit; $controller->getModel()->getState()->limit = $limit; } }
[ "protected", "function", "_beforeGet", "(", "DispatcherContext", "$", "context", ")", "{", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "if", "(", "$", "controller", "instanceof", "ControllerModellable", ")", "{", "$", "controller...
Sets a maximum and a default limit for GET requests @param DispatcherContext $context The active command context @return void
[ "Sets", "a", "maximum", "and", "a", "default", "limit", "for", "GET", "requests" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/limitable.php#L45-L68
train
timble/kodekit
code/template/helper/abstract.php
TemplateHelperAbstract.setTemplate
public function setTemplate($template) { if(!$template instanceof TemplateInterface) { if(empty($template) || (is_string($template) && strpos($template, '.') === false) ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('template'); $identifier['name'] = $template; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($template); $template = $identifier; } $this->__template = $template; return $this->__template; }
php
public function setTemplate($template) { if(!$template instanceof TemplateInterface) { if(empty($template) || (is_string($template) && strpos($template, '.') === false) ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('template'); $identifier['name'] = $template; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($template); $template = $identifier; } $this->__template = $template; return $this->__template; }
[ "public", "function", "setTemplate", "(", "$", "template", ")", "{", "if", "(", "!", "$", "template", "instanceof", "TemplateInterface", ")", "{", "if", "(", "empty", "(", "$", "template", ")", "||", "(", "is_string", "(", "$", "template", ")", "&&", "...
Sets the template object @param TemplateInterface $template @return $this
[ "Sets", "the", "template", "object" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/helper/abstract.php#L85-L105
train
timble/kodekit
code/controller/behavior/editable.php
ControllerBehaviorEditable.getReferrer
public function getReferrer(ControllerContextModel $context) { if($context->request->cookies->has($this->_cookie_name)) { $referrer = $context->request->cookies->get($this->_cookie_name, 'url'); $referrer = $this->getObject('lib:http.url', array('url' => $referrer)); } else $referrer = $this->findReferrer($context); return $referrer; }
php
public function getReferrer(ControllerContextModel $context) { if($context->request->cookies->has($this->_cookie_name)) { $referrer = $context->request->cookies->get($this->_cookie_name, 'url'); $referrer = $this->getObject('lib:http.url', array('url' => $referrer)); } else $referrer = $this->findReferrer($context); return $referrer; }
[ "public", "function", "getReferrer", "(", "ControllerContextModel", "$", "context", ")", "{", "if", "(", "$", "context", "->", "request", "->", "cookies", "->", "has", "(", "$", "this", "->", "_cookie_name", ")", ")", "{", "$", "referrer", "=", "$", "con...
Get the referrer @param ControllerContextModel $context A controller context object @return HttpUrl A HttpUrl object
[ "Get", "the", "referrer" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/editable.php#L98-L108
train
timble/kodekit
code/controller/behavior/editable.php
ControllerBehaviorEditable.isLockable
public function isLockable() { $controller = $this->getMixer(); if($controller instanceof ControllerModellable) { if($this->getModel()->getState()->isUnique()) { $entity = $this->getModel()->fetch(); if($entity->isLockable()) { return true; } } } return false; }
php
public function isLockable() { $controller = $this->getMixer(); if($controller instanceof ControllerModellable) { if($this->getModel()->getState()->isUnique()) { $entity = $this->getModel()->fetch(); if($entity->isLockable()) { return true; } } } return false; }
[ "public", "function", "isLockable", "(", ")", "{", "$", "controller", "=", "$", "this", "->", "getMixer", "(", ")", ";", "if", "(", "$", "controller", "instanceof", "ControllerModellable", ")", "{", "if", "(", "$", "this", "->", "getModel", "(", ")", "...
Check if the resource is lockable @return bool Returns TRUE if the resource is can be locked, FALSE otherwise.
[ "Check", "if", "the", "resource", "is", "lockable" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/editable.php#L224-L241
train
timble/kodekit
code/controller/behavior/editable.php
ControllerBehaviorEditable._afterRead
protected function _afterRead(ControllerContextModel $context) { $entity = $context->result; //Add the notice if the resource is locked if($this->canEdit() && $entity->isLockable() && $entity->isLocked()) { //Prevent a re-render of the message if($context->request->getUrl() != $context->request->getReferrer()) { if($entity->isLockable() && $entity->isLocked()) { $user = $entity->getLocker(); $date = $this->getObject('date', array('date' => $entity->locked_on)); $message = $this->getObject('translator')->translate( 'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize()) ); $context->response->addMessage($message, 'notice'); } } } }
php
protected function _afterRead(ControllerContextModel $context) { $entity = $context->result; //Add the notice if the resource is locked if($this->canEdit() && $entity->isLockable() && $entity->isLocked()) { //Prevent a re-render of the message if($context->request->getUrl() != $context->request->getReferrer()) { if($entity->isLockable() && $entity->isLocked()) { $user = $entity->getLocker(); $date = $this->getObject('date', array('date' => $entity->locked_on)); $message = $this->getObject('translator')->translate( 'Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize()) ); $context->response->addMessage($message, 'notice'); } } } }
[ "protected", "function", "_afterRead", "(", "ControllerContextModel", "$", "context", ")", "{", "$", "entity", "=", "$", "context", "->", "result", ";", "//Add the notice if the resource is locked", "if", "(", "$", "this", "->", "canEdit", "(", ")", "&&", "$", ...
Add a lock flash message if the resource is locked @param ControllerContextModel $context A command context object @return void
[ "Add", "a", "lock", "flash", "message", "if", "the", "resource", "is", "locked" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/controller/behavior/editable.php#L426-L448
train
timble/kodekit
code/object/set.php
ObjectSet.filter
public function filter(/*Callable*/ $filter) { $result = clone $this; foreach ($this as $object) { if (call_user_func($filter, $object) === false) { $result->remove($object); } } return $result; }
php
public function filter(/*Callable*/ $filter) { $result = clone $this; foreach ($this as $object) { if (call_user_func($filter, $object) === false) { $result->remove($object); } } return $result; }
[ "public", "function", "filter", "(", "/*Callable*/", "$", "filter", ")", "{", "$", "result", "=", "clone", "$", "this", ";", "foreach", "(", "$", "this", "as", "$", "object", ")", "{", "if", "(", "call_user_func", "(", "$", "filter", ",", "$", "objec...
Filter the set using a callback If the callback returns FALSE the object will not be included in the resulting object set. @param Callable $filter A callback that will handle the filtering @return ObjectSet Returns an object subset
[ "Filter", "the", "set", "using", "a", "callback" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/set.php#L105-L116
train
symbiote/silverstripe-seed
code/dataobjects/CustomMenuBlockItem.php
CustomMenuBlockItem.stageChildren
public function stageChildren($showAll = false) { $baseClass = $this->class; $staged = $baseClass::get() ->filter('ParentID', (int)$this->owner->ID) ->exclude('ID', (int)$this->owner->ID); $this->owner->extend("augmentStageChildren", $staged, $showAll); return $staged; }
php
public function stageChildren($showAll = false) { $baseClass = $this->class; $staged = $baseClass::get() ->filter('ParentID', (int)$this->owner->ID) ->exclude('ID', (int)$this->owner->ID); $this->owner->extend("augmentStageChildren", $staged, $showAll); return $staged; }
[ "public", "function", "stageChildren", "(", "$", "showAll", "=", "false", ")", "{", "$", "baseClass", "=", "$", "this", "->", "class", ";", "$", "staged", "=", "$", "baseClass", "::", "get", "(", ")", "->", "filter", "(", "'ParentID'", ",", "(", "int...
Overridden to use this->class instead of base class
[ "Overridden", "to", "use", "this", "-", ">", "class", "instead", "of", "base", "class" ]
bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d
https://github.com/symbiote/silverstripe-seed/blob/bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d/code/dataobjects/CustomMenuBlockItem.php#L88-L96
train
timble/kodekit
code/database/iterator/recursive.php
DatabaseIteratorRecursive._createInnerIterator
protected static function _createInnerIterator(DatabaseRowsetInterface $rowset) { $iterator = new \RecursiveArrayIterator($rowset->getIterator()); $iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY); return $iterator; }
php
protected static function _createInnerIterator(DatabaseRowsetInterface $rowset) { $iterator = new \RecursiveArrayIterator($rowset->getIterator()); $iterator = new \RecursiveCachingIterator($iterator, \CachingIterator::TOSTRING_USE_KEY); return $iterator; }
[ "protected", "static", "function", "_createInnerIterator", "(", "DatabaseRowsetInterface", "$", "rowset", ")", "{", "$", "iterator", "=", "new", "\\", "RecursiveArrayIterator", "(", "$", "rowset", "->", "getIterator", "(", ")", ")", ";", "$", "iterator", "=", ...
Create a recursive iterator from a rowset @param DatabaseRowsetInterface $rowset @return \RecursiveIterator
[ "Create", "a", "recursive", "iterator", "from", "a", "rowset" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/iterator/recursive.php#L92-L98
train
timble/kodekit
code/dispatcher/authenticator/jwt.php
DispatcherAuthenticatorJwt.createToken
public function createToken(UserInterface $user = null) { if(!$user) { $user = $this->getObject('user'); } $token = $this->getObject('lib:http.token') ->setSubject($user->getId()) ->sign($this->getSecret()); return $token; }
php
public function createToken(UserInterface $user = null) { if(!$user) { $user = $this->getObject('user'); } $token = $this->getObject('lib:http.token') ->setSubject($user->getId()) ->sign($this->getSecret()); return $token; }
[ "public", "function", "createToken", "(", "UserInterface", "$", "user", "=", "null", ")", "{", "if", "(", "!", "$", "user", ")", "{", "$", "user", "=", "$", "this", "->", "getObject", "(", "'user'", ")", ";", "}", "$", "token", "=", "$", "this", ...
Create a new signed JWT authorisation token If not user passed, the context user object will be used. @param UserInterface $user The user object. Default NULL @return string The signed authorisation token
[ "Create", "a", "new", "signed", "JWT", "authorisation", "token" ]
4c376f8873f8d10c55e3d290616ff622605cd246
https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/authenticator/jwt.php#L182-L193
train
rosasurfer/ministruts
src/monitor/FileDependency.php
FileDependency.create
public static function create($fileNames) { if (!is_array($fileNames)) { if (!is_string($fileNames)) throw new IllegalTypeException('Illegal type of parameter $fileNames: '.gettype($fileNames)); if (!strlen($fileNames)) throw new InvalidArgumentException('Invalid argument $fileNames: '.$fileNames); $fileNames = [$fileNames]; } if (!$fileNames) throw new InvalidArgumentException('Invalid argument $fileNames: '.$fileNames); $dependency = null; foreach ($fileNames as $name) { if (!$dependency) $dependency = new static($name); else $dependency = $dependency->andDependency(new static($name)); } return $dependency; }
php
public static function create($fileNames) { if (!is_array($fileNames)) { if (!is_string($fileNames)) throw new IllegalTypeException('Illegal type of parameter $fileNames: '.gettype($fileNames)); if (!strlen($fileNames)) throw new InvalidArgumentException('Invalid argument $fileNames: '.$fileNames); $fileNames = [$fileNames]; } if (!$fileNames) throw new InvalidArgumentException('Invalid argument $fileNames: '.$fileNames); $dependency = null; foreach ($fileNames as $name) { if (!$dependency) $dependency = new static($name); else $dependency = $dependency->andDependency(new static($name)); } return $dependency; }
[ "public", "static", "function", "create", "(", "$", "fileNames", ")", "{", "if", "(", "!", "is_array", "(", "$", "fileNames", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "fileNames", ")", ")", "throw", "new", "IllegalTypeException", "(", "'Il...
Erzeugt eine neue FileDependency, die eine oder mehrere Dateien ueberwacht. @param mixed $fileNames - einzelner Dateiname (String) oder Array von Dateinamen @return Dependency
[ "Erzeugt", "eine", "neue", "FileDependency", "die", "eine", "oder", "mehrere", "Dateien", "ueberwacht", "." ]
9d27f93dd53d2d626c75c92cfde9d004bab34d30
https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/monitor/FileDependency.php#L76-L92
train