repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
scherersoftware/cake-model-history
src/Model/Transform/DateTransform.php
DateTransform.save
public function save(string $fieldname, array $config, EntityInterface $entity) { $dateValue = $entity->$fieldname; if (!is_object($dateValue)) { $dateValue = new Time($dateValue); } $dateValue->setTimezone('Europe/Berlin'); return $dateValue; }
php
public function save(string $fieldname, array $config, EntityInterface $entity) { $dateValue = $entity->$fieldname; if (!is_object($dateValue)) { $dateValue = new Time($dateValue); } $dateValue->setTimezone('Europe/Berlin'); return $dateValue; }
[ "public", "function", "save", "(", "string", "$", "fieldname", ",", "array", "$", "config", ",", "EntityInterface", "$", "entity", ")", "{", "$", "dateValue", "=", "$", "entity", "->", "$", "fieldname", ";", "if", "(", "!", "is_object", "(", "$", "date...
Amend the data before saving. @param string $fieldname Field name @param array $config field config @param \Cake\Datasource\EntityInterface $entity entity @return mixed
[ "Amend", "the", "data", "before", "saving", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/DateTransform.php#L19-L28
scherersoftware/cake-model-history
src/Model/Transform/DateTransform.php
DateTransform.display
public function display(string $fieldname, $value, string $model = null) { if (!is_object($value)) { $value = new Time($value); } $value->setTimezone('Europe/Berlin'); return $value->nice(); }
php
public function display(string $fieldname, $value, string $model = null) { if (!is_object($value)) { $value = new Time($value); } $value->setTimezone('Europe/Berlin'); return $value->nice(); }
[ "public", "function", "display", "(", "string", "$", "fieldname", ",", "$", "value", ",", "string", "$", "model", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "new", "Time", "(", "$", "v...
Amend the data before displaying. @param string $fieldname Field name @param mixed $value Value to be amended @param string $model Optional model to be used @return mixed
[ "Amend", "the", "data", "before", "displaying", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/DateTransform.php#L38-L46
venca-x/social-login
src/FacebookLogin.php
FacebookLogin.getLoginUrl
public function getLoginUrl() { $loginUrl = $this->helper->getLoginUrl($this->callBackUrl, $this->scope); return $loginUrl; }
php
public function getLoginUrl() { $loginUrl = $this->helper->getLoginUrl($this->callBackUrl, $this->scope); return $loginUrl; }
[ "public", "function", "getLoginUrl", "(", ")", "{", "$", "loginUrl", "=", "$", "this", "->", "helper", "->", "getLoginUrl", "(", "$", "this", "->", "callBackUrl", ",", "$", "this", "->", "scope", ")", ";", "return", "$", "loginUrl", ";", "}" ]
Get URL for login @param string $callbackURL @return string URL login
[ "Get", "URL", "for", "login" ]
train
https://github.com/venca-x/social-login/blob/ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab/src/FacebookLogin.php#L197-L201
venca-x/social-login
src/FacebookLogin.php
FacebookLogin.getMe
public function getMe($fields) { $accessTokenObject = $this->helper->getAccessToken($this->callBackUrl); if ($accessTokenObject == null) { throw new Exception('User not allowed permissions'); } if ($fields == '' || !is_array($fields) || count($fields) == 0) { //array is empty $fields = [self::ID];//set ID field } try { if (isset($_SESSION['facebook_access_token'])) { $this->fb->setDefaultAccessToken($_SESSION['facebook_access_token']); } else { $_SESSION['facebook_access_token'] = (string) $accessTokenObject; } $client = $this->fb->getOAuth2Client(); $accessToken = $client->getLongLivedAccessToken($accessTokenObject->getValue()); $response = $this->fb->get('/me?fields=' . implode(',', $fields), $accessToken); $this->setSocialLoginCookie(self::SOCIAL_NAME); return $response->getDecodedBody(); } catch (Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error throw new Exception($e->getMessage()); } catch (Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues throw new Exception($e->getMessage()); } }
php
public function getMe($fields) { $accessTokenObject = $this->helper->getAccessToken($this->callBackUrl); if ($accessTokenObject == null) { throw new Exception('User not allowed permissions'); } if ($fields == '' || !is_array($fields) || count($fields) == 0) { //array is empty $fields = [self::ID];//set ID field } try { if (isset($_SESSION['facebook_access_token'])) { $this->fb->setDefaultAccessToken($_SESSION['facebook_access_token']); } else { $_SESSION['facebook_access_token'] = (string) $accessTokenObject; } $client = $this->fb->getOAuth2Client(); $accessToken = $client->getLongLivedAccessToken($accessTokenObject->getValue()); $response = $this->fb->get('/me?fields=' . implode(',', $fields), $accessToken); $this->setSocialLoginCookie(self::SOCIAL_NAME); return $response->getDecodedBody(); } catch (Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error throw new Exception($e->getMessage()); } catch (Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues throw new Exception($e->getMessage()); } }
[ "public", "function", "getMe", "(", "$", "fields", ")", "{", "$", "accessTokenObject", "=", "$", "this", "->", "helper", "->", "getAccessToken", "(", "$", "this", "->", "callBackUrl", ")", ";", "if", "(", "$", "accessTokenObject", "==", "null", ")", "{",...
Return info about facebook user @param $fields @return array @throws Exception
[ "Return", "info", "about", "facebook", "user" ]
train
https://github.com/venca-x/social-login/blob/ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab/src/FacebookLogin.php#L210-L244
baleen/migrations
src/Delta/Collection/Resolver/DefaultResolverStackFactory.php
DefaultResolverStackFactory.create
public static function create() { return new ResolverStack([ new OffsetResolver(false), new HeadResolver(false), new FirstLastResolver(false), new FilenameResolver(false), new LazyIdResolver(false), ]); }
php
public static function create() { return new ResolverStack([ new OffsetResolver(false), new HeadResolver(false), new FirstLastResolver(false), new FilenameResolver(false), new LazyIdResolver(false), ]); }
[ "public", "static", "function", "create", "(", ")", "{", "return", "new", "ResolverStack", "(", "[", "new", "OffsetResolver", "(", "false", ")", ",", "new", "HeadResolver", "(", "false", ")", ",", "new", "FirstLastResolver", "(", "false", ")", ",", "new", ...
create @return ResolverStack
[ "create" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/DefaultResolverStackFactory.php#L33-L42
kaliop-uk/kueueingbundle
Service/WorkerManager.php
WorkerManager.getWorkersCommands
public function getWorkersCommands($env = null) { $procs = array(); foreach ($this->getWorkersNames() as $name) { $procs[$name] = $this->getWorkerCommand($name, $env); } return $procs; }
php
public function getWorkersCommands($env = null) { $procs = array(); foreach ($this->getWorkersNames() as $name) { $procs[$name] = $this->getWorkerCommand($name, $env); } return $procs; }
[ "public", "function", "getWorkersCommands", "(", "$", "env", "=", "null", ")", "{", "$", "procs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getWorkersNames", "(", ")", "as", "$", "name", ")", "{", "$", "procs", "[", "$", "nam...
Returns the list of commands for all workers configured to be running as daemons @param string $env @return array key: worker name, value: command to execute to start the worker @throws \Exception
[ "Returns", "the", "list", "of", "commands", "for", "all", "workers", "configured", "to", "be", "running", "as", "daemons" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L32-L39
kaliop-uk/kueueingbundle
Service/WorkerManager.php
WorkerManager.getWorkerCommand
public function getWorkerCommand($name, $env = null, $unescaped = false) { $defs = $this->workersList; if (!isset($defs[$name])) { throw new \Exception("No worker configuration for $name"); } $workerDef = $defs[$name]; if (empty($workerDef['queue_name']) || (isset($workerDef['options']) && !is_array($workerDef['options']))) { throw new \Exception("Bad worker configuration for $name"); } $cmd = $this->getConsoleCommand($env, $unescaped) . " kaliop_queueing:consumer " . ($unescaped ? $workerDef['queue_name'] : escapeshellarg($workerDef['queue_name'])) . " --label=" . ($unescaped ? $name : escapeshellarg($name)) . " -w"; if (isset($workerDef['options'])) { foreach ($workerDef['options'] as $name => $value) { $cmd .= ' ' . (strlen($name) == 1 ? '-' : '--') . $name . '=' . ($unescaped ? $value : escapeshellarg($value)); } } return $cmd; }
php
public function getWorkerCommand($name, $env = null, $unescaped = false) { $defs = $this->workersList; if (!isset($defs[$name])) { throw new \Exception("No worker configuration for $name"); } $workerDef = $defs[$name]; if (empty($workerDef['queue_name']) || (isset($workerDef['options']) && !is_array($workerDef['options']))) { throw new \Exception("Bad worker configuration for $name"); } $cmd = $this->getConsoleCommand($env, $unescaped) . " kaliop_queueing:consumer " . ($unescaped ? $workerDef['queue_name'] : escapeshellarg($workerDef['queue_name'])) . " --label=" . ($unescaped ? $name : escapeshellarg($name)) . " -w"; if (isset($workerDef['options'])) { foreach ($workerDef['options'] as $name => $value) { $cmd .= ' ' . (strlen($name) == 1 ? '-' : '--') . $name . '=' . ($unescaped ? $value : escapeshellarg($value)); } } return $cmd; }
[ "public", "function", "getWorkerCommand", "(", "$", "name", ",", "$", "env", "=", "null", ",", "$", "unescaped", "=", "false", ")", "{", "$", "defs", "=", "$", "this", "->", "workersList", ";", "if", "(", "!", "isset", "(", "$", "defs", "[", "$", ...
Returns the command line of a worker configured to be running as daemon @param string $name @param string $env set it to non null to force execution using a specific environment @param bool $unescaped do not add shell escaping to the command. NB: never use this option for executing stuff, only for grepping @return string @throws \Exception @todo make queue_name optional: take it from $name if not set (it is only used to allow many workers for the same queue) @todo allow to take path to php binary from config @todo filter out any undesirable cli options from the ones given by the user @todo tighten security: option names should be checked against the valid ones in the rabbitmq:consumer process @todo get the name of the console command from himself
[ "Returns", "the", "command", "line", "of", "a", "worker", "configured", "to", "be", "running", "as", "daemon" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L64-L83
kaliop-uk/kueueingbundle
Service/WorkerManager.php
WorkerManager.getConsoleCommand
public function getConsoleCommand($env = null, $unescaped = false) { $phpFinder = new PhpExecutableFinder; if (!$php = $phpFinder->find()) { throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); } $out = $php . ' ' . escapeshellcmd($this->kernelRootDir . DIRECTORY_SEPARATOR . "console"); if ($env != '') { $out .= ' --env=' . ($unescaped ? $env : escapeshellarg($env)); } return $out; }
php
public function getConsoleCommand($env = null, $unescaped = false) { $phpFinder = new PhpExecutableFinder; if (!$php = $phpFinder->find()) { throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); } $out = $php . ' ' . escapeshellcmd($this->kernelRootDir . DIRECTORY_SEPARATOR . "console"); if ($env != '') { $out .= ' --env=' . ($unescaped ? $env : escapeshellarg($env)); } return $out; }
[ "public", "function", "getConsoleCommand", "(", "$", "env", "=", "null", ",", "$", "unescaped", "=", "false", ")", "{", "$", "phpFinder", "=", "new", "PhpExecutableFinder", ";", "if", "(", "!", "$", "php", "=", "$", "phpFinder", "->", "find", "(", ")",...
Generates the php command to run the sf console @param string $env when not null an environment is set for the cmd to execute @param bool $unescaped do not add shell escaping to the command. NB: never use this option for executing stuff, only for grepping @return string @throws \RuntimeException @todo should get the name of the 'console' file in some kind of flexible way as well?
[ "Generates", "the", "php", "command", "to", "run", "the", "sf", "console" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/WorkerManager.php#L95-L107
bigwhoop/sentence-breaker
src/Abbreviations/FlatFileProvider.php
FlatFileProvider.getValues
public function getValues() { $values = []; foreach ($this->getPaths() as $path) { $values = array_merge($values, file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); } $values = array_unique($values); sort($values); return $values; }
php
public function getValues() { $values = []; foreach ($this->getPaths() as $path) { $values = array_merge($values, file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); } $values = array_unique($values); sort($values); return $values; }
[ "public", "function", "getValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getPaths", "(", ")", "as", "$", "path", ")", "{", "$", "values", "=", "array_merge", "(", "$", "values", ",", "file", "(", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Abbreviations/FlatFileProvider.php#L34-L45
fab2s/NodalFlow
src/Nodes/InterruptNodeAbstract.php
InterruptNodeAbstract.exec
public function exec($param) { $flowInterrupt = $this->interrupt($param); if ($flowInterrupt === null) { // do nothing, let the flow proceed return; } if ($flowInterrupt instanceof InterrupterInterface) { $flowInterruptType = $flowInterrupt->getType(); } elseif ($flowInterrupt) { $flowInterruptType = InterrupterInterface::TYPE_CONTINUE; $flowInterrupt = null; } else { $flowInterruptType = InterrupterInterface::TYPE_BREAK; $flowInterrupt = null; } /* @var null|InterrupterInterface $flowInterrupt */ $this->carrier->interruptFlow($flowInterruptType, $flowInterrupt); }
php
public function exec($param) { $flowInterrupt = $this->interrupt($param); if ($flowInterrupt === null) { // do nothing, let the flow proceed return; } if ($flowInterrupt instanceof InterrupterInterface) { $flowInterruptType = $flowInterrupt->getType(); } elseif ($flowInterrupt) { $flowInterruptType = InterrupterInterface::TYPE_CONTINUE; $flowInterrupt = null; } else { $flowInterruptType = InterrupterInterface::TYPE_BREAK; $flowInterrupt = null; } /* @var null|InterrupterInterface $flowInterrupt */ $this->carrier->interruptFlow($flowInterruptType, $flowInterrupt); }
[ "public", "function", "exec", "(", "$", "param", ")", "{", "$", "flowInterrupt", "=", "$", "this", "->", "interrupt", "(", "$", "param", ")", ";", "if", "(", "$", "flowInterrupt", "===", "null", ")", "{", "// do nothing, let the flow proceed", "return", ";...
The interrupt's method interface is simple : - return false to break - return true to continue - return void|null (whatever) to proceed with the flow @param mixed $param @return mixed|void
[ "The", "interrupt", "s", "method", "interface", "is", "simple", ":", "-", "return", "false", "to", "break", "-", "return", "true", "to", "continue", "-", "return", "void|null", "(", "whatever", ")", "to", "proceed", "with", "the", "flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Nodes/InterruptNodeAbstract.php#L50-L70
budde377/Part
lib/view/template/SiteVariableTwigTokenParserImpl.php
SiteVariableTwigTokenParserImpl.parse
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); $expr = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteVariableTwigNodeImpl($token->getLine(), $this->getTag(), $expr); }
php
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); $expr = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return new SiteVariableTwigNodeImpl($token->getLine(), $this->getTag(), $expr); }
[ "public", "function", "parse", "(", "Twig_Token", "$", "token", ")", "{", "$", "stream", "=", "$", "this", "->", "parser", "->", "getStream", "(", ")", ";", "$", "expr", "=", "$", "this", "->", "parser", "->", "getExpressionParser", "(", ")", "->", "...
Parses a token and returns a node. @param Twig_Token $token A Twig_Token instance @return Twig_Node A Twig_NodeInterface instance @throws Twig_Error_Syntax
[ "Parses", "a", "token", "and", "returns", "a", "node", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/template/SiteVariableTwigTokenParserImpl.php#L26-L32
yoanm/symfony-jsonrpc-http-server
src/DependencyInjection/JsonRpcHttpServerExtension.php
JsonRpcHttpServerExtension.process
public function process(ContainerBuilder $container) { $this->bindJsonRpcServerDispatcher($container); $this->bindValidatorIfDefined($container); $this->binJsonRpcMethods($container); }
php
public function process(ContainerBuilder $container) { $this->bindJsonRpcServerDispatcher($container); $this->bindValidatorIfDefined($container); $this->binJsonRpcMethods($container); }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "this", "->", "bindJsonRpcServerDispatcher", "(", "$", "container", ")", ";", "$", "this", "->", "bindValidatorIfDefined", "(", "$", "container", ")", ";", "$", "this", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/DependencyInjection/JsonRpcHttpServerExtension.php#L65-L70
yoanm/symfony-jsonrpc-http-server
src/DependencyInjection/JsonRpcHttpServerExtension.php
JsonRpcHttpServerExtension.findAndValidateMappingAwareDefinitionList
private function findAndValidateMappingAwareDefinitionList(ContainerBuilder $container): array { $mappingAwareServiceDefinitionList = []; $methodAwareServiceIdList = array_keys($container->findTaggedServiceIds(self::JSONRPC_METHOD_AWARE_TAG)); foreach ($methodAwareServiceIdList as $serviceId) { $definition = $container->getDefinition($serviceId); $this->checkMethodAwareServiceIdList($definition, $serviceId, $container); $mappingAwareServiceDefinitionList[$serviceId] = $definition; } return $mappingAwareServiceDefinitionList; }
php
private function findAndValidateMappingAwareDefinitionList(ContainerBuilder $container): array { $mappingAwareServiceDefinitionList = []; $methodAwareServiceIdList = array_keys($container->findTaggedServiceIds(self::JSONRPC_METHOD_AWARE_TAG)); foreach ($methodAwareServiceIdList as $serviceId) { $definition = $container->getDefinition($serviceId); $this->checkMethodAwareServiceIdList($definition, $serviceId, $container); $mappingAwareServiceDefinitionList[$serviceId] = $definition; } return $mappingAwareServiceDefinitionList; }
[ "private", "function", "findAndValidateMappingAwareDefinitionList", "(", "ContainerBuilder", "$", "container", ")", ":", "array", "{", "$", "mappingAwareServiceDefinitionList", "=", "[", "]", ";", "$", "methodAwareServiceIdList", "=", "array_keys", "(", "$", "container"...
@param ContainerBuilder $container @return array
[ "@param", "ContainerBuilder", "$container" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/DependencyInjection/JsonRpcHttpServerExtension.php#L200-L213
hollodotme/phpunit-testdox-markdown
src/Output/MarkdownFile.php
MarkdownFile.writeLegend
public function writeLegend( array $legend ) : void { $legendStrings = []; foreach ( $legend as $status => $output ) { $legendStrings[] = "{$output} {$status}"; } $this->write( "%s\n\n", implode( ' | ', $legendStrings ) ); }
php
public function writeLegend( array $legend ) : void { $legendStrings = []; foreach ( $legend as $status => $output ) { $legendStrings[] = "{$output} {$status}"; } $this->write( "%s\n\n", implode( ' | ', $legendStrings ) ); }
[ "public", "function", "writeLegend", "(", "array", "$", "legend", ")", ":", "void", "{", "$", "legendStrings", "=", "[", "]", ";", "foreach", "(", "$", "legend", "as", "$", "status", "=>", "$", "output", ")", "{", "$", "legendStrings", "[", "]", "=",...
@param array $legend @throws RuntimeException
[ "@param", "array", "$legend" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Output/MarkdownFile.php#L31-L40
hollodotme/phpunit-testdox-markdown
src/Output/MarkdownFile.php
MarkdownFile.write
public function write( string $formatOrContents, ...$contextValues ) : void { fwrite( $this->getFileHandle(), sprintf( $formatOrContents, ...$contextValues ) ); }
php
public function write( string $formatOrContents, ...$contextValues ) : void { fwrite( $this->getFileHandle(), sprintf( $formatOrContents, ...$contextValues ) ); }
[ "public", "function", "write", "(", "string", "$", "formatOrContents", ",", "...", "$", "contextValues", ")", ":", "void", "{", "fwrite", "(", "$", "this", "->", "getFileHandle", "(", ")", ",", "sprintf", "(", "$", "formatOrContents", ",", "...", "$", "c...
@param string $formatOrContents @param mixed ...$contextValues @throws RuntimeException
[ "@param", "string", "$formatOrContents", "@param", "mixed", "...", "$contextValues" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Output/MarkdownFile.php#L48-L54
hollodotme/phpunit-testdox-markdown
src/Output/MarkdownFile.php
MarkdownFile.writeHeadline
public function writeHeadline( string $title, int $level ) : void { $this->write( "%s %s\n\n", str_repeat( '#', $level ), $title ); }
php
public function writeHeadline( string $title, int $level ) : void { $this->write( "%s %s\n\n", str_repeat( '#', $level ), $title ); }
[ "public", "function", "writeHeadline", "(", "string", "$", "title", ",", "int", "$", "level", ")", ":", "void", "{", "$", "this", "->", "write", "(", "\"%s %s\\n\\n\"", ",", "str_repeat", "(", "'#'", ",", "$", "level", ")", ",", "$", "title", ")", ";...
@param string $title @param int $level @throws RuntimeException
[ "@param", "string", "$title", "@param", "int", "$level" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Output/MarkdownFile.php#L81-L84
hollodotme/phpunit-testdox-markdown
src/Output/MarkdownFile.php
MarkdownFile.writeListing
private function writeListing( array $elements, int $indentLevel, string $lineChar ) : void { if ( 0 === count( $elements ) ) { return; } $indent = str_repeat( ' ', $indentLevel * 2 ); $this->write( "%s%s %s \n\n", $indent, $lineChar, implode( " \n{$indent}{$lineChar} ", $elements ) ); }
php
private function writeListing( array $elements, int $indentLevel, string $lineChar ) : void { if ( 0 === count( $elements ) ) { return; } $indent = str_repeat( ' ', $indentLevel * 2 ); $this->write( "%s%s %s \n\n", $indent, $lineChar, implode( " \n{$indent}{$lineChar} ", $elements ) ); }
[ "private", "function", "writeListing", "(", "array", "$", "elements", ",", "int", "$", "indentLevel", ",", "string", "$", "lineChar", ")", ":", "void", "{", "if", "(", "0", "===", "count", "(", "$", "elements", ")", ")", "{", "return", ";", "}", "$",...
@param array $elements @param int $indentLevel @param string $lineChar @throws RuntimeException
[ "@param", "array", "$elements", "@param", "int", "$indentLevel", "@param", "string", "$lineChar" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Output/MarkdownFile.php#L104-L119
hollodotme/phpunit-testdox-markdown
src/Output/MarkdownFile.php
MarkdownFile.writeCheckbox
public function writeCheckbox( string $label, bool $ticked ) : void { $this->write( "- [%s] %s\n", $ticked ? 'x' : ' ', $label ); }
php
public function writeCheckbox( string $label, bool $ticked ) : void { $this->write( "- [%s] %s\n", $ticked ? 'x' : ' ', $label ); }
[ "public", "function", "writeCheckbox", "(", "string", "$", "label", ",", "bool", "$", "ticked", ")", ":", "void", "{", "$", "this", "->", "write", "(", "\"- [%s] %s\\n\"", ",", "$", "ticked", "?", "'x'", ":", "' '", ",", "$", "label", ")", ";", "}" ]
@param string $label @param bool $ticked @throws RuntimeException
[ "@param", "string", "$label", "@param", "bool", "$ticked" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Output/MarkdownFile.php#L138-L145
fab2s/NodalFlow
src/Flows/FlowInterruptAbstract.php
FlowInterruptAbstract.interruptFlow
public function interruptFlow($interruptType, InterrupterInterface $flowInterrupt = null) { $node = isset($this->nodes[$this->nodeIdx]) ? $this->nodes[$this->nodeIdx] : null; switch ($interruptType) { case InterrupterInterface::TYPE_CONTINUE: $this->continue = true; $this->flowMap->incrementFlow('num_continue'); $this->triggerEvent(FlowEvent::FLOW_CONTINUE, $node); break; case InterrupterInterface::TYPE_BREAK: $this->flowStatus = new FlowStatus(FlowStatus::FLOW_DIRTY); $this->break = true; $this->flowMap->incrementFlow('num_break'); $this->triggerEvent(FlowEvent::FLOW_BREAK, $node); break; default: throw new NodalFlowException('FlowInterrupt Type missing'); } if ($flowInterrupt) { $flowInterrupt->setType($interruptType)->propagate($this); } return $this; }
php
public function interruptFlow($interruptType, InterrupterInterface $flowInterrupt = null) { $node = isset($this->nodes[$this->nodeIdx]) ? $this->nodes[$this->nodeIdx] : null; switch ($interruptType) { case InterrupterInterface::TYPE_CONTINUE: $this->continue = true; $this->flowMap->incrementFlow('num_continue'); $this->triggerEvent(FlowEvent::FLOW_CONTINUE, $node); break; case InterrupterInterface::TYPE_BREAK: $this->flowStatus = new FlowStatus(FlowStatus::FLOW_DIRTY); $this->break = true; $this->flowMap->incrementFlow('num_break'); $this->triggerEvent(FlowEvent::FLOW_BREAK, $node); break; default: throw new NodalFlowException('FlowInterrupt Type missing'); } if ($flowInterrupt) { $flowInterrupt->setType($interruptType)->propagate($this); } return $this; }
[ "public", "function", "interruptFlow", "(", "$", "interruptType", ",", "InterrupterInterface", "$", "flowInterrupt", "=", "null", ")", "{", "$", "node", "=", "isset", "(", "$", "this", "->", "nodes", "[", "$", "this", "->", "nodeIdx", "]", ")", "?", "$",...
@param string $interruptType @param InterrupterInterface|null $flowInterrupt @throws NodalFlowException @return $this
[ "@param", "string", "$interruptType", "@param", "InterrupterInterface|null", "$flowInterrupt" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowInterruptAbstract.php#L95-L119
fab2s/NodalFlow
src/Flows/FlowInterruptAbstract.php
FlowInterruptAbstract.setInterruptNodeId
public function setInterruptNodeId($interruptNodeId) { if ($interruptNodeId !== null && !is_bool($interruptNodeId) && !$this->registry->getNode($interruptNodeId)) { throw new NodalFlowException('Targeted Node not found in target Flow for Interruption', 1, null, [ 'targetFlow' => $this->getId(), 'targetNode' => $interruptNodeId, ]); } $this->interruptNodeId = $interruptNodeId; return $this; }
php
public function setInterruptNodeId($interruptNodeId) { if ($interruptNodeId !== null && !is_bool($interruptNodeId) && !$this->registry->getNode($interruptNodeId)) { throw new NodalFlowException('Targeted Node not found in target Flow for Interruption', 1, null, [ 'targetFlow' => $this->getId(), 'targetNode' => $interruptNodeId, ]); } $this->interruptNodeId = $interruptNodeId; return $this; }
[ "public", "function", "setInterruptNodeId", "(", "$", "interruptNodeId", ")", "{", "if", "(", "$", "interruptNodeId", "!==", "null", "&&", "!", "is_bool", "(", "$", "interruptNodeId", ")", "&&", "!", "$", "this", "->", "registry", "->", "getNode", "(", "$"...
Used to set the eventual Node Target of an Interrupt signal set to : - A Node Id to target - true to interrupt every upstream nodes in this Flow - false to only interrupt up to the first upstream Traversable in this Flow @param null|string|bool $interruptNodeId @throws NodalFlowException @return $this
[ "Used", "to", "set", "the", "eventual", "Node", "Target", "of", "an", "Interrupt", "signal", "set", "to", ":", "-", "A", "Node", "Id", "to", "target", "-", "true", "to", "interrupt", "every", "upstream", "nodes", "in", "this", "Flow", "-", "false", "to...
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowInterruptAbstract.php#L136-L148
fab2s/NodalFlow
src/Flows/FlowInterruptAbstract.php
FlowInterruptAbstract.interruptNode
protected function interruptNode(NodeInterface $node) { // if we have an interruptNodeId, bubble up until we match a node // else stop propagation return $this->interruptNodeId ? $this->interruptNodeId !== $node->getId() : false; }
php
protected function interruptNode(NodeInterface $node) { // if we have an interruptNodeId, bubble up until we match a node // else stop propagation return $this->interruptNodeId ? $this->interruptNodeId !== $node->getId() : false; }
[ "protected", "function", "interruptNode", "(", "NodeInterface", "$", "node", ")", "{", "// if we have an interruptNodeId, bubble up until we match a node", "// else stop propagation", "return", "$", "this", "->", "interruptNodeId", "?", "$", "this", "->", "interruptNodeId", ...
@param NodeInterface $node @return bool
[ "@param", "NodeInterface", "$node" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowInterruptAbstract.php#L155-L160
yeephp/yeephp
Yee/Http/Util.php
Util.stripSlashesIfMagicQuotes
public static function stripSlashesIfMagicQuotes($rawData, $overrideStripSlashes = null) { $strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes; if ($strip) { return self::stripSlashes($rawData); } else { return $rawData; } }
php
public static function stripSlashesIfMagicQuotes($rawData, $overrideStripSlashes = null) { $strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes; if ($strip) { return self::stripSlashes($rawData); } else { return $rawData; } }
[ "public", "static", "function", "stripSlashesIfMagicQuotes", "(", "$", "rawData", ",", "$", "overrideStripSlashes", "=", "null", ")", "{", "$", "strip", "=", "is_null", "(", "$", "overrideStripSlashes", ")", "?", "get_magic_quotes_gpc", "(", ")", ":", "$", "ov...
Strip slashes from string or array This method strips slashes from its input. By default, this method will only strip slashes from its input if magic quotes are enabled. Otherwise, you may override the magic quotes setting with either TRUE or FALSE as the send argument to force this method to strip or not strip slashes from its input. @param array|string $rawData @param bool $overrideStripSlashes @return array|string
[ "Strip", "slashes", "from", "string", "or", "array" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L58-L66
yeephp/yeephp
Yee/Http/Util.php
Util.serializeCookies
public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config) { if ($config['cookies.encrypt']) { foreach ($cookies as $name => $settings) { if (is_string($settings['expires'])) { $expires = strtotime($settings['expires']); } else { $expires = (int) $settings['expires']; } $settings['value'] = static::encodeSecureCookie( $settings['value'], $expires, $config['cookies.secret_key'], $config['cookies.cipher'], $config['cookies.cipher_mode'] ); static::setCookieHeader($headers, $name, $settings); } } else { foreach ($cookies as $name => $settings) { static::setCookieHeader($headers, $name, $settings); } } }
php
public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config) { if ($config['cookies.encrypt']) { foreach ($cookies as $name => $settings) { if (is_string($settings['expires'])) { $expires = strtotime($settings['expires']); } else { $expires = (int) $settings['expires']; } $settings['value'] = static::encodeSecureCookie( $settings['value'], $expires, $config['cookies.secret_key'], $config['cookies.cipher'], $config['cookies.cipher_mode'] ); static::setCookieHeader($headers, $name, $settings); } } else { foreach ($cookies as $name => $settings) { static::setCookieHeader($headers, $name, $settings); } } }
[ "public", "static", "function", "serializeCookies", "(", "\\", "Yee", "\\", "Http", "\\", "Headers", "&", "$", "headers", ",", "\\", "Yee", "\\", "Http", "\\", "Cookies", "$", "cookies", ",", "array", "$", "config", ")", "{", "if", "(", "$", "config", ...
Serialize Response cookies into raw HTTP header @param \Yee\Http\Headers $headers The Response headers @param \Yee\Http\Cookies $cookies The Response cookies @param array $config The Yee app settings
[ "Serialize", "Response", "cookies", "into", "raw", "HTTP", "header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L185-L209
yeephp/yeephp
Yee/Http/Util.php
Util.decodeSecureCookie
public static function decodeSecureCookie($value, $secret, $algorithm, $mode) { if ($value) { $value = explode('|', $value); if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) { $key = hash_hmac('sha1', $value[0], $secret); $iv = self::getIv($value[0], $secret); $data = self::decrypt( base64_decode($value[1]), $key, $iv, array( 'algorithm' => $algorithm, 'mode' => $mode ) ); $verificationString = hash_hmac('sha1', $value[0] . $data, $key); if ($verificationString === $value[2]) { return $data; } } } return false; }
php
public static function decodeSecureCookie($value, $secret, $algorithm, $mode) { if ($value) { $value = explode('|', $value); if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) { $key = hash_hmac('sha1', $value[0], $secret); $iv = self::getIv($value[0], $secret); $data = self::decrypt( base64_decode($value[1]), $key, $iv, array( 'algorithm' => $algorithm, 'mode' => $mode ) ); $verificationString = hash_hmac('sha1', $value[0] . $data, $key); if ($verificationString === $value[2]) { return $data; } } } return false; }
[ "public", "static", "function", "decodeSecureCookie", "(", "$", "value", ",", "$", "secret", ",", "$", "algorithm", ",", "$", "mode", ")", "{", "if", "(", "$", "value", ")", "{", "$", "value", "=", "explode", "(", "'|'", ",", "$", "value", ")", ";"...
Decode secure cookie value This method will decode the secure value of an HTTP cookie. The cookie value is encrypted and hashed so that its value is secure and checked for integrity when read in subsequent requests. @param string $value The secure HTTP cookie value @param string $secret The secret key used to hash the cookie value @param int $algorithm The algorithm to use for encryption @param int $mode The algorithm mode to use for encryption @return bool|string
[ "Decode", "secure", "cookie", "value" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L258-L282
yeephp/yeephp
Yee/Http/Util.php
Util.setCookieHeader
public static function setCookieHeader(&$header, $name, $value) { //Build cookie header if (is_array($value)) { $domain = ''; $path = ''; $expires = ''; $secure = ''; $httponly = ''; if (isset($value['domain']) && $value['domain']) { $domain = '; domain=' . $value['domain']; } if (isset($value['path']) && $value['path']) { $path = '; path=' . $value['path']; } if (isset($value['expires'])) { if (is_string($value['expires'])) { $timestamp = strtotime($value['expires']); } else { $timestamp = (int) $value['expires']; } if ($timestamp !== 0) { $expires = '; expires=' . gmdate('D, d-M-Y H:i:s e', $timestamp); } } if (isset($value['secure']) && $value['secure']) { $secure = '; secure'; } if (isset($value['httponly']) && $value['httponly']) { $httponly = '; HttpOnly'; } $cookie = sprintf('%s=%s%s', urlencode($name), urlencode((string) $value['value']), $domain . $path . $expires . $secure . $httponly); } else { $cookie = sprintf('%s=%s', urlencode($name), urlencode((string) $value)); } //Set cookie header if (!isset($header['Set-Cookie']) || $header['Set-Cookie'] === '') { $header['Set-Cookie'] = $cookie; } else { $header['Set-Cookie'] = implode("\n", array($header['Set-Cookie'], $cookie)); } }
php
public static function setCookieHeader(&$header, $name, $value) { //Build cookie header if (is_array($value)) { $domain = ''; $path = ''; $expires = ''; $secure = ''; $httponly = ''; if (isset($value['domain']) && $value['domain']) { $domain = '; domain=' . $value['domain']; } if (isset($value['path']) && $value['path']) { $path = '; path=' . $value['path']; } if (isset($value['expires'])) { if (is_string($value['expires'])) { $timestamp = strtotime($value['expires']); } else { $timestamp = (int) $value['expires']; } if ($timestamp !== 0) { $expires = '; expires=' . gmdate('D, d-M-Y H:i:s e', $timestamp); } } if (isset($value['secure']) && $value['secure']) { $secure = '; secure'; } if (isset($value['httponly']) && $value['httponly']) { $httponly = '; HttpOnly'; } $cookie = sprintf('%s=%s%s', urlencode($name), urlencode((string) $value['value']), $domain . $path . $expires . $secure . $httponly); } else { $cookie = sprintf('%s=%s', urlencode($name), urlencode((string) $value)); } //Set cookie header if (!isset($header['Set-Cookie']) || $header['Set-Cookie'] === '') { $header['Set-Cookie'] = $cookie; } else { $header['Set-Cookie'] = implode("\n", array($header['Set-Cookie'], $cookie)); } }
[ "public", "static", "function", "setCookieHeader", "(", "&", "$", "header", ",", "$", "name", ",", "$", "value", ")", "{", "//Build cookie header", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "domain", "=", "''", ";", "$", "path", "...
Set HTTP cookie header This method will construct and set the HTTP `Set-Cookie` header. Yee uses this method instead of PHP's native `setcookie` method. This allows more control of the HTTP header irrespective of the native implementation's dependency on PHP versions. This method accepts the Yee_Http_Headers object by reference as its first argument; this method directly modifies this object instead of returning a value. @param array $header @param string $name @param string $value
[ "Set", "HTTP", "cookie", "header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L300-L342
yeephp/yeephp
Yee/Http/Util.php
Util.deleteCookieHeader
public static function deleteCookieHeader(&$header, $name, $value = array()) { //Remove affected cookies from current response header $cookiesOld = array(); $cookiesNew = array(); if (isset($header['Set-Cookie'])) { $cookiesOld = explode("\n", $header['Set-Cookie']); } foreach ($cookiesOld as $c) { if (isset($value['domain']) && $value['domain']) { $regex = sprintf('@%s=.*domain=%s@', urlencode($name), preg_quote($value['domain'])); } else { $regex = sprintf('@%s=@', urlencode($name)); } if (preg_match($regex, $c) === 0) { $cookiesNew[] = $c; } } if ($cookiesNew) { $header['Set-Cookie'] = implode("\n", $cookiesNew); } else { unset($header['Set-Cookie']); } //Set invalidating cookie to clear client-side cookie self::setCookieHeader($header, $name, array_merge(array('value' => '', 'path' => null, 'domain' => null, 'expires' => time() - 100), $value)); }
php
public static function deleteCookieHeader(&$header, $name, $value = array()) { //Remove affected cookies from current response header $cookiesOld = array(); $cookiesNew = array(); if (isset($header['Set-Cookie'])) { $cookiesOld = explode("\n", $header['Set-Cookie']); } foreach ($cookiesOld as $c) { if (isset($value['domain']) && $value['domain']) { $regex = sprintf('@%s=.*domain=%s@', urlencode($name), preg_quote($value['domain'])); } else { $regex = sprintf('@%s=@', urlencode($name)); } if (preg_match($regex, $c) === 0) { $cookiesNew[] = $c; } } if ($cookiesNew) { $header['Set-Cookie'] = implode("\n", $cookiesNew); } else { unset($header['Set-Cookie']); } //Set invalidating cookie to clear client-side cookie self::setCookieHeader($header, $name, array_merge(array('value' => '', 'path' => null, 'domain' => null, 'expires' => time() - 100), $value)); }
[ "public", "static", "function", "deleteCookieHeader", "(", "&", "$", "header", ",", "$", "name", ",", "$", "value", "=", "array", "(", ")", ")", "{", "//Remove affected cookies from current response header", "$", "cookiesOld", "=", "array", "(", ")", ";", "$",...
Delete HTTP cookie header This method will construct and set the HTTP `Set-Cookie` header to invalidate a client-side HTTP cookie. If a cookie with the same name (and, optionally, domain) is already set in the HTTP response, it will also be removed. Yee uses this method instead of PHP's native `setcookie` method. This allows more control of the HTTP header irrespective of PHP's native implementation's dependency on PHP versions. This method accepts the Yee_Http_Headers object by reference as its first argument; this method directly modifies this object instead of returning a value. @param array $header @param string $name @param array $value
[ "Delete", "HTTP", "cookie", "header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L361-L387
yeephp/yeephp
Yee/Http/Util.php
Util.parseCookieHeader
public static function parseCookieHeader($header) { $cookies = array(); $header = rtrim($header, "\r\n"); $headerPieces = preg_split('@\s*[;,]\s*@', $header); foreach ($headerPieces as $c) { $cParts = explode('=', $c, 2); if (count($cParts) === 2) { $key = urldecode($cParts[0]); $value = urldecode($cParts[1]); if (!isset($cookies[$key])) { $cookies[$key] = $value; } } } return $cookies; }
php
public static function parseCookieHeader($header) { $cookies = array(); $header = rtrim($header, "\r\n"); $headerPieces = preg_split('@\s*[;,]\s*@', $header); foreach ($headerPieces as $c) { $cParts = explode('=', $c, 2); if (count($cParts) === 2) { $key = urldecode($cParts[0]); $value = urldecode($cParts[1]); if (!isset($cookies[$key])) { $cookies[$key] = $value; } } } return $cookies; }
[ "public", "static", "function", "parseCookieHeader", "(", "$", "header", ")", "{", "$", "cookies", "=", "array", "(", ")", ";", "$", "header", "=", "rtrim", "(", "$", "header", ",", "\"\\r\\n\"", ")", ";", "$", "headerPieces", "=", "preg_split", "(", "...
Parse cookie header This method will parse the HTTP request's `Cookie` header and extract cookies into an associative array. @param string @return array
[ "Parse", "cookie", "header" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L398-L415
yeephp/yeephp
Yee/Http/Util.php
Util.getIv
private static function getIv($expires, $secret) { $data1 = hash_hmac('sha1', 'a'.$expires.'b', $secret); $data2 = hash_hmac('sha1', 'z'.$expires.'y', $secret); return pack("h*", $data1.$data2); }
php
private static function getIv($expires, $secret) { $data1 = hash_hmac('sha1', 'a'.$expires.'b', $secret); $data2 = hash_hmac('sha1', 'z'.$expires.'y', $secret); return pack("h*", $data1.$data2); }
[ "private", "static", "function", "getIv", "(", "$", "expires", ",", "$", "secret", ")", "{", "$", "data1", "=", "hash_hmac", "(", "'sha1'", ",", "'a'", ".", "$", "expires", ".", "'b'", ",", "$", "secret", ")", ";", "$", "data2", "=", "hash_hmac", "...
Generate a random IV This method will generate a non-predictable IV for use with the cookie encryption @param int $expires The UNIX timestamp at which this cookie will expire @param string $secret The secret key used to hash the cookie value @return string Hash
[ "Generate", "a", "random", "IV" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Util.php#L427-L433
yoanm/symfony-jsonrpc-http-server
features/demo_app/src/AbstractKernel.php
AbstractKernel.getCacheDir
public function getCacheDir() { // Use a specific cache for each kernels if (null === $this->customCacheDir) { $this->customCacheDir = $this->getProjectDir().'/var/cache/'.$this->environment.'/'.$this->getConfigDirectory(); } return $this->customCacheDir; }
php
public function getCacheDir() { // Use a specific cache for each kernels if (null === $this->customCacheDir) { $this->customCacheDir = $this->getProjectDir().'/var/cache/'.$this->environment.'/'.$this->getConfigDirectory(); } return $this->customCacheDir; }
[ "public", "function", "getCacheDir", "(", ")", "{", "// Use a specific cache for each kernels", "if", "(", "null", "===", "$", "this", "->", "customCacheDir", ")", "{", "$", "this", "->", "customCacheDir", "=", "$", "this", "->", "getProjectDir", "(", ")", "."...
{@inheritdoc}
[ "{" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/features/demo_app/src/AbstractKernel.php#L19-L27
marvin255/bxcodegen
src/service/yaml/SymfonyYaml.php
SymfonyYaml.parseFromFile
public function parseFromFile($pathToFile) { if (!file_exists($pathToFile)) { throw new Exception( "There is no {$pathToFile} file for parsing" ); } try { $return = Yaml::parseFile($pathToFile); } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } return $return; }
php
public function parseFromFile($pathToFile) { if (!file_exists($pathToFile)) { throw new Exception( "There is no {$pathToFile} file for parsing" ); } try { $return = Yaml::parseFile($pathToFile); } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } return $return; }
[ "public", "function", "parseFromFile", "(", "$", "pathToFile", ")", "{", "if", "(", "!", "file_exists", "(", "$", "pathToFile", ")", ")", "{", "throw", "new", "Exception", "(", "\"There is no {$pathToFile} file for parsing\"", ")", ";", "}", "try", "{", "$", ...
{@inheritdoc} @throws \marvin255\bxcodegen\Exception
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/yaml/SymfonyYaml.php#L18-L33
yeephp/yeephp
Yee/View.php
View.setData
public function setData() { $args = func_get_args(); if (count($args) === 1 && is_array($args[0])) { $this->data->replace($args[0]); } elseif (count($args) === 2) { // Ensure original behavior is maintained. DO NOT invoke stored Closures. if (is_object($args[1]) && method_exists($args[1], '__invoke')) { $this->data->set($args[0], $this->data->protect($args[1])); } else { $this->data->set($args[0], $args[1]); } } else { throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); } }
php
public function setData() { $args = func_get_args(); if (count($args) === 1 && is_array($args[0])) { $this->data->replace($args[0]); } elseif (count($args) === 2) { // Ensure original behavior is maintained. DO NOT invoke stored Closures. if (is_object($args[1]) && method_exists($args[1], '__invoke')) { $this->data->set($args[0], $this->data->protect($args[1])); } else { $this->data->set($args[0], $args[1]); } } else { throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); } }
[ "public", "function", "setData", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", "===", "1", "&&", "is_array", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "this", "->", "data"...
DEPRECATION WARNING! This method will be removed in the next major point release Set data for view
[ "DEPRECATION", "WARNING!", "This", "method", "will", "be", "removed", "in", "the", "next", "major", "point", "release" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/View.php#L165-L180
yeephp/yeephp
Yee/View.php
View.render
protected function render($template, $data = null) { $templatePathname = $this->getTemplatePathname($template); if (!is_file($templatePathname)) { throw new \RuntimeException("View cannot render `$template` because the template does not exist"); } $data = array_merge($this->data->all(), (array) $data); extract($data); ob_start(); require $templatePathname; return ob_get_clean(); }
php
protected function render($template, $data = null) { $templatePathname = $this->getTemplatePathname($template); if (!is_file($templatePathname)) { throw new \RuntimeException("View cannot render `$template` because the template does not exist"); } $data = array_merge($this->data->all(), (array) $data); extract($data); ob_start(); require $templatePathname; return ob_get_clean(); }
[ "protected", "function", "render", "(", "$", "template", ",", "$", "data", "=", "null", ")", "{", "$", "templatePathname", "=", "$", "this", "->", "getTemplatePathname", "(", "$", "template", ")", ";", "if", "(", "!", "is_file", "(", "$", "templatePathna...
Render a template file NOTE: This method should be overridden by custom view subclasses @param string $template The template pathname, relative to the template base directory @param array $data Any additonal data to be passed to the template. @return string The rendered template @throws \RuntimeException If resolved template pathname is not a valid file
[ "Render", "a", "template", "file" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/View.php#L268-L281
budde377/Part
lib/util/file/LogFileImpl.php
LogFileImpl.log
public function log($message, $level, &$createDumpFile = false) { $this->create(); $array = array($level, $t = time(), $message); if($createDumpFile !== false){ $createDumpFile = new DumpFileImpl($this->getParentFolder()->getAbsolutePath()."/dump-".uniqid()); $this->dumparray[$array[] = $createDumpFile->getFilename()] = $createDumpFile; } fputcsv($r = $this->getResource(), $array); fclose($r); return $t; }
php
public function log($message, $level, &$createDumpFile = false) { $this->create(); $array = array($level, $t = time(), $message); if($createDumpFile !== false){ $createDumpFile = new DumpFileImpl($this->getParentFolder()->getAbsolutePath()."/dump-".uniqid()); $this->dumparray[$array[] = $createDumpFile->getFilename()] = $createDumpFile; } fputcsv($r = $this->getResource(), $array); fclose($r); return $t; }
[ "public", "function", "log", "(", "$", "message", ",", "$", "level", ",", "&", "$", "createDumpFile", "=", "false", ")", "{", "$", "this", "->", "create", "(", ")", ";", "$", "array", "=", "array", "(", "$", "level", ",", "$", "t", "=", "time", ...
Will log a message and write to file. @param string $message @param int $level @param bool|DumpFile $createDumpFile @return int
[ "Will", "log", "a", "message", "and", "write", "to", "file", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/LogFileImpl.php#L24-L39
budde377/Part
lib/util/file/LogFileImpl.php
LogFileImpl.clearLog
public function clearLog() { $this->listLog(); foreach($this->dumparray as $df){ /** @var $df DumpFile */ $df->delete(); } $this->setAccessMode(File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH); $this->write(""); $this->setAccessMode(File::FILE_MODE_RW_POINTER_AT_END); }
php
public function clearLog() { $this->listLog(); foreach($this->dumparray as $df){ /** @var $df DumpFile */ $df->delete(); } $this->setAccessMode(File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH); $this->write(""); $this->setAccessMode(File::FILE_MODE_RW_POINTER_AT_END); }
[ "public", "function", "clearLog", "(", ")", "{", "$", "this", "->", "listLog", "(", ")", ";", "foreach", "(", "$", "this", "->", "dumparray", "as", "$", "df", ")", "{", "/** @var $df DumpFile */", "$", "df", "->", "delete", "(", ")", ";", "}", "$", ...
Will clear the log and remove all dump files. @return void
[ "Will", "clear", "the", "log", "and", "remove", "all", "dump", "files", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/LogFileImpl.php#L74-L85
MW-Peachy/Peachy
Plugins/RFA.php
RFA.findSigInLine
protected function findSigInLine( $input, &$iffy ) { $iffy = 0; $parsee_array = explode( "\n", $input ); for( $n = 0; $n < count( $parsee_array ); $n++ ){ //This for will terminate when a sig is found. $parsee = $parsee_array[$n]; //Okay, let's try and remove "copied from above" messages. If the line has more than one timestamp, we'll disregard anything after the first. //Note: we're ignoring people who use custom timestamps - if these peoples' votes are moved, the mover's name will show up as having voted. //If more than one timestamp is found in the first portion of the vote: $tsmatches = array(); $dummymatches = array(); if( preg_match_all( '/' . "[0-2][0-9]\:[0-5][0-9], [1-3]?[0-9] (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{4} \(UTC\)" . '/', $parsee, $tsmatches, PREG_OFFSET_CAPTURE ) > 1 ) { //Go through each timestamp-section, looking for a signature foreach( $tsmatches[0] as $minisection ){ $temp = substr( $parsee, 0, $minisection[1] ); //If a signature is found, stop and use it as voter if( $this->findSig( $temp, $dummymatches ) != 0 ) { //KNOWN ISSUE: Write description later $parsee = $temp; break; } } } //Start the main signature-finding: $matches = array(); if( $this->findSig( $parsee, $matches ) == 0 ) { //Okay, signature not found. Let's try the backup regex if( $this->findSigAlt( $parsee, $matches ) == 0 ) { //Signature was not found in this iteration of the main loop :( continue; //Go on to next newline (may be iffy) } else { $merged = array_merge( $matches[1], $matches[2] ); } } else { //Merge the match arrays: $merged = array_merge( $matches[5], $matches[1], $matches[3], $matches[2], $matches[4] ); } //Remove blank values and arrays of the form ('',-1): foreach( $merged as $key => $value ){ if( is_array( $value ) && ( $value[0] == '' ) && ( $value[1] == -1 ) ) { unset( $merged[$key] ); } elseif( $value == "" ) { unset( $merged[$key] ); } } //Let's find out the real signature $keys = array(); $values = array(); foreach( $merged as $mergee ){ $keys[] = $mergee[0]; $values[] = $mergee[1]; } //Now sort: array_multisort( $values, SORT_DESC, SORT_NUMERIC, $keys ); //Now we should have the most relevant match (i.e., the sig) at the top of $keys $i = 0; $foundsig = ''; while( $foundsig == '' ){ $foundsig = trim( $keys[$i++] ); if( $i == count( $keys ) ) break; //If we can only find blank usernames in the sig, catch overflow //Also fires when the first sig is also the last sig, so not an error } //Set iffy flag (level 1) if went beyond first line if( $n > 0 ) { $iffy = 1; } return $foundsig; } return false; }
php
protected function findSigInLine( $input, &$iffy ) { $iffy = 0; $parsee_array = explode( "\n", $input ); for( $n = 0; $n < count( $parsee_array ); $n++ ){ //This for will terminate when a sig is found. $parsee = $parsee_array[$n]; //Okay, let's try and remove "copied from above" messages. If the line has more than one timestamp, we'll disregard anything after the first. //Note: we're ignoring people who use custom timestamps - if these peoples' votes are moved, the mover's name will show up as having voted. //If more than one timestamp is found in the first portion of the vote: $tsmatches = array(); $dummymatches = array(); if( preg_match_all( '/' . "[0-2][0-9]\:[0-5][0-9], [1-3]?[0-9] (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{4} \(UTC\)" . '/', $parsee, $tsmatches, PREG_OFFSET_CAPTURE ) > 1 ) { //Go through each timestamp-section, looking for a signature foreach( $tsmatches[0] as $minisection ){ $temp = substr( $parsee, 0, $minisection[1] ); //If a signature is found, stop and use it as voter if( $this->findSig( $temp, $dummymatches ) != 0 ) { //KNOWN ISSUE: Write description later $parsee = $temp; break; } } } //Start the main signature-finding: $matches = array(); if( $this->findSig( $parsee, $matches ) == 0 ) { //Okay, signature not found. Let's try the backup regex if( $this->findSigAlt( $parsee, $matches ) == 0 ) { //Signature was not found in this iteration of the main loop :( continue; //Go on to next newline (may be iffy) } else { $merged = array_merge( $matches[1], $matches[2] ); } } else { //Merge the match arrays: $merged = array_merge( $matches[5], $matches[1], $matches[3], $matches[2], $matches[4] ); } //Remove blank values and arrays of the form ('',-1): foreach( $merged as $key => $value ){ if( is_array( $value ) && ( $value[0] == '' ) && ( $value[1] == -1 ) ) { unset( $merged[$key] ); } elseif( $value == "" ) { unset( $merged[$key] ); } } //Let's find out the real signature $keys = array(); $values = array(); foreach( $merged as $mergee ){ $keys[] = $mergee[0]; $values[] = $mergee[1]; } //Now sort: array_multisort( $values, SORT_DESC, SORT_NUMERIC, $keys ); //Now we should have the most relevant match (i.e., the sig) at the top of $keys $i = 0; $foundsig = ''; while( $foundsig == '' ){ $foundsig = trim( $keys[$i++] ); if( $i == count( $keys ) ) break; //If we can only find blank usernames in the sig, catch overflow //Also fires when the first sig is also the last sig, so not an error } //Set iffy flag (level 1) if went beyond first line if( $n > 0 ) { $iffy = 1; } return $foundsig; } return false; }
[ "protected", "function", "findSigInLine", "(", "$", "input", ",", "&", "$", "iffy", ")", "{", "$", "iffy", "=", "0", ";", "$", "parsee_array", "=", "explode", "(", "\"\\n\"", ",", "$", "input", ")", ";", "for", "(", "$", "n", "=", "0", ";", "$", ...
Attempts to find a signature in $input. Returns the name of the user, false on failure. @param $input @param $iffy @return bool|string false if not found Signature, or the Signature if it is found
[ "Attempts", "to", "find", "a", "signature", "in", "$input", ".", "Returns", "the", "name", "of", "the", "user", "false", "on", "failure", ".", "@param", "$input", "@param", "$iffy" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/RFA.php#L209-L282
MW-Peachy/Peachy
Plugins/RFA.php
RFA.analyzeSection
private function analyzeSection( $input ) { //Remove trailing sharp, if any $input = preg_replace( '/#\s*$/', '', $input ); //Old preg_split regex: "/(^|\n)\s*\#[^\#\:\*]/" $parsed = preg_split( "/(^|\n)\#/", $input ); //Shift off first empty element: array_shift( $parsed ); foreach( $parsed as &$parsee ){ //Foreach line //If the line is empty for some reason, ignore $parsee = trim( $parsee ); if( empty( $parsee ) ) continue; //If the line has been indented (disabled), or is a comment, ignore if( ( $parsee[0] == ':' ) || ( $parsee[0] == '*' ) || ( $parsee[0] == '#' ) ) { $parsee = '///###///'; continue; }; //struck-out vote or comment $parsedsig = $this->findSigInLine( $parsee, $iffy ); //Find signature $orgsig = $parsee; $parsee = array(); $parsee['context'] = $orgsig; if( $parsedsig === false ) { $parsee['error'] = 'Signature not found'; } else { $parsee['name'] = $parsedsig; } if( @$iffy == 1 ) { $parsee['iffy'] = '1'; } } //Foreach line if( ( count( $parsed ) == 1 ) && ( @trim( $parsed[0]['name'] ) == '' ) ) { //filters out placeholder sharp sign used in empty sections $parsed = array(); } //Delete struck-out keys "continued" in foreach foreach( $parsed as $key => $value ){ if( $value == '///###///' ) { unset( $parsed[$key] ); } } return $parsed; }
php
private function analyzeSection( $input ) { //Remove trailing sharp, if any $input = preg_replace( '/#\s*$/', '', $input ); //Old preg_split regex: "/(^|\n)\s*\#[^\#\:\*]/" $parsed = preg_split( "/(^|\n)\#/", $input ); //Shift off first empty element: array_shift( $parsed ); foreach( $parsed as &$parsee ){ //Foreach line //If the line is empty for some reason, ignore $parsee = trim( $parsee ); if( empty( $parsee ) ) continue; //If the line has been indented (disabled), or is a comment, ignore if( ( $parsee[0] == ':' ) || ( $parsee[0] == '*' ) || ( $parsee[0] == '#' ) ) { $parsee = '///###///'; continue; }; //struck-out vote or comment $parsedsig = $this->findSigInLine( $parsee, $iffy ); //Find signature $orgsig = $parsee; $parsee = array(); $parsee['context'] = $orgsig; if( $parsedsig === false ) { $parsee['error'] = 'Signature not found'; } else { $parsee['name'] = $parsedsig; } if( @$iffy == 1 ) { $parsee['iffy'] = '1'; } } //Foreach line if( ( count( $parsed ) == 1 ) && ( @trim( $parsed[0]['name'] ) == '' ) ) { //filters out placeholder sharp sign used in empty sections $parsed = array(); } //Delete struck-out keys "continued" in foreach foreach( $parsed as $key => $value ){ if( $value == '///###///' ) { unset( $parsed[$key] ); } } return $parsed; }
[ "private", "function", "analyzeSection", "(", "$", "input", ")", "{", "//Remove trailing sharp, if any", "$", "input", "=", "preg_replace", "(", "'/#\\s*$/'", ",", "''", ",", "$", "input", ")", ";", "//Old preg_split regex: \"/(^|\\n)\\s*\\#[^\\#\\:\\*]/\"", "$", "par...
Analyzes an RFA section. Returns an array of parsed signatures on success. Undefined behaviour on failure. @param string $input @return array
[ "Analyzes", "an", "RFA", "section", ".", "Returns", "an", "array", "of", "parsed", "signatures", "on", "success", ".", "Undefined", "behaviour", "on", "failure", ".", "@param", "string", "$input" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/RFA.php#L290-L336
yarcode/yii2-email-manager
src/models/Template.php
Template.validateTwig
public function validateTwig($attribute) { $twig = $this->getTwig(new \Twig_Loader_String()); try { $twig->render($this->$attribute); } catch (\Exception $e) { $message = "Error compiling {$attribute}: " . $e->getMessage(); $this->addError($attribute, $message); } }
php
public function validateTwig($attribute) { $twig = $this->getTwig(new \Twig_Loader_String()); try { $twig->render($this->$attribute); } catch (\Exception $e) { $message = "Error compiling {$attribute}: " . $e->getMessage(); $this->addError($attribute, $message); } }
[ "public", "function", "validateTwig", "(", "$", "attribute", ")", "{", "$", "twig", "=", "$", "this", "->", "getTwig", "(", "new", "\\", "Twig_Loader_String", "(", ")", ")", ";", "try", "{", "$", "twig", "->", "render", "(", "$", "this", "->", "$", ...
Validator for twig attributes @param $attribute
[ "Validator", "for", "twig", "attributes" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L78-L88
yarcode/yii2-email-manager
src/models/Template.php
Template.getTwig
protected function getTwig(\Twig_LoaderInterface $loader) { $twig = new \Twig_Environment($loader); $twig->setCache(false); return $twig; }
php
protected function getTwig(\Twig_LoaderInterface $loader) { $twig = new \Twig_Environment($loader); $twig->setCache(false); return $twig; }
[ "protected", "function", "getTwig", "(", "\\", "Twig_LoaderInterface", "$", "loader", ")", "{", "$", "twig", "=", "new", "\\", "Twig_Environment", "(", "$", "loader", ")", ";", "$", "twig", "->", "setCache", "(", "false", ")", ";", "return", "$", "twig",...
Twig instance factory @param \Twig_LoaderInterface $loader @return \Twig_Environment
[ "Twig", "instance", "factory" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L96-L102
yarcode/yii2-email-manager
src/models/Template.php
Template.queue
public function queue($to, array $params = [], $priority = 0, $files = [], $bcc = null) { $text = nl2br($this->renderAttribute('text', $params)); $subject = $this->renderAttribute('subject', $params); EmailManager::getInstance()->queue( $this->from, $to, $subject, $text, $priority, $files, $bcc ); return true; }
php
public function queue($to, array $params = [], $priority = 0, $files = [], $bcc = null) { $text = nl2br($this->renderAttribute('text', $params)); $subject = $this->renderAttribute('subject', $params); EmailManager::getInstance()->queue( $this->from, $to, $subject, $text, $priority, $files, $bcc ); return true; }
[ "public", "function", "queue", "(", "$", "to", ",", "array", "$", "params", "=", "[", "]", ",", "$", "priority", "=", "0", ",", "$", "files", "=", "[", "]", ",", "$", "bcc", "=", "null", ")", "{", "$", "text", "=", "nl2br", "(", "$", "this", ...
Queues current template for sending with the given priority @param $to @param array $params @param int $priority @param array $files @param null $bcc @return bool @throws \yii\base\InvalidConfigException
[ "Queues", "current", "template", "for", "sending", "with", "the", "given", "priority" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L129-L143
yarcode/yii2-email-manager
src/models/Template.php
Template.renderAttribute
public function renderAttribute($attribute, array $params) { $twig = $this->getTwig(new EmailTemplateLoader([ 'attributeName' => $attribute, ])); try { $result = $twig->render($this->shortcut, $params); } catch (\Exception $e) { $result = 'Error compiling email ' . $attribute . ': ' . $e->getMessage(); } return $result; }
php
public function renderAttribute($attribute, array $params) { $twig = $this->getTwig(new EmailTemplateLoader([ 'attributeName' => $attribute, ])); try { $result = $twig->render($this->shortcut, $params); } catch (\Exception $e) { $result = 'Error compiling email ' . $attribute . ': ' . $e->getMessage(); } return $result; }
[ "public", "function", "renderAttribute", "(", "$", "attribute", ",", "array", "$", "params", ")", "{", "$", "twig", "=", "$", "this", "->", "getTwig", "(", "new", "EmailTemplateLoader", "(", "[", "'attributeName'", "=>", "$", "attribute", ",", "]", ")", ...
Renders attribute using twig @param string $attribute @param array $params @return string
[ "Renders", "attribute", "using", "twig" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/models/Template.php#L152-L165
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addFunctionAuthFunction
public function addFunctionAuthFunction($type, $functionName, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $functionName, $function){ $this->fnAuthFunctions[$type][$functionName][] = $function; }, function($target) use ($functionName, $function){ $this->addFunctionAuthFunction($target, $functionName, $function); }); }
php
public function addFunctionAuthFunction($type, $functionName, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $functionName, $function){ $this->fnAuthFunctions[$type][$functionName][] = $function; }, function($target) use ($functionName, $function){ $this->addFunctionAuthFunction($target, $functionName, $function); }); }
[ "public", "function", "addFunctionAuthFunction", "(", "$", "type", ",", "$", "functionName", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type...
Adds an auth function of type: f(type, instance, function_name, arguments) => bool @param string $type @param string $functionName @param callable $function
[ "Adds", "an", "auth", "function", "of", "type", ":", "f", "(", "type", "instance", "function_name", "arguments", ")", "=", ">", "bool" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L87-L96
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addTypeAuthFunction
public function addTypeAuthFunction($type, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $function){ $this->tAuthFunctions[$type][] = $function; }, function($target) use ( $function){ $this->addTypeAuthFunction($target, $function); }); }
php
public function addTypeAuthFunction($type, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $function){ $this->tAuthFunctions[$type][] = $function; }, function($target) use ( $function){ $this->addTypeAuthFunction($target, $function); }); }
[ "public", "function", "addTypeAuthFunction", "(", "$", "type", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type", ",", "$", "function", ")"...
Adds an auth function of type: f(type, instance, function_name, arguments) => bool @param string $type @param callable $function
[ "Adds", "an", "auth", "function", "of", "type", ":", "f", "(", "type", "instance", "function_name", "arguments", ")", "=", ">", "bool" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L103-L111
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addFunction
public function addFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->customFunctions[$type][$name] = $function; }, function($target) use ( $function, $name){ $this->addFunction($target, $name, $function); }); }
php
public function addFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->customFunctions[$type][$name] = $function; }, function($target) use ( $function, $name){ $this->addFunction($target, $name, $function); }); }
[ "public", "function", "addFunction", "(", "$", "type", ",", "$", "name", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type", ",", "$", "...
Adds a function of type: f(instance, arguments ... ) => mixed @param string $type @param string $name @param callable $function
[ "Adds", "a", "function", "of", "type", ":", "f", "(", "instance", "arguments", "...", ")", "=", ">", "mixed" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L119-L128
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addTypePreCallFunction
public function addTypePreCallFunction($type, callable $function) { if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { $this->addTypePreCallFunction($target, $function); } return; } $this->tPreCallFunctions[$type][] = $function; }
php
public function addTypePreCallFunction($type, callable $function) { if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { $this->addTypePreCallFunction($target, $function); } return; } $this->tPreCallFunctions[$type][] = $function; }
[ "public", "function", "addTypePreCallFunction", "(", "$", "type", ",", "callable", "$", "function", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "alias", "[", "$", "type", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "alias", "[", ...
If added function will be called before the function. The function should be of type : f(instance, &arguments) => void @param $type @param callable $function
[ "If", "added", "function", "will", "be", "called", "before", "the", "function", ".", "The", "function", "should", "be", "of", "type", ":", "f", "(", "instance", "&arguments", ")", "=", ">", "void" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L156-L166
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addTypePostCallFunction
public function addTypePostCallFunction($type, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $function){ $this->tPostCallFunctions[$type][] = $function; }, function($target) use ( $function){ $this->addTypePostCallFunction($target, $function); }); }
php
public function addTypePostCallFunction($type, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $function){ $this->tPostCallFunctions[$type][] = $function; }, function($target) use ( $function){ $this->addTypePostCallFunction($target, $function); }); }
[ "public", "function", "addTypePostCallFunction", "(", "$", "type", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type", ",", "$", "function", ...
If added function will be called after the function. The function should be of type : f(instance, &result) => void @param $type @param callable $function
[ "If", "added", "function", "will", "be", "called", "after", "the", "function", ".", "The", "function", "should", "be", "of", "type", ":", "f", "(", "instance", "&result", ")", "=", ">", "void" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L174-L185
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addFunctionPreCallFunction
public function addFunctionPreCallFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->fnPreCallFunctions[$type][$name][] = $function; }, function($target) use ( $function, $name){ $this->addFunctionPreCallFunction($target, $name, $function); }); }
php
public function addFunctionPreCallFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->fnPreCallFunctions[$type][$name][] = $function; }, function($target) use ( $function, $name){ $this->addFunctionPreCallFunction($target, $name, $function); }); }
[ "public", "function", "addFunctionPreCallFunction", "(", "$", "type", ",", "$", "name", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type", ...
If added function will be called before the function. The function should be of type : f(instance, &arguments) => void @param $type @param $name @param callable $function
[ "If", "added", "function", "will", "be", "called", "before", "the", "function", ".", "The", "function", "should", "be", "of", "type", ":", "f", "(", "instance", "&arguments", ")", "=", ">", "void" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L194-L203
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addFunctionPostCallFunction
public function addFunctionPostCallFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->fnPostCallFunctions[$type][$name][] = $function; }, function($target) use ( $function, $name){ $this->addFunctionPostCallFunction($target, $name, $function); }); }
php
public function addFunctionPostCallFunction($type, $name, callable $function) { $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $name, $function){ $this->fnPostCallFunctions[$type][$name][] = $function; }, function($target) use ( $function, $name){ $this->addFunctionPostCallFunction($target, $name, $function); }); }
[ "public", "function", "addFunctionPostCallFunction", "(", "$", "type", ",", "$", "name", ",", "callable", "$", "function", ")", "{", "$", "this", "->", "appendToArrayOrCallForEachAlias", "(", "$", "type", ",", "function", "(", ")", "use", "(", "$", "type", ...
If added function will be called after the function. The function should be of type : f(instance, &result) => void @param $type @param $name @param callable $function
[ "If", "added", "function", "will", "be", "called", "after", "the", "function", ".", "The", "function", "should", "be", "of", "type", ":", "f", "(", "instance", "&result", ")", "=", ">", "void" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L212-L221
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.whitelistType
public function whitelistType($type) { foreach (func_get_args() as $arg) { if (!in_array($arg, $this->types)) { continue; } if (isset($this->alias[$arg])) { call_user_func_array([$this, "whitelistType"], $this->alias[$arg]); } $this->typeWhitelist[] = $arg; } }
php
public function whitelistType($type) { foreach (func_get_args() as $arg) { if (!in_array($arg, $this->types)) { continue; } if (isset($this->alias[$arg])) { call_user_func_array([$this, "whitelistType"], $this->alias[$arg]); } $this->typeWhitelist[] = $arg; } }
[ "public", "function", "whitelistType", "(", "$", "type", ")", "{", "foreach", "(", "func_get_args", "(", ")", "as", "$", "arg", ")", "{", "if", "(", "!", "in_array", "(", "$", "arg", ",", "$", "this", "->", "types", ")", ")", "{", "continue", ";", ...
Whitelists a type, if no type is whitelisted; all found types are whitelisted. @param string $type , ...
[ "Whitelists", "a", "type", "if", "no", "type", "is", "whitelisted", ";", "all", "found", "types", "are", "whitelisted", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L227-L240
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.whitelistFunction
public function whitelistFunction($type, $functionName) { if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { call_user_func_array([$this, "whitelistFunction"], array_merge([$target], array_slice(func_get_args(), 1))); } return; } $first = true; foreach (func_get_args() as $arg) { if ($first) { $first = false; continue; } $this->functionWhitelist[$type][] = $arg; } }
php
public function whitelistFunction($type, $functionName) { if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { call_user_func_array([$this, "whitelistFunction"], array_merge([$target], array_slice(func_get_args(), 1))); } return; } $first = true; foreach (func_get_args() as $arg) { if ($first) { $first = false; continue; } $this->functionWhitelist[$type][] = $arg; } }
[ "public", "function", "whitelistFunction", "(", "$", "type", ",", "$", "functionName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "alias", "[", "$", "type", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "alias", "[", "$", "type"...
Whitelists a function, if no function is whitelisted; all found types are whitelisted. @param string $type @param string $functionName , ...
[ "Whitelists", "a", "function", "if", "no", "function", "is", "whitelisted", ";", "all", "found", "types", "are", "whitelisted", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L247-L268
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.setUp
public function setUp(Server $server, $type) { if (in_array($type, $this->hasBeenSetUp)) { return; } $this->hasBeenSetUp[] = $type; if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { $this->setUp($server, $target); } return; } if (!class_exists($type) && !interface_exists($type)) { return; } $methods = (new ReflectionClass($type))->getMethods(); $this->functions[$type] = array_map(function (ReflectionMethod $method) { return $method->getName(); }, $methods); if (!isset($this->functionWhitelist[$type])) { return; } foreach ($this->functionWhitelist[$type] as $k => $fn) { if (in_array($fn, $this->functions[$type]) || (isset($this->customFunctions[$type], $this->customFunctions[$type][$fn]))) { continue; } unset($this->functionWhitelist[$type][$k]); } }
php
public function setUp(Server $server, $type) { if (in_array($type, $this->hasBeenSetUp)) { return; } $this->hasBeenSetUp[] = $type; if (isset($this->alias[$type])) { foreach ($this->alias[$type] as $target) { $this->setUp($server, $target); } return; } if (!class_exists($type) && !interface_exists($type)) { return; } $methods = (new ReflectionClass($type))->getMethods(); $this->functions[$type] = array_map(function (ReflectionMethod $method) { return $method->getName(); }, $methods); if (!isset($this->functionWhitelist[$type])) { return; } foreach ($this->functionWhitelist[$type] as $k => $fn) { if (in_array($fn, $this->functions[$type]) || (isset($this->customFunctions[$type], $this->customFunctions[$type][$fn]))) { continue; } unset($this->functionWhitelist[$type][$k]); } }
[ "public", "function", "setUp", "(", "Server", "$", "server", ",", "$", "type", ")", "{", "if", "(", "in_array", "(", "$", "type", ",", "$", "this", "->", "hasBeenSetUp", ")", ")", "{", "return", ";", "}", "$", "this", "->", "hasBeenSetUp", "[", "]"...
Sets up the type handler for provided type. This should be called for each registered type. @param Server $server The server which is setting-up the handler @param string $type The type currently being set-up @return void
[ "Sets", "up", "the", "type", "handler", "for", "provided", "type", ".", "This", "should", "be", "called", "for", "each", "registered", "type", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L278-L311
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.canHandle
public function canHandle($type, JSONFunction $function, $instance = null) { if (isset($this->alias[$type])) { $canHandle = false; foreach ($this->alias[$type] as $target) { $canHandle = $canHandle || $this->canHandle($target, $function, $instance); } return $canHandle; } $name = $function->getName(); if (!$this->hasFunction($type, $name)) { return false; } $instance = $instance == null ? $this->object : $instance; $args = $function->getArgs(); /** @var \ReflectionParameter[] $parameters */ $parameters = null; $this->callPreCallFunctions($type, $instance, $name, $args); if (isset($this->customFunctions[$type][$name])) { $parameters = (new \ReflectionFunction($this->customFunctions[$type][$name]))->getParameters(); $args = array_merge([$instance], $args); } else if ($instance != null && isset($this->functions[$type]) && in_array($name, $this->functions[$type])) { $parameters = (new \ReflectionMethod($instance, $name))->getParameters(); } if ($parameters === null) { return false; } return $this->parametersCheck($args, $parameters); }
php
public function canHandle($type, JSONFunction $function, $instance = null) { if (isset($this->alias[$type])) { $canHandle = false; foreach ($this->alias[$type] as $target) { $canHandle = $canHandle || $this->canHandle($target, $function, $instance); } return $canHandle; } $name = $function->getName(); if (!$this->hasFunction($type, $name)) { return false; } $instance = $instance == null ? $this->object : $instance; $args = $function->getArgs(); /** @var \ReflectionParameter[] $parameters */ $parameters = null; $this->callPreCallFunctions($type, $instance, $name, $args); if (isset($this->customFunctions[$type][$name])) { $parameters = (new \ReflectionFunction($this->customFunctions[$type][$name]))->getParameters(); $args = array_merge([$instance], $args); } else if ($instance != null && isset($this->functions[$type]) && in_array($name, $this->functions[$type])) { $parameters = (new \ReflectionMethod($instance, $name))->getParameters(); } if ($parameters === null) { return false; } return $this->parametersCheck($args, $parameters); }
[ "public", "function", "canHandle", "(", "$", "type", ",", "JSONFunction", "$", "function", ",", "$", "instance", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "alias", "[", "$", "type", "]", ")", ")", "{", "$", "canHandle", "="...
Checks if handler can handle. If so handle will be called with same arguments, else next suitable handler will be called. @param string $type @param \ChristianBudde\Part\controller\json\JSONFunction $function @param mixed $instance @return bool
[ "Checks", "if", "handler", "can", "handle", ".", "If", "so", "handle", "will", "be", "called", "with", "same", "arguments", "else", "next", "suitable", "handler", "will", "be", "called", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L365-L401
budde377/Part
lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php
GenericObjectTypeHandlerImpl.addAlias
public function addAlias($alias, array $target) { $this->alias[$alias] = isset($this->alias[$alias]) ? array_merge($this->alias[$alias], $target) : $target; if (in_array($alias, $this->types)) { return; } $this->types[] = $alias; }
php
public function addAlias($alias, array $target) { $this->alias[$alias] = isset($this->alias[$alias]) ? array_merge($this->alias[$alias], $target) : $target; if (in_array($alias, $this->types)) { return; } $this->types[] = $alias; }
[ "public", "function", "addAlias", "(", "$", "alias", ",", "array", "$", "target", ")", "{", "$", "this", "->", "alias", "[", "$", "alias", "]", "=", "isset", "(", "$", "this", "->", "alias", "[", "$", "alias", "]", ")", "?", "array_merge", "(", "...
Adds an alias. If the alias already exists the types are merged. @param string $alias @param array $target
[ "Adds", "an", "alias", ".", "If", "the", "alias", "already", "exists", "the", "types", "are", "merged", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/GenericObjectTypeHandlerImpl.php#L602-L611
budde377/Part
lib/controller/ajax/type_handler/ArrayAccessTypeHandlerImpl.php
ArrayAccessTypeHandlerImpl.canHandle
public function canHandle($type, JSONFunction $function, $instance = null) { return $function->getName() == "arrayAccess" && (isset($this->arrays[$type]) || ($type == "array" && is_array($instance))); }
php
public function canHandle($type, JSONFunction $function, $instance = null) { return $function->getName() == "arrayAccess" && (isset($this->arrays[$type]) || ($type == "array" && is_array($instance))); }
[ "public", "function", "canHandle", "(", "$", "type", ",", "JSONFunction", "$", "function", ",", "$", "instance", "=", "null", ")", "{", "return", "$", "function", "->", "getName", "(", ")", "==", "\"arrayAccess\"", "&&", "(", "isset", "(", "$", "this", ...
Checks if handler can handle. If so handle will be called with same arguments, else next suitable handler will be called. @param string $type @param \ChristianBudde\Part\controller\json\JSONFunction $function @param mixed $instance @return bool
[ "Checks", "if", "handler", "can", "handle", ".", "If", "so", "handle", "will", "be", "called", "with", "same", "arguments", "else", "next", "suitable", "handler", "will", "be", "called", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/ArrayAccessTypeHandlerImpl.php#L43-L46
venca-x/social-login
src/GoogleLogin.php
GoogleLogin.getMe
public function getMe($code) { $google_oauthV2 = new \Google_Service_Oauth2($this->client); try { $this->client->authenticate($code); $user = $google_oauthV2->userinfo->get(); } catch (\Google_Auth_Exception $e) { throw new Exception($e->getMessage()); } $this->setSocialLoginCookie(self::SOCIAL_NAME); return $user; }
php
public function getMe($code) { $google_oauthV2 = new \Google_Service_Oauth2($this->client); try { $this->client->authenticate($code); $user = $google_oauthV2->userinfo->get(); } catch (\Google_Auth_Exception $e) { throw new Exception($e->getMessage()); } $this->setSocialLoginCookie(self::SOCIAL_NAME); return $user; }
[ "public", "function", "getMe", "(", "$", "code", ")", "{", "$", "google_oauthV2", "=", "new", "\\", "Google_Service_Oauth2", "(", "$", "this", "->", "client", ")", ";", "try", "{", "$", "this", "->", "client", "->", "authenticate", "(", "$", "code", ")...
Return info about login user @param $code @return \Google_Service_Oauth2_Userinfoplus @throws Exception
[ "Return", "info", "about", "login", "user" ]
train
https://github.com/venca-x/social-login/blob/ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab/src/GoogleLogin.php#L80-L94
scherersoftware/cake-model-history
src/Model/Transform/MassAssociationTransform.php
MassAssociationTransform.save
public function save(string $fieldname, array $config, EntityInterface $entity = null) { if (!empty($entity[$config['name']])) { $assocData = $entity[$config['name']]; if (is_array($assocData)) { $data = []; foreach ($assocData as $assocEntity) { $entityTable = TableRegistry::get($assocEntity->source()); $data[] = $assocEntity->{$entityTable->displayField()}; } return $data; } } return $entity[$config['name']]; }
php
public function save(string $fieldname, array $config, EntityInterface $entity = null) { if (!empty($entity[$config['name']])) { $assocData = $entity[$config['name']]; if (is_array($assocData)) { $data = []; foreach ($assocData as $assocEntity) { $entityTable = TableRegistry::get($assocEntity->source()); $data[] = $assocEntity->{$entityTable->displayField()}; } return $data; } } return $entity[$config['name']]; }
[ "public", "function", "save", "(", "string", "$", "fieldname", ",", "array", "$", "config", ",", "EntityInterface", "$", "entity", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "entity", "[", "$", "config", "[", "'name'", "]", "]", ")", ...
Amend the data before saving. @param string $fieldname Field name @param array $config field config @param \Cake\Datasource\EntityInterface $entity entity @return mixed
[ "Amend", "the", "data", "before", "saving", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/MassAssociationTransform.php#L20-L36
scherersoftware/cake-model-history
src/Model/Transform/MassAssociationTransform.php
MassAssociationTransform.display
public function display(string $fieldname, $value, string $model = null) { if (is_array($value)) { return implode(', ', $value); } $tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldname))); $table = TableRegistry::get($tableName); $tableConfig = []; $historizableBehavior = TableRegistry::get($model, $tableConfig)->behaviors()->get('Historizable'); if (is_object($historizableBehavior) && method_exists($historizableBehavior, 'getRelationLink')) { return $historizableBehavior->getRelationLink($fieldname, $value); } return $value; }
php
public function display(string $fieldname, $value, string $model = null) { if (is_array($value)) { return implode(', ', $value); } $tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldname))); $table = TableRegistry::get($tableName); $tableConfig = []; $historizableBehavior = TableRegistry::get($model, $tableConfig)->behaviors()->get('Historizable'); if (is_object($historizableBehavior) && method_exists($historizableBehavior, 'getRelationLink')) { return $historizableBehavior->getRelationLink($fieldname, $value); } return $value; }
[ "public", "function", "display", "(", "string", "$", "fieldname", ",", "$", "value", ",", "string", "$", "model", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "implode", "(", "', '", ",", "$", "value", "...
Amend the data before displaying. @param string $fieldname Field name @param mixed $value Value to be amended @param string $model Optional model to be used @return mixed
[ "Amend", "the", "data", "before", "displaying", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/MassAssociationTransform.php#L46-L63
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/AdminController.php
AdminController.index
public function index() { return View::make('core::admin.index') ->with('users', $this->users->all()) ->with('user', $this->auth->user()) ->with('locale', $this->loadLanguage()); }
php
public function index() { return View::make('core::admin.index') ->with('users', $this->users->all()) ->with('user', $this->auth->user()) ->with('locale', $this->loadLanguage()); }
[ "public", "function", "index", "(", ")", "{", "return", "View", "::", "make", "(", "'core::admin.index'", ")", "->", "with", "(", "'users'", ",", "$", "this", "->", "users", "->", "all", "(", ")", ")", "->", "with", "(", "'user'", ",", "$", "this", ...
Get the main admin view.
[ "Get", "the", "main", "admin", "view", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/AdminController.php#L35-L41
skrz/meta
src/Skrz/Meta/Reflection/MixedType.php
MixedType.fromString
public static function fromString($string) { $lowercaseString = trim(strtolower($string), "\\"); // TODO: variant types if ($lowercaseString === "mixed") { return MixedType::getInstance(); } elseif ($lowercaseString === "scalar") { return ScalarType::getInstance(); } elseif ($lowercaseString === "object") { return ObjectType::getInstance(); } elseif ($lowercaseString === "void" || $lowercaseString === "null") { return VoidType::getInstance(); } elseif ($lowercaseString === "numeric" || $lowercaseString === "number") { return NumericType::getInstance(); } elseif ($lowercaseString === "int" || $lowercaseString === "integer") { return IntType::getInstance(); } elseif ($lowercaseString === "float" || $lowercaseString === "double") { return FloatType::getInstance(); } elseif ($lowercaseString === "bool" || $lowercaseString === "boolean") { return BoolType::getInstance(); } elseif ($lowercaseString === "string") { return StringType::getInstance(); } elseif ($lowercaseString === "resource" || $lowercaseString === "stream") { return ResourceType::getInstance(); } elseif ($lowercaseString === "callable" || $lowercaseString === "callback" || trim($lowercaseString, "\\") === "closure") { return CallableType::getInstance(); } elseif (strncmp($lowercaseString, "array", 5 /* strlen("array") */) === 0) { return ArrayType::create(MixedType::getInstance()); } else { if (func_num_args() > 1) { $stack = func_get_arg(1); } else { $stack = new \ArrayObject(); } if (func_num_args() > 2) { $reader = func_get_arg(2); } else { $reader = new AnnotationReader(); } if (func_num_args() > 3) { $phpParser = func_get_arg(3); } else { $phpParser = new PhpParser(); } if (func_num_args() > 4 && func_get_arg(4) !== null) { /** @var Type $declaringType */ $declaringType = func_get_arg(4); $useStatements = $declaringType->getUseStatements(); } else { $declaringType = null; $useStatements = array(); } if ($lowercaseString === "\$this" || $lowercaseString === "self" || $lowercaseString === "static") { if ($declaringType === null) { throw new \InvalidArgumentException("Type string references declaring class, but no declaring class given."); } return $declaringType; } elseif (substr($string, -2) === "[]") { $baseString = substr($string, 0, strlen($string) - 2); return ArrayType::create(MixedType::fromString($baseString, $stack, $reader, $phpParser, $declaringType)); } else { if ($string[0] === "\\") { $typeName = trim($string, "\\"); } elseif (isset($useStatements[$lowercaseString])) { $typeName = $useStatements[$lowercaseString]; // TODO: `use` with namespace (e.g. `use Doctrine\Mapping as ORM;`) } elseif ($declaringType !== null) { $typeName = $declaringType->getNamespaceName() . "\\" . $string; } else { $typeName = $string; } return Type::fromReflection(new \ReflectionClass($typeName), $stack, $reader, $phpParser); } } }
php
public static function fromString($string) { $lowercaseString = trim(strtolower($string), "\\"); // TODO: variant types if ($lowercaseString === "mixed") { return MixedType::getInstance(); } elseif ($lowercaseString === "scalar") { return ScalarType::getInstance(); } elseif ($lowercaseString === "object") { return ObjectType::getInstance(); } elseif ($lowercaseString === "void" || $lowercaseString === "null") { return VoidType::getInstance(); } elseif ($lowercaseString === "numeric" || $lowercaseString === "number") { return NumericType::getInstance(); } elseif ($lowercaseString === "int" || $lowercaseString === "integer") { return IntType::getInstance(); } elseif ($lowercaseString === "float" || $lowercaseString === "double") { return FloatType::getInstance(); } elseif ($lowercaseString === "bool" || $lowercaseString === "boolean") { return BoolType::getInstance(); } elseif ($lowercaseString === "string") { return StringType::getInstance(); } elseif ($lowercaseString === "resource" || $lowercaseString === "stream") { return ResourceType::getInstance(); } elseif ($lowercaseString === "callable" || $lowercaseString === "callback" || trim($lowercaseString, "\\") === "closure") { return CallableType::getInstance(); } elseif (strncmp($lowercaseString, "array", 5 /* strlen("array") */) === 0) { return ArrayType::create(MixedType::getInstance()); } else { if (func_num_args() > 1) { $stack = func_get_arg(1); } else { $stack = new \ArrayObject(); } if (func_num_args() > 2) { $reader = func_get_arg(2); } else { $reader = new AnnotationReader(); } if (func_num_args() > 3) { $phpParser = func_get_arg(3); } else { $phpParser = new PhpParser(); } if (func_num_args() > 4 && func_get_arg(4) !== null) { /** @var Type $declaringType */ $declaringType = func_get_arg(4); $useStatements = $declaringType->getUseStatements(); } else { $declaringType = null; $useStatements = array(); } if ($lowercaseString === "\$this" || $lowercaseString === "self" || $lowercaseString === "static") { if ($declaringType === null) { throw new \InvalidArgumentException("Type string references declaring class, but no declaring class given."); } return $declaringType; } elseif (substr($string, -2) === "[]") { $baseString = substr($string, 0, strlen($string) - 2); return ArrayType::create(MixedType::fromString($baseString, $stack, $reader, $phpParser, $declaringType)); } else { if ($string[0] === "\\") { $typeName = trim($string, "\\"); } elseif (isset($useStatements[$lowercaseString])) { $typeName = $useStatements[$lowercaseString]; // TODO: `use` with namespace (e.g. `use Doctrine\Mapping as ORM;`) } elseif ($declaringType !== null) { $typeName = $declaringType->getNamespaceName() . "\\" . $string; } else { $typeName = $string; } return Type::fromReflection(new \ReflectionClass($typeName), $stack, $reader, $phpParser); } } }
[ "public", "static", "function", "fromString", "(", "$", "string", ")", "{", "$", "lowercaseString", "=", "trim", "(", "strtolower", "(", "$", "string", ")", ",", "\"\\\\\"", ")", ";", "// TODO: variant types", "if", "(", "$", "lowercaseString", "===", "\"mix...
Type string @param string $string @throws \InvalidArgumentException @return ArrayType|BoolType|CallableType|FloatType|IntType|MixedType|ResourceType|StringType|Type
[ "Type", "string" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Reflection/MixedType.php#L37-L136
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.getPageOrder
public function getPageOrder(Page $parentPage = null) { if ($parentPage instanceof Page) { $parentPageString = $parentPage->getID(); } else { $parentPageString = ''; } if (!isset($this->pageOrder[$parentPageString])) { return []; } $retArray = []; foreach ($this->pageOrder[$parentPageString] as $id) { $retArray[] = $this->activePages[$id]; } return $retArray; }
php
public function getPageOrder(Page $parentPage = null) { if ($parentPage instanceof Page) { $parentPageString = $parentPage->getID(); } else { $parentPageString = ''; } if (!isset($this->pageOrder[$parentPageString])) { return []; } $retArray = []; foreach ($this->pageOrder[$parentPageString] as $id) { $retArray[] = $this->activePages[$id]; } return $retArray; }
[ "public", "function", "getPageOrder", "(", "Page", "$", "parentPage", "=", "null", ")", "{", "if", "(", "$", "parentPage", "instanceof", "Page", ")", "{", "$", "parentPageString", "=", "$", "parentPage", "->", "getID", "(", ")", ";", "}", "else", "{", ...
This will return pageOrder. If null is given, it will return top-level order, else if valid page id is given, it will return the order of the sub-list. The return array will, if non-empty, contain instances of Page If invalid id is provided, it will return empty array @param null|Page $parentPage @throws MalformedParameterException @return array
[ "This", "will", "return", "pageOrder", ".", "If", "null", "is", "given", "it", "will", "return", "top", "-", "level", "order", "else", "if", "valid", "page", "id", "is", "given", "it", "will", "return", "the", "order", "of", "the", "sub", "-", "list", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L86-L103
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.setPageOrder
public function setPageOrder(Page $page, $place = PageOrder::PAGE_ORDER_LAST, Page $parentPage = null) { if ($parentPage instanceof Page) { if ($this->findPage($parentPage) !== false) { $parentPageId = $parentPage->getID(); } else { return false; } } else { $parentPageId = ''; } if (!isset($this->pageOrder[$parentPageId])) { $this->pageOrder[$parentPageId] = []; } $findPage = $this->findPage($page); if ($findPage === false || $this->detectLoop($page->getID(), $parentPageId)) { return false; } if ($findPage == 'active') { $this->removeIDFromSubLists($page->getID()); } else { $this->activatePageId($page->getID()); } $this->connection->beginTransaction(); $this->insertPageID($page->getID(), $place, $parentPageId); $this->connection->commit(); return true; }
php
public function setPageOrder(Page $page, $place = PageOrder::PAGE_ORDER_LAST, Page $parentPage = null) { if ($parentPage instanceof Page) { if ($this->findPage($parentPage) !== false) { $parentPageId = $parentPage->getID(); } else { return false; } } else { $parentPageId = ''; } if (!isset($this->pageOrder[$parentPageId])) { $this->pageOrder[$parentPageId] = []; } $findPage = $this->findPage($page); if ($findPage === false || $this->detectLoop($page->getID(), $parentPageId)) { return false; } if ($findPage == 'active') { $this->removeIDFromSubLists($page->getID()); } else { $this->activatePageId($page->getID()); } $this->connection->beginTransaction(); $this->insertPageID($page->getID(), $place, $parentPageId); $this->connection->commit(); return true; }
[ "public", "function", "setPageOrder", "(", "Page", "$", "page", ",", "$", "place", "=", "PageOrder", "::", "PAGE_ORDER_LAST", ",", "Page", "$", "parentPage", "=", "null", ")", "{", "if", "(", "$", "parentPage", "instanceof", "Page", ")", "{", "if", "(", ...
This will set the pageOrder of given Page. There must not be created loops and parent/id must be valid Page (and existing), else the function will fail and return FALSE. If proper id('s) and no loops created, function will return TRUE @param Page $page @param int $place @param null | Page $parentPage @throws \ChristianBudde\Part\exception\MalformedParameterException @return bool
[ "This", "will", "set", "the", "pageOrder", "of", "given", "Page", ".", "There", "must", "not", "be", "created", "loops", "and", "parent", "/", "id", "must", "be", "valid", "Page", "(", "and", "existing", ")", "else", "the", "function", "will", "fail", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L116-L146
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.listPages
public function listPages($listMode = PageOrder::LIST_ALL) { $retArray = array(); if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) { foreach ($this->inactivePages as $page) { $retArray[] = $page; } } if ($listMode == PageOrder::LIST_ALL || $listMode == PageOrder::LIST_ACTIVE) { foreach ($this->activePages as $page) { $retArray[] = $page; } } return $retArray; }
php
public function listPages($listMode = PageOrder::LIST_ALL) { $retArray = array(); if ($listMode == PageOrder::LIST_INACTIVE || $listMode == PageOrder::LIST_ALL) { foreach ($this->inactivePages as $page) { $retArray[] = $page; } } if ($listMode == PageOrder::LIST_ALL || $listMode == PageOrder::LIST_ACTIVE) { foreach ($this->activePages as $page) { $retArray[] = $page; } } return $retArray; }
[ "public", "function", "listPages", "(", "$", "listMode", "=", "PageOrder", "::", "LIST_ALL", ")", "{", "$", "retArray", "=", "array", "(", ")", ";", "if", "(", "$", "listMode", "==", "PageOrder", "::", "LIST_INACTIVE", "||", "$", "listMode", "==", "PageO...
Will list all pages in an array as instances of Page @param int $listMode Must be of ListPageEnum @return array
[ "Will", "list", "all", "pages", "in", "an", "array", "as", "instances", "of", "Page" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L163-L179
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.deactivatePage
public function deactivatePage(Page $page) { if (!$this->isActive($page)) { return; } $this->deactivatePageId($page->getID()); }
php
public function deactivatePage(Page $page) { if (!$this->isActive($page)) { return; } $this->deactivatePageId($page->getID()); }
[ "public", "function", "deactivatePage", "(", "Page", "$", "page", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", "(", "$", "page", ")", ")", "{", "return", ";", "}", "$", "this", "->", "deactivatePageId", "(", "$", "page", "->", "getID", ...
Will deactivate a page and all it's sub pages. The page order remains the same @param Page $page @return void
[ "Will", "deactivate", "a", "page", "and", "all", "it", "s", "sub", "pages", ".", "The", "page", "order", "remains", "the", "same" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L223-L232
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.deletePage
public function deletePage(Page $page) { $findPage = $this->findPage($page); if ($findPage === false) { return false; } $deleteStm = $this->connection->prepare("DELETE FROM Page WHERE page_id=?"); $deleteStm->execute([$page->getID()]); if (!$deleteStm->rowCount() > 0) { return false; } if ($findPage == 'active') { unset($this->activePages[$page->getID()]); } else { unset($this->inactivePages[$page->getID()]); } return true; }
php
public function deletePage(Page $page) { $findPage = $this->findPage($page); if ($findPage === false) { return false; } $deleteStm = $this->connection->prepare("DELETE FROM Page WHERE page_id=?"); $deleteStm->execute([$page->getID()]); if (!$deleteStm->rowCount() > 0) { return false; } if ($findPage == 'active') { unset($this->activePages[$page->getID()]); } else { unset($this->inactivePages[$page->getID()]); } return true; }
[ "public", "function", "deletePage", "(", "Page", "$", "page", ")", "{", "$", "findPage", "=", "$", "this", "->", "findPage", "(", "$", "page", ")", ";", "if", "(", "$", "findPage", "===", "false", ")", "{", "return", "false", ";", "}", "$", "delete...
This will delete a page from page order and in general @param Page $page @return bool
[ "This", "will", "delete", "a", "page", "from", "page", "order", "and", "in", "general" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L262-L281
budde377/Part
lib/model/page/PageOrderImpl.php
PageOrderImpl.getPagePath
public function getPagePath(Page $page) { if (($status = $this->findPage($page)) == 'inactive') { return array(); } else if ($status === false) { return false; } return $this->recursiveCalculatePath($page); }
php
public function getPagePath(Page $page) { if (($status = $this->findPage($page)) == 'inactive') { return array(); } else if ($status === false) { return false; } return $this->recursiveCalculatePath($page); }
[ "public", "function", "getPagePath", "(", "Page", "$", "page", ")", "{", "if", "(", "(", "$", "status", "=", "$", "this", "->", "findPage", "(", "$", "page", ")", ")", "==", "'inactive'", ")", "{", "return", "array", "(", ")", ";", "}", "else", "...
Will return the path of an page as an array. If the page is at top level an array containing an single entrance will be returned Else a numeric array with the top level as first entrance, and lowest level as last entrance will be returned. If a page is inactive, an empty array will be returned. If a page is not found, FALSE will be returned. @param Page $page @return bool | array
[ "Will", "return", "the", "path", "of", "an", "page", "as", "an", "array", ".", "If", "the", "page", "is", "at", "top", "level", "an", "array", "containing", "an", "single", "entrance", "will", "be", "returned", "Else", "a", "numeric", "array", "with", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/PageOrderImpl.php#L377-L386
meare/juggler
src/HttpClient/GuzzleClient.php
GuzzleClient.convertToMountebankException
private function convertToMountebankException(ClientException $e) { return $this->exceptionFactory->createInstanceFromMountebankResponse( (string)$e->getResponse()->getBody() ); }
php
private function convertToMountebankException(ClientException $e) { return $this->exceptionFactory->createInstanceFromMountebankResponse( (string)$e->getResponse()->getBody() ); }
[ "private", "function", "convertToMountebankException", "(", "ClientException", "$", "e", ")", "{", "return", "$", "this", "->", "exceptionFactory", "->", "createInstanceFromMountebankResponse", "(", "(", "string", ")", "$", "e", "->", "getResponse", "(", ")", "->"...
Creates MountebankException instance from mountebank response @param ClientException $e @return MountebankException
[ "Creates", "MountebankException", "instance", "from", "mountebank", "response" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/HttpClient/GuzzleClient.php#L114-L119
meare/juggler
src/Exception/MountebankExceptionFactory.php
MountebankExceptionFactory.createInstanceFromMountebankResponse
public function createInstanceFromMountebankResponse($response_body) { $errors = \GuzzleHttp\json_decode($response_body, true)['errors']; $first_error = reset($errors); return $this->createInstance( $first_error['code'], $first_error['message'], isset($first_error['source']) ? $first_error['source'] : null, isset($first_error['data']) ? $first_error['data'] : null ); }
php
public function createInstanceFromMountebankResponse($response_body) { $errors = \GuzzleHttp\json_decode($response_body, true)['errors']; $first_error = reset($errors); return $this->createInstance( $first_error['code'], $first_error['message'], isset($first_error['source']) ? $first_error['source'] : null, isset($first_error['data']) ? $first_error['data'] : null ); }
[ "public", "function", "createInstanceFromMountebankResponse", "(", "$", "response_body", ")", "{", "$", "errors", "=", "\\", "GuzzleHttp", "\\", "json_decode", "(", "$", "response_body", ",", "true", ")", "[", "'errors'", "]", ";", "$", "first_error", "=", "re...
Takes first error from mountebank response and wraps it into according MountebankException @param string $response_body @return MountebankException
[ "Takes", "first", "error", "from", "mountebank", "response", "and", "wraps", "it", "into", "according", "MountebankException" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Exception/MountebankExceptionFactory.php#L37-L48
kaliop-uk/kueueingbundle
Adapter/RabbitMq/QueueManager.php
QueueManager.listQueues
public function listQueues($type = Queue::TYPE_ANY) { $out = array(); if ($type = Queue::TYPE_PRODUCER || $type = Queue::TYPE_ANY) { foreach ($this->registeredProducers as $queueName) { $out[$queueName] = Queue::TYPE_PRODUCER; } } if ($type = Queue::TYPE_CONSUMER || $type = Queue::TYPE_ANY) { foreach ($this->registeredConsumers as $queueName) { if (isset($out[$queueName])) { $out[$queueName] = Queue::TYPE_ANY; } else { $out[$queueName] = Queue::TYPE_CONSUMER; } } } return $out; }
php
public function listQueues($type = Queue::TYPE_ANY) { $out = array(); if ($type = Queue::TYPE_PRODUCER || $type = Queue::TYPE_ANY) { foreach ($this->registeredProducers as $queueName) { $out[$queueName] = Queue::TYPE_PRODUCER; } } if ($type = Queue::TYPE_CONSUMER || $type = Queue::TYPE_ANY) { foreach ($this->registeredConsumers as $queueName) { if (isset($out[$queueName])) { $out[$queueName] = Queue::TYPE_ANY; } else { $out[$queueName] = Queue::TYPE_CONSUMER; } } } return $out; }
[ "public", "function", "listQueues", "(", "$", "type", "=", "Queue", "::", "TYPE_ANY", ")", "{", "$", "out", "=", "array", "(", ")", ";", "if", "(", "$", "type", "=", "Queue", "::", "TYPE_PRODUCER", "||", "$", "type", "=", "Queue", "::", "TYPE_ANY", ...
Returns (if supported) an array of queues configured in the application. NB: these are the names of queues as seen by the app - NOT the queues available on the broker - NOT using the queues names used by the broker (unless those are always identical to the names used by the app) It is a bit dumb, but so far all we have found is to go through all services, and check based on names: @param int $type @return string[] index is queue name, value is queue type
[ "Returns", "(", "if", "supported", ")", "an", "array", "of", "queues", "configured", "in", "the", "application", ".", "NB", ":", "these", "are", "the", "names", "of", "queues", "as", "seen", "by", "the", "app", "-", "NOT", "the", "queues", "available", ...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/QueueManager.php#L128-L146
kaliop-uk/kueueingbundle
Adapter/RabbitMq/QueueManager.php
QueueManager.getProducerService
protected function getProducerService() { try { return $this->container->get('old_sound_rabbit_mq.' . $this->getQueueName() . '_consumer'); } catch (ServiceNotFoundException $e) { return $this->container->get('old_sound_rabbit_mq.' . $this->getQueueName() . '_producer'); } }
php
protected function getProducerService() { try { return $this->container->get('old_sound_rabbit_mq.' . $this->getQueueName() . '_consumer'); } catch (ServiceNotFoundException $e) { return $this->container->get('old_sound_rabbit_mq.' . $this->getQueueName() . '_producer'); } }
[ "protected", "function", "getProducerService", "(", ")", "{", "try", "{", "return", "$", "this", "->", "container", "->", "get", "(", "'old_sound_rabbit_mq.'", ".", "$", "this", "->", "getQueueName", "(", ")", ".", "'_consumer'", ")", ";", "}", "catch", "(...
Hack: generally queues are defined consumer-side, so we try that 1st and producer-side 2nd (but that only gives us channel usually). Note also that we bypass the driver here, as this message producer is quite specific
[ "Hack", ":", "generally", "queues", "are", "defined", "consumer", "-", "side", "so", "we", "try", "that", "1st", "and", "producer", "-", "side", "2nd", "(", "but", "that", "only", "gives", "us", "channel", "usually", ")", ".", "Note", "also", "that", "...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/QueueManager.php#L191-L198
baleen/migrations
src/Delta/Comparator/ReversedComparator.php
ReversedComparator.compare
public function compare(DeltaInterface $version1, DeltaInterface $version2) { return $this->internalComparator->compare($version1, $version2) * -1; }
php
public function compare(DeltaInterface $version1, DeltaInterface $version2) { return $this->internalComparator->compare($version1, $version2) * -1; }
[ "public", "function", "compare", "(", "DeltaInterface", "$", "version1", ",", "DeltaInterface", "$", "version2", ")", "{", "return", "$", "this", "->", "internalComparator", "->", "compare", "(", "$", "version1", ",", "$", "version2", ")", "*", "-", "1", "...
Compares two versions with each other using the internal comparator, and returns the opposite result. @param DeltaInterface $version1 @param DeltaInterface $version2 @return int
[ "Compares", "two", "versions", "with", "each", "other", "using", "the", "internal", "comparator", "and", "returns", "the", "opposite", "result", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Comparator/ReversedComparator.php#L52-L55
marvin255/bxcodegen
src/Bxcodegen.php
Bxcodegen.run
public function run($generatorName, CollectionInterface $operationOptions) { $generators = $this->options->get('generators'); if (!empty($generators[$generatorName]['class'])) { $arGenerator = $generators[$generatorName]; } else { throw new InvalidArgumentException( "Can't find {$generatorName} generator" ); } $class = $arGenerator['class']; unset($arGenerator['class']); $defaultGeneratorOptions = new Collection($arGenerator); $generator = new $class; return $generator->generate( $defaultGeneratorOptions->merge($operationOptions), $this->initLocator() ); }
php
public function run($generatorName, CollectionInterface $operationOptions) { $generators = $this->options->get('generators'); if (!empty($generators[$generatorName]['class'])) { $arGenerator = $generators[$generatorName]; } else { throw new InvalidArgumentException( "Can't find {$generatorName} generator" ); } $class = $arGenerator['class']; unset($arGenerator['class']); $defaultGeneratorOptions = new Collection($arGenerator); $generator = new $class; return $generator->generate( $defaultGeneratorOptions->merge($operationOptions), $this->initLocator() ); }
[ "public", "function", "run", "(", "$", "generatorName", ",", "CollectionInterface", "$", "operationOptions", ")", "{", "$", "generators", "=", "$", "this", "->", "options", "->", "get", "(", "'generators'", ")", ";", "if", "(", "!", "empty", "(", "$", "g...
Инициирует соответствующий генератор и запускает на выполнение. @param string $generatorName @param \marvin255\bxcodegen\service\options\CollectionInterface $options @return mixed @throws \InvalidArgumentException
[ "Инициирует", "соответствующий", "генератор", "и", "запускает", "на", "выполнение", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Bxcodegen.php#L58-L79
marvin255/bxcodegen
src/Bxcodegen.php
Bxcodegen.initLocator
protected function initLocator() { $services = $this->options->get('services'); if (is_array($services) && !$this->isServicesInited) { $this->isServicesInited = true; foreach ($services as $serviceName => $serviceDescription) { $instance = $this->instantiateFromArray($serviceDescription); $this->locator->set($serviceName, $instance); } } return $this->locator; }
php
protected function initLocator() { $services = $this->options->get('services'); if (is_array($services) && !$this->isServicesInited) { $this->isServicesInited = true; foreach ($services as $serviceName => $serviceDescription) { $instance = $this->instantiateFromArray($serviceDescription); $this->locator->set($serviceName, $instance); } } return $this->locator; }
[ "protected", "function", "initLocator", "(", ")", "{", "$", "services", "=", "$", "this", "->", "options", "->", "get", "(", "'services'", ")", ";", "if", "(", "is_array", "(", "$", "services", ")", "&&", "!", "$", "this", "->", "isServicesInited", ")"...
Инициирует сервисы, которые определены в настройках. @return \marvin255\bxcodegen\ServiceLocatorInterface
[ "Инициирует", "сервисы", "которые", "определены", "в", "настройках", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Bxcodegen.php#L86-L99
fab2s/NodalFlow
src/Flows/FlowEventAbstract.php
FlowEventAbstract.triggerEvent
protected function triggerEvent($eventName, NodeInterface $node = null) { if (isset($this->activeEvents[$eventName])) { $this->dispatcher->dispatch($eventName, $this->sharedEvent->setNode($node)); } return $this; }
php
protected function triggerEvent($eventName, NodeInterface $node = null) { if (isset($this->activeEvents[$eventName])) { $this->dispatcher->dispatch($eventName, $this->sharedEvent->setNode($node)); } return $this; }
[ "protected", "function", "triggerEvent", "(", "$", "eventName", ",", "NodeInterface", "$", "node", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "activeEvents", "[", "$", "eventName", "]", ")", ")", "{", "$", "this", "->", "dispatc...
@param string $eventName @param NodeInterface|null $node @return $this
[ "@param", "string", "$eventName", "@param", "NodeInterface|null", "$node" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowEventAbstract.php#L120-L127
fab2s/NodalFlow
src/Flows/FlowEventAbstract.php
FlowEventAbstract.listActiveEvent
protected function listActiveEvent($reload = false) { if (!isset($this->dispatcher) || (isset($this->activeEvents) && !$reload)) { return $this; } $this->activeEvents = []; $eventList = FlowEvent::getEventList(); $sortedListeners = $this->dispatcher->getListeners(); foreach ($sortedListeners as $eventName => $listeners) { if (isset($eventList[$eventName]) && !empty($listeners)) { $this->activeEvents[$eventName] = 1; } } return $this; }
php
protected function listActiveEvent($reload = false) { if (!isset($this->dispatcher) || (isset($this->activeEvents) && !$reload)) { return $this; } $this->activeEvents = []; $eventList = FlowEvent::getEventList(); $sortedListeners = $this->dispatcher->getListeners(); foreach ($sortedListeners as $eventName => $listeners) { if (isset($eventList[$eventName]) && !empty($listeners)) { $this->activeEvents[$eventName] = 1; } } return $this; }
[ "protected", "function", "listActiveEvent", "(", "$", "reload", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dispatcher", ")", "||", "(", "isset", "(", "$", "this", "->", "activeEvents", ")", "&&", "!", "$", "reload", ")"...
@param bool $reload @return $this
[ "@param", "bool", "$reload" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowEventAbstract.php#L134-L150
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.containsFile
public function containsFile(File $file) { if(!$file->exists()){ return false; } $p1 = $this->filesDir->getAbsolutePath(); $p2 = $file->getParentFolder()->getParentFolder()->getAbsolutePath(); return $p1 == $p2; }
php
public function containsFile(File $file) { if(!$file->exists()){ return false; } $p1 = $this->filesDir->getAbsolutePath(); $p2 = $file->getParentFolder()->getParentFolder()->getAbsolutePath(); return $p1 == $p2; }
[ "public", "function", "containsFile", "(", "File", "$", "file", ")", "{", "if", "(", "!", "$", "file", "->", "exists", "(", ")", ")", "{", "return", "false", ";", "}", "$", "p1", "=", "$", "this", "->", "filesDir", "->", "getAbsolutePath", "(", ")"...
Check if file is in library @param File $file @return bool TRUE if contained in library else FASLE
[ "Check", "if", "file", "is", "in", "library" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L37-L45
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.removeFromWhitelist
public function removeFromWhitelist(File $file) { if(!$this->whitelistContainsFile($file)){ return false; } if(($key = array_search($this->filePath($file), $this->whiteList)) !== false) { unset($this->whiteList[$key]); } $this->writeWhitelist(); return !$this->whitelistContainsFile($file); }
php
public function removeFromWhitelist(File $file) { if(!$this->whitelistContainsFile($file)){ return false; } if(($key = array_search($this->filePath($file), $this->whiteList)) !== false) { unset($this->whiteList[$key]); } $this->writeWhitelist(); return !$this->whitelistContainsFile($file); }
[ "public", "function", "removeFromWhitelist", "(", "File", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "whitelistContainsFile", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "$", "key", "=", "array_search", ...
Remove a file from the whitelist @param File $file @return boolean TRUE on success else FALSE
[ "Remove", "a", "file", "from", "the", "whitelist" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L110-L121
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.addToLibrary
public function addToLibrary(User $user, File $file) { $folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId()); $ext = $file->getExtension() == ""?"":".".$file->getExtension(); $name = str_replace(".", "", uniqid("",true)).$ext; return $this->addToLibraryHelper($folder, $file, $name); }
php
public function addToLibrary(User $user, File $file) { $folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId()); $ext = $file->getExtension() == ""?"":".".$file->getExtension(); $name = str_replace(".", "", uniqid("",true)).$ext; return $this->addToLibraryHelper($folder, $file, $name); }
[ "public", "function", "addToLibrary", "(", "User", "$", "user", ",", "File", "$", "file", ")", "{", "$", "folder", "=", "new", "FolderImpl", "(", "$", "this", "->", "filesDir", "->", "getAbsolutePath", "(", ")", ".", "\"/\"", ".", "$", "user", "->", ...
This will copy the file given to a implementation specific location. @param \ChristianBudde\Part\model\user\User $user The uploading user @param File $file The file to be uploaded. @return File The location of the new file
[ "This", "will", "copy", "the", "file", "given", "to", "a", "implementation", "specific", "location", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L133-L139
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.cleanLibrary
public function cleanLibrary(User $user = null) { foreach($this->getFileList($user) as $file){ /** @var $file File */ if(!$this->whitelistContainsFile($file)){ /** @var $vf File */ foreach($this->listVersionsToOriginal($file) as $vf){ $vf->delete(); } $file->delete(); } } }
php
public function cleanLibrary(User $user = null) { foreach($this->getFileList($user) as $file){ /** @var $file File */ if(!$this->whitelistContainsFile($file)){ /** @var $vf File */ foreach($this->listVersionsToOriginal($file) as $vf){ $vf->delete(); } $file->delete(); } } }
[ "public", "function", "cleanLibrary", "(", "User", "$", "user", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "getFileList", "(", "$", "user", ")", "as", "$", "file", ")", "{", "/** @var $file File */", "if", "(", "!", "$", "this", "->", ...
This will clean the library from any file not present in the white-list If the user argument is not null, only files uploaded by this user will be subject to cleaning, else the whole library is checked. @param \ChristianBudde\Part\model\user\User $user @return bool TRUE on success else FALSE
[ "This", "will", "clean", "the", "library", "from", "any", "file", "not", "present", "in", "the", "white", "-", "list", "If", "the", "user", "argument", "is", "not", "null", "only", "files", "uploaded", "by", "this", "user", "will", "be", "subject", "to",...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L159-L171
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.removeFromLibrary
public function removeFromLibrary(File $file) { if(!$this->containsFile($file)){ return false; } if($this->whitelistContainsFile($file)){ $this->removeFromWhitelist($file); } $file->delete(); return !$this->containsFile($file); }
php
public function removeFromLibrary(File $file) { if(!$this->containsFile($file)){ return false; } if($this->whitelistContainsFile($file)){ $this->removeFromWhitelist($file); } $file->delete(); return !$this->containsFile($file); }
[ "public", "function", "removeFromLibrary", "(", "File", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "containsFile", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "whitelistContainsFile", "(", ...
Will remove a file from library. @param File $file @return bool TRUE on success else FALSE
[ "Will", "remove", "a", "file", "from", "library", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L201-L211
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.addVersionOfFile
public function addVersionOfFile(File $origFile, File $newFile, $version = null) { if(!$this->containsFile($origFile)){ return null; } $name = $this->versionFileName($origFile, $version); $f = new FileImpl($origFile->getParentFolder()->getAbsolutePath()."/".$name); if($f->exists()){ return $f; } return $this->addToLibraryHelper($origFile->getParentFolder(),$newFile, $name); }
php
public function addVersionOfFile(File $origFile, File $newFile, $version = null) { if(!$this->containsFile($origFile)){ return null; } $name = $this->versionFileName($origFile, $version); $f = new FileImpl($origFile->getParentFolder()->getAbsolutePath()."/".$name); if($f->exists()){ return $f; } return $this->addToLibraryHelper($origFile->getParentFolder(),$newFile, $name); }
[ "public", "function", "addVersionOfFile", "(", "File", "$", "origFile", ",", "File", "$", "newFile", ",", "$", "version", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "containsFile", "(", "$", "origFile", ")", ")", "{", "return", "null", ...
A version of a file is a new file that shares the name of the original file plus some appended version: original file: file.txt Version 2 : file-2.txt @param File $origFile @param File $newFile @param null|string $version @return File
[ "A", "version", "of", "a", "file", "is", "a", "new", "file", "that", "shares", "the", "name", "of", "the", "original", "file", "plus", "some", "appended", "version", ":", "original", "file", ":", "file", ".", "txt", "Version", "2", ":", "file", "-", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L224-L238
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.findOriginalFileToVersion
public function findOriginalFileToVersion(File $file) { if(!$this->containsFile($file)){ return null; } preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches); $ext = $file->getExtension() == ""?"":".".$file->getExtension(); return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext); }
php
public function findOriginalFileToVersion(File $file) { if(!$this->containsFile($file)){ return null; } preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches); $ext = $file->getExtension() == ""?"":".".$file->getExtension(); return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext); }
[ "public", "function", "findOriginalFileToVersion", "(", "File", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "containsFile", "(", "$", "file", ")", ")", "{", "return", "null", ";", "}", "preg_match", "(", "\"/([^-]+)(-.*)?/\"", ",", "$", "fi...
Given a version file this will return the original. If the given file isn't in the library, null will be returned. If the given file isn't a version of a file, null will be returned. @param File $file @return File
[ "Given", "a", "version", "file", "this", "will", "return", "the", "original", ".", "If", "the", "given", "file", "isn", "t", "in", "the", "library", "null", "will", "be", "returned", ".", "If", "the", "given", "file", "isn", "t", "a", "version", "of", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L256-L265
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.listVersionsToOriginal
public function listVersionsToOriginal(File $file) { if(!$this->containsFile($file)){ return array(); } if($this->isVersion($file)){ return array(); } return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){ return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0; }); }
php
public function listVersionsToOriginal(File $file) { if(!$this->containsFile($file)){ return array(); } if($this->isVersion($file)){ return array(); } return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){ return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0; }); }
[ "public", "function", "listVersionsToOriginal", "(", "File", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "containsFile", "(", "$", "file", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "this", "->", "isVersion", ...
Will list the versions of a given file. @param File $file @return array
[ "Will", "list", "the", "versions", "of", "a", "given", "file", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L272-L285
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.containsVersionOfFile
public function containsVersionOfFile($file, $version) { $f = $this->findVersionOfFile($file, $version); return $f != null; }
php
public function containsVersionOfFile($file, $version) { $f = $this->findVersionOfFile($file, $version); return $f != null; }
[ "public", "function", "containsVersionOfFile", "(", "$", "file", ",", "$", "version", ")", "{", "$", "f", "=", "$", "this", "->", "findVersionOfFile", "(", "$", "file", ",", "$", "version", ")", ";", "return", "$", "f", "!=", "null", ";", "}" ]
Will check if a version of the given file already exists. @param File $file @param string $version @return bool
[ "Will", "check", "if", "a", "version", "of", "the", "given", "file", "already", "exists", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L314-L318
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.findVersionOfFile
public function findVersionOfFile($file, $version) { if($file == null || ($f2 = $this->findOriginalFileToVersion($file)) == null || $file->getAbsoluteFilePath() != $f2->getAbsoluteFilePath()){ return null; } $name = $this->versionFileName($file, $version); $f = new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$name); return $this->containsFile($f)?$f:null; }
php
public function findVersionOfFile($file, $version) { if($file == null || ($f2 = $this->findOriginalFileToVersion($file)) == null || $file->getAbsoluteFilePath() != $f2->getAbsoluteFilePath()){ return null; } $name = $this->versionFileName($file, $version); $f = new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$name); return $this->containsFile($f)?$f:null; }
[ "public", "function", "findVersionOfFile", "(", "$", "file", ",", "$", "version", ")", "{", "if", "(", "$", "file", "==", "null", "||", "(", "$", "f2", "=", "$", "this", "->", "findOriginalFileToVersion", "(", "$", "file", ")", ")", "==", "null", "||...
This will return the desired version of the file, if it exists, else null. @param File $file @param string $version @return File
[ "This", "will", "return", "the", "desired", "version", "of", "the", "file", "if", "it", "exists", "else", "null", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L326-L335
budde377/Part
lib/util/file/FileLibraryImpl.php
FileLibraryImpl.uploadToLibrary
public function uploadToLibrary(User $user, array $fileArray) { $nameFile = new FileImpl(isset($fileArray['name'])?$fileArray['name']:$fileArray['tmp_name']); $file = new FileImpl($fileArray['tmp_name']); $folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId()); $ext = $nameFile->getExtension() == ""?"":".".$nameFile->getExtension(); $name = str_replace(".", "", uniqid("",true)).$ext; if(!$this->filesDir->exists()){ $this->filesDir->create(); } if(!$folder->exists()){ $folder->create(); } $f = new FileImpl($folder->getAbsolutePath().'/'.$name); move_uploaded_file($file->getAbsoluteFilePath(),$f->getAbsoluteFilePath()); return $f; }
php
public function uploadToLibrary(User $user, array $fileArray) { $nameFile = new FileImpl(isset($fileArray['name'])?$fileArray['name']:$fileArray['tmp_name']); $file = new FileImpl($fileArray['tmp_name']); $folder = new FolderImpl($this->filesDir->getAbsolutePath()."/".$user->getUniqueId()); $ext = $nameFile->getExtension() == ""?"":".".$nameFile->getExtension(); $name = str_replace(".", "", uniqid("",true)).$ext; if(!$this->filesDir->exists()){ $this->filesDir->create(); } if(!$folder->exists()){ $folder->create(); } $f = new FileImpl($folder->getAbsolutePath().'/'.$name); move_uploaded_file($file->getAbsoluteFilePath(),$f->getAbsoluteFilePath()); return $f; }
[ "public", "function", "uploadToLibrary", "(", "User", "$", "user", ",", "array", "$", "fileArray", ")", "{", "$", "nameFile", "=", "new", "FileImpl", "(", "isset", "(", "$", "fileArray", "[", "'name'", "]", ")", "?", "$", "fileArray", "[", "'name'", "]...
Will move a file to the library. It will use move_upload_file function. @param \ChristianBudde\Part\model\user\User $user The uploading user @param array $fileArray The file array to be added @return File Will return newly added file
[ "Will", "move", "a", "file", "to", "the", "library", ".", "It", "will", "use", "move_upload_file", "function", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileLibraryImpl.php#L353-L370
kaliop-uk/kueueingbundle
Command/ConsumerCommand.php
ConsumerCommand.initConsumer
protected function initConsumer($input) { // set up signal handlers first, in case something goes on during consumer constructor $handleSignals = extension_loaded('pcntl') && (!$input->getOption('without-signals')); if ($handleSignals && !function_exists('pcntl_signal')) { throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called."); } if ($handleSignals && !function_exists('pcntl_signal_dispatch')) { throw new \BadFunctionCallException("Function 'pcntl_signal_dispatch' is referenced in the php.ini 'disable_functions' and can't be called."); } if ($handleSignals) { pcntl_signal(SIGTERM, array($this, 'haltConsumer')); pcntl_signal(SIGINT, array($this, 'haltConsumer')); pcntl_signal(SIGHUP, array($this, 'restartConsumer')); } $this->consumer = $this->driver->getConsumer($input->getArgument('name')); if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) { $this->consumer->setMemoryLimit($input->getOption('memory-limit')); } if (($routingKey = $input->getOption('route')) !== '') { $this->consumer->setRoutingKey($routingKey); } if (self::$label != '' && is_callable(array($this->consumer, 'setLabel'))) { $this->consumer->setLabel(self::$label); } if ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) { $this->consumer->setHandleSignals($handleSignals); } }
php
protected function initConsumer($input) { // set up signal handlers first, in case something goes on during consumer constructor $handleSignals = extension_loaded('pcntl') && (!$input->getOption('without-signals')); if ($handleSignals && !function_exists('pcntl_signal')) { throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called."); } if ($handleSignals && !function_exists('pcntl_signal_dispatch')) { throw new \BadFunctionCallException("Function 'pcntl_signal_dispatch' is referenced in the php.ini 'disable_functions' and can't be called."); } if ($handleSignals) { pcntl_signal(SIGTERM, array($this, 'haltConsumer')); pcntl_signal(SIGINT, array($this, 'haltConsumer')); pcntl_signal(SIGHUP, array($this, 'restartConsumer')); } $this->consumer = $this->driver->getConsumer($input->getArgument('name')); if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) { $this->consumer->setMemoryLimit($input->getOption('memory-limit')); } if (($routingKey = $input->getOption('route')) !== '') { $this->consumer->setRoutingKey($routingKey); } if (self::$label != '' && is_callable(array($this->consumer, 'setLabel'))) { $this->consumer->setLabel(self::$label); } if ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) { $this->consumer->setHandleSignals($handleSignals); } }
[ "protected", "function", "initConsumer", "(", "$", "input", ")", "{", "// set up signal handlers first, in case something goes on during consumer constructor", "$", "handleSignals", "=", "extension_loaded", "(", "'pcntl'", ")", "&&", "(", "!", "$", "input", "->", "getOpti...
Reimplemented to allow drivers to give us a Consumer. Also, only set the routing key to the consumer if it has been passed on the command line @param $input
[ "Reimplemented", "to", "allow", "drivers", "to", "give", "us", "a", "Consumer", ".", "Also", "only", "set", "the", "routing", "key", "to", "the", "consumer", "if", "it", "has", "been", "passed", "on", "the", "command", "line" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Command/ConsumerCommand.php#L102-L136
kaliop-uk/kueueingbundle
Command/ConsumerCommand.php
ConsumerCommand.haltConsumer
public function haltConsumer($sigNo) { if ($this->consumer instanceof BaseConsumer) { // Process current message, then halt consumer $this->consumer->forceStopConsumer(); // Halt consumer if waiting for a new message from the queue try { $this->consumer->stopConsuming(); } catch (AMQPTimeoutException $e) { // exit gracefully with a message echo("Stopped because: Received stop signal $sigNo\n"); } } elseif ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) { $this->consumer->forceStop("Received stop signal $sigNo"); } else { exit(); } }
php
public function haltConsumer($sigNo) { if ($this->consumer instanceof BaseConsumer) { // Process current message, then halt consumer $this->consumer->forceStopConsumer(); // Halt consumer if waiting for a new message from the queue try { $this->consumer->stopConsuming(); } catch (AMQPTimeoutException $e) { // exit gracefully with a message echo("Stopped because: Received stop signal $sigNo\n"); } } elseif ($this->consumer instanceof \Kaliop\QueueingBundle\Queue\SignalHandlingConsumerInterface) { $this->consumer->forceStop("Received stop signal $sigNo"); } else { exit(); } }
[ "public", "function", "haltConsumer", "(", "$", "sigNo", ")", "{", "if", "(", "$", "this", "->", "consumer", "instanceof", "BaseConsumer", ")", "{", "// Process current message, then halt consumer", "$", "this", "->", "consumer", "->", "forceStopConsumer", "(", ")...
Reimplementation of stopConsumer to allow non-amqp consumer to react gracefully to stop signals @param int $sigNo
[ "Reimplementation", "of", "stopConsumer", "to", "allow", "non", "-", "amqp", "consumer", "to", "react", "gracefully", "to", "stop", "signals" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Command/ConsumerCommand.php#L142-L163
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
ReservedRangeMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ReservedRange(); case 1: return new ReservedRange(func_get_arg(0)); case 2: return new ReservedRange(func_get_arg(0), func_get_arg(1)); case 3: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new ReservedRange(); case 1: return new ReservedRange(func_get_arg(0)); case 2: return new ReservedRange(func_get_arg(0), func_get_arg(1)); case 3: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "ReservedRange", "(", ")", ";", "case", "1", ":", "return", "new", "ReservedRange", "(", "func_get_arg", "(", ...
Creates new instance of \Google\Protobuf\DescriptorProto\ReservedRange @throws \InvalidArgumentException @return ReservedRange
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ReservedRange" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
ReservedRangeMeta.reset
public static function reset($object) { if (!($object instanceof ReservedRange)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ReservedRange.'); } $object->start = NULL; $object->end = NULL; }
php
public static function reset($object) { if (!($object instanceof ReservedRange)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ReservedRange.'); } $object->start = NULL; $object->end = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "ReservedRange", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Descr...
Resets properties of \Google\Protobuf\DescriptorProto\ReservedRange to default values @param ReservedRange $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ReservedRange", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L95-L102
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
ReservedRangeMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->start)) { hash_update($ctx, 'start'); hash_update($ctx, (string)$object->start); } if (isset($object->end)) { hash_update($ctx, 'end'); hash_update($ctx, (string)$object->end); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->start)) { hash_update($ctx, 'start'); hash_update($ctx, (string)$object->start); } if (isset($object->end)) { hash_update($ctx, 'end'); hash_update($ctx, (string)$object->end); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\DescriptorProto\ReservedRange @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ReservedRange" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L114-L137
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php
ReservedRangeMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->start) && ($filter === null || isset($filter['start']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->start); } if (isset($object->end) && ($filter === null || isset($filter['end']))) { $output .= "\x10"; $output .= Binary::encodeVarint($object->end); } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->start) && ($filter === null || isset($filter['start']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->start); } if (isset($object->end) && ($filter === null || isset($filter['end']))) { $output .= "\x10"; $output .= Binary::encodeVarint($object->end); } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "start", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\DescriptorProto\ReservedRange to Protocol Buffers message. @param ReservedRange $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ReservedRange", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ReservedRangeMeta.php#L213-L228
baleen/migrations
src/Delta/Collection/Resolver/ResolverStack.php
ResolverStack.doResolve
public function doResolve($alias, Collection $collection) { foreach ($this->resolvers as $resolver) { $result = $resolver->resolve($alias, $collection); if ($result !== null) { return $result; } } return null; }
php
public function doResolve($alias, Collection $collection) { foreach ($this->resolvers as $resolver) { $result = $resolver->resolve($alias, $collection); if ($result !== null) { return $result; } } return null; }
[ "public", "function", "doResolve", "(", "$", "alias", ",", "Collection", "$", "collection", ")", "{", "foreach", "(", "$", "this", "->", "resolvers", "as", "$", "resolver", ")", "{", "$", "result", "=", "$", "resolver", "->", "resolve", "(", "$", "alia...
Resolves an alias @param string $alias @param Collection $collection @return \Baleen\Migrations\Delta\DeltaInterface|null @throws \Baleen\Migrations\Exception\Version\Collection\ResolverException
[ "Resolves", "an", "alias" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/ResolverStack.php#L67-L76
bigwhoop/sentence-breaker
src/Rules/RulePattern.php
RulePattern.getTokensOffsetRelativeToStartToken
public function getTokensOffsetRelativeToStartToken($startTokenName) { $startTokenIdx = null; foreach ($this->tokens as $idx => $token) { if ($token->getTokenName() === $startTokenName) { $startTokenIdx = $idx; } elseif ($token->isStartToken()) { $startTokenIdx = $idx; } } if ($startTokenIdx === null) { throw new ConfigurationException('No start token found for pattern '.print_r($this, true)); } $numTokens = count($this->tokens); $offsets = array_map(function ($idx) use ($startTokenIdx) { return $idx - $startTokenIdx; }, range(0, $numTokens - 1)); return array_combine($offsets, $this->tokens); }
php
public function getTokensOffsetRelativeToStartToken($startTokenName) { $startTokenIdx = null; foreach ($this->tokens as $idx => $token) { if ($token->getTokenName() === $startTokenName) { $startTokenIdx = $idx; } elseif ($token->isStartToken()) { $startTokenIdx = $idx; } } if ($startTokenIdx === null) { throw new ConfigurationException('No start token found for pattern '.print_r($this, true)); } $numTokens = count($this->tokens); $offsets = array_map(function ($idx) use ($startTokenIdx) { return $idx - $startTokenIdx; }, range(0, $numTokens - 1)); return array_combine($offsets, $this->tokens); }
[ "public", "function", "getTokensOffsetRelativeToStartToken", "(", "$", "startTokenName", ")", "{", "$", "startTokenIdx", "=", "null", ";", "foreach", "(", "$", "this", "->", "tokens", "as", "$", "idx", "=>", "$", "token", ")", "{", "if", "(", "$", "token",...
Returns the offset for each token relative to the start token. Let's say we have the following tokens: T_A, T_B, T_C, T_D If the $startTokenName were T_A we'd return: 0, 1, 2, 3 If the $startTokenName were T_C we'd return: -2, -1, 0, 1 @param string $startTokenName @return RulePatternToken[] @throws ConfigurationException
[ "Returns", "the", "offset", "for", "each", "token", "relative", "to", "the", "start", "token", "." ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Rules/RulePattern.php#L78-L101
budde377/Part
lib/model/ContentImpl.php
ContentImpl.containsSubString
public function containsSubString($string, $fromTime = null) { $this->containsSubStrStm->bindValue(":like", "%" . $string . "%"); $this->containsSubStrStm->bindValue(":id", $this->id); $this->containsSubStrStm->bindValue(":time", $fromTime == null ? 0 : $fromTime); $this->containsSubStrStm->execute(); return $this->containsSubStrStm->rowCount() > 0; }
php
public function containsSubString($string, $fromTime = null) { $this->containsSubStrStm->bindValue(":like", "%" . $string . "%"); $this->containsSubStrStm->bindValue(":id", $this->id); $this->containsSubStrStm->bindValue(":time", $fromTime == null ? 0 : $fromTime); $this->containsSubStrStm->execute(); return $this->containsSubStrStm->rowCount() > 0; }
[ "public", "function", "containsSubString", "(", "$", "string", ",", "$", "fromTime", "=", "null", ")", "{", "$", "this", "->", "containsSubStrStm", "->", "bindValue", "(", "\":like\"", ",", "\"%\"", ".", "$", "string", ".", "\"%\"", ")", ";", "$", "this"...
Searches content for the the string from a given time ($fromTime). The time should be present when available as it would cut down the search time. @param String $string @param int $fromTime Timestamp @return bool TRUE if found else FALSE
[ "Searches", "content", "for", "the", "the", "string", "from", "a", "given", "time", "(", "$fromTime", ")", ".", "The", "time", "should", "be", "present", "when", "available", "as", "it", "would", "cut", "down", "the", "search", "time", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentImpl.php#L157-L165
bigwhoop/sentence-breaker
src/Lexing/States/TextState.php
TextState.call
protected function call(Lexer $lexer) { while (true) { $peek = $lexer->peek(); //file_put_contents(__DIR__ . '/foo.log', '#' . $lexer->pos() . ' ' . $peek . ' (' . $lexer->getTokenValue() . ')' . PHP_EOL, FILE_APPEND); if ($peek === null) { $lexer->emit(new EOFToken()); return; } if ('.' === $peek) { $lexer->next(); $lexer->emit(new PeriodToken()); continue; } if ('?' === $peek) { $lexer->next(); $lexer->emit(new QuestionMarkToken()); continue; } if ('!' === $peek) { $lexer->next(); $lexer->emit(new ExclamationPointToken()); continue; } if (in_array($peek, QuotedStringState::CHARS, true)) { return new QuotedStringState(); } if (in_array($peek, WhitespaceState::CHARS, true)) { return new WhitespaceState(); } return new WordState(); } }
php
protected function call(Lexer $lexer) { while (true) { $peek = $lexer->peek(); //file_put_contents(__DIR__ . '/foo.log', '#' . $lexer->pos() . ' ' . $peek . ' (' . $lexer->getTokenValue() . ')' . PHP_EOL, FILE_APPEND); if ($peek === null) { $lexer->emit(new EOFToken()); return; } if ('.' === $peek) { $lexer->next(); $lexer->emit(new PeriodToken()); continue; } if ('?' === $peek) { $lexer->next(); $lexer->emit(new QuestionMarkToken()); continue; } if ('!' === $peek) { $lexer->next(); $lexer->emit(new ExclamationPointToken()); continue; } if (in_array($peek, QuotedStringState::CHARS, true)) { return new QuotedStringState(); } if (in_array($peek, WhitespaceState::CHARS, true)) { return new WhitespaceState(); } return new WordState(); } }
[ "protected", "function", "call", "(", "Lexer", "$", "lexer", ")", "{", "while", "(", "true", ")", "{", "$", "peek", "=", "$", "lexer", "->", "peek", "(", ")", ";", "//file_put_contents(__DIR__ . '/foo.log', '#' . $lexer->pos() . ' ' . $peek . ' (' . $lexer->getTokenVa...
{@inheritdoc}
[ "{" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/States/TextState.php#L24-L66
calcinai/php-mmap
lib/MMap/StreamWrapper.php
StreamWrapper.stream_seek
public function stream_seek($address, $whence = SEEK_SET){ $this->subprocess_write(self::COMMAND_SEEK, pack('v', $address)); //This is an assumption that the stream will always seek where its sold - can get some info back if this fails. $this->position = $address; return true; }
php
public function stream_seek($address, $whence = SEEK_SET){ $this->subprocess_write(self::COMMAND_SEEK, pack('v', $address)); //This is an assumption that the stream will always seek where its sold - can get some info back if this fails. $this->position = $address; return true; }
[ "public", "function", "stream_seek", "(", "$", "address", ",", "$", "whence", "=", "SEEK_SET", ")", "{", "$", "this", "->", "subprocess_write", "(", "self", "::", "COMMAND_SEEK", ",", "pack", "(", "'v'", ",", "$", "address", ")", ")", ";", "//This is an ...
TODO send whence @param $address @param int $whence @return bool
[ "TODO", "send", "whence" ]
train
https://github.com/calcinai/php-mmap/blob/67a8f56727ecd255b0d61c1dc4ea0604f84fb294/lib/MMap/StreamWrapper.php#L77-L83
calcinai/php-mmap
lib/MMap/StreamWrapper.php
StreamWrapper.parseURI
private static function parseURI($uri){ //Remove protocol (for clarity). $uri = substr($uri, strlen('mmap://')); $parts = explode('?', $uri); $file_name_block_size = explode(':', $parts[0]); if(!isset($file_name_block_size[1])){ throw new \Exception(sprintf('%s is not a valid uri', $uri)); } $parsed = []; list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size; if(isset($parts[1])){ //Extra params parse_str($parts[1], $parsed['options']); } else { $parsed['options'] = []; } return $parsed; }
php
private static function parseURI($uri){ //Remove protocol (for clarity). $uri = substr($uri, strlen('mmap://')); $parts = explode('?', $uri); $file_name_block_size = explode(':', $parts[0]); if(!isset($file_name_block_size[1])){ throw new \Exception(sprintf('%s is not a valid uri', $uri)); } $parsed = []; list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size; if(isset($parts[1])){ //Extra params parse_str($parts[1], $parsed['options']); } else { $parsed['options'] = []; } return $parsed; }
[ "private", "static", "function", "parseURI", "(", "$", "uri", ")", "{", "//Remove protocol (for clarity).", "$", "uri", "=", "substr", "(", "$", "uri", ",", "strlen", "(", "'mmap://'", ")", ")", ";", "$", "parts", "=", "explode", "(", "'?'", ",", "$", ...
Can't parse_url as it's too malformed @param $uri @return array @throws \Exception
[ "Can", "t", "parse_url", "as", "it", "s", "too", "malformed" ]
train
https://github.com/calcinai/php-mmap/blob/67a8f56727ecd255b0d61c1dc4ea0604f84fb294/lib/MMap/StreamWrapper.php#L151-L174
fab2s/NodalFlow
src/PayloadNodeFactory.php
PayloadNodeFactory.create
public static function create($payload, $isAReturningVal, $isATraversable = false) { if (\is_array($payload) || \is_string($payload)) { return new CallableNode($payload, $isAReturningVal, $isATraversable); } if ($payload instanceof \Closure) { // distinguishing Closures actually is surrealistic return new ClosureNode($payload, $isAReturningVal, $isATraversable); } if ($payload instanceof FlowInterface) { return new BranchNode($payload, $isAReturningVal); } throw new NodalFlowException('Payload not supported, must be Callable or Flow'); }
php
public static function create($payload, $isAReturningVal, $isATraversable = false) { if (\is_array($payload) || \is_string($payload)) { return new CallableNode($payload, $isAReturningVal, $isATraversable); } if ($payload instanceof \Closure) { // distinguishing Closures actually is surrealistic return new ClosureNode($payload, $isAReturningVal, $isATraversable); } if ($payload instanceof FlowInterface) { return new BranchNode($payload, $isAReturningVal); } throw new NodalFlowException('Payload not supported, must be Callable or Flow'); }
[ "public", "static", "function", "create", "(", "$", "payload", ",", "$", "isAReturningVal", ",", "$", "isATraversable", "=", "false", ")", "{", "if", "(", "\\", "is_array", "(", "$", "payload", ")", "||", "\\", "is_string", "(", "$", "payload", ")", ")...
Instantiate the proper Payload Node for the payload @param mixed $payload @param bool $isAReturningVal @param bool $isATraversable @throws NodalFlowException @return PayloadNodeInterface
[ "Instantiate", "the", "proper", "Payload", "Node", "for", "the", "payload" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/PayloadNodeFactory.php#L35-L51
jkphl/dom-factory
src/Domfactory/Domain/Dom.php
Dom.load
public function load($source) { $source = mb_convert_encoding($source, 'HTML-ENTITIES', mb_detect_encoding($source)); $dom = new \DOMDocument(); // Try to load the source as standard XML document first, then as HTML document if (!$dom->loadXML($source, LIBXML_NOWARNING | LIBXML_NOERROR)) { $dom = $this->htmlParser->loadHTML($source); } return $dom; }
php
public function load($source) { $source = mb_convert_encoding($source, 'HTML-ENTITIES', mb_detect_encoding($source)); $dom = new \DOMDocument(); // Try to load the source as standard XML document first, then as HTML document if (!$dom->loadXML($source, LIBXML_NOWARNING | LIBXML_NOERROR)) { $dom = $this->htmlParser->loadHTML($source); } return $dom; }
[ "public", "function", "load", "(", "$", "source", ")", "{", "$", "source", "=", "mb_convert_encoding", "(", "$", "source", ",", "'HTML-ENTITIES'", ",", "mb_detect_encoding", "(", "$", "source", ")", ")", ";", "$", "dom", "=", "new", "\\", "DOMDocument", ...
Create a DOM document from a string @param string $source XML/HTML string @return \DOMDocument DOM document
[ "Create", "a", "DOM", "document", "from", "a", "string" ]
train
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Domain/Dom.php#L70-L81
baleen/migrations
src/Delta/DeltaId.php
DeltaId.fromNative
public static function fromNative($value) { $str = (string) $value; if (empty($str)) { throw new InvalidArgumentException( 'Refusing to create a DeltaId from an empty string or any other type of value that casts into an ' . 'empty string.' ); } return new static(hash(self::HASH_ALGORITHM, $str)); }
php
public static function fromNative($value) { $str = (string) $value; if (empty($str)) { throw new InvalidArgumentException( 'Refusing to create a DeltaId from an empty string or any other type of value that casts into an ' . 'empty string.' ); } return new static(hash(self::HASH_ALGORITHM, $str)); }
[ "public", "static", "function", "fromNative", "(", "$", "value", ")", "{", "$", "str", "=", "(", "string", ")", "$", "value", ";", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Refusing to create a...
@inheritdoc @throws InvalidArgumentException
[ "@inheritdoc" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/DeltaId.php#L100-L111
budde377/Part
lib/view/page_element/LogoutPageElementImpl.php
LogoutPageElementImpl.setUpElement
public function setUpElement() { parent::setUpElement(); $path = "/"; if(isset($_SERVER["HTTP_REFERER"]) && ($url = parse_url($_SERVER["HTTP_REFERER"])) && $url["host"] == $_SERVER["HTTP_HOST"]){ $path = $url["path"]; } $currentUser = $this->container->getUserLibraryInstance()->getUserLoggedIn(); if ($currentUser == null) { HTTPHeaderHelper::redirectToLocation("/"); return; } $site = $this->container->getSiteInstance(); $vars = $currentUser->getUserVariables(); $lastRun = $vars->getValue("last-file-lib-cleanup"); $lastRun = $lastRun == null ? 0 : $lastRun; $fileLib = $this->container->getFileLibraryInstance(); $contentLibraries = array(); /** @var Page $page */ foreach ($this->container->getPageOrderInstance()->listPages() as $page) { if ($page->lastModified() < $lastRun) { continue; } $contentLibraries[] = $page->getContentLibrary(); } if($site->lastModified() >= $lastRun){ $contentLibraries[] = $site->getContentLibrary(); } $fileList = array(); /** @var File $file */ foreach ($fileLib->getFileList($currentUser) as $file) { if ($fileLib->whitelistContainsFile($file)) { continue; } /** @var $contentLib ContentLibrary */ foreach ($contentLibraries as $contentLib) { if (!count($contentLib->searchLibrary($file->getBasename(), $lastRun))) { continue; } $fileLib->addToWhitelist($file); break; } $fileList[] = $file; } $fileLib->cleanLibrary($currentUser); $vars->setValue("last-file-lib-cleanup", time()); $currentUser->logout(); HTTPHeaderHelper::redirectToLocation($path); }
php
public function setUpElement() { parent::setUpElement(); $path = "/"; if(isset($_SERVER["HTTP_REFERER"]) && ($url = parse_url($_SERVER["HTTP_REFERER"])) && $url["host"] == $_SERVER["HTTP_HOST"]){ $path = $url["path"]; } $currentUser = $this->container->getUserLibraryInstance()->getUserLoggedIn(); if ($currentUser == null) { HTTPHeaderHelper::redirectToLocation("/"); return; } $site = $this->container->getSiteInstance(); $vars = $currentUser->getUserVariables(); $lastRun = $vars->getValue("last-file-lib-cleanup"); $lastRun = $lastRun == null ? 0 : $lastRun; $fileLib = $this->container->getFileLibraryInstance(); $contentLibraries = array(); /** @var Page $page */ foreach ($this->container->getPageOrderInstance()->listPages() as $page) { if ($page->lastModified() < $lastRun) { continue; } $contentLibraries[] = $page->getContentLibrary(); } if($site->lastModified() >= $lastRun){ $contentLibraries[] = $site->getContentLibrary(); } $fileList = array(); /** @var File $file */ foreach ($fileLib->getFileList($currentUser) as $file) { if ($fileLib->whitelistContainsFile($file)) { continue; } /** @var $contentLib ContentLibrary */ foreach ($contentLibraries as $contentLib) { if (!count($contentLib->searchLibrary($file->getBasename(), $lastRun))) { continue; } $fileLib->addToWhitelist($file); break; } $fileList[] = $file; } $fileLib->cleanLibrary($currentUser); $vars->setValue("last-file-lib-cleanup", time()); $currentUser->logout(); HTTPHeaderHelper::redirectToLocation($path); }
[ "public", "function", "setUpElement", "(", ")", "{", "parent", "::", "setUpElement", "(", ")", ";", "$", "path", "=", "\"/\"", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"HTTP_REFERER\"", "]", ")", "&&", "(", "$", "url", "=", "parse_url", "...
Will set up the page element. If you want to ensure that you register some files, this would be the place to do this. This should always be called before generateContent, at the latest right before. @return void
[ "Will", "set", "up", "the", "page", "element", ".", "If", "you", "want", "to", "ensure", "that", "you", "register", "some", "files", "this", "would", "be", "the", "place", "to", "do", "this", ".", "This", "should", "always", "be", "called", "before", "...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/page_element/LogoutPageElementImpl.php#L31-L85