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
skrz/meta
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
UninterpretedOptionMeta.reset
public static function reset($object) { if (!($object instanceof UninterpretedOption)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption.'); } $object->name = NULL; $object->identifierValue = NULL; $object->positiveIntValue = NULL; $object->negativeIntValue = NULL; $object->doubleValue = NULL; $object->stringValue = NULL; $object->aggregateValue = NULL; }
php
public static function reset($object) { if (!($object instanceof UninterpretedOption)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption.'); } $object->name = NULL; $object->identifierValue = NULL; $object->positiveIntValue = NULL; $object->negativeIntValue = NULL; $object->doubleValue = NULL; $object->stringValue = NULL; $object->aggregateValue = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "UninterpretedOption", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\...
Resets properties of \Google\Protobuf\UninterpretedOption to default values @param UninterpretedOption $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L101-L113
skrz/meta
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
UninterpretedOptionMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $v0) { NamePartMeta::hash($v0, $ctx); } } if (isset($object->identifierValue)) { hash_update($ctx, 'identifierValue'); hash_update($ctx, (string)$object->identifierValue); } if (isset($object->positiveIntValue)) { hash_update($ctx, 'positiveIntValue'); hash_update($ctx, (string)$object->positiveIntValue); } if (isset($object->negativeIntValue)) { hash_update($ctx, 'negativeIntValue'); hash_update($ctx, (string)$object->negativeIntValue); } if (isset($object->doubleValue)) { hash_update($ctx, 'doubleValue'); hash_update($ctx, (string)$object->doubleValue); } if (isset($object->stringValue)) { hash_update($ctx, 'stringValue'); hash_update($ctx, (string)$object->stringValue); } if (isset($object->aggregateValue)) { hash_update($ctx, 'aggregateValue'); hash_update($ctx, (string)$object->aggregateValue); } 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->name)) { hash_update($ctx, 'name'); foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $v0) { NamePartMeta::hash($v0, $ctx); } } if (isset($object->identifierValue)) { hash_update($ctx, 'identifierValue'); hash_update($ctx, (string)$object->identifierValue); } if (isset($object->positiveIntValue)) { hash_update($ctx, 'positiveIntValue'); hash_update($ctx, (string)$object->positiveIntValue); } if (isset($object->negativeIntValue)) { hash_update($ctx, 'negativeIntValue'); hash_update($ctx, (string)$object->negativeIntValue); } if (isset($object->doubleValue)) { hash_update($ctx, 'doubleValue'); hash_update($ctx, (string)$object->doubleValue); } if (isset($object->stringValue)) { hash_update($ctx, 'stringValue'); hash_update($ctx, (string)$object->stringValue); } if (isset($object->aggregateValue)) { hash_update($ctx, 'aggregateValue'); hash_update($ctx, (string)$object->aggregateValue); } 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\UninterpretedOption @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L125-L175
skrz/meta
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
UninterpretedOptionMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new UninterpretedOption(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->name) && is_array($object->name))) { $object->name = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name[] = NamePartMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->identifierValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->positiveIntValue = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->negativeIntValue = Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 1) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number); } $expectedStart = $start + 8; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->doubleValue = Binary::decodeDouble($input, $start); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->stringValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->aggregateValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new UninterpretedOption(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->name) && is_array($object->name))) { $object->name = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name[] = NamePartMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->identifierValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->positiveIntValue = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->negativeIntValue = Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 1) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number); } $expectedStart = $start + 8; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->doubleValue = Binary::decodeDouble($input, $start); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->stringValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->aggregateValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\UninterpretedOption object from serialized Protocol Buffers message. @param string $input @param UninterpretedOption $object @param int $start @param int $end @throws \Exception @return UninterpretedOption
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L190-L313
skrz/meta
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
UninterpretedOptionMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $k => $v) { $output .= "\x12"; $buffer = NamePartMeta::toProtobuf($v, $filter === null ? null : $filter['name']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->identifierValue) && ($filter === null || isset($filter['identifierValue']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->identifierValue)); $output .= $object->identifierValue; } if (isset($object->positiveIntValue) && ($filter === null || isset($filter['positiveIntValue']))) { $output .= "\x20"; $output .= Binary::encodeVarint($object->positiveIntValue); } if (isset($object->negativeIntValue) && ($filter === null || isset($filter['negativeIntValue']))) { $output .= "\x28"; $output .= Binary::encodeVarint($object->negativeIntValue); } if (isset($object->doubleValue) && ($filter === null || isset($filter['doubleValue']))) { $output .= "\x31"; $output .= Binary::encodeDouble($object->doubleValue); } if (isset($object->stringValue) && ($filter === null || isset($filter['stringValue']))) { $output .= "\x3a"; $output .= Binary::encodeVarint(strlen($object->stringValue)); $output .= $object->stringValue; } if (isset($object->aggregateValue) && ($filter === null || isset($filter['aggregateValue']))) { $output .= "\x42"; $output .= Binary::encodeVarint(strlen($object->aggregateValue)); $output .= $object->aggregateValue; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $k => $v) { $output .= "\x12"; $buffer = NamePartMeta::toProtobuf($v, $filter === null ? null : $filter['name']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->identifierValue) && ($filter === null || isset($filter['identifierValue']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->identifierValue)); $output .= $object->identifierValue; } if (isset($object->positiveIntValue) && ($filter === null || isset($filter['positiveIntValue']))) { $output .= "\x20"; $output .= Binary::encodeVarint($object->positiveIntValue); } if (isset($object->negativeIntValue) && ($filter === null || isset($filter['negativeIntValue']))) { $output .= "\x28"; $output .= Binary::encodeVarint($object->negativeIntValue); } if (isset($object->doubleValue) && ($filter === null || isset($filter['doubleValue']))) { $output .= "\x31"; $output .= Binary::encodeDouble($object->doubleValue); } if (isset($object->stringValue) && ($filter === null || isset($filter['stringValue']))) { $output .= "\x3a"; $output .= Binary::encodeVarint(strlen($object->stringValue)); $output .= $object->stringValue; } if (isset($object->aggregateValue) && ($filter === null || isset($filter['aggregateValue']))) { $output .= "\x42"; $output .= Binary::encodeVarint(strlen($object->aggregateValue)); $output .= $object->aggregateValue; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\UninterpretedOption to Protocol Buffers message. @param UninterpretedOption $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L326-L373
kaliop-uk/kueueingbundle
Service/EventDispatcher.php
EventDispatcher.addListenerService
public function addListenerService($eventName, $callback, $priority = 0, $queueName = null) { parent::addListenerService($eventName, $callback, $priority); $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority, $queueName); }
php
public function addListenerService($eventName, $callback, $priority = 0, $queueName = null) { parent::addListenerService($eventName, $callback, $priority); $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority, $queueName); }
[ "public", "function", "addListenerService", "(", "$", "eventName", ",", "$", "callback", ",", "$", "priority", "=", "0", ",", "$", "queueName", "=", "null", ")", "{", "parent", "::", "addListenerService", "(", "$", "eventName", ",", "$", "callback", ",", ...
Adds a service as event listener. @param string $eventName Event for which the listener is added @param array $callback The service ID of the listener service & the method name that has to be called @param int $priority The higher this value, the earlier an event listener will be triggered in the chain. Defaults to 0. @param string $queueName Use null to subscribe to all queues @throws \InvalidArgumentException
[ "Adds", "a", "service", "as", "event", "listener", "." ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L36-L41
kaliop-uk/kueueingbundle
Service/EventDispatcher.php
EventDispatcher.doDispatch
protected function doDispatch($listeners, $eventName, Event $event) { foreach ($listeners as $id => $listener) { if (isset($this->listeners[$eventName])) { foreach($this->listeners[$eventName] as $key => $val) { // services if ($val[0] === $listener[0]) { // queue names if ($val[1] != null && $val[1] != $event->getMessage()->getQueueName()) { continue 2; } break; } } } call_user_func($listener, $event, $eventName, $this); if ($event->isPropagationStopped()) { break; } } }
php
protected function doDispatch($listeners, $eventName, Event $event) { foreach ($listeners as $id => $listener) { if (isset($this->listeners[$eventName])) { foreach($this->listeners[$eventName] as $key => $val) { // services if ($val[0] === $listener[0]) { // queue names if ($val[1] != null && $val[1] != $event->getMessage()->getQueueName()) { continue 2; } break; } } } call_user_func($listener, $event, $eventName, $this); if ($event->isPropagationStopped()) { break; } } }
[ "protected", "function", "doDispatch", "(", "$", "listeners", ",", "$", "eventName", ",", "Event", "$", "event", ")", "{", "foreach", "(", "$", "listeners", "as", "$", "id", "=>", "$", "listener", ")", "{", "if", "(", "isset", "(", "$", "this", "->",...
Triggers the listeners of an event UNLESS they are only listening to a different queue. Since we get an array of listener instances which are not tied any more to the service key, we have to do a slow loop to find if any listener was tied to a particular queue... @param callable[] $listeners The event listeners. @param string $eventName The name of the event to dispatch. @param Event $event The event object to pass to the event handlers/listeners.
[ "Triggers", "the", "listeners", "of", "an", "event", "UNLESS", "they", "are", "only", "listening", "to", "a", "different", "queue", ".", "Since", "we", "get", "an", "array", "of", "listener", "instances", "which", "are", "not", "tied", "any", "more", "to",...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L52-L74
kaliop-uk/kueueingbundle
Service/EventDispatcher.php
EventDispatcher.lazyLoad
protected function lazyLoad($eventName) { parent::lazyLoad($eventName); if (isset($this->listenerIds[$eventName])) { foreach ($this->listenerIds[$eventName] as $args) { list($serviceId, $method, $priority, $queueName) = $args; if ($queueName != null) { $listener = $this->container->get($serviceId); $key = $serviceId.'.'.$method; $this->listeners[$eventName][$key] = array($listener, $queueName); } } } }
php
protected function lazyLoad($eventName) { parent::lazyLoad($eventName); if (isset($this->listenerIds[$eventName])) { foreach ($this->listenerIds[$eventName] as $args) { list($serviceId, $method, $priority, $queueName) = $args; if ($queueName != null) { $listener = $this->container->get($serviceId); $key = $serviceId.'.'.$method; $this->listeners[$eventName][$key] = array($listener, $queueName); } } } }
[ "protected", "function", "lazyLoad", "(", "$", "eventName", ")", "{", "parent", "::", "lazyLoad", "(", "$", "eventName", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "listenerIds", "[", "$", "eventName", "]", ")", ")", "{", "foreach", "(", "...
When loading listener services, store in a separate index the queue to which service is limited @param string $eventName
[ "When", "loading", "listener", "services", "store", "in", "a", "separate", "index", "the", "queue", "to", "which", "service", "is", "limited" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L80-L94
bigwhoop/sentence-breaker
src/Lexing/States/QuotedStringState.php
QuotedStringState.call
protected function call(Lexer $lexer) { $start = $lexer->next(); while (true) { $next = $lexer->next(); if ($next === null) { throw new StateException('Failed to find end of quote. Reached end of input. Read: '.$lexer->getTokenValue()); } if ($start === $next) { break; } } $lexer->emit(new QuotedStringToken()); return new TextState(); }
php
protected function call(Lexer $lexer) { $start = $lexer->next(); while (true) { $next = $lexer->next(); if ($next === null) { throw new StateException('Failed to find end of quote. Reached end of input. Read: '.$lexer->getTokenValue()); } if ($start === $next) { break; } } $lexer->emit(new QuotedStringToken()); return new TextState(); }
[ "protected", "function", "call", "(", "Lexer", "$", "lexer", ")", "{", "$", "start", "=", "$", "lexer", "->", "next", "(", ")", ";", "while", "(", "true", ")", "{", "$", "next", "=", "$", "lexer", "->", "next", "(", ")", ";", "if", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/States/QuotedStringState.php#L23-L42
marvin255/bxcodegen
src/generator/Rocketeer.php
Rocketeer.generate
public function generate(CollectionInterface $options, ServiceLocatorInterface $locator) { $rocketeerFolder = $options->get('rocketeer_folder', '.rocketeer'); $templateData = $this->collectDataFromInputForTemplate($options); $sourcePath = $options->get('source', dirname(dirname(__DIR__)) . '/templates/rocketeer'); $destinationPath = $locator->get('pathManager')->getAbsolutePath("/{$rocketeerFolder}"); $copier = $this->getAndConfigurateCopierFromLocator($locator, $templateData); $source = new Directory($sourcePath); $destination = new Directory($destinationPath); if ($destination->isExists()) { throw new InvalidArgumentException( 'Directory ' . $destination->getPathname() . ' already exists' ); } $copier->copyDir($source, $destination); if ($options->get('gitignore_inject', false)) { $gitignorePath = $locator->get('pathManager')->getAbsolutePath( $options->get('gitignore_path', '.gitignore') ); $gitignoreData = '.rocketeer/logs'; if (!file_exists($gitignorePath)) { file_put_contents($gitignorePath, $gitignoreData); } elseif (mb_strpos(file_get_contents($gitignorePath), $gitignoreData) === false) { file_put_contents($gitignorePath, "\r\n\r\n" . $gitignoreData, FILE_APPEND); } } if ($options->get('phar_inject', false)) { $pharUrl = $options->get('phar_url', 'http://rocketeer.autopergamene.eu/versions/rocketeer.phar'); $pharPath = $locator->get('pathManager')->getAbsolutePath( 'rocketeer.phar' ); $fh = @fopen($pharUrl, 'r'); if ($fh === false) { throw new InvalidArgumentException( "Can't open {$pharUrl} for download" ); } file_put_contents($pharPath, $fh); fclose($fh); } }
php
public function generate(CollectionInterface $options, ServiceLocatorInterface $locator) { $rocketeerFolder = $options->get('rocketeer_folder', '.rocketeer'); $templateData = $this->collectDataFromInputForTemplate($options); $sourcePath = $options->get('source', dirname(dirname(__DIR__)) . '/templates/rocketeer'); $destinationPath = $locator->get('pathManager')->getAbsolutePath("/{$rocketeerFolder}"); $copier = $this->getAndConfigurateCopierFromLocator($locator, $templateData); $source = new Directory($sourcePath); $destination = new Directory($destinationPath); if ($destination->isExists()) { throw new InvalidArgumentException( 'Directory ' . $destination->getPathname() . ' already exists' ); } $copier->copyDir($source, $destination); if ($options->get('gitignore_inject', false)) { $gitignorePath = $locator->get('pathManager')->getAbsolutePath( $options->get('gitignore_path', '.gitignore') ); $gitignoreData = '.rocketeer/logs'; if (!file_exists($gitignorePath)) { file_put_contents($gitignorePath, $gitignoreData); } elseif (mb_strpos(file_get_contents($gitignorePath), $gitignoreData) === false) { file_put_contents($gitignorePath, "\r\n\r\n" . $gitignoreData, FILE_APPEND); } } if ($options->get('phar_inject', false)) { $pharUrl = $options->get('phar_url', 'http://rocketeer.autopergamene.eu/versions/rocketeer.phar'); $pharPath = $locator->get('pathManager')->getAbsolutePath( 'rocketeer.phar' ); $fh = @fopen($pharUrl, 'r'); if ($fh === false) { throw new InvalidArgumentException( "Can't open {$pharUrl} for download" ); } file_put_contents($pharPath, $fh); fclose($fh); } }
[ "public", "function", "generate", "(", "CollectionInterface", "$", "options", ",", "ServiceLocatorInterface", "$", "locator", ")", "{", "$", "rocketeerFolder", "=", "$", "options", "->", "get", "(", "'rocketeer_folder'", ",", "'.rocketeer'", ")", ";", "$", "temp...
{@inheritdoc} @throws \InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/generator/Rocketeer.php#L20-L65
marvin255/bxcodegen
src/generator/Rocketeer.php
Rocketeer.collectDataFromInputForTemplate
protected function collectDataFromInputForTemplate(CollectionInterface $options) { return [ 'application_name' => $options->get('application_name', ''), 'root_directory' => $options->get('root_directory', ''), 'repository' => $options->get('repository', ''), 'branch' => $options->get('branch', 'master'), 'host' => $options->get('host', ''), 'username' => $options->get('username', ''), 'password' => $options->get('password', ''), 'key' => $options->get('key', ''), 'keyphrase' => $options->get('keyphrase', ''), ]; }
php
protected function collectDataFromInputForTemplate(CollectionInterface $options) { return [ 'application_name' => $options->get('application_name', ''), 'root_directory' => $options->get('root_directory', ''), 'repository' => $options->get('repository', ''), 'branch' => $options->get('branch', 'master'), 'host' => $options->get('host', ''), 'username' => $options->get('username', ''), 'password' => $options->get('password', ''), 'key' => $options->get('key', ''), 'keyphrase' => $options->get('keyphrase', ''), ]; }
[ "protected", "function", "collectDataFromInputForTemplate", "(", "CollectionInterface", "$", "options", ")", "{", "return", "[", "'application_name'", "=>", "$", "options", "->", "get", "(", "'application_name'", ",", "''", ")", ",", "'root_directory'", "=>", "$", ...
Собирает массив опций для шаблонов из тех опций, что пришли от пользователя. @param \marvin255\bxcodegen\service\options\CollectionInterface $options @return array @throws \InvalidArgumentException
[ "Собирает", "массив", "опций", "для", "шаблонов", "из", "тех", "опций", "что", "пришли", "от", "пользователя", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/generator/Rocketeer.php#L76-L89
scherersoftware/cake-notifications
src/Notification/EmailNotification.php
EmailNotification.push
public function push() { return Queue::push($this->_transport . '::processQueueObject', [ 'email' => $this->_email->serialize(), 'beforeSendCallback' => $this->_beforeSendCallback, 'afterSendCallback' => $this->_afterSendCallback, 'locale' => $this->_locale ], $this->_queueOptions); }
php
public function push() { return Queue::push($this->_transport . '::processQueueObject', [ 'email' => $this->_email->serialize(), 'beforeSendCallback' => $this->_beforeSendCallback, 'afterSendCallback' => $this->_afterSendCallback, 'locale' => $this->_locale ], $this->_queueOptions); }
[ "public", "function", "push", "(", ")", "{", "return", "Queue", "::", "push", "(", "$", "this", "->", "_transport", ".", "'::processQueueObject'", ",", "[", "'email'", "=>", "$", "this", "->", "_email", "->", "serialize", "(", ")", ",", "'beforeSendCallbac...
{@inheritdoc}
[ "{" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Notification/EmailNotification.php#L39-L47
budde377/Part
lib/model/page/DefaultPageImpl.php
DefaultPageImpl.match
public function match($id) { return $id == $this->id || (strlen($this->getAlias()) && @preg_match($this->getAlias(), $id)); }
php
public function match($id) { return $id == $this->id || (strlen($this->getAlias()) && @preg_match($this->getAlias(), $id)); }
[ "public", "function", "match", "(", "$", "id", ")", "{", "return", "$", "id", "==", "$", "this", "->", "id", "||", "(", "strlen", "(", "$", "this", "->", "getAlias", "(", ")", ")", "&&", "@", "preg_match", "(", "$", "this", "->", "getAlias", "(",...
This will return TRUE if the $id match the page else FALSE. @param $id string @return bool
[ "This", "will", "return", "TRUE", "if", "the", "$id", "match", "the", "page", "else", "FALSE", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/DefaultPageImpl.php#L140-L143
ronisaha/easy-bangla-date
src/Types/BnDateTime.php
BnDateTime.create
public static function create($time = null) { if (is_string($time)) { $time = new self($time); } if (self::isNullOrBnDateTimeObject($time)) { return $time; } $dateTime = new self(); if ($time instanceof \DateTime) { $dateTime->setTimezone($time->getTimezone()); $time = $time->getTimestamp(); } $dateTime->setTimestamp($time); return $dateTime; }
php
public static function create($time = null) { if (is_string($time)) { $time = new self($time); } if (self::isNullOrBnDateTimeObject($time)) { return $time; } $dateTime = new self(); if ($time instanceof \DateTime) { $dateTime->setTimezone($time->getTimezone()); $time = $time->getTimestamp(); } $dateTime->setTimestamp($time); return $dateTime; }
[ "public", "static", "function", "create", "(", "$", "time", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "time", ")", ")", "{", "$", "time", "=", "new", "self", "(", "$", "time", ")", ";", "}", "if", "(", "self", "::", "isNullOrBnDate...
@param DateTime|\DateTime|BnDateTime|string $time @return null|BnDateTime
[ "@param", "DateTime|", "\\", "DateTime|BnDateTime|string", "$time" ]
train
https://github.com/ronisaha/easy-bangla-date/blob/bae41f86401854a31bf8465e7d85e4fe892908eb/src/Types/BnDateTime.php#L54-L74
nymo/silex-twig-breadcrumb-extension
src/nymo/Twig/Extension/BreadCrumbExtension.php
BreadCrumbExtension.renderBreadCrumbs
public function renderBreadCrumbs(): string { $translator = isset($this->app['translator']) ? true : false; return $this->app['twig']->render( 'breadcrumbs.html.twig', [ 'breadcrumbs' => $this->app['breadcrumbs']->getItems(), 'separator' => $this->separator, 'translator' => $translator ] ); }
php
public function renderBreadCrumbs(): string { $translator = isset($this->app['translator']) ? true : false; return $this->app['twig']->render( 'breadcrumbs.html.twig', [ 'breadcrumbs' => $this->app['breadcrumbs']->getItems(), 'separator' => $this->separator, 'translator' => $translator ] ); }
[ "public", "function", "renderBreadCrumbs", "(", ")", ":", "string", "{", "$", "translator", "=", "isset", "(", "$", "this", "->", "app", "[", "'translator'", "]", ")", "?", "true", ":", "false", ";", "return", "$", "this", "->", "app", "[", "'twig'", ...
Returns the rendered breadcrumb template @return string
[ "Returns", "the", "rendered", "breadcrumb", "template" ]
train
https://github.com/nymo/silex-twig-breadcrumb-extension/blob/9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56/src/nymo/Twig/Extension/BreadCrumbExtension.php#L64-L76
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeResponse
public function decodeResponse($response) { $xml_data = simplexml_load_string($response); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC response"); $data = array(); try { if ( isset($xml_data->fault) ) { $this->is_fault = true; array_push($data, $this->decodeValue($xml_data->fault->value)); } else if ( isset($xml_data->params) ) { foreach ( $xml_data->params->param as $param ) array_push($data, $this->decodeValue($param->value)); } else throw new XmlrpcException("Uncomprensible response"); } catch (XmlrpcException $xe) { throw $xe; } return isset($data[0]) ? $data[0] : $data; }
php
public function decodeResponse($response) { $xml_data = simplexml_load_string($response); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC response"); $data = array(); try { if ( isset($xml_data->fault) ) { $this->is_fault = true; array_push($data, $this->decodeValue($xml_data->fault->value)); } else if ( isset($xml_data->params) ) { foreach ( $xml_data->params->param as $param ) array_push($data, $this->decodeValue($param->value)); } else throw new XmlrpcException("Uncomprensible response"); } catch (XmlrpcException $xe) { throw $xe; } return isset($data[0]) ? $data[0] : $data; }
[ "public", "function", "decodeResponse", "(", "$", "response", ")", "{", "$", "xml_data", "=", "simplexml_load_string", "(", "$", "response", ")", ";", "if", "(", "$", "xml_data", "===", "false", ")", "throw", "new", "XmlrpcException", "(", "\"Not a valid XMLRP...
Decode an xmlrpc response @param string $response @return array @throws \Comodojo\Exception\XmlrpcException
[ "Decode", "an", "xmlrpc", "response" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L43-L73
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeCall
public function decodeCall($request) { $xml_data = simplexml_load_string($request); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC call"); if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible request"); $method_name = $this->decodeString($xml_data->methodName[0]); if ( $method_name == "system.multicall" ) { try { $data = $this->multicallDecode($xml_data); } catch (XmlrpcException $xe) { throw $xe; } } else { $parsed = array(); try { foreach ( $xml_data->params->param as $param ) $parsed[] = $this->decodeValue($param->value); } catch (XmlrpcException $xe) { throw $xe; } $data = array($method_name, $parsed); } return $data; }
php
public function decodeCall($request) { $xml_data = simplexml_load_string($request); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC call"); if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible request"); $method_name = $this->decodeString($xml_data->methodName[0]); if ( $method_name == "system.multicall" ) { try { $data = $this->multicallDecode($xml_data); } catch (XmlrpcException $xe) { throw $xe; } } else { $parsed = array(); try { foreach ( $xml_data->params->param as $param ) $parsed[] = $this->decodeValue($param->value); } catch (XmlrpcException $xe) { throw $xe; } $data = array($method_name, $parsed); } return $data; }
[ "public", "function", "decodeCall", "(", "$", "request", ")", "{", "$", "xml_data", "=", "simplexml_load_string", "(", "$", "request", ")", ";", "if", "(", "$", "xml_data", "===", "false", ")", "throw", "new", "XmlrpcException", "(", "\"Not a valid XMLRPC call...
Decode an xmlrpc request. Can handle single or multicall requests and return an array of: [method], [data] WARNING: in case of multicall, it will not throw any exception for an invalid boxcarred request; a null value will be placed instead of array(method,params). @param string $request @return array @throws \Comodojo\Exception\XmlrpcException
[ "Decode", "an", "xmlrpc", "request", "." ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L95-L137
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeMulticall
public function decodeMulticall($request) { $xml_data = simplexml_load_string($request); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC multicall"); if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible multicall request"); if ( $this->decodeString($xml_data->methodName[0]) != "system.multicall" ) throw new XmlrpcException("Invalid multicall request"); try { $data = $this->multicallDecode($xml_data); } catch (XmlrpcException $xe) { throw $xe; } return $data; }
php
public function decodeMulticall($request) { $xml_data = simplexml_load_string($request); if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC multicall"); if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible multicall request"); if ( $this->decodeString($xml_data->methodName[0]) != "system.multicall" ) throw new XmlrpcException("Invalid multicall request"); try { $data = $this->multicallDecode($xml_data); } catch (XmlrpcException $xe) { throw $xe; } return $data; }
[ "public", "function", "decodeMulticall", "(", "$", "request", ")", "{", "$", "xml_data", "=", "simplexml_load_string", "(", "$", "request", ")", ";", "if", "(", "$", "xml_data", "===", "false", ")", "throw", "new", "XmlrpcException", "(", "\"Not a valid XMLRPC...
Decode an xmlrpc multicall @param string $request @return array @throws \Comodojo\Exception\XmlrpcException
[ "Decode", "an", "xmlrpc", "multicall" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L148-L170
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeValue
private function decodeValue($value) { $children = $value->children(); if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element"); $child = $children[0]; $child_type = $child->getName(); switch ( $child_type ) { case "i4": case "int": $return_value = $this->decodeInt($child); break; case "double": $return_value = $this->decodeDouble($child); break; case "boolean": $return_value = $this->decodeBool($child); break; case "base64": $return_value = $this->decodeBase($child); break; case "dateTime.iso8601": $return_value = $this->decodeIso8601Datetime($child); break; case "string": $return_value = $this->decodeString($child); break; case "array": $return_value = $this->decodeArray($child); break; case "struct": $return_value = $this->decodeStruct($child); break; case "nil": case "ex:nil": $return_value = $this->decodeNil(); break; default: throw new XmlrpcException("Cannot decode value: invalid value type"); break; } return $return_value; }
php
private function decodeValue($value) { $children = $value->children(); if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element"); $child = $children[0]; $child_type = $child->getName(); switch ( $child_type ) { case "i4": case "int": $return_value = $this->decodeInt($child); break; case "double": $return_value = $this->decodeDouble($child); break; case "boolean": $return_value = $this->decodeBool($child); break; case "base64": $return_value = $this->decodeBase($child); break; case "dateTime.iso8601": $return_value = $this->decodeIso8601Datetime($child); break; case "string": $return_value = $this->decodeString($child); break; case "array": $return_value = $this->decodeArray($child); break; case "struct": $return_value = $this->decodeStruct($child); break; case "nil": case "ex:nil": $return_value = $this->decodeNil(); break; default: throw new XmlrpcException("Cannot decode value: invalid value type"); break; } return $return_value; }
[ "private", "function", "decodeValue", "(", "$", "value", ")", "{", "$", "children", "=", "$", "value", "->", "children", "(", ")", ";", "if", "(", "count", "(", "$", "children", ")", "!=", "1", ")", "throw", "new", "XmlrpcException", "(", "\"Cannot dec...
Decode a value from xmlrpc data @param mixed $value @return mixed @throws \Comodojo\Exception\XmlrpcException
[ "Decode", "a", "value", "from", "xmlrpc", "data" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L181-L239
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeStruct
private function decodeStruct($struct) { $return_value = array(); foreach ( $struct->member as $member ) { $name = $member->name.""; $value = $this->decodeValue($member->value); $return_value[$name] = $value; } return $return_value; }
php
private function decodeStruct($struct) { $return_value = array(); foreach ( $struct->member as $member ) { $name = $member->name.""; $value = $this->decodeValue($member->value); $return_value[$name] = $value; } return $return_value; }
[ "private", "function", "decodeStruct", "(", "$", "struct", ")", "{", "$", "return_value", "=", "array", "(", ")", ";", "foreach", "(", "$", "struct", "->", "member", "as", "$", "member", ")", "{", "$", "name", "=", "$", "member", "->", "name", ".", ...
Decode an XML-RPC <struct>
[ "Decode", "an", "XML", "-", "RPC", "<struct", ">" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L307-L321
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.decodeArray
private function decodeArray($array) { $return_value = array(); foreach ( $array->data->value as $value ) { $return_value[] = $this->decodeValue($value); } return $return_value; }
php
private function decodeArray($array) { $return_value = array(); foreach ( $array->data->value as $value ) { $return_value[] = $this->decodeValue($value); } return $return_value; }
[ "private", "function", "decodeArray", "(", "$", "array", ")", "{", "$", "return_value", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "->", "data", "->", "value", "as", "$", "value", ")", "{", "$", "return_value", "[", "]", "=", "$", "...
Decode an XML-RPC <array> element
[ "Decode", "an", "XML", "-", "RPC", "<array", ">", "element" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L326-L338
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
XmlrpcDecoder.multicallDecode
private function multicallDecode($xml_data) { $data = array(); try { $calls = $xml_data->params->param->value->children(); $calls_array = $this->decodeArray($calls[0]); foreach ( $calls_array as $call ) { $data[] = (!isset($call['methodName']) || !isset($call['params'])) ? null : array($call['methodName'], $call['params']); } } catch (XmlrpcException $xe) { throw $xe; } return $data; }
php
private function multicallDecode($xml_data) { $data = array(); try { $calls = $xml_data->params->param->value->children(); $calls_array = $this->decodeArray($calls[0]); foreach ( $calls_array as $call ) { $data[] = (!isset($call['methodName']) || !isset($call['params'])) ? null : array($call['methodName'], $call['params']); } } catch (XmlrpcException $xe) { throw $xe; } return $data; }
[ "private", "function", "multicallDecode", "(", "$", "xml_data", ")", "{", "$", "data", "=", "array", "(", ")", ";", "try", "{", "$", "calls", "=", "$", "xml_data", "->", "params", "->", "param", "->", "value", "->", "children", "(", ")", ";", "$", ...
Decode an XML-RPC multicall request (internal) @param \SimpleXMLElement $xml_data
[ "Decode", "an", "XML", "-", "RPC", "multicall", "request", "(", "internal", ")" ]
train
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L344-L368
wardrobecms/core-archived
src/Wardrobe/Core/Console/UserCommand.php
UserCommand.fire
public function fire() { $first_name = $this->argument('first_name'); $last_name = $this->argument('last_name'); $email = $this->argument('email'); $password = $this->argument('password'); if ($this->userRepo->create($first_name, $last_name, $email, true, $password)) { $this->info('User Created Successfully'); return; } else { return $this->error('User Could Not Be Created'); } }
php
public function fire() { $first_name = $this->argument('first_name'); $last_name = $this->argument('last_name'); $email = $this->argument('email'); $password = $this->argument('password'); if ($this->userRepo->create($first_name, $last_name, $email, true, $password)) { $this->info('User Created Successfully'); return; } else { return $this->error('User Could Not Be Created'); } }
[ "public", "function", "fire", "(", ")", "{", "$", "first_name", "=", "$", "this", "->", "argument", "(", "'first_name'", ")", ";", "$", "last_name", "=", "$", "this", "->", "argument", "(", "'last_name'", ")", ";", "$", "email", "=", "$", "this", "->...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Console/UserCommand.php#L41-L54
bigwhoop/sentence-breaker
src/ProbabilityCalculator.php
ProbabilityCalculator.calculate
public function calculate(array $tokens) { foreach ($tokens as $idx => $token) { if ($token instanceof PotentialAbbreviationToken) { if ($this->abbreviations->hasAbbreviation($token->getValue())) { $tokens[$idx] = new AbbreviationToken($token->getValue()); } } } $probabilities = []; for ($i = 0, $c = count($tokens); $i < $c; $i++) { $token = $tokens[$i]; $probability = new TokenProbability($token, 0); if ($this->rules->hasRule($token->getName())) { $patterns = $this->rules->getRule($token->getName())->getPatterns(); foreach ($patterns as $pattern) { $offsets = $pattern->getTokensOffsetRelativeToStartToken($token->getName()); foreach ($offsets as $offset => $expectedToken) { if (!array_key_exists($i + $offset, $tokens)) { continue 2; } $actualToken = $tokens[$i + $offset]; if ($actualToken->getName() !== $expectedToken->getTokenName()) { continue 2; } } $probability->setProbability($pattern->getProbability()); } } $probabilities[] = $probability; } return $probabilities; }
php
public function calculate(array $tokens) { foreach ($tokens as $idx => $token) { if ($token instanceof PotentialAbbreviationToken) { if ($this->abbreviations->hasAbbreviation($token->getValue())) { $tokens[$idx] = new AbbreviationToken($token->getValue()); } } } $probabilities = []; for ($i = 0, $c = count($tokens); $i < $c; $i++) { $token = $tokens[$i]; $probability = new TokenProbability($token, 0); if ($this->rules->hasRule($token->getName())) { $patterns = $this->rules->getRule($token->getName())->getPatterns(); foreach ($patterns as $pattern) { $offsets = $pattern->getTokensOffsetRelativeToStartToken($token->getName()); foreach ($offsets as $offset => $expectedToken) { if (!array_key_exists($i + $offset, $tokens)) { continue 2; } $actualToken = $tokens[$i + $offset]; if ($actualToken->getName() !== $expectedToken->getTokenName()) { continue 2; } } $probability->setProbability($pattern->getProbability()); } } $probabilities[] = $probability; } return $probabilities; }
[ "public", "function", "calculate", "(", "array", "$", "tokens", ")", "{", "foreach", "(", "$", "tokens", "as", "$", "idx", "=>", "$", "token", ")", "{", "if", "(", "$", "token", "instanceof", "PotentialAbbreviationToken", ")", "{", "if", "(", "$", "thi...
@param Token[] $tokens @return TokenProbability[]
[ "@param", "Token", "[]", "$tokens" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/ProbabilityCalculator.php#L73-L115
fab2s/NodalFlow
src/Flows/FlowIdTrait.php
FlowIdTrait.getId
public function getId() { if ($this->id === null) { return $this->id = SoUuid::generate()->getString(); } return $this->id; }
php
public function getId() { if ($this->id === null) { return $this->id = SoUuid::generate()->getString(); } return $this->id; }
[ "public", "function", "getId", "(", ")", "{", "if", "(", "$", "this", "->", "id", "===", "null", ")", "{", "return", "$", "this", "->", "id", "=", "SoUuid", "::", "generate", "(", ")", "->", "getString", "(", ")", ";", "}", "return", "$", "this",...
Return the immutable unique Flow / Node id Since this method is not used in the actual flow execution loop, but only when an interruption is raised, it's not a performance issue to add an if. And it's more convenient to lazy generate as this trait does not need any init/construct logic. @return string immutable unique id
[ "Return", "the", "immutable", "unique", "Flow", "/", "Node", "id", "Since", "this", "method", "is", "not", "used", "in", "the", "actual", "flow", "execution", "loop", "but", "only", "when", "an", "interruption", "is", "raised", "it", "s", "not", "a", "pe...
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowIdTrait.php#L57-L64
budde377/Part
lib/model/user/UserImpl.php
UserImpl.setUsername
public function setUsername($username) { if($username == $this->username){ return true; } if ($this->usernameExists($username)) { return false; } if ($this->setUsernameStatement === null) { $this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?"); } $wasLoggedIn = $this->isLoggedIn(); $this->setUsernameStatement->execute(array($username, $this->username)); $this->username = $username; if ($wasLoggedIn) { $this->updateLoginSession(); } $this->notifyObservers(User::EVENT_USERNAME_UPDATE); return true; }
php
public function setUsername($username) { if($username == $this->username){ return true; } if ($this->usernameExists($username)) { return false; } if ($this->setUsernameStatement === null) { $this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?"); } $wasLoggedIn = $this->isLoggedIn(); $this->setUsernameStatement->execute(array($username, $this->username)); $this->username = $username; if ($wasLoggedIn) { $this->updateLoginSession(); } $this->notifyObservers(User::EVENT_USERNAME_UPDATE); return true; }
[ "public", "function", "setUsername", "(", "$", "username", ")", "{", "if", "(", "$", "username", "==", "$", "this", "->", "username", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "usernameExists", "(", "$", "username", ")", ")"...
Will set the username, if username is unique. @param string $username @return bool FALSE if username invalid, TRUE on success
[ "Will", "set", "the", "username", "if", "username", "is", "unique", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L95-L117
budde377/Part
lib/model/user/UserImpl.php
UserImpl.setMail
public function setMail($mail) { if (!$this->validMail($mail)) { return false; } if ($this->setMailStatement === null) { $this->setMailStatement = $this->connection->prepare("UPDATE User SET mail = ? WHERE username = ?"); $this->setMailStatement->bindParam(1, $this->mail); $this->setMailStatement->bindParam(2, $this->username); } $this->mail = $mail; $this->setMailStatement->execute(); return true; }
php
public function setMail($mail) { if (!$this->validMail($mail)) { return false; } if ($this->setMailStatement === null) { $this->setMailStatement = $this->connection->prepare("UPDATE User SET mail = ? WHERE username = ?"); $this->setMailStatement->bindParam(1, $this->mail); $this->setMailStatement->bindParam(2, $this->username); } $this->mail = $mail; $this->setMailStatement->execute(); return true; }
[ "public", "function", "setMail", "(", "$", "mail", ")", "{", "if", "(", "!", "$", "this", "->", "validMail", "(", "$", "mail", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "setMailStatement", "===", "null", ")", "{", ...
Set the mail of the user, if mail is of right format. @param string $mail @return bool FALSE on wrong format of mail, else TRUE on success
[ "Set", "the", "mail", "of", "the", "user", "if", "mail", "is", "of", "right", "format", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L124-L138
budde377/Part
lib/model/user/UserImpl.php
UserImpl.setPassword
public function setPassword($password) { if(!$this->isValidPassword($password)){ return false; } if ($this->setPasswordStatement === null) { $this->setPasswordStatement = $this->connection->prepare("UPDATE User SET password=? WHERE username=?"); $this->setPasswordStatement->bindParam(1, $this->password); $this->setPasswordStatement->bindParam(2, $this->username); } $wasLoggedIn = $this->isLoggedIn(); $this->password = $this->hashPassword($password); $this->setPasswordStatement->execute(); if ($wasLoggedIn) { $this->updateLoginSession(); } return true; }
php
public function setPassword($password) { if(!$this->isValidPassword($password)){ return false; } if ($this->setPasswordStatement === null) { $this->setPasswordStatement = $this->connection->prepare("UPDATE User SET password=? WHERE username=?"); $this->setPasswordStatement->bindParam(1, $this->password); $this->setPasswordStatement->bindParam(2, $this->username); } $wasLoggedIn = $this->isLoggedIn(); $this->password = $this->hashPassword($password); $this->setPasswordStatement->execute(); if ($wasLoggedIn) { $this->updateLoginSession(); } return true; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "if", "(", "!", "$", "this", "->", "isValidPassword", "(", "$", "password", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "setPasswordStatement", "===", "n...
Sets the password. Password must be non-empty string @param string $password @return bool
[ "Sets", "the", "password", ".", "Password", "must", "be", "non", "-", "empty", "string" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L145-L166
budde377/Part
lib/model/user/UserImpl.php
UserImpl.delete
public function delete() { if ($this->deleteStatement == null) { $this->deleteStatement = $this->connection->prepare("DELETE FROM User WHERE username = ?"); $this->deleteStatement->bindParam(1, $this->username); } try{ $this->deleteStatement->execute(); } catch (PDOException $exception){ return false; } if ($this->exists()) { return false; } $this->notifyObservers(User::EVENT_DELETE); return true; }
php
public function delete() { if ($this->deleteStatement == null) { $this->deleteStatement = $this->connection->prepare("DELETE FROM User WHERE username = ?"); $this->deleteStatement->bindParam(1, $this->username); } try{ $this->deleteStatement->execute(); } catch (PDOException $exception){ return false; } if ($this->exists()) { return false; } $this->notifyObservers(User::EVENT_DELETE); return true; }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "deleteStatement", "==", "null", ")", "{", "$", "this", "->", "deleteStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM User WHERE username = ?\"",...
Will delete user from persistent storage @return bool Will return FALSE on failure, else TRUE
[ "Will", "delete", "user", "from", "persistent", "storage" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L182-L198
budde377/Part
lib/model/user/UserImpl.php
UserImpl.create
public function create() { if ($this->createStatement == null) { $this->createStatement = $this->connection->prepare(" INSERT INTO User (username,mail,password,id,parent) VALUES (?,?,?,?,?)"); $this->createStatement->bindParam(1, $this->username); $this->createStatement->bindParam(2, $this->mail); $this->createStatement->bindParam(3, $this->password); $this->createStatement->bindParam(4, $this->userId); $this->createStatement->bindParam(5, $this->parentID); } try { $this->createStatement->execute(); } catch (PDOException $e) { return false; } $this->setInitialValues(); return $this->exists(); }
php
public function create() { if ($this->createStatement == null) { $this->createStatement = $this->connection->prepare(" INSERT INTO User (username,mail,password,id,parent) VALUES (?,?,?,?,?)"); $this->createStatement->bindParam(1, $this->username); $this->createStatement->bindParam(2, $this->mail); $this->createStatement->bindParam(3, $this->password); $this->createStatement->bindParam(4, $this->userId); $this->createStatement->bindParam(5, $this->parentID); } try { $this->createStatement->execute(); } catch (PDOException $e) { return false; } $this->setInitialValues(); return $this->exists(); }
[ "public", "function", "create", "(", ")", "{", "if", "(", "$", "this", "->", "createStatement", "==", "null", ")", "{", "$", "this", "->", "createStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"\n INSERT INTO User (usernam...
Create the user on persistent storage @return bool Will return TRUE if user has been created on persistent storage, else FALSE
[ "Create", "the", "user", "on", "persistent", "storage" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L204-L222
budde377/Part
lib/model/user/UserImpl.php
UserImpl.login
public function login($password) { if (!$this->exists() || !$this->verifyLogin($password) || $this->someOneLoggedIn() ) { return false; } if ($this->lastLoginStatement === null) { $this->lastLoginStatement = $this->connection->prepare("UPDATE User SET lastLogin = FROM_UNIXTIME(?) WHERE username = ?"); $this->lastLoginStatement->bindParam(1, $this->lastLogin); $this->lastLoginStatement->bindParam(2, $this->username); } $this->lastLogin = time(); $this->lastLoginStatement->execute(); $this->updateLoginSession(); $this->notifyObservers(User::EVENT_LOGIN); return true; }
php
public function login($password) { if (!$this->exists() || !$this->verifyLogin($password) || $this->someOneLoggedIn() ) { return false; } if ($this->lastLoginStatement === null) { $this->lastLoginStatement = $this->connection->prepare("UPDATE User SET lastLogin = FROM_UNIXTIME(?) WHERE username = ?"); $this->lastLoginStatement->bindParam(1, $this->lastLogin); $this->lastLoginStatement->bindParam(2, $this->username); } $this->lastLogin = time(); $this->lastLoginStatement->execute(); $this->updateLoginSession(); $this->notifyObservers(User::EVENT_LOGIN); return true; }
[ "public", "function", "login", "(", "$", "password", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", "||", "!", "$", "this", "->", "verifyLogin", "(", "$", "password", ")", "||", "$", "this", "->", "someOneLoggedIn", "(", ")", ")",...
Will login the user @param string $password @return bool FALSE if another user is logged in, including self, or if password is not valid. Else TRUE.
[ "Will", "login", "the", "user" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L247-L269
toni-kolev/MultilingualExtension
src/ServiceContainer/MultilingualExtension.php
MultilingualExtension.configure
public function configure(ArrayNodeDefinition $builder) { $config = $builder->children(); foreach (['default_language', 'translations'] as $param) { $config->scalarNode($param) ->end(); } $config->end(); }
php
public function configure(ArrayNodeDefinition $builder) { $config = $builder->children(); foreach (['default_language', 'translations'] as $param) { $config->scalarNode($param) ->end(); } $config->end(); }
[ "public", "function", "configure", "(", "ArrayNodeDefinition", "$", "builder", ")", "{", "$", "config", "=", "$", "builder", "->", "children", "(", ")", ";", "foreach", "(", "[", "'default_language'", ",", "'translations'", "]", "as", "$", "param", ")", "{...
{@inheritdoc}
[ "{" ]
train
https://github.com/toni-kolev/MultilingualExtension/blob/e0e1a9fc30e176e597bebb467ddf195cd5d555c3/src/ServiceContainer/MultilingualExtension.php#L54-L64
vcarreira/wordsapi
src/WordService.php
WordService.fetch
public function fetch($word, $verb, $prefetchDetails = false) { $url = 'https://wordsapiv1.p.mashape.com/words/'.rawurlencode($word); $verbIsHidden = array_key_exists($verb, $this->hiddenVerbs) || $prefetchDetails; if (!$verbIsHidden) { $url .= '/'.$verb; } $headers = [ 'X-Mashape-Key: '.$this->api_key, 'Accept: application/json', ]; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($statusCode !== 200) { return false; } if (is_null($response) || empty($response)) { return false; } $data = json_decode($response, true); if ($verbIsHidden) { return $this->transformFullRequest($data); } return [$verb => $this->transformVerb($data, $verb)]; }
php
public function fetch($word, $verb, $prefetchDetails = false) { $url = 'https://wordsapiv1.p.mashape.com/words/'.rawurlencode($word); $verbIsHidden = array_key_exists($verb, $this->hiddenVerbs) || $prefetchDetails; if (!$verbIsHidden) { $url .= '/'.$verb; } $headers = [ 'X-Mashape-Key: '.$this->api_key, 'Accept: application/json', ]; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($statusCode !== 200) { return false; } if (is_null($response) || empty($response)) { return false; } $data = json_decode($response, true); if ($verbIsHidden) { return $this->transformFullRequest($data); } return [$verb => $this->transformVerb($data, $verb)]; }
[ "public", "function", "fetch", "(", "$", "word", ",", "$", "verb", ",", "$", "prefetchDetails", "=", "false", ")", "{", "$", "url", "=", "'https://wordsapiv1.p.mashape.com/words/'", ".", "rawurlencode", "(", "$", "word", ")", ";", "$", "verbIsHidden", "=", ...
Fetch information about a specific word. @param string $word the word to fetch. @param string $verb the type of information to fetch. Check the {@link https://www.wordsapi.com/docs Words API documentation}. @param bool $prefetchDetails true to ignore the verb and pre-fetch all word details. @return array|false an associative array (indexed by verb) with the requested information, false if the word is not found.
[ "Fetch", "information", "about", "a", "specific", "word", "." ]
train
https://github.com/vcarreira/wordsapi/blob/60ca55823ffdf8c422e6bbed614161dc8d6af394/src/WordService.php#L102-L137
scherersoftware/cake-model-history
src/Model/Transform/BoolTransform.php
BoolTransform.display
public function display(string $fieldname, $value, string $model = null) { $value = $value === true ? 'true' : 'false'; return $value; }
php
public function display(string $fieldname, $value, string $model = null) { $value = $value === true ? 'true' : 'false'; return $value; }
[ "public", "function", "display", "(", "string", "$", "fieldname", ",", "$", "value", ",", "string", "$", "model", "=", "null", ")", "{", "$", "value", "=", "$", "value", "===", "true", "?", "'true'", ":", "'false'", ";", "return", "$", "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/BoolTransform.php#L31-L36
baleen/migrations
src/Migration/Factory/SimpleFactory.php
SimpleFactory.create
public function create($class, $args = []) { $class = (string) $class; if (empty($class)) { throw new InvalidArgumentException( 'Cannot create a migration from an empty class name!' ); } if (!is_array($args)) { throw new InvalidArgumentException( 'Argument "params" must be an array of parameters.' ); } if (!empty($args)) { $class = new \ReflectionClass($class); $instance = $class->newInstanceArgs($args); } else { $instance = new $class(); } return $instance; }
php
public function create($class, $args = []) { $class = (string) $class; if (empty($class)) { throw new InvalidArgumentException( 'Cannot create a migration from an empty class name!' ); } if (!is_array($args)) { throw new InvalidArgumentException( 'Argument "params" must be an array of parameters.' ); } if (!empty($args)) { $class = new \ReflectionClass($class); $instance = $class->newInstanceArgs($args); } else { $instance = new $class(); } return $instance; }
[ "public", "function", "create", "(", "$", "class", ",", "$", "args", "=", "[", "]", ")", "{", "$", "class", "=", "(", "string", ")", "$", "class", ";", "if", "(", "empty", "(", "$", "class", ")", ")", "{", "throw", "new", "InvalidArgumentException"...
@inheritdoc @throws InvalidArgumentException
[ "@inheritdoc" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Factory/SimpleFactory.php#L34-L58
baleen/migrations
src/Delta/Collection/Resolver/OffsetResolver.php
OffsetResolver.doResolve
protected function doResolve($alias, Collection $collection) { // parse alias $matches = []; if (!preg_match(self::PATTERN, $alias, $matches)) { return null; } list(, $newAlias, $operator) = $matches; // resolve the new alias (this will allow to resolve e.g. HEAD-1) $absoluteVersion = $collection->get($newAlias); if (null === $absoluteVersion) { return null; } // calculate the offset $count = !isset($matches[3]) ? strlen($operator) : (int) $matches[3]; if (strlen($operator) > 1) { $operator = substr($operator, 0, 1); } $multiplier = $operator === '+' ? 1 : -1; $offset = $count * $multiplier; // find version by absolute getPosition + offset $absolutePos = $collection->getPosition($absoluteVersion); return $collection->getByPosition($absolutePos + $offset); }
php
protected function doResolve($alias, Collection $collection) { // parse alias $matches = []; if (!preg_match(self::PATTERN, $alias, $matches)) { return null; } list(, $newAlias, $operator) = $matches; // resolve the new alias (this will allow to resolve e.g. HEAD-1) $absoluteVersion = $collection->get($newAlias); if (null === $absoluteVersion) { return null; } // calculate the offset $count = !isset($matches[3]) ? strlen($operator) : (int) $matches[3]; if (strlen($operator) > 1) { $operator = substr($operator, 0, 1); } $multiplier = $operator === '+' ? 1 : -1; $offset = $count * $multiplier; // find version by absolute getPosition + offset $absolutePos = $collection->getPosition($absoluteVersion); return $collection->getByPosition($absolutePos + $offset); }
[ "protected", "function", "doResolve", "(", "$", "alias", ",", "Collection", "$", "collection", ")", "{", "// parse alias", "$", "matches", "=", "[", "]", ";", "if", "(", "!", "preg_match", "(", "self", "::", "PATTERN", ",", "$", "alias", ",", "$", "mat...
@{inheritdoc} IMPROVE: this method has an NPath complexity of 400. The configured NPath complexity threshold is 200. @SuppressWarnings(PHPMD.NPathComplexity) @param string $alias @param Collection $collection @return DeltaInterface|null
[ "@", "{", "inheritdoc", "}" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/OffsetResolver.php#L58-L84
xylemical/php-expressions
src/ExpressionFactory.php
ExpressionFactory.getOperators
public function getOperators() { // Order the by priority then precedent. $list = (array)$this->operators; usort($list, function(Operator $a, Operator $b) { // Sort by priority. if ($a->getPriority() === $b->getPriority()) { // Then by associativity. if ($a->getAssociativity() == $b->getAssociativity()) { // Then by regex length (the longer the better). if (strlen($a->getRegex()) === strlen($b->getRegex())) { return 0; } return strlen($a->getRegex()) > strlen($b->getRegex()) ? -1 : 1; } return $a->getAssociativity() > $b->getAssociativity() ? -1 : 1; } return $a->getPriority() > $b->getPriority() ? -1 : 1; }); return $list; }
php
public function getOperators() { // Order the by priority then precedent. $list = (array)$this->operators; usort($list, function(Operator $a, Operator $b) { // Sort by priority. if ($a->getPriority() === $b->getPriority()) { // Then by associativity. if ($a->getAssociativity() == $b->getAssociativity()) { // Then by regex length (the longer the better). if (strlen($a->getRegex()) === strlen($b->getRegex())) { return 0; } return strlen($a->getRegex()) > strlen($b->getRegex()) ? -1 : 1; } return $a->getAssociativity() > $b->getAssociativity() ? -1 : 1; } return $a->getPriority() > $b->getPriority() ? -1 : 1; }); return $list; }
[ "public", "function", "getOperators", "(", ")", "{", "// Order the by priority then precedent.", "$", "list", "=", "(", "array", ")", "$", "this", "->", "operators", ";", "usort", "(", "$", "list", ",", "function", "(", "Operator", "$", "a", ",", "Operator",...
Get the list of operators ordered by priority and association. @return array
[ "Get", "the", "list", "of", "operators", "ordered", "by", "priority", "and", "association", "." ]
train
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/ExpressionFactory.php#L136-L157
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php
ExtensionRangeMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ExtensionRange(); case 1: return new ExtensionRange(func_get_arg(0)); case 2: return new ExtensionRange(func_get_arg(0), func_get_arg(1)); case 3: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ExtensionRange(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 ExtensionRange(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 ExtensionRange(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 ExtensionRange(); case 1: return new ExtensionRange(func_get_arg(0)); case 2: return new ExtensionRange(func_get_arg(0), func_get_arg(1)); case 3: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ExtensionRange(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 ExtensionRange(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 ExtensionRange(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", "ExtensionRange", "(", ")", ";", "case", "1", ":", "return", "new", "ExtensionRange", "(", "func_get_arg", "("...
Creates new instance of \Google\Protobuf\DescriptorProto\ExtensionRange @throws \InvalidArgumentException @return ExtensionRange
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ExtensionRange" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php
ExtensionRangeMeta.reset
public static function reset($object) { if (!($object instanceof ExtensionRange)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ExtensionRange.'); } $object->start = NULL; $object->end = NULL; }
php
public static function reset($object) { if (!($object instanceof ExtensionRange)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ExtensionRange.'); } $object->start = NULL; $object->end = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "ExtensionRange", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Desc...
Resets properties of \Google\Protobuf\DescriptorProto\ExtensionRange to default values @param ExtensionRange $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "DescriptorProto", "\\", "ExtensionRange", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php#L95-L102
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/PostController.php
PostController.index
public function index() { $search = trim(Input::get('q')); if ($search) { $posts = $this->posts->search(Input::get('q'), Config::get('wardrobe.per_page')); } else { $posts = $this->posts->active(Config::get('wardrobe.per_page')); } return View::make($this->theme.'.archive', compact('posts', 'search')); }
php
public function index() { $search = trim(Input::get('q')); if ($search) { $posts = $this->posts->search(Input::get('q'), Config::get('wardrobe.per_page')); } else { $posts = $this->posts->active(Config::get('wardrobe.per_page')); } return View::make($this->theme.'.archive', compact('posts', 'search')); }
[ "public", "function", "index", "(", ")", "{", "$", "search", "=", "trim", "(", "Input", "::", "get", "(", "'q'", ")", ")", ";", "if", "(", "$", "search", ")", "{", "$", "posts", "=", "$", "this", "->", "posts", "->", "search", "(", "Input", "::...
Display a listing of the resource. @return Response
[ "Display", "a", "listing", "of", "the", "resource", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L34-L47
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/PostController.php
PostController.tag
public function tag($tag) { $posts = $this->posts->activeByTag($tag, Config::get('wardrobe.per_page')); if ( ! $posts) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.archive', compact('posts', 'tag')); }
php
public function tag($tag) { $posts = $this->posts->activeByTag($tag, Config::get('wardrobe.per_page')); if ( ! $posts) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.archive', compact('posts', 'tag')); }
[ "public", "function", "tag", "(", "$", "tag", ")", "{", "$", "posts", "=", "$", "this", "->", "posts", "->", "activeByTag", "(", "$", "tag", ",", "Config", "::", "get", "(", "'wardrobe.per_page'", ")", ")", ";", "if", "(", "!", "$", "posts", ")", ...
Get posts by tag @param string $tag @return Response
[ "Get", "posts", "by", "tag" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L56-L66
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/PostController.php
PostController.show
public function show($slug) { $post = $this->posts->findBySlug($slug); if ( ! $post) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.post', compact('post')); }
php
public function show($slug) { $post = $this->posts->findBySlug($slug); if ( ! $post) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.post', compact('post')); }
[ "public", "function", "show", "(", "$", "slug", ")", "{", "$", "post", "=", "$", "this", "->", "posts", "->", "findBySlug", "(", "$", "slug", ")", ";", "if", "(", "!", "$", "post", ")", "{", "return", "App", "::", "abort", "(", "404", ",", "'Pa...
Display the specified resource. @param string $slug @return Response
[ "Display", "the", "specified", "resource", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L75-L85
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/PostController.php
PostController.preview
public function preview($id) { if ( ! $this->auth->check()) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.preview', array('id' => $id)); }
php
public function preview($id) { if ( ! $this->auth->check()) { return App::abort(404, 'Page not found'); } return View::make($this->theme.'.preview', array('id' => $id)); }
[ "public", "function", "preview", "(", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "auth", "->", "check", "(", ")", ")", "{", "return", "App", "::", "abort", "(", "404", ",", "'Page not found'", ")", ";", "}", "return", "View", "::", "...
Show a post preview. @param int $id @return Response
[ "Show", "a", "post", "preview", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L94-L102
bigwhoop/sentence-breaker
src/Lexing/States/WhitespaceState.php
WhitespaceState.call
protected function call(Lexer $lexer) { while (in_array($lexer->peek(), self::CHARS, true)) { $lexer->next(); } $lexer->emit(new WhitespaceToken()); return new TextState(); }
php
protected function call(Lexer $lexer) { while (in_array($lexer->peek(), self::CHARS, true)) { $lexer->next(); } $lexer->emit(new WhitespaceToken()); return new TextState(); }
[ "protected", "function", "call", "(", "Lexer", "$", "lexer", ")", "{", "while", "(", "in_array", "(", "$", "lexer", "->", "peek", "(", ")", ",", "self", "::", "CHARS", ",", "true", ")", ")", "{", "$", "lexer", "->", "next", "(", ")", ";", "}", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/States/WhitespaceState.php#L23-L32
kss-php/kss-php
lib/CommentParser.php
CommentParser.parseBlocks
protected function parseBlocks() { $this->blocks = array(); $currentBlock = ''; // Do we need insideSingleLineBlock? It doesn't seem to be used anywhere // Original Ruby version of KSS had it but I'm not seeing a purpose to it $insideSingleLineBlock = false; $insideMultiLineBlock = false; foreach ($this->file as $line) { $isSingleLineComment = self::isSingleLineComment($line); $isStartMultiLineComment = self::isStartMultiLineComment($line); $isEndMultiLineComment = self::isEndMultiLineComment($line); if ($isSingleLineComment) { $parsed = self::parseSingleLineComment($line); if ($insideSingleLineBlock) { $currentBlock .= "\n"; } else { $insideSingleLineBlock = true; } $currentBlock .= $parsed; } if ($isStartMultiLineComment || $insideMultiLineBlock) { $parsed = self::parseMultiLineComment($line); if ($insideMultiLineBlock) { $currentBlock .= "\n"; } else { $insideMultiLineBlock = true; } $currentBlock .= $parsed; } if ($isEndMultiLineComment) { $insideMultiLineBlock = false; } // If we're not in a comment then end the current block and go to // the next one if (!$isSingleLineComment && !$insideMultiLineBlock) { if (!empty($currentBlock)) { $this->blocks[] = $this->normalize($currentBlock); $insideSingleLineBlock = false; $currentBlock = ''; } } } $this->parsed = true; return $this->blocks; }
php
protected function parseBlocks() { $this->blocks = array(); $currentBlock = ''; // Do we need insideSingleLineBlock? It doesn't seem to be used anywhere // Original Ruby version of KSS had it but I'm not seeing a purpose to it $insideSingleLineBlock = false; $insideMultiLineBlock = false; foreach ($this->file as $line) { $isSingleLineComment = self::isSingleLineComment($line); $isStartMultiLineComment = self::isStartMultiLineComment($line); $isEndMultiLineComment = self::isEndMultiLineComment($line); if ($isSingleLineComment) { $parsed = self::parseSingleLineComment($line); if ($insideSingleLineBlock) { $currentBlock .= "\n"; } else { $insideSingleLineBlock = true; } $currentBlock .= $parsed; } if ($isStartMultiLineComment || $insideMultiLineBlock) { $parsed = self::parseMultiLineComment($line); if ($insideMultiLineBlock) { $currentBlock .= "\n"; } else { $insideMultiLineBlock = true; } $currentBlock .= $parsed; } if ($isEndMultiLineComment) { $insideMultiLineBlock = false; } // If we're not in a comment then end the current block and go to // the next one if (!$isSingleLineComment && !$insideMultiLineBlock) { if (!empty($currentBlock)) { $this->blocks[] = $this->normalize($currentBlock); $insideSingleLineBlock = false; $currentBlock = ''; } } } $this->parsed = true; return $this->blocks; }
[ "protected", "function", "parseBlocks", "(", ")", "{", "$", "this", "->", "blocks", "=", "array", "(", ")", ";", "$", "currentBlock", "=", "''", ";", "// Do we need insideSingleLineBlock? It doesn't seem to be used anywhere", "// Original Ruby version of KSS had it but I'm ...
Parses each line of the file looking for single or multi-line comments @return array
[ "Parses", "each", "line", "of", "the", "file", "looking", "for", "single", "or", "multi", "-", "line", "comments" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L73-L128
kss-php/kss-php
lib/CommentParser.php
CommentParser.normalize
protected function normalize($block) { // Remove any [whitespace]*'s from the start of each line $normalizedBlock = preg_replace('-^\s*\*+-m', '', $block); $indentSize = null; $blockLines = explode("\n", $normalizedBlock); $normalizedLines = array(); foreach ($blockLines as $line) { preg_match('/^\s*/', $line, $matches); $precedingWhitespace = strlen($matches[0]); if ($indentSize === null) { $indentSize = $precedingWhitespace; } if ($indentSize <= $precedingWhitespace && $indentSize > 0) { $line = substr($line, $indentSize); } $normalizedLines[] = $line; } return trim(implode("\n", $normalizedLines)); }
php
protected function normalize($block) { // Remove any [whitespace]*'s from the start of each line $normalizedBlock = preg_replace('-^\s*\*+-m', '', $block); $indentSize = null; $blockLines = explode("\n", $normalizedBlock); $normalizedLines = array(); foreach ($blockLines as $line) { preg_match('/^\s*/', $line, $matches); $precedingWhitespace = strlen($matches[0]); if ($indentSize === null) { $indentSize = $precedingWhitespace; } if ($indentSize <= $precedingWhitespace && $indentSize > 0) { $line = substr($line, $indentSize); } $normalizedLines[] = $line; } return trim(implode("\n", $normalizedLines)); }
[ "protected", "function", "normalize", "(", "$", "block", ")", "{", "// Remove any [whitespace]*'s from the start of each line", "$", "normalizedBlock", "=", "preg_replace", "(", "'-^\\s*\\*+-m'", ",", "''", ",", "$", "block", ")", ";", "$", "indentSize", "=", "null"...
Makes all the white space consistent among the lines in a comment block. That is if the first and second line had 10 spaces but the third line was indented to 15 spaces, we'd normalize it so the first and second line have no spaces and the third line has 5 spaces. @param string $block @return string
[ "Makes", "all", "the", "white", "space", "consistent", "among", "the", "lines", "in", "a", "comment", "block", ".", "That", "is", "if", "the", "first", "and", "second", "line", "had", "10", "spaces", "but", "the", "third", "line", "was", "indented", "to"...
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L140-L163
kss-php/kss-php
lib/CommentParser.php
CommentParser.parseMultiLineComment
public static function parseMultiLineComment($line) { $parsed = preg_replace('-^\s*/\*+-', '', $line); $parsed = preg_replace('-\*/-', '', $parsed); return rtrim($parsed); }
php
public static function parseMultiLineComment($line) { $parsed = preg_replace('-^\s*/\*+-', '', $line); $parsed = preg_replace('-\*/-', '', $parsed); return rtrim($parsed); }
[ "public", "static", "function", "parseMultiLineComment", "(", "$", "line", ")", "{", "$", "parsed", "=", "preg_replace", "(", "'-^\\s*/\\*+-'", ",", "''", ",", "$", "line", ")", ";", "$", "parsed", "=", "preg_replace", "(", "'-\\*/-'", ",", "''", ",", "$...
Removes the comment markers from a multi line comment and trims the line @param string $line @return string
[ "Removes", "the", "comment", "markers", "from", "a", "multi", "line", "comment", "and", "trims", "the", "line" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L220-L225
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.deleteUser
public function deleteUser(User $user) { $parent = $user->getParent(); if (!isset($this->userList[$user->getUsername()]) || $this->userList[$user->getUsername()] !== $user || $parent == null ) { return false; } $this->connection->beginTransaction(); $children = $this->getChildren($user); $success = true; foreach ($children as $child) { /** @var $child User */ $success = $success && $child->setParent($parent); } $success = $success && $user->delete(); if ($success) { $this->connection->commit(); $this->setUpIterator(); } else { $this->connection->rollBack(); } return $success; }
php
public function deleteUser(User $user) { $parent = $user->getParent(); if (!isset($this->userList[$user->getUsername()]) || $this->userList[$user->getUsername()] !== $user || $parent == null ) { return false; } $this->connection->beginTransaction(); $children = $this->getChildren($user); $success = true; foreach ($children as $child) { /** @var $child User */ $success = $success && $child->setParent($parent); } $success = $success && $user->delete(); if ($success) { $this->connection->commit(); $this->setUpIterator(); } else { $this->connection->rollBack(); } return $success; }
[ "public", "function", "deleteUser", "(", "User", "$", "user", ")", "{", "$", "parent", "=", "$", "user", "->", "getParent", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "userList", "[", "$", "user", "->", "getUsername", "(", ")",...
Will delete user. The user must be instance in library. @param User $user @return bool
[ "Will", "delete", "user", ".", "The", "user", "must", "be", "instance", "in", "library", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L70-L94
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.createUser
public function createUser($username, $password, $mail, User $parent=null) { $user = new UserImpl($this->container, $username); if (!$user->setMail($mail) || !$user->setPassword($password) ) { return false; } if($parent != null && !$user->setParent($parent->getUsername())){ return false; } if(!$user->create()){ return false; } $this->userList[$user->getUsername()] = $user; $user->attachObserver($this); $this->setUpIterator(); return $user; }
php
public function createUser($username, $password, $mail, User $parent=null) { $user = new UserImpl($this->container, $username); if (!$user->setMail($mail) || !$user->setPassword($password) ) { return false; } if($parent != null && !$user->setParent($parent->getUsername())){ return false; } if(!$user->create()){ return false; } $this->userList[$user->getUsername()] = $user; $user->attachObserver($this); $this->setUpIterator(); return $user; }
[ "public", "function", "createUser", "(", "$", "username", ",", "$", "password", ",", "$", "mail", ",", "User", "$", "parent", "=", "null", ")", "{", "$", "user", "=", "new", "UserImpl", "(", "$", "this", "->", "container", ",", "$", "username", ")", ...
Will create a user, the username must be unique The created instance can be deleted and will be in list from listUsers. @param string $username @param string $password @param string $mail @param User $parent @return User | bool FALSE on failure else instance of User
[ "Will", "create", "a", "user", "the", "username", "must", "be", "unique", "The", "created", "instance", "can", "be", "deleted", "and", "will", "be", "in", "list", "from", "listUsers", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L106-L125
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.getChildren
public function getChildren(User $user) { $returnArray = array(); foreach ($this->userList as $u) { /** @var $u User */ if ($u->getParent() == $user->getUsername()) { $returnArray[] = $u; $returnArray = array_merge($returnArray, $this->getChildren($u)); } } return $returnArray; }
php
public function getChildren(User $user) { $returnArray = array(); foreach ($this->userList as $u) { /** @var $u User */ if ($u->getParent() == $user->getUsername()) { $returnArray[] = $u; $returnArray = array_merge($returnArray, $this->getChildren($u)); } } return $returnArray; }
[ "public", "function", "getChildren", "(", "User", "$", "user", ")", "{", "$", "returnArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "userList", "as", "$", "u", ")", "{", "/** @var $u User */", "if", "(", "$", "u", "->", "getP...
Input must be instance of User and an instance provided by the library. @param User $user @return array Array containing children User instances. Empty array on no children or input not valid.
[ "Input", "must", "be", "instance", "of", "User", "and", "an", "instance", "provided", "by", "the", "library", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L196-L207
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.getUserSessionToken
public function getUserSessionToken() { if (($u = $this->getUserLoggedIn()) == null) { return null; } return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken(); }
php
public function getUserSessionToken() { if (($u = $this->getUserLoggedIn()) == null) { return null; } return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken(); }
[ "public", "function", "getUserSessionToken", "(", ")", "{", "if", "(", "(", "$", "u", "=", "$", "this", "->", "getUserLoggedIn", "(", ")", ")", "==", "null", ")", "{", "return", "null", ";", "}", "return", "isset", "(", "$", "_SESSION", "[", "'model-...
Returns the current user settings token. If no user is logged in, the token will be null. @return string
[ "Returns", "the", "current", "user", "settings", "token", ".", "If", "no", "user", "is", "logged", "in", "the", "token", "will", "be", "null", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L299-L306
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.serialize
public function serialize() { return serialize([$this->container, $this->userList, $this->database, $this->connection]); }
php
public function serialize() { return serialize([$this->container, $this->userList, $this->database, $this->connection]); }
[ "public", "function", "serialize", "(", ")", "{", "return", "serialize", "(", "[", "$", "this", "->", "container", ",", "$", "this", "->", "userList", ",", "$", "this", "->", "database", ",", "$", "this", "->", "connection", "]", ")", ";", "}" ]
(PHP 5 &gt;= 5.1.0)<br/> String representation of object @link http://php.net/manual/en/serializable.serialize.php @return string the string representation of the object or null
[ "(", "PHP", "5", "&gt", ";", "=", "5", ".", "1", ".", "0", ")", "<br", "/", ">", "String", "representation", "of", "object" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L343-L346
budde377/Part
lib/model/user/UserLibraryImpl.php
UserLibraryImpl.unserialize
public function unserialize($serialized) { $array = unserialize($serialized); $this->container = $array[0]; $this->userList = $array[1]; $this->database = $array[2]; $this->connection = $array[3]; }
php
public function unserialize($serialized) { $array = unserialize($serialized); $this->container = $array[0]; $this->userList = $array[1]; $this->database = $array[2]; $this->connection = $array[3]; }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "$", "array", "=", "unserialize", "(", "$", "serialized", ")", ";", "$", "this", "->", "container", "=", "$", "array", "[", "0", "]", ";", "$", "this", "->", "userList", "=", "$",...
(PHP 5 &gt;= 5.1.0)<br/> Constructs the object @link http://php.net/manual/en/serializable.unserialize.php @param string $serialized <p> The string representation of the object. </p> @return void
[ "(", "PHP", "5", "&gt", ";", "=", "5", ".", "1", ".", "0", ")", "<br", "/", ">", "Constructs", "the", "object" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L357-L364
budde377/Part
lib/util/mail/MailImpl.php
MailImpl.setMailType
public function setMailType($type) { switch($type){ case Mail::MAIL_TYPE_HTML: $this->mailTypeHeaders = array(); $this->mailTypeHeaders[] = 'MIME-Version: 1.0'; $this->mailTypeHeaders[] = 'Content-type: text/html; charset=UTF-8'; break; case Mail::MAIL_TYPE_PLAIN: $this->mailTypeHeaders = array(); break; } }
php
public function setMailType($type) { switch($type){ case Mail::MAIL_TYPE_HTML: $this->mailTypeHeaders = array(); $this->mailTypeHeaders[] = 'MIME-Version: 1.0'; $this->mailTypeHeaders[] = 'Content-type: text/html; charset=UTF-8'; break; case Mail::MAIL_TYPE_PLAIN: $this->mailTypeHeaders = array(); break; } }
[ "public", "function", "setMailType", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "Mail", "::", "MAIL_TYPE_HTML", ":", "$", "this", "->", "mailTypeHeaders", "=", "array", "(", ")", ";", "$", "this", "->", "mailTypeHeaders", ...
Will set the mail type. Possible mail types are specified in the Mail interface as MAIL_TYPE_* constants. @param string $type @return void
[ "Will", "set", "the", "mail", "type", ".", "Possible", "mail", "types", "are", "specified", "in", "the", "Mail", "interface", "as", "MAIL_TYPE_", "*", "constants", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/mail/MailImpl.php#L55-L67
skeeks-semenov/yii2-ckeditor
src/assets/ckeditor/plugins/codesnippetgeshi/dev/geshi/geshi.php
GeSHi.finalise
function finalise(&$parsed_code) { // Remove end parts of important declarations // This is BUGGY!! My fault for bad code: fix coming in 1.2 // @todo Remove this crap if ($this->enable_important_blocks && (strpos($parsed_code, $this->hsc(GESHI_START_IMPORTANT)) === false)) { $parsed_code = str_replace($this->hsc(GESHI_END_IMPORTANT), '', $parsed_code); } // Add HTML whitespace stuff if we're using the <div> header if ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) { $this->indent($parsed_code); } // purge some unnecessary stuff /** NOTE: memorypeak #1 */ $parsed_code = preg_replace('#<span[^>]+>(\s*)</span>#', '\\1', $parsed_code); // If we are using IDs for line numbers, there needs to be an overall // ID set to prevent collisions. if ($this->add_ids && !$this->overall_id) { $this->overall_id = 'geshi-' . substr(md5(microtime()), 0, 4); } // Get code into lines /** NOTE: memorypeak #2 */ $code = explode("\n", $parsed_code); $parsed_code = $this->header(); // If we're using line numbers, we insert <li>s and appropriate // markup to style them (otherwise we don't need to do anything) if ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->header_type != GESHI_HEADER_PRE_TABLE) { // If we're using the <pre> header, we shouldn't add newlines because // the <pre> will line-break them (and the <li>s already do this for us) $ls = ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) ? "\n" : ''; // Set vars to defaults for following loop $i = 0; // Foreach line... for ($i = 0, $n = count($code); $i < $n;) { //Reset the attributes for a new line ... $attrs = array(); // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks if ('' == trim($code[$i])) { $code[$i] = '&nbsp;'; } // If this is a "special line"... if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { //$attr = ' class="li2"'; $attrs['class'][] = 'li2'; $def_attr = ' class="de2"'; } else { //$attr = ' style="' . $this->line_style2 . '"'; $attrs['style'][] = $this->line_style2; // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $def_attr = ' style="' . $this->code_style . '"'; } } else { if ($this->use_classes) { //$attr = ' class="li1"'; $attrs['class'][] = 'li1'; $def_attr = ' class="de1"'; } else { //$attr = ' style="' . $this->line_style1 . '"'; $attrs['style'][] = $this->line_style1; $def_attr = ' style="' . $this->code_style . '"'; } } //Check which type of tag to insert for this line if ($this->header_type == GESHI_HEADER_PRE_VALID) { $start = "<pre$def_attr>"; $end = '</pre>'; } else { // Span or div? $start = "<div$def_attr>"; $end = '</div>'; } ++$i; // Are we supposed to use ids? If so, add them if ($this->add_ids) { $attrs['id'][] = "$this->overall_id-$i"; } //Is this some line with extra styles??? if (in_array($i, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $attrs['class'][] = "lx$i"; } else { $attrs['class'][] = "ln-xtra"; } } else { array_push($attrs['style'], $this->get_line_style($i)); } } // Add in the line surrounded by appropriate list HTML $attr_string = ''; foreach ($attrs as $key => $attr) { $attr_string .= ' ' . $key . '="' . implode(' ', $attr) . '"'; } $parsed_code .= "<li$attr_string>$start{$code[$i-1]}$end</li>$ls"; unset($code[$i - 1]); } } else { $n = count($code); if ($this->use_classes) { $attributes = ' class="de1"'; } else { $attributes = ' style="'. $this->code_style .'"'; } if ($this->header_type == GESHI_HEADER_PRE_VALID) { $parsed_code .= '<pre'. $attributes .'>'; } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { if ($this->use_classes) { $attrs = ' class="ln"'; } else { $attrs = ' style="'. $this->table_linenumber_style .'"'; } $parsed_code .= '<td'.$attrs.'><pre'.$attributes.'>'; // get linenumbers // we don't merge it with the for below, since it should be better for // memory consumption this way // @todo: but... actually it would still be somewhat nice to merge the two loops // the mem peaks are at different positions for ($i = 0; $i < $n; ++$i) { $close = 0; // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { $parsed_code .= '<span class="xtra li2"><span class="de2">'; } else { // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">' .'<span style="' . $this->code_style .'">'; } $close += 2; } //Is this some line with extra styles??? if (in_array($i + 1, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $parsed_code .= "<span class=\"xtra lx$i\">"; } else { $parsed_code .= "<span class=\"xtra ln-xtra\">"; } } else { $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">"; } ++$close; } $parsed_code .= $this->line_numbers_start + $i; if ($close) { $parsed_code .= str_repeat('</span>', $close); } elseif ($i != $n) { $parsed_code .= "\n"; } } $parsed_code .= '</pre></td><td'.$attributes.'>'; } $parsed_code .= '<pre'. $attributes .'>'; } // No line numbers, but still need to handle highlighting lines extra. // Have to use divs so the full width of the code is highlighted $close = 0; for ($i = 0; $i < $n; ++$i) { // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks if ('' == trim($code[$i])) { $code[$i] = '&nbsp;'; } // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { $parsed_code .= '<span class="xtra li2"><span class="de2">'; } else { // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">' .'<span style="' . $this->code_style .'">'; } $close += 2; } //Is this some line with extra styles??? if (in_array($i + 1, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $parsed_code .= "<span class=\"xtra lx$i\">"; } else { $parsed_code .= "<span class=\"xtra ln-xtra\">"; } } else { $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">"; } ++$close; } $parsed_code .= $code[$i]; if ($close) { $parsed_code .= str_repeat('</span>', $close); $close = 0; } elseif ($i + 1 < $n) { $parsed_code .= "\n"; } unset($code[$i]); } if ($this->header_type == GESHI_HEADER_PRE_VALID || $this->header_type == GESHI_HEADER_PRE_TABLE) { $parsed_code .= '</pre>'; } if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) { $parsed_code .= '</td>'; } } $parsed_code .= $this->footer(); }
php
function finalise(&$parsed_code) { // Remove end parts of important declarations // This is BUGGY!! My fault for bad code: fix coming in 1.2 // @todo Remove this crap if ($this->enable_important_blocks && (strpos($parsed_code, $this->hsc(GESHI_START_IMPORTANT)) === false)) { $parsed_code = str_replace($this->hsc(GESHI_END_IMPORTANT), '', $parsed_code); } // Add HTML whitespace stuff if we're using the <div> header if ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) { $this->indent($parsed_code); } // purge some unnecessary stuff /** NOTE: memorypeak #1 */ $parsed_code = preg_replace('#<span[^>]+>(\s*)</span>#', '\\1', $parsed_code); // If we are using IDs for line numbers, there needs to be an overall // ID set to prevent collisions. if ($this->add_ids && !$this->overall_id) { $this->overall_id = 'geshi-' . substr(md5(microtime()), 0, 4); } // Get code into lines /** NOTE: memorypeak #2 */ $code = explode("\n", $parsed_code); $parsed_code = $this->header(); // If we're using line numbers, we insert <li>s and appropriate // markup to style them (otherwise we don't need to do anything) if ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->header_type != GESHI_HEADER_PRE_TABLE) { // If we're using the <pre> header, we shouldn't add newlines because // the <pre> will line-break them (and the <li>s already do this for us) $ls = ($this->header_type != GESHI_HEADER_PRE && $this->header_type != GESHI_HEADER_PRE_VALID) ? "\n" : ''; // Set vars to defaults for following loop $i = 0; // Foreach line... for ($i = 0, $n = count($code); $i < $n;) { //Reset the attributes for a new line ... $attrs = array(); // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks if ('' == trim($code[$i])) { $code[$i] = '&nbsp;'; } // If this is a "special line"... if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { //$attr = ' class="li2"'; $attrs['class'][] = 'li2'; $def_attr = ' class="de2"'; } else { //$attr = ' style="' . $this->line_style2 . '"'; $attrs['style'][] = $this->line_style2; // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $def_attr = ' style="' . $this->code_style . '"'; } } else { if ($this->use_classes) { //$attr = ' class="li1"'; $attrs['class'][] = 'li1'; $def_attr = ' class="de1"'; } else { //$attr = ' style="' . $this->line_style1 . '"'; $attrs['style'][] = $this->line_style1; $def_attr = ' style="' . $this->code_style . '"'; } } //Check which type of tag to insert for this line if ($this->header_type == GESHI_HEADER_PRE_VALID) { $start = "<pre$def_attr>"; $end = '</pre>'; } else { // Span or div? $start = "<div$def_attr>"; $end = '</div>'; } ++$i; // Are we supposed to use ids? If so, add them if ($this->add_ids) { $attrs['id'][] = "$this->overall_id-$i"; } //Is this some line with extra styles??? if (in_array($i, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $attrs['class'][] = "lx$i"; } else { $attrs['class'][] = "ln-xtra"; } } else { array_push($attrs['style'], $this->get_line_style($i)); } } // Add in the line surrounded by appropriate list HTML $attr_string = ''; foreach ($attrs as $key => $attr) { $attr_string .= ' ' . $key . '="' . implode(' ', $attr) . '"'; } $parsed_code .= "<li$attr_string>$start{$code[$i-1]}$end</li>$ls"; unset($code[$i - 1]); } } else { $n = count($code); if ($this->use_classes) { $attributes = ' class="de1"'; } else { $attributes = ' style="'. $this->code_style .'"'; } if ($this->header_type == GESHI_HEADER_PRE_VALID) { $parsed_code .= '<pre'. $attributes .'>'; } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { if ($this->use_classes) { $attrs = ' class="ln"'; } else { $attrs = ' style="'. $this->table_linenumber_style .'"'; } $parsed_code .= '<td'.$attrs.'><pre'.$attributes.'>'; // get linenumbers // we don't merge it with the for below, since it should be better for // memory consumption this way // @todo: but... actually it would still be somewhat nice to merge the two loops // the mem peaks are at different positions for ($i = 0; $i < $n; ++$i) { $close = 0; // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { $parsed_code .= '<span class="xtra li2"><span class="de2">'; } else { // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">' .'<span style="' . $this->code_style .'">'; } $close += 2; } //Is this some line with extra styles??? if (in_array($i + 1, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $parsed_code .= "<span class=\"xtra lx$i\">"; } else { $parsed_code .= "<span class=\"xtra ln-xtra\">"; } } else { $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">"; } ++$close; } $parsed_code .= $this->line_numbers_start + $i; if ($close) { $parsed_code .= str_repeat('</span>', $close); } elseif ($i != $n) { $parsed_code .= "\n"; } } $parsed_code .= '</pre></td><td'.$attributes.'>'; } $parsed_code .= '<pre'. $attributes .'>'; } // No line numbers, but still need to handle highlighting lines extra. // Have to use divs so the full width of the code is highlighted $close = 0; for ($i = 0; $i < $n; ++$i) { // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks if ('' == trim($code[$i])) { $code[$i] = '&nbsp;'; } // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { // Set the attributes to style the line if ($this->use_classes) { $parsed_code .= '<span class="xtra li2"><span class="de2">'; } else { // This style "covers up" the special styles set for special lines // so that styles applied to special lines don't apply to the actual // code on that line $parsed_code .= '<span style="display:block;' . $this->line_style2 . '">' .'<span style="' . $this->code_style .'">'; } $close += 2; } //Is this some line with extra styles??? if (in_array($i + 1, $this->highlight_extra_lines)) { if ($this->use_classes) { if (isset($this->highlight_extra_lines_styles[$i])) { $parsed_code .= "<span class=\"xtra lx$i\">"; } else { $parsed_code .= "<span class=\"xtra ln-xtra\">"; } } else { $parsed_code .= "<span style=\"display:block;" . $this->get_line_style($i) . "\">"; } ++$close; } $parsed_code .= $code[$i]; if ($close) { $parsed_code .= str_repeat('</span>', $close); $close = 0; } elseif ($i + 1 < $n) { $parsed_code .= "\n"; } unset($code[$i]); } if ($this->header_type == GESHI_HEADER_PRE_VALID || $this->header_type == GESHI_HEADER_PRE_TABLE) { $parsed_code .= '</pre>'; } if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) { $parsed_code .= '</td>'; } } $parsed_code .= $this->footer(); }
[ "function", "finalise", "(", "&", "$", "parsed_code", ")", "{", "// Remove end parts of important declarations", "// This is BUGGY!! My fault for bad code: fix coming in 1.2", "// @todo Remove this crap", "if", "(", "$", "this", "->", "enable_important_blocks", "&&", "(", "strp...
Takes the parsed code and various options, and creates the HTML surrounding it to make it look nice. @param string The code already parsed (reference!) @since 1.0.0 @access private
[ "Takes", "the", "parsed", "code", "and", "various", "options", "and", "creates", "the", "HTML", "surrounding", "it", "to", "make", "it", "look", "nice", "." ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/ckeditor/plugins/codesnippetgeshi/dev/geshi/geshi.php#L3842-L4081
yeephp/yeephp
Yee/Http/Headers.php
Headers.extract
public static function extract($data) { $results = array(); foreach ($data as $key => $value) { $key = strtoupper($key); if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) { if ($key === 'HTTP_CONTENT_LENGTH') { continue; } $results[$key] = $value; } } return $results; }
php
public static function extract($data) { $results = array(); foreach ($data as $key => $value) { $key = strtoupper($key); if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) { if ($key === 'HTTP_CONTENT_LENGTH') { continue; } $results[$key] = $value; } } return $results; }
[ "public", "static", "function", "extract", "(", "$", "data", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "strtoupper", "(", "$", "key", ")", ...
Extract HTTP headers from an array of data (e.g. $_SERVER) @param array $data @return array
[ "Extract", "HTTP", "headers", "from", "an", "array", "of", "data", "(", "e", ".", "g", ".", "$_SERVER", ")" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Headers.php#L69-L83
skrz/meta
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
MessageOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new MessageOptions(); case 1: return new MessageOptions(func_get_arg(0)); case 2: return new MessageOptions(func_get_arg(0), func_get_arg(1)); case 3: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MessageOptions(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 MessageOptions(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 MessageOptions(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 MessageOptions(); case 1: return new MessageOptions(func_get_arg(0)); case 2: return new MessageOptions(func_get_arg(0), func_get_arg(1)); case 3: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MessageOptions(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 MessageOptions(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 MessageOptions(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", "MessageOptions", "(", ")", ";", "case", "1", ":", "return", "new", "MessageOptions", "(", "func_get_arg", "("...
Creates new instance of \Google\Protobuf\MessageOptions @throws \InvalidArgumentException @return MessageOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "MessageOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L61-L85
skrz/meta
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
MessageOptionsMeta.reset
public static function reset($object) { if (!($object instanceof MessageOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MessageOptions.'); } $object->messageSetWireFormat = NULL; $object->noStandardDescriptorAccessor = NULL; $object->deprecated = NULL; $object->mapEntry = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof MessageOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MessageOptions.'); } $object->messageSetWireFormat = NULL; $object->noStandardDescriptorAccessor = NULL; $object->deprecated = NULL; $object->mapEntry = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "MessageOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Mess...
Resets properties of \Google\Protobuf\MessageOptions to default values @param MessageOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "MessageOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L98-L108
skrz/meta
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
MessageOptionsMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->messageSetWireFormat)) { hash_update($ctx, 'messageSetWireFormat'); hash_update($ctx, (string)$object->messageSetWireFormat); } if (isset($object->noStandardDescriptorAccessor)) { hash_update($ctx, 'noStandardDescriptorAccessor'); hash_update($ctx, (string)$object->noStandardDescriptorAccessor); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->mapEntry)) { hash_update($ctx, 'mapEntry'); hash_update($ctx, (string)$object->mapEntry); } if (isset($object->uninterpretedOption)) { hash_update($ctx, 'uninterpretedOption'); foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) { UninterpretedOptionMeta::hash($v0, $ctx); } } 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->messageSetWireFormat)) { hash_update($ctx, 'messageSetWireFormat'); hash_update($ctx, (string)$object->messageSetWireFormat); } if (isset($object->noStandardDescriptorAccessor)) { hash_update($ctx, 'noStandardDescriptorAccessor'); hash_update($ctx, (string)$object->noStandardDescriptorAccessor); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->mapEntry)) { hash_update($ctx, 'mapEntry'); hash_update($ctx, (string)$object->mapEntry); } if (isset($object->uninterpretedOption)) { hash_update($ctx, 'uninterpretedOption'); foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) { UninterpretedOptionMeta::hash($v0, $ctx); } } 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\MessageOptions @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "MessageOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L120-L160
skrz/meta
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
MessageOptionsMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new MessageOptions(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->messageSetWireFormat = (bool)Binary::decodeVarint($input, $start); break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->noStandardDescriptorAccessor = (bool)Binary::decodeVarint($input, $start); break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 7: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->mapEntry = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new MessageOptions(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->messageSetWireFormat = (bool)Binary::decodeVarint($input, $start); break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->noStandardDescriptorAccessor = (bool)Binary::decodeVarint($input, $start); break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 7: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->mapEntry = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\MessageOptions object from serialized Protocol Buffers message. @param string $input @param MessageOptions $object @param int $start @param int $end @throws \Exception @return MessageOptions
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "MessageOptions", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L175-L252
skrz/meta
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
MessageOptionsMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->messageSetWireFormat) && ($filter === null || isset($filter['messageSetWireFormat']))) { $output .= "\x08"; $output .= Binary::encodeVarint((int)$object->messageSetWireFormat); } if (isset($object->noStandardDescriptorAccessor) && ($filter === null || isset($filter['noStandardDescriptorAccessor']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->noStandardDescriptorAccessor); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->mapEntry) && ($filter === null || isset($filter['mapEntry']))) { $output .= "\x38"; $output .= Binary::encodeVarint((int)$object->mapEntry); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->messageSetWireFormat) && ($filter === null || isset($filter['messageSetWireFormat']))) { $output .= "\x08"; $output .= Binary::encodeVarint((int)$object->messageSetWireFormat); } if (isset($object->noStandardDescriptorAccessor) && ($filter === null || isset($filter['noStandardDescriptorAccessor']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->noStandardDescriptorAccessor); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->mapEntry) && ($filter === null || isset($filter['mapEntry']))) { $output .= "\x38"; $output .= Binary::encodeVarint((int)$object->mapEntry); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "messageSetWireFormat", ")", "&&", "(", "$", "filter", "===", "n...
Serialized \Google\Protobuf\MessageOptions to Protocol Buffers message. @param MessageOptions $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "MessageOptions", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L265-L299
scherersoftware/cake-model-history
src/Model/Entity/ModelHistory.php
ModelHistory._getData
protected function _getData(array $data): array { // Stringify empty values if (!empty($data)) { foreach ($data as $fieldName => $value) { $data[$fieldName] = $this->_stringifyEmptyValue($value); } } return $data; }
php
protected function _getData(array $data): array { // Stringify empty values if (!empty($data)) { foreach ($data as $fieldName => $value) { $data[$fieldName] = $this->_stringifyEmptyValue($value); } } return $data; }
[ "protected", "function", "_getData", "(", "array", "$", "data", ")", ":", "array", "{", "// Stringify empty values", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "fieldName", "=>", "$", "value", ")",...
getter for data @param array $data data @return array
[ "getter", "for", "data" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/ModelHistory.php#L46-L56
scherersoftware/cake-model-history
src/Model/Entity/ModelHistory.php
ModelHistory.getContextTypes
public static function getContextTypes(): array { return [ self::CONTEXT_TYPE_CONTROLLER => __d('model_history', 'context.type.controller'), self::CONTEXT_TYPE_SHELL => __d('model_history', 'context.type.shell'), self::CONTEXT_TYPE_SLUG => __d('model_history', 'context.type.slug') ]; }
php
public static function getContextTypes(): array { return [ self::CONTEXT_TYPE_CONTROLLER => __d('model_history', 'context.type.controller'), self::CONTEXT_TYPE_SHELL => __d('model_history', 'context.type.shell'), self::CONTEXT_TYPE_SLUG => __d('model_history', 'context.type.slug') ]; }
[ "public", "static", "function", "getContextTypes", "(", ")", ":", "array", "{", "return", "[", "self", "::", "CONTEXT_TYPE_CONTROLLER", "=>", "__d", "(", "'model_history'", ",", "'context.type.controller'", ")", ",", "self", "::", "CONTEXT_TYPE_SHELL", "=>", "__d"...
Retrieve available context types @return array
[ "Retrieve", "available", "context", "types" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/ModelHistory.php#L80-L87
dav-is/flarum-ext-inviteonly
src/Providers/StorageServiceProvider.php
StorageServiceProvider.register
public function register() { $avatarsFilesystem = function (Container $app) { return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); }; $this->app->when('Davis\InviteOnly\Commands\RegisterUserHandler') ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); }
php
public function register() { $avatarsFilesystem = function (Container $app) { return $app->make('Illuminate\Contracts\Filesystem\Factory')->disk('flarum-avatars')->getDriver(); }; $this->app->when('Davis\InviteOnly\Commands\RegisterUserHandler') ->needs('League\Flysystem\FilesystemInterface') ->give($avatarsFilesystem); }
[ "public", "function", "register", "(", ")", "{", "$", "avatarsFilesystem", "=", "function", "(", "Container", "$", "app", ")", "{", "return", "$", "app", "->", "make", "(", "'Illuminate\\Contracts\\Filesystem\\Factory'", ")", "->", "disk", "(", "'flarum-avatars'...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/dav-is/flarum-ext-inviteonly/blob/1efdc32feb952bb641d97839d5b592536c9ca748/src/Providers/StorageServiceProvider.php#L18-L26
kaliop-uk/kueueingbundle
Helper/BaseCommand.php
BaseCommand.writeln
protected function writeln($msg, $verbosity = OutputInterface::VERBOSITY_NORMAL) { if ($this->output->getVerbosity() >= $verbosity) { $this->output->writeln($msg); } }
php
protected function writeln($msg, $verbosity = OutputInterface::VERBOSITY_NORMAL) { if ($this->output->getVerbosity() >= $verbosity) { $this->output->writeln($msg); } }
[ "protected", "function", "writeln", "(", "$", "msg", ",", "$", "verbosity", "=", "OutputInterface", "::", "VERBOSITY_NORMAL", ")", "{", "if", "(", "$", "this", "->", "output", "->", "getVerbosity", "(", ")", ">=", "$", "verbosity", ")", "{", "$", "this",...
/ Sf writeln api is braindead
[ "/", "Sf", "writeln", "api", "is", "braindead" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Helper/BaseCommand.php#L21-L26
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php
ClassWithVarintPropertyMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ClassWithVarintProperty(); case 1: return new ClassWithVarintProperty(func_get_arg(0)); case 2: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithVarintProperty(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 ClassWithVarintProperty(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 ClassWithVarintProperty(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 ClassWithVarintProperty(); case 1: return new ClassWithVarintProperty(func_get_arg(0)); case 2: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithVarintProperty(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 ClassWithVarintProperty(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 ClassWithVarintProperty(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", "ClassWithVarintProperty", "(", ")", ";", "case", "1", ":", "return", "new", "ClassWithVarintProperty", "(", "fu...
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithVarintProperty @throws \InvalidArgumentException @return ClassWithVarintProperty
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithVarintProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php#L66-L90
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php
ClassWithVarintPropertyMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->x); } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->x); } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "x", ")", "&&", "(", "$", "filter", "===", "null", "||", "is...
Serialized \Skrz\Meta\Fixtures\Protobuf\ClassWithVarintProperty to Protocol Buffers message. @param ClassWithVarintProperty $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithVarintProperty", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php#L387-L397
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.devices
public function devices() { if (empty($this->all_devices)) { $response = $this->fromJson($this->api->get('devices')); $this->all_devices = array_map(function ($device) { return new Device($device); }, $response['devices']); } return $this->all_devices; }
php
public function devices() { if (empty($this->all_devices)) { $response = $this->fromJson($this->api->get('devices')); $this->all_devices = array_map(function ($device) { return new Device($device); }, $response['devices']); } return $this->all_devices; }
[ "public", "function", "devices", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "all_devices", ")", ")", "{", "$", "response", "=", "$", "this", "->", "fromJson", "(", "$", "this", "->", "api", "->", "get", "(", "'devices'", ")", ")", ...
Get a list of all of the devices available @return array
[ "Get", "a", "list", "of", "all", "of", "the", "devices", "available" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L69-L80
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.device
public function device() { $devices = $this->argsToArray(func_get_args()); foreach ($devices as $destination) { $device = $this->getDeviceIden($destination); if (!$device) { throw new \Exception("{$destination} is not a valid device."); } $this->devices[] = $device; } return $this; }
php
public function device() { $devices = $this->argsToArray(func_get_args()); foreach ($devices as $destination) { $device = $this->getDeviceIden($destination); if (!$device) { throw new \Exception("{$destination} is not a valid device."); } $this->devices[] = $device; } return $this; }
[ "public", "function", "device", "(", ")", "{", "$", "devices", "=", "$", "this", "->", "argsToArray", "(", "func_get_args", "(", ")", ")", ";", "foreach", "(", "$", "devices", "as", "$", "destination", ")", "{", "$", "device", "=", "$", "this", "->",...
Set the passed in device(s) for the current push @return \PHPushbullet\PHPushbullet
[ "Set", "the", "passed", "in", "device", "(", "s", ")", "for", "the", "current", "push" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L96-L111
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.all
public function all() { foreach ($this->devices() as $device) { if ($device->pushable == true) { $this->devices[] = $device->iden; } } return $this; }
php
public function all() { foreach ($this->devices() as $device) { if ($device->pushable == true) { $this->devices[] = $device->iden; } } return $this; }
[ "public", "function", "all", "(", ")", "{", "foreach", "(", "$", "this", "->", "devices", "(", ")", "as", "$", "device", ")", "{", "if", "(", "$", "device", "->", "pushable", "==", "true", ")", "{", "$", "this", "->", "devices", "[", "]", "=", ...
Set all of the devices for the current push @return \PHPushbullet\PHPushbullet
[ "Set", "all", "of", "the", "devices", "for", "the", "current", "push" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L130-L139
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.push
public function push($request) { if (empty($this->devices) && empty($this->users) && empty($this->channels)) { throw new \Exception('You must specify something to push to.'); } $responses = []; $destinations = [ 'devices' => 'device_iden', 'users' => 'email', 'channels' => 'channel_tag', ]; foreach ($destinations as $destination => $key) { foreach ($this->{$destination} as $dest) { $responses[] = $this->pushRequest($request, [$key => $dest]); } } $this->devices = []; $this->users = []; $this->channels = []; return $responses; }
php
public function push($request) { if (empty($this->devices) && empty($this->users) && empty($this->channels)) { throw new \Exception('You must specify something to push to.'); } $responses = []; $destinations = [ 'devices' => 'device_iden', 'users' => 'email', 'channels' => 'channel_tag', ]; foreach ($destinations as $destination => $key) { foreach ($this->{$destination} as $dest) { $responses[] = $this->pushRequest($request, [$key => $dest]); } } $this->devices = []; $this->users = []; $this->channels = []; return $responses; }
[ "public", "function", "push", "(", "$", "request", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "devices", ")", "&&", "empty", "(", "$", "this", "->", "users", ")", "&&", "empty", "(", "$", "this", "->", "channels", ")", ")", "{", "throw...
Actually send the push @return array
[ "Actually", "send", "the", "push" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L146-L171
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.pushRequest
protected function pushRequest($request, $merge) { $request = array_merge($request, $merge); $response = $this->api->post('pushes', ['json' => $request]); return $this->fromJson($response); }
php
protected function pushRequest($request, $merge) { $request = array_merge($request, $merge); $response = $this->api->post('pushes', ['json' => $request]); return $this->fromJson($response); }
[ "protected", "function", "pushRequest", "(", "$", "request", ",", "$", "merge", ")", "{", "$", "request", "=", "array_merge", "(", "$", "request", ",", "$", "merge", ")", ";", "$", "response", "=", "$", "this", "->", "api", "->", "post", "(", "'pushe...
Create push request and... push it @param array $request @param array $merge @return array
[ "Create", "push", "request", "and", "...", "push", "it" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L186-L192
joetannenbaum/phpushbullet
src/PHPushbullet.php
PHPushbullet.getDeviceIden
protected function getDeviceIden($device) { foreach ($this->devices() as $available_device) { foreach (['iden', 'nickname'] as $field) { if ($available_device->$field == $device) { return $available_device->iden; } } } return false; }
php
protected function getDeviceIden($device) { foreach ($this->devices() as $available_device) { foreach (['iden', 'nickname'] as $field) { if ($available_device->$field == $device) { return $available_device->iden; } } } return false; }
[ "protected", "function", "getDeviceIden", "(", "$", "device", ")", "{", "foreach", "(", "$", "this", "->", "devices", "(", ")", "as", "$", "available_device", ")", "{", "foreach", "(", "[", "'iden'", ",", "'nickname'", "]", "as", "$", "field", ")", "{"...
Get the `iden` for the device by either the iden or nickname @param string $device @return mixed (boolean|string)
[ "Get", "the", "iden", "for", "the", "device", "by", "either", "the", "iden", "or", "nickname" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L201-L212
bigwhoop/sentence-breaker
src/Lexing/Lexer.php
Lexer.run
public function run($input) { $this->setInput($input); while ($this->state instanceof States\State) { $stateFn = $this->state; $this->state = $stateFn($this); } return $this->tokens; }
php
public function run($input) { $this->setInput($input); while ($this->state instanceof States\State) { $stateFn = $this->state; $this->state = $stateFn($this); } return $this->tokens; }
[ "public", "function", "run", "(", "$", "input", ")", "{", "$", "this", "->", "setInput", "(", "$", "input", ")", ";", "while", "(", "$", "this", "->", "state", "instanceof", "States", "\\", "State", ")", "{", "$", "stateFn", "=", "$", "this", "->",...
@param string $input @return Token[]
[ "@param", "string", "$input" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/Lexer.php#L43-L53
bigwhoop/sentence-breaker
src/Lexing/Lexer.php
Lexer.next
public function next($offset = 0) { fseek($this->input, $this->pos + $offset, SEEK_SET); $c = fgetc($this->input); $this->pos += 1 + $offset; if ($c === false) { return; } return $c; }
php
public function next($offset = 0) { fseek($this->input, $this->pos + $offset, SEEK_SET); $c = fgetc($this->input); $this->pos += 1 + $offset; if ($c === false) { return; } return $c; }
[ "public", "function", "next", "(", "$", "offset", "=", "0", ")", "{", "fseek", "(", "$", "this", "->", "input", ",", "$", "this", "->", "pos", "+", "$", "offset", ",", "SEEK_SET", ")", ";", "$", "c", "=", "fgetc", "(", "$", "this", "->", "input...
@param int $offset @return null|string
[ "@param", "int", "$offset" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/Lexer.php#L102-L113
bigwhoop/sentence-breaker
src/Lexing/Lexer.php
Lexer.peek
public function peek($offset = 0) { $c = $this->next($offset); $this->backup($offset); return $c; }
php
public function peek($offset = 0) { $c = $this->next($offset); $this->backup($offset); return $c; }
[ "public", "function", "peek", "(", "$", "offset", "=", "0", ")", "{", "$", "c", "=", "$", "this", "->", "next", "(", "$", "offset", ")", ";", "$", "this", "->", "backup", "(", "$", "offset", ")", ";", "return", "$", "c", ";", "}" ]
@param int $offset @return null|string
[ "@param", "int", "$offset" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/Lexer.php#L139-L145
yeephp/yeephp
Yee/Log/FileLogger.php
FileLogger.write
public function write($object, $level) { //Determine label $label = 'DEBUG'; switch ($level) { case \Yee\Log::FATAL: $label = 'FATAL'; break; case \Yee\Log::ERROR: $label = 'ERROR'; break; case \Yee\Log::WARN: $label = 'WARN'; break; case \Yee\Log::INFO: $label = 'INFO'; break; } //Get formatted log message $message = str_replace(array( '%label%', '%date%', '%message%' ), array( $label, date('Y-m-d H:i:s'), (string)$object ), $this->settings['message_format']); //Open resource handle to log file if (!$this->resource) { $filename = date($this->settings['name_format']); if (! empty($this->settings['extension'])) { $filename .= '.' . $this->settings['extension']; } $this->resource = fopen($this->settings['path'] . DIRECTORY_SEPARATOR . $filename, 'a'); } //Output to resource fwrite($this->resource, $message . PHP_EOL); }
php
public function write($object, $level) { //Determine label $label = 'DEBUG'; switch ($level) { case \Yee\Log::FATAL: $label = 'FATAL'; break; case \Yee\Log::ERROR: $label = 'ERROR'; break; case \Yee\Log::WARN: $label = 'WARN'; break; case \Yee\Log::INFO: $label = 'INFO'; break; } //Get formatted log message $message = str_replace(array( '%label%', '%date%', '%message%' ), array( $label, date('Y-m-d H:i:s'), (string)$object ), $this->settings['message_format']); //Open resource handle to log file if (!$this->resource) { $filename = date($this->settings['name_format']); if (! empty($this->settings['extension'])) { $filename .= '.' . $this->settings['extension']; } $this->resource = fopen($this->settings['path'] . DIRECTORY_SEPARATOR . $filename, 'a'); } //Output to resource fwrite($this->resource, $message . PHP_EOL); }
[ "public", "function", "write", "(", "$", "object", ",", "$", "level", ")", "{", "//Determine label", "$", "label", "=", "'DEBUG'", ";", "switch", "(", "$", "level", ")", "{", "case", "\\", "Yee", "\\", "Log", "::", "FATAL", ":", "$", "label", "=", ...
Write to log @param mixed $object @param int $level @return void
[ "Write", "to", "log" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Log/FileLogger.php#L82-L125
reliv/swagger-expressive
src/Api/BuildSwaggerConfigBasic.php
BuildSwaggerConfigBasic.buildSwaggerPaths
protected function buildSwaggerPaths( array $routeConfig ): array { $swaggerPaths = []; foreach ($routeConfig as $key => $routeData) { $path = Options::getString( $routeData, 'path' ); if (empty($path)) { throw new \Exception( 'Path is required in route config' ); } $configName = BuildRouteName::invoke( $key, $routeData ); $swaggerPathData = $this->buildSwaggerPathData( $configName, $path, $routeData ); if (array_key_exists($path, $swaggerPaths)) { $swaggerPaths[$path] = array_merge($swaggerPaths[$path], $swaggerPathData); continue; } $swaggerPaths[$path] = $swaggerPathData; } return $swaggerPaths; }
php
protected function buildSwaggerPaths( array $routeConfig ): array { $swaggerPaths = []; foreach ($routeConfig as $key => $routeData) { $path = Options::getString( $routeData, 'path' ); if (empty($path)) { throw new \Exception( 'Path is required in route config' ); } $configName = BuildRouteName::invoke( $key, $routeData ); $swaggerPathData = $this->buildSwaggerPathData( $configName, $path, $routeData ); if (array_key_exists($path, $swaggerPaths)) { $swaggerPaths[$path] = array_merge($swaggerPaths[$path], $swaggerPathData); continue; } $swaggerPaths[$path] = $swaggerPathData; } return $swaggerPaths; }
[ "protected", "function", "buildSwaggerPaths", "(", "array", "$", "routeConfig", ")", ":", "array", "{", "$", "swaggerPaths", "=", "[", "]", ";", "foreach", "(", "$", "routeConfig", "as", "$", "key", "=>", "$", "routeData", ")", "{", "$", "path", "=", "...
@param array $routeConfig @return array @throws \Exception
[ "@param", "array", "$routeConfig" ]
train
https://github.com/reliv/swagger-expressive/blob/65f94262f1709c0d6ed8723938aac618b63d8fd9/src/Api/BuildSwaggerConfigBasic.php#L59-L94
reliv/swagger-expressive
src/Api/BuildSwaggerConfigBasic.php
BuildSwaggerConfigBasic.buildSwaggerPathData
protected function buildSwaggerPathData( string $name, string $path, array $routeData ): array { $swaggerPathData = []; $swaggerConfig = Options::getArray( $routeData, ConfigKey::SWAGGER, [] ); $allowedMethods = Options::getArray( $routeData, 'allowed_methods', [] ); if (is_string($allowedMethods)) { $allowedMethods = [$allowedMethods]; } foreach ($allowedMethods as $allowedMethod) { $allowedMethod = strtolower($allowedMethod); $data = Options::getArray( $swaggerConfig, $allowedMethod, [] ); $data['description'] = Options::getString( $data, 'description', 'Name: ' . $name ); $data['operationId'] = Options::getString( $swaggerPathData, 'operationId', '[' . $allowedMethod . ']' . $name ); $data['produces'] = Options::getArray( $data, 'produces', ['application/json'] ); $parameters = Options::getArray( $data, 'parameters', [] ); $data['parameters'] = $this->buildPathParameters->__invoke( $parameters, $path ); $data['responses'] = Options::getArray( $data, 'responses', [ "default" => [ 'description' => "undefined" ] ] ); $swaggerPathData[$allowedMethod] = $data; } return $swaggerPathData; }
php
protected function buildSwaggerPathData( string $name, string $path, array $routeData ): array { $swaggerPathData = []; $swaggerConfig = Options::getArray( $routeData, ConfigKey::SWAGGER, [] ); $allowedMethods = Options::getArray( $routeData, 'allowed_methods', [] ); if (is_string($allowedMethods)) { $allowedMethods = [$allowedMethods]; } foreach ($allowedMethods as $allowedMethod) { $allowedMethod = strtolower($allowedMethod); $data = Options::getArray( $swaggerConfig, $allowedMethod, [] ); $data['description'] = Options::getString( $data, 'description', 'Name: ' . $name ); $data['operationId'] = Options::getString( $swaggerPathData, 'operationId', '[' . $allowedMethod . ']' . $name ); $data['produces'] = Options::getArray( $data, 'produces', ['application/json'] ); $parameters = Options::getArray( $data, 'parameters', [] ); $data['parameters'] = $this->buildPathParameters->__invoke( $parameters, $path ); $data['responses'] = Options::getArray( $data, 'responses', [ "default" => [ 'description' => "undefined" ] ] ); $swaggerPathData[$allowedMethod] = $data; } return $swaggerPathData; }
[ "protected", "function", "buildSwaggerPathData", "(", "string", "$", "name", ",", "string", "$", "path", ",", "array", "$", "routeData", ")", ":", "array", "{", "$", "swaggerPathData", "=", "[", "]", ";", "$", "swaggerConfig", "=", "Options", "::", "getArr...
@param string $name @param string $path @param array $routeData @return array
[ "@param", "string", "$name", "@param", "string", "$path", "@param", "array", "$routeData" ]
train
https://github.com/reliv/swagger-expressive/blob/65f94262f1709c0d6ed8723938aac618b63d8fd9/src/Api/BuildSwaggerConfigBasic.php#L103-L178
yoanm/symfony-jsonrpc-http-server
features/demo_app/src/DefaultKernel.php
DefaultKernel.configureRoutes
protected function configureRoutes(RouteCollectionBuilder $routes) { $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); }
php
protected function configureRoutes(RouteCollectionBuilder $routes) { $confDir = $this->getProjectDir().'/'.$this->getConfigDirectory(); $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); }
[ "protected", "function", "configureRoutes", "(", "RouteCollectionBuilder", "$", "routes", ")", "{", "$", "confDir", "=", "$", "this", "->", "getProjectDir", "(", ")", ".", "'/'", ".", "$", "this", "->", "getConfigDirectory", "(", ")", ";", "$", "routes", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/features/demo_app/src/DefaultKernel.php#L35-L39
venca-x/social-login
src/TwitterLogin.php
TwitterLogin.getLoginUrl
public function getLoginUrl() { $this->twitterOAuth = new \TwitterOAuth($this->params['consumerKey'], $this->params['consumerSecret']); $this->requestToken = $this->twitterOAuth->getRequestToken($this->params['callbackURL']); $sessionSection = $this->session->getSection('twitter'); $sessionSection->oauth_token = $token = $this->requestToken['oauth_token']; $sessionSection->oauth_token_secret = $this->requestToken['oauth_token_secret']; $loginUrl = $this->twitterOAuth->getAuthorizeURL($this->requestToken); // Use Sign in with Twitter return $loginUrl; }
php
public function getLoginUrl() { $this->twitterOAuth = new \TwitterOAuth($this->params['consumerKey'], $this->params['consumerSecret']); $this->requestToken = $this->twitterOAuth->getRequestToken($this->params['callbackURL']); $sessionSection = $this->session->getSection('twitter'); $sessionSection->oauth_token = $token = $this->requestToken['oauth_token']; $sessionSection->oauth_token_secret = $this->requestToken['oauth_token_secret']; $loginUrl = $this->twitterOAuth->getAuthorizeURL($this->requestToken); // Use Sign in with Twitter return $loginUrl; }
[ "public", "function", "getLoginUrl", "(", ")", "{", "$", "this", "->", "twitterOAuth", "=", "new", "\\", "TwitterOAuth", "(", "$", "this", "->", "params", "[", "'consumerKey'", "]", ",", "$", "this", "->", "params", "[", "'consumerSecret'", "]", ")", ";"...
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/TwitterLogin.php#L64-L75
venca-x/social-login
src/TwitterLogin.php
TwitterLogin.getMe
public function getMe($oauthToken, $oauthVerifier) { $sessionSection = $this->session->getSection('twitter'); if (($oauthToken != '') && ($sessionSection->oauth_token !== $oauthToken)) { //$sessionSection->oauth_status = 'oldtoken'; throw new Exception('Twitter token is old. Try again login'); } //Create TwitteroAuth object with app key/secret and token key/secret from default phase $this->twitterOAuth = new \TwitterOAuth($this->params['consumerKey'], $this->params['consumerSecret'], $sessionSection->oauth_token, $sessionSection->oauth_token_secret); //Request access tokens from twitter $access_token = $this->twitterOAuth->getAccessToken($oauthVerifier); //Save the access tokens $sessionSection->access_token = $access_token; // Remove no longer needed request tokens unset($sessionSection->oauth_token , $sessionSection->oauth_token_secret); if ($this->twitterOAuth->http_code != 200) { //Save HTTP status for error dialog on connnect page. throw new Exception('Twitter login. Something is wrong'); } //The user has been verified //$sessionSection->status = 'verified'; $user_info = $this->twitterOAuth->get('account/verify_credentials'); $this->setSocialLoginCookie(self::SOCIAL_NAME); return $user_info; }
php
public function getMe($oauthToken, $oauthVerifier) { $sessionSection = $this->session->getSection('twitter'); if (($oauthToken != '') && ($sessionSection->oauth_token !== $oauthToken)) { //$sessionSection->oauth_status = 'oldtoken'; throw new Exception('Twitter token is old. Try again login'); } //Create TwitteroAuth object with app key/secret and token key/secret from default phase $this->twitterOAuth = new \TwitterOAuth($this->params['consumerKey'], $this->params['consumerSecret'], $sessionSection->oauth_token, $sessionSection->oauth_token_secret); //Request access tokens from twitter $access_token = $this->twitterOAuth->getAccessToken($oauthVerifier); //Save the access tokens $sessionSection->access_token = $access_token; // Remove no longer needed request tokens unset($sessionSection->oauth_token , $sessionSection->oauth_token_secret); if ($this->twitterOAuth->http_code != 200) { //Save HTTP status for error dialog on connnect page. throw new Exception('Twitter login. Something is wrong'); } //The user has been verified //$sessionSection->status = 'verified'; $user_info = $this->twitterOAuth->get('account/verify_credentials'); $this->setSocialLoginCookie(self::SOCIAL_NAME); return $user_info; }
[ "public", "function", "getMe", "(", "$", "oauthToken", ",", "$", "oauthVerifier", ")", "{", "$", "sessionSection", "=", "$", "this", "->", "session", "->", "getSection", "(", "'twitter'", ")", ";", "if", "(", "(", "$", "oauthToken", "!=", "''", ")", "&...
Return info about login user @param $oauthToken @param $oauthVerifier @return \API|mixed @throws Exception
[ "Return", "info", "about", "login", "user" ]
train
https://github.com/venca-x/social-login/blob/ca2ae72b30f1d4e1a5bd78c06cd72faefd625dab/src/TwitterLogin.php#L85-L120
marvin255/bxcodegen
src/generator/Module.php
Module.generate
public function generate(CollectionInterface $options, ServiceLocatorInterface $locator) { $templateData = $this->collectDataFromInputForTemplate($options); $sourcePath = $options->get('source', dirname(dirname(__DIR__)) . '/templates/module'); $destinationPath = $locator->get('pathManager')->getAbsolutePath( "@modules/{$templateData['full_module_name']}" ); $copier = $this->getAndConfigurateCopierFromLocator($locator, $templateData); $source = new Directory($sourcePath); $destination = new Directory($destinationPath); if ($destination->isExists()) { throw new InvalidArgumentException( 'Directory ' . $destination->getPathname() . ' already exists' ); } $copier->copyDir($source, $destination); }
php
public function generate(CollectionInterface $options, ServiceLocatorInterface $locator) { $templateData = $this->collectDataFromInputForTemplate($options); $sourcePath = $options->get('source', dirname(dirname(__DIR__)) . '/templates/module'); $destinationPath = $locator->get('pathManager')->getAbsolutePath( "@modules/{$templateData['full_module_name']}" ); $copier = $this->getAndConfigurateCopierFromLocator($locator, $templateData); $source = new Directory($sourcePath); $destination = new Directory($destinationPath); if ($destination->isExists()) { throw new InvalidArgumentException( 'Directory ' . $destination->getPathname() . ' already exists' ); } $copier->copyDir($source, $destination); }
[ "public", "function", "generate", "(", "CollectionInterface", "$", "options", ",", "ServiceLocatorInterface", "$", "locator", ")", "{", "$", "templateData", "=", "$", "this", "->", "collectDataFromInputForTemplate", "(", "$", "options", ")", ";", "$", "sourcePath"...
{@inheritdoc} @throws \InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/generator/Module.php#L21-L40
marvin255/bxcodegen
src/generator/Module.php
Module.collectDataFromInputForTemplate
protected function collectDataFromInputForTemplate(CollectionInterface $options) { $name = $options->get('name'); if (!$name) { throw new InvalidArgumentException( 'Module name option must be a non empty string' ); } elseif (!preg_match('/^([a-z0-9_]{3,})\.([a-z0-9_]{3,})$/', $name, $matches)) { throw new InvalidArgumentException( "Module name option must be in format vendor.module, got: {$name}" ); } $return = [ 'full_module_name' => $name, 'module_partner_name' => $matches[1], 'module_name' => $matches[2], 'php_namespace' => '\\' . implode('\\', array_map('ucfirst', explode('.', $name))), 'install_class' => str_replace('.', '_', $name), 'version_number' => $options->get('version_number', '0.0.1'), 'version_date' => $options->get('version_date', date('Y-m-d')), 'readable_title' => $options->get('title', ucfirst($matches[2])), 'options' => $options->get('options', true), ]; return $return; }
php
protected function collectDataFromInputForTemplate(CollectionInterface $options) { $name = $options->get('name'); if (!$name) { throw new InvalidArgumentException( 'Module name option must be a non empty string' ); } elseif (!preg_match('/^([a-z0-9_]{3,})\.([a-z0-9_]{3,})$/', $name, $matches)) { throw new InvalidArgumentException( "Module name option must be in format vendor.module, got: {$name}" ); } $return = [ 'full_module_name' => $name, 'module_partner_name' => $matches[1], 'module_name' => $matches[2], 'php_namespace' => '\\' . implode('\\', array_map('ucfirst', explode('.', $name))), 'install_class' => str_replace('.', '_', $name), 'version_number' => $options->get('version_number', '0.0.1'), 'version_date' => $options->get('version_date', date('Y-m-d')), 'readable_title' => $options->get('title', ucfirst($matches[2])), 'options' => $options->get('options', true), ]; return $return; }
[ "protected", "function", "collectDataFromInputForTemplate", "(", "CollectionInterface", "$", "options", ")", "{", "$", "name", "=", "$", "options", "->", "get", "(", "'name'", ")", ";", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "InvalidArgumentE...
Собирает массив опций для шаблонов из тех опций, что пришли от пользователя. @param \marvin255\bxcodegen\service\options\CollectionInterface $options @return array @throws \InvalidArgumentException
[ "Собирает", "массив", "опций", "для", "шаблонов", "из", "тех", "опций", "что", "пришли", "от", "пользователя", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/generator/Module.php#L51-L78
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.register
public function register(NodeInterface $node, $index, $replace = false) { if (!$replace) { $this->registry->registerNode($node); } else { $this->registry->removeNode($this->reverseMap[$index]); } $nodeId = $node->getId(); $this->nodeMap[$nodeId] = array_replace($this->nodeMapDefault, [ 'class' => get_class($node), 'flowId' => $this->flowId, 'hash' => $nodeId, 'index' => $index, 'isATraversable' => $node->isTraversable(), 'isAReturningVal' => $node->isReturningVal(), 'isAFlow' => $node->isFlow(), ], $this->nodeIncrements); $this->setNodeIncrement($node); if (isset($this->reverseMap[$index])) { // replacing a node, maintain nodeMap accordingly unset($this->nodeMap[$this->reverseMap[$index]->getId()], $this->reverseMap[$index]); } $this->reverseMap[$index] = $node; return $this; }
php
public function register(NodeInterface $node, $index, $replace = false) { if (!$replace) { $this->registry->registerNode($node); } else { $this->registry->removeNode($this->reverseMap[$index]); } $nodeId = $node->getId(); $this->nodeMap[$nodeId] = array_replace($this->nodeMapDefault, [ 'class' => get_class($node), 'flowId' => $this->flowId, 'hash' => $nodeId, 'index' => $index, 'isATraversable' => $node->isTraversable(), 'isAReturningVal' => $node->isReturningVal(), 'isAFlow' => $node->isFlow(), ], $this->nodeIncrements); $this->setNodeIncrement($node); if (isset($this->reverseMap[$index])) { // replacing a node, maintain nodeMap accordingly unset($this->nodeMap[$this->reverseMap[$index]->getId()], $this->reverseMap[$index]); } $this->reverseMap[$index] = $node; return $this; }
[ "public", "function", "register", "(", "NodeInterface", "$", "node", ",", "$", "index", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "!", "$", "replace", ")", "{", "$", "this", "->", "registry", "->", "registerNode", "(", "$", "node", ")",...
@param NodeInterface $node @param int $index @param bool $replace @throws NodalFlowException @return $this
[ "@param", "NodeInterface", "$node", "@param", "int", "$index", "@param", "bool", "$replace" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L150-L179
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.getNodeIndex
public function getNodeIndex($nodeId) { return isset($this->nodeMap[$nodeId]) ? $this->nodeMap[$nodeId]['index'] : null; }
php
public function getNodeIndex($nodeId) { return isset($this->nodeMap[$nodeId]) ? $this->nodeMap[$nodeId]['index'] : null; }
[ "public", "function", "getNodeIndex", "(", "$", "nodeId", ")", "{", "return", "isset", "(", "$", "this", "->", "nodeMap", "[", "$", "nodeId", "]", ")", "?", "$", "this", "->", "nodeMap", "[", "$", "nodeId", "]", "[", "'index'", "]", ":", "null", ";...
@param string $nodeId @return int|null
[ "@param", "string", "$nodeId" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L186-L189
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.flowEnd
public function flowEnd() { $this->flowStats['end'] = microtime(true); $this->flowStats['mib'] = memory_get_peak_usage(true) / 1048576; $this->flowStats['elapsed'] = $this->flowStats['end'] - $this->flowStats['start']; $this->flowStats = array_replace($this->flowStats, $this->duration($this->flowStats['elapsed'])); return $this; }
php
public function flowEnd() { $this->flowStats['end'] = microtime(true); $this->flowStats['mib'] = memory_get_peak_usage(true) / 1048576; $this->flowStats['elapsed'] = $this->flowStats['end'] - $this->flowStats['start']; $this->flowStats = array_replace($this->flowStats, $this->duration($this->flowStats['elapsed'])); return $this; }
[ "public", "function", "flowEnd", "(", ")", "{", "$", "this", "->", "flowStats", "[", "'end'", "]", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "flowStats", "[", "'mib'", "]", "=", "memory_get_peak_usage", "(", "true", ")", "/", "1048576...
Triggered right after the flow stops @return $this
[ "Triggered", "right", "after", "the", "flow", "stops" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L208-L217
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.getNodeMap
public function getNodeMap() { foreach ($this->flow->getNodes() as $node) { $nodeId = $node->getId(); if ($node instanceof BranchNodeInterface || $node instanceof AggregateNodeInterface) { $this->nodeMap[$nodeId]['nodes'] = $node->getPayload()->getNodeMap(); continue; } } return $this->nodeMap; }
php
public function getNodeMap() { foreach ($this->flow->getNodes() as $node) { $nodeId = $node->getId(); if ($node instanceof BranchNodeInterface || $node instanceof AggregateNodeInterface) { $this->nodeMap[$nodeId]['nodes'] = $node->getPayload()->getNodeMap(); continue; } } return $this->nodeMap; }
[ "public", "function", "getNodeMap", "(", ")", "{", "foreach", "(", "$", "this", "->", "flow", "->", "getNodes", "(", ")", "as", "$", "node", ")", "{", "$", "nodeId", "=", "$", "node", "->", "getId", "(", ")", ";", "if", "(", "$", "node", "instanc...
Get/Generate Node Map @return array
[ "Get", "/", "Generate", "Node", "Map" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L236-L247
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.getStats
public function getStats() { $this->resetTotals(); foreach ($this->flow->getNodes() as $node) { $nodeMap = $this->nodeMap[$node->getId()]; foreach ($this->incrementTotals as $srcKey => $totalKey) { if (isset($nodeMap[$srcKey])) { $this->flowStats[$totalKey] += $nodeMap[$srcKey]; } } if ($node instanceof BranchNodeInterface) { $childFlowId = $node->getPayload()->getId(); $this->flowStats['branches'][$childFlowId] = $node->getPayload()->getStats(); foreach ($this->incrementTotals as $srcKey => $totalKey) { if (isset($this->flowStats['branches'][$childFlowId][$totalKey])) { $this->flowStats[$totalKey] += $this->flowStats['branches'][$childFlowId][$totalKey]; } } } } $flowStatus = $this->flow->getFlowStatus(); if ($flowStatus !== null) { $this->flowStats['flow_status'] = $flowStatus->getStatus(); } return $this->flowStats; }
php
public function getStats() { $this->resetTotals(); foreach ($this->flow->getNodes() as $node) { $nodeMap = $this->nodeMap[$node->getId()]; foreach ($this->incrementTotals as $srcKey => $totalKey) { if (isset($nodeMap[$srcKey])) { $this->flowStats[$totalKey] += $nodeMap[$srcKey]; } } if ($node instanceof BranchNodeInterface) { $childFlowId = $node->getPayload()->getId(); $this->flowStats['branches'][$childFlowId] = $node->getPayload()->getStats(); foreach ($this->incrementTotals as $srcKey => $totalKey) { if (isset($this->flowStats['branches'][$childFlowId][$totalKey])) { $this->flowStats[$totalKey] += $this->flowStats['branches'][$childFlowId][$totalKey]; } } } } $flowStatus = $this->flow->getFlowStatus(); if ($flowStatus !== null) { $this->flowStats['flow_status'] = $flowStatus->getStatus(); } return $this->flowStats; }
[ "public", "function", "getStats", "(", ")", "{", "$", "this", "->", "resetTotals", "(", ")", ";", "foreach", "(", "$", "this", "->", "flow", "->", "getNodes", "(", ")", "as", "$", "node", ")", "{", "$", "nodeMap", "=", "$", "this", "->", "nodeMap",...
Get the latest Node stats @return array<string,integer|string>
[ "Get", "the", "latest", "Node", "stats" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L254-L282
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.resetNodeStats
public function resetNodeStats() { foreach ($this->nodeMap as &$nodeStat) { foreach ($this->nodeIncrements as $key => $value) { if (isset($nodeStat[$key])) { $nodeStat[$key] = $value; } } } return $this; }
php
public function resetNodeStats() { foreach ($this->nodeMap as &$nodeStat) { foreach ($this->nodeIncrements as $key => $value) { if (isset($nodeStat[$key])) { $nodeStat[$key] = $value; } } } return $this; }
[ "public", "function", "resetNodeStats", "(", ")", "{", "foreach", "(", "$", "this", "->", "nodeMap", "as", "&", "$", "nodeStat", ")", "{", "foreach", "(", "$", "this", "->", "nodeIncrements", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(",...
Resets Nodes stats, can be used prior to Flow's re-exec @return $this
[ "Resets", "Nodes", "stats", "can", "be", "used", "prior", "to", "Flow", "s", "re", "-", "exec" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L314-L325
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.duration
public function duration($seconds) { $result = [ 'hour' => (int) floor($seconds / 3600), 'min' => (int) floor(($seconds / 60) % 60), 'sec' => $seconds % 60, 'ms' => (int) round(\fmod($seconds, 1) * 1000), ]; $duration = ''; foreach ($result as $unit => $value) { if (!empty($value) || $unit === 'ms') { $duration .= $value . "$unit "; } } $result['duration'] = trim($duration); return $result; }
php
public function duration($seconds) { $result = [ 'hour' => (int) floor($seconds / 3600), 'min' => (int) floor(($seconds / 60) % 60), 'sec' => $seconds % 60, 'ms' => (int) round(\fmod($seconds, 1) * 1000), ]; $duration = ''; foreach ($result as $unit => $value) { if (!empty($value) || $unit === 'ms') { $duration .= $value . "$unit "; } } $result['duration'] = trim($duration); return $result; }
[ "public", "function", "duration", "(", "$", "seconds", ")", "{", "$", "result", "=", "[", "'hour'", "=>", "(", "int", ")", "floor", "(", "$", "seconds", "/", "3600", ")", ",", "'min'", "=>", "(", "int", ")", "floor", "(", "(", "$", "seconds", "/"...
Computes a human readable duration string from floating seconds @param float $seconds @return array<string,integer|string>
[ "Computes", "a", "human", "readable", "duration", "string", "from", "floating", "seconds" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L334-L353
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.setFlowIncrement
protected function setFlowIncrement(array $flowIncrements) { foreach ($flowIncrements as $incrementKey => $target) { if (is_string($target)) { if (!isset($this->flowStats[$target])) { throw new NodalFlowException('Cannot set reference on unset target'); } $this->flowStats[$incrementKey] = &$this->flowStats[$target]; $this->flowStats[$incrementKey . '_total'] = &$this->flowStats[$target . '_total']; continue; } $this->flowIncrements[$incrementKey] = $target; $this->incrementTotals[$incrementKey] = $incrementKey . '_total'; $this->flowStats[$incrementKey] = $target; } return $this; }
php
protected function setFlowIncrement(array $flowIncrements) { foreach ($flowIncrements as $incrementKey => $target) { if (is_string($target)) { if (!isset($this->flowStats[$target])) { throw new NodalFlowException('Cannot set reference on unset target'); } $this->flowStats[$incrementKey] = &$this->flowStats[$target]; $this->flowStats[$incrementKey . '_total'] = &$this->flowStats[$target . '_total']; continue; } $this->flowIncrements[$incrementKey] = $target; $this->incrementTotals[$incrementKey] = $incrementKey . '_total'; $this->flowStats[$incrementKey] = $target; } return $this; }
[ "protected", "function", "setFlowIncrement", "(", "array", "$", "flowIncrements", ")", "{", "foreach", "(", "$", "flowIncrements", "as", "$", "incrementKey", "=>", "$", "target", ")", "{", "if", "(", "is_string", "(", "$", "target", ")", ")", "{", "if", ...
Set additional increment keys, use : 'keyName' => int to add keyName as increment, starting at int or : 'keyName' => 'existingIncrement' to assign keyName as a reference to existingIncrement @param array $flowIncrements @throws NodalFlowException @return $this
[ "Set", "additional", "increment", "keys", "use", ":", "keyName", "=", ">", "int", "to", "add", "keyName", "as", "increment", "starting", "at", "int", "or", ":", "keyName", "=", ">", "existingIncrement", "to", "assign", "keyName", "as", "a", "reference", "t...
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L416-L435
fab2s/NodalFlow
src/Flows/FlowMap.php
FlowMap.setNodeIncrement
protected function setNodeIncrement(NodeInterface $node) { $nodeId = $node->getId(); foreach ($node->getNodeIncrements() as $incrementKey => $target) { if (is_string($target)) { if (!isset($this->nodeIncrements[$target])) { throw new NodalFlowException('Tried to set an increment alias to an un-registered increment', 1, null, [ 'aliasKey' => $incrementKey, 'targetKey' => $target, ]); } $this->nodeMap[$nodeId][$incrementKey] = &$this->nodeMap[$nodeId][$target]; continue; } $this->nodeIncrements[$incrementKey] = $target; $this->nodeMap[$nodeId][$incrementKey] = $target; } return $this; }
php
protected function setNodeIncrement(NodeInterface $node) { $nodeId = $node->getId(); foreach ($node->getNodeIncrements() as $incrementKey => $target) { if (is_string($target)) { if (!isset($this->nodeIncrements[$target])) { throw new NodalFlowException('Tried to set an increment alias to an un-registered increment', 1, null, [ 'aliasKey' => $incrementKey, 'targetKey' => $target, ]); } $this->nodeMap[$nodeId][$incrementKey] = &$this->nodeMap[$nodeId][$target]; continue; } $this->nodeIncrements[$incrementKey] = $target; $this->nodeMap[$nodeId][$incrementKey] = $target; } return $this; }
[ "protected", "function", "setNodeIncrement", "(", "NodeInterface", "$", "node", ")", "{", "$", "nodeId", "=", "$", "node", "->", "getId", "(", ")", ";", "foreach", "(", "$", "node", "->", "getNodeIncrements", "(", ")", "as", "$", "incrementKey", "=>", "$...
@param NodeInterface $node @throws NodalFlowException @return $this
[ "@param", "NodeInterface", "$node" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L444-L465
skrz/meta
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
FieldDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FieldDescriptorProto(); case 1: return new FieldDescriptorProto(func_get_arg(0)); case 2: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FieldDescriptorProto(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 FieldDescriptorProto(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 FieldDescriptorProto(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 FieldDescriptorProto(); case 1: return new FieldDescriptorProto(func_get_arg(0)); case 2: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FieldDescriptorProto(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 FieldDescriptorProto(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 FieldDescriptorProto(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", "FieldDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "FieldDescriptorProto", "(", "func_get...
Creates new instance of \Google\Protobuf\FieldDescriptorProto @throws \InvalidArgumentException @return FieldDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L66-L90
skrz/meta
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
FieldDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof FieldDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldDescriptorProto.'); } $object->name = NULL; $object->number = NULL; $object->label = NULL; $object->type = NULL; $object->typeName = NULL; $object->extendee = NULL; $object->defaultValue = NULL; $object->oneofIndex = NULL; $object->jsonName = NULL; $object->options = NULL; }
php
public static function reset($object) { if (!($object instanceof FieldDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldDescriptorProto.'); } $object->name = NULL; $object->number = NULL; $object->label = NULL; $object->type = NULL; $object->typeName = NULL; $object->extendee = NULL; $object->defaultValue = NULL; $object->oneofIndex = NULL; $object->jsonName = NULL; $object->options = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "FieldDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf...
Resets properties of \Google\Protobuf\FieldDescriptorProto to default values @param FieldDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldDescriptorProto", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L103-L118
skrz/meta
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
FieldDescriptorProtoMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->number)) { hash_update($ctx, 'number'); hash_update($ctx, (string)$object->number); } if (isset($object->label)) { hash_update($ctx, 'label'); hash_update($ctx, (string)$object->label); } if (isset($object->type)) { hash_update($ctx, 'type'); hash_update($ctx, (string)$object->type); } if (isset($object->typeName)) { hash_update($ctx, 'typeName'); hash_update($ctx, (string)$object->typeName); } if (isset($object->extendee)) { hash_update($ctx, 'extendee'); hash_update($ctx, (string)$object->extendee); } if (isset($object->defaultValue)) { hash_update($ctx, 'defaultValue'); hash_update($ctx, (string)$object->defaultValue); } if (isset($object->oneofIndex)) { hash_update($ctx, 'oneofIndex'); hash_update($ctx, (string)$object->oneofIndex); } if (isset($object->jsonName)) { hash_update($ctx, 'jsonName'); hash_update($ctx, (string)$object->jsonName); } if (isset($object->options)) { hash_update($ctx, 'options'); FieldOptionsMeta::hash($object->options, $ctx); } 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->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->number)) { hash_update($ctx, 'number'); hash_update($ctx, (string)$object->number); } if (isset($object->label)) { hash_update($ctx, 'label'); hash_update($ctx, (string)$object->label); } if (isset($object->type)) { hash_update($ctx, 'type'); hash_update($ctx, (string)$object->type); } if (isset($object->typeName)) { hash_update($ctx, 'typeName'); hash_update($ctx, (string)$object->typeName); } if (isset($object->extendee)) { hash_update($ctx, 'extendee'); hash_update($ctx, (string)$object->extendee); } if (isset($object->defaultValue)) { hash_update($ctx, 'defaultValue'); hash_update($ctx, (string)$object->defaultValue); } if (isset($object->oneofIndex)) { hash_update($ctx, 'oneofIndex'); hash_update($ctx, (string)$object->oneofIndex); } if (isset($object->jsonName)) { hash_update($ctx, 'jsonName'); hash_update($ctx, (string)$object->jsonName); } if (isset($object->options)) { hash_update($ctx, 'options'); FieldOptionsMeta::hash($object->options, $ctx); } 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\FieldDescriptorProto @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L130-L193
skrz/meta
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
FieldDescriptorProtoMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FieldDescriptorProto(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->number = Binary::decodeVarint($input, $start); break; case 4: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->label = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->type = Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->typeName = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->extendee = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->defaultValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 9: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->oneofIndex = Binary::decodeVarint($input, $start); break; case 10: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->jsonName = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->options = FieldOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FieldDescriptorProto(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->name = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->number = Binary::decodeVarint($input, $start); break; case 4: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->label = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->type = Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->typeName = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->extendee = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 7: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->defaultValue = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 9: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->oneofIndex = Binary::decodeVarint($input, $start); break; case 10: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->jsonName = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->options = FieldOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\FieldDescriptorProto object from serialized Protocol Buffers message. @param string $input @param FieldDescriptorProto $object @param int $start @param int $end @throws \Exception @return FieldDescriptorProto
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "FieldDescriptorProto", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L208-L357
skrz/meta
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
FieldDescriptorProtoMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->number) && ($filter === null || isset($filter['number']))) { $output .= "\x18"; $output .= Binary::encodeVarint($object->number); } if (isset($object->label) && ($filter === null || isset($filter['label']))) { $output .= "\x20"; $output .= Binary::encodeVarint($object->label); } if (isset($object->type) && ($filter === null || isset($filter['type']))) { $output .= "\x28"; $output .= Binary::encodeVarint($object->type); } if (isset($object->typeName) && ($filter === null || isset($filter['typeName']))) { $output .= "\x32"; $output .= Binary::encodeVarint(strlen($object->typeName)); $output .= $object->typeName; } if (isset($object->extendee) && ($filter === null || isset($filter['extendee']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->extendee)); $output .= $object->extendee; } if (isset($object->defaultValue) && ($filter === null || isset($filter['defaultValue']))) { $output .= "\x3a"; $output .= Binary::encodeVarint(strlen($object->defaultValue)); $output .= $object->defaultValue; } if (isset($object->oneofIndex) && ($filter === null || isset($filter['oneofIndex']))) { $output .= "\x48"; $output .= Binary::encodeVarint($object->oneofIndex); } if (isset($object->jsonName) && ($filter === null || isset($filter['jsonName']))) { $output .= "\x52"; $output .= Binary::encodeVarint(strlen($object->jsonName)); $output .= $object->jsonName; } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x42"; $buffer = FieldOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->number) && ($filter === null || isset($filter['number']))) { $output .= "\x18"; $output .= Binary::encodeVarint($object->number); } if (isset($object->label) && ($filter === null || isset($filter['label']))) { $output .= "\x20"; $output .= Binary::encodeVarint($object->label); } if (isset($object->type) && ($filter === null || isset($filter['type']))) { $output .= "\x28"; $output .= Binary::encodeVarint($object->type); } if (isset($object->typeName) && ($filter === null || isset($filter['typeName']))) { $output .= "\x32"; $output .= Binary::encodeVarint(strlen($object->typeName)); $output .= $object->typeName; } if (isset($object->extendee) && ($filter === null || isset($filter['extendee']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->extendee)); $output .= $object->extendee; } if (isset($object->defaultValue) && ($filter === null || isset($filter['defaultValue']))) { $output .= "\x3a"; $output .= Binary::encodeVarint(strlen($object->defaultValue)); $output .= $object->defaultValue; } if (isset($object->oneofIndex) && ($filter === null || isset($filter['oneofIndex']))) { $output .= "\x48"; $output .= Binary::encodeVarint($object->oneofIndex); } if (isset($object->jsonName) && ($filter === null || isset($filter['jsonName']))) { $output .= "\x52"; $output .= Binary::encodeVarint(strlen($object->jsonName)); $output .= $object->jsonName; } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x42"; $buffer = FieldOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\FieldDescriptorProto to Protocol Buffers message. @param FieldDescriptorProto $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "FieldDescriptorProto", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L370-L432
baleen/migrations
src/Service/DomainBus/DomainBus.php
DomainBus.createWithLocator
public static function createWithLocator(HandlerLocator $locator) { $handlerMiddleware = new CommandHandlerMiddleware( new ClassNameExtractor(), $locator, new HandleInflector() ); $lockingMiddleware = new LockingMiddleware(); return new DomainBus([$lockingMiddleware, $handlerMiddleware]); }
php
public static function createWithLocator(HandlerLocator $locator) { $handlerMiddleware = new CommandHandlerMiddleware( new ClassNameExtractor(), $locator, new HandleInflector() ); $lockingMiddleware = new LockingMiddleware(); return new DomainBus([$lockingMiddleware, $handlerMiddleware]); }
[ "public", "static", "function", "createWithLocator", "(", "HandlerLocator", "$", "locator", ")", "{", "$", "handlerMiddleware", "=", "new", "CommandHandlerMiddleware", "(", "new", "ClassNameExtractor", "(", ")", ",", "$", "locator", ",", "new", "HandleInflector", ...
create @param HandlerLocator $locator @return DomainBus
[ "create" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/DomainBus/DomainBus.php#L42-L53
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/HomeController.php
HomeController.index
public function index() { $posts = $this->posts->active(Config::get('core::wardrobe.per_page')); return View::make($this->theme.'.index', compact('posts')); }
php
public function index() { $posts = $this->posts->active(Config::get('core::wardrobe.per_page')); return View::make($this->theme.'.index', compact('posts')); }
[ "public", "function", "index", "(", ")", "{", "$", "posts", "=", "$", "this", "->", "posts", "->", "active", "(", "Config", "::", "get", "(", "'core::wardrobe.per_page'", ")", ")", ";", "return", "View", "::", "make", "(", "$", "this", "->", "theme", ...
Get the Wardrobe index. @return Response
[ "Get", "the", "Wardrobe", "index", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/HomeController.php#L34-L39
scherersoftware/cake-notifications
src/Transport/Transport.php
Transport._performCallback
protected static function _performCallback(array $items, Notification &$notificationInstance = null) { $success = false; foreach ($items as $item) { if (!isset($item['class']) || !is_callable($item['class'])) { $class = $item['class']; if (is_array($item['class'])) { $class = implode($item['class']); } throw new \InvalidArgumentException("{$class} is not callable"); } $args = []; if (isset($item['args']) && is_array($item['args'])) { $args = $item['args']; } if (is_array($item['class']) && count($item['class']) == 2) { $className = $item['class'][0]; $methodName = $item['class'][1]; $instance = new $className; $success = call_user_func_array([$instance, $methodName], $args); } elseif (is_string($item['class'])) { $success = call_user_func_array($item['class'], $args); } if (is_callable($success)) { $success($notificationInstance); } } }
php
protected static function _performCallback(array $items, Notification &$notificationInstance = null) { $success = false; foreach ($items as $item) { if (!isset($item['class']) || !is_callable($item['class'])) { $class = $item['class']; if (is_array($item['class'])) { $class = implode($item['class']); } throw new \InvalidArgumentException("{$class} is not callable"); } $args = []; if (isset($item['args']) && is_array($item['args'])) { $args = $item['args']; } if (is_array($item['class']) && count($item['class']) == 2) { $className = $item['class'][0]; $methodName = $item['class'][1]; $instance = new $className; $success = call_user_func_array([$instance, $methodName], $args); } elseif (is_string($item['class'])) { $success = call_user_func_array($item['class'], $args); } if (is_callable($success)) { $success($notificationInstance); } } }
[ "protected", "static", "function", "_performCallback", "(", "array", "$", "items", ",", "Notification", "&", "$", "notificationInstance", "=", "null", ")", "{", "$", "success", "=", "false", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", ...
Performs the before- or after send callback of the notification @param array $items Contains the class and function name and optional, function params @param Notification $notificationInstance Reference to the notification instance for a possible callbacks callback @throws InvalidArgumentException
[ "Performs", "the", "before", "-", "or", "after", "send", "callback", "of", "the", "notification" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Transport/Transport.php#L16-L45