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/EnumValueDescriptorProtoMeta.php
EnumValueDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new EnumValueDescriptorProto(); case 1: return new EnumValueDescriptorProto(func_get_arg(0)); case 2: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto(); case 1: return new EnumValueDescriptorProto(func_get_arg(0)); case 2: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumValueDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumValueDescriptorProto(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 EnumValueDescriptorProto(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 EnumValueDescriptorProto(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", "EnumValueDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "EnumValueDescriptorProto", "(", "...
Creates new instance of \Google\Protobuf\EnumValueDescriptorProto @throws \InvalidArgumentException @return EnumValueDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L59-L83
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
EnumValueDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof EnumValueDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueDescriptorProto.'); } $object->name = NULL; $object->number = NULL; $object->options = NULL; }
php
public static function reset($object) { if (!($object instanceof EnumValueDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueDescriptorProto.'); } $object->name = NULL; $object->number = NULL; $object->options = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "EnumValueDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Prot...
Resets properties of \Google\Protobuf\EnumValueDescriptorProto to default values @param EnumValueDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueDescriptorProto", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L96-L104
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
EnumValueDescriptorProtoMeta.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->options)) { hash_update($ctx, 'options'); EnumValueOptionsMeta::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->options)) { hash_update($ctx, 'options'); EnumValueOptionsMeta::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\EnumValueDescriptorProto @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L116-L144
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
EnumValueDescriptorProtoMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new EnumValueDescriptorProto(); } 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 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->number = Binary::decodeVarint($input, $start); 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->options = EnumValueOptionsMeta::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 EnumValueDescriptorProto(); } 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 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->number = Binary::decodeVarint($input, $start); 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->options = EnumValueOptionsMeta::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\EnumValueDescriptorProto object from serialized Protocol Buffers message. @param string $input @param EnumValueDescriptorProto $object @param int $start @param int $end @throws \Exception @return EnumValueDescriptorProto
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueDescriptorProto", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L159-L230
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php
EnumValueDescriptorProtoMeta.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 .= "\x10"; $output .= Binary::encodeVarint($object->number); } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x1a"; $buffer = EnumValueOptionsMeta::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 .= "\x10"; $output .= Binary::encodeVarint($object->number); } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x1a"; $buffer = EnumValueOptionsMeta::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\EnumValueDescriptorProto to Protocol Buffers message. @param EnumValueDescriptorProto $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueDescriptorProto", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueDescriptorProtoMeta.php#L243-L266
meare/juggler
src/Juggler.php
Juggler.getImposter
public function getImposter($port, $replayable = false, $remove_proxies = false) { return $this->abstractImposterBuilder->build($this->getImposterContract($port, $replayable, $remove_proxies)); }
php
public function getImposter($port, $replayable = false, $remove_proxies = false) { return $this->abstractImposterBuilder->build($this->getImposterContract($port, $replayable, $remove_proxies)); }
[ "public", "function", "getImposter", "(", "$", "port", ",", "$", "replayable", "=", "false", ",", "$", "remove_proxies", "=", "false", ")", "{", "return", "$", "this", "->", "abstractImposterBuilder", "->", "build", "(", "$", "this", "->", "getImposterContra...
Retrieves contract and builds Imposter @param int $port @param bool $replayable @param bool $remove_proxies @throws MountebankException @return Imposter
[ "Retrieves", "contract", "and", "builds", "Imposter" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Juggler.php#L159-L162
meare/juggler
src/Juggler.php
Juggler.deleteImposter
public function deleteImposter($imposter, $replayable = false, $remove_proxies = false) { $query = $this->composeQueryString($replayable, $remove_proxies); $port = $imposter instanceof Imposter ? $imposter->getPort() : $imposter; return $this->httpClient->delete("/imposters/$port?$query"); }
php
public function deleteImposter($imposter, $replayable = false, $remove_proxies = false) { $query = $this->composeQueryString($replayable, $remove_proxies); $port = $imposter instanceof Imposter ? $imposter->getPort() : $imposter; return $this->httpClient->delete("/imposters/$port?$query"); }
[ "public", "function", "deleteImposter", "(", "$", "imposter", ",", "$", "replayable", "=", "false", ",", "$", "remove_proxies", "=", "false", ")", "{", "$", "query", "=", "$", "this", "->", "composeQueryString", "(", "$", "replayable", ",", "$", "remove_pr...
@param int|Imposter $imposter Port or Imposter instance @param bool $replayable @param bool $remove_proxies @return string Imposter contract @throws MountebankException
[ "@param", "int|Imposter", "$imposter", "Port", "or", "Imposter", "instance", "@param", "bool", "$replayable", "@param", "bool", "$remove_proxies" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Juggler.php#L196-L202
meare/juggler
src/Juggler.php
Juggler.composeQueryString
private function composeQueryString($replayable, $remove_proxies) { return http_build_query(array_filter([ self::PARAM_REPLAYABLE => $replayable ? 'true' : null, self::PARAM_REMOVE_PROXIES => $remove_proxies ? 'true' : null, ])); }
php
private function composeQueryString($replayable, $remove_proxies) { return http_build_query(array_filter([ self::PARAM_REPLAYABLE => $replayable ? 'true' : null, self::PARAM_REMOVE_PROXIES => $remove_proxies ? 'true' : null, ])); }
[ "private", "function", "composeQueryString", "(", "$", "replayable", ",", "$", "remove_proxies", ")", "{", "return", "http_build_query", "(", "array_filter", "(", "[", "self", "::", "PARAM_REPLAYABLE", "=>", "$", "replayable", "?", "'true'", ":", "null", ",", ...
mountebank API only supports string 'true' as boolean param value @param bool $replayable @param bool $remove_proxies @return string
[ "mountebank", "API", "only", "supports", "string", "true", "as", "boolean", "param", "value" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Juggler.php#L284-L290
skrz/meta
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
CodeGeneratorRequestMeta.create
public static function create() { switch (func_num_args()) { case 0: return new CodeGeneratorRequest(); case 1: return new CodeGeneratorRequest(func_get_arg(0)); case 2: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1)); case 3: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest(); case 1: return new CodeGeneratorRequest(func_get_arg(0)); case 2: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1)); case 3: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new CodeGeneratorRequest(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new CodeGeneratorRequest(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 CodeGeneratorRequest(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 CodeGeneratorRequest(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", "CodeGeneratorRequest", "(", ")", ";", "case", "1", ":", "return", "new", "CodeGeneratorRequest", "(", "func_get...
Creates new instance of \Google\Protobuf\Compiler\CodeGeneratorRequest @throws \InvalidArgumentException @return CodeGeneratorRequest
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorRequest" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L60-L84
skrz/meta
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
CodeGeneratorRequestMeta.reset
public static function reset($object) { if (!($object instanceof CodeGeneratorRequest)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorRequest.'); } $object->fileToGenerate = NULL; $object->parameter = NULL; $object->protoFile = NULL; }
php
public static function reset($object) { if (!($object instanceof CodeGeneratorRequest)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorRequest.'); } $object->fileToGenerate = NULL; $object->parameter = NULL; $object->protoFile = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "CodeGeneratorRequest", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf...
Resets properties of \Google\Protobuf\Compiler\CodeGeneratorRequest to default values @param CodeGeneratorRequest $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorRequest", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L97-L105
skrz/meta
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
CodeGeneratorRequestMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->fileToGenerate)) { hash_update($ctx, 'fileToGenerate'); foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->parameter)) { hash_update($ctx, 'parameter'); hash_update($ctx, (string)$object->parameter); } if (isset($object->protoFile)) { hash_update($ctx, 'protoFile'); foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $v0) { FileDescriptorProtoMeta::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->fileToGenerate)) { hash_update($ctx, 'fileToGenerate'); foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->parameter)) { hash_update($ctx, 'parameter'); hash_update($ctx, (string)$object->parameter); } if (isset($object->protoFile)) { hash_update($ctx, 'protoFile'); foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $v0) { FileDescriptorProtoMeta::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\Compiler\CodeGeneratorRequest @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorRequest" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L117-L149
skrz/meta
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
CodeGeneratorRequestMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new CodeGeneratorRequest(); } 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); } if (!(isset($object->fileToGenerate) && is_array($object->fileToGenerate))) { $object->fileToGenerate = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->fileToGenerate[] = 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->parameter = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 15: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->protoFile) && is_array($object->protoFile))) { $object->protoFile = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->protoFile[] = FileDescriptorProtoMeta::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 CodeGeneratorRequest(); } 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); } if (!(isset($object->fileToGenerate) && is_array($object->fileToGenerate))) { $object->fileToGenerate = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->fileToGenerate[] = 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->parameter = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 15: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->protoFile) && is_array($object->protoFile))) { $object->protoFile = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->protoFile[] = FileDescriptorProtoMeta::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\Compiler\CodeGeneratorRequest object from serialized Protocol Buffers message. @param string $input @param CodeGeneratorRequest $object @param int $start @param int $end @throws \Exception @return CodeGeneratorRequest
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorRequest", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L164-L250
skrz/meta
gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php
CodeGeneratorRequestMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) { foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->parameter)); $output .= $object->parameter; } if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) { foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) { $output .= "\x7a"; $buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) { foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->parameter)); $output .= $object->parameter; } if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) { foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) { $output .= "\x7a"; $buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "fileToGenerate", ")", "&&", "(", "$", "filter", "===", "null", ...
Serialized \Google\Protobuf\Compiler\CodeGeneratorRequest to Protocol Buffers message. @param CodeGeneratorRequest $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorRequest", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorRequestMeta.php#L263-L291
bigwhoop/sentence-breaker
src/Lexing/States/WordState.php
WordState.call
protected function call(Lexer $lexer) { $nonWordChars = $this->getNonWordChars(); while (!in_array($lexer->peek(), $nonWordChars, true)) { $lexer->next(); } $value = $lexer->getTokenValue(); $firstChar = substr($value, 0, 1); if (ctype_upper($firstChar)) { $lexer->emit(new CapitalizedWordToken()); } else { $lexer->emit(new WordToken()); } return new TextState(); }
php
protected function call(Lexer $lexer) { $nonWordChars = $this->getNonWordChars(); while (!in_array($lexer->peek(), $nonWordChars, true)) { $lexer->next(); } $value = $lexer->getTokenValue(); $firstChar = substr($value, 0, 1); if (ctype_upper($firstChar)) { $lexer->emit(new CapitalizedWordToken()); } else { $lexer->emit(new WordToken()); } return new TextState(); }
[ "protected", "function", "call", "(", "Lexer", "$", "lexer", ")", "{", "$", "nonWordChars", "=", "$", "this", "->", "getNonWordChars", "(", ")", ";", "while", "(", "!", "in_array", "(", "$", "lexer", "->", "peek", "(", ")", ",", "$", "nonWordChars", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Lexing/States/WordState.php#L30-L48
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/RssController.php
RssController.index
public function index() { $posts = $this->posts->active(100); $data = array( 'posts' => $posts, 'updated' => isset($posts[0]) ? $posts[0]->atom_date : date('Y-m-d H:i:s'), ); return Response::view($this->theme.'.atom', $data, 200, array( 'Content-Type' => 'application/rss+xml; charset=UTF-8', )); }
php
public function index() { $posts = $this->posts->active(100); $data = array( 'posts' => $posts, 'updated' => isset($posts[0]) ? $posts[0]->atom_date : date('Y-m-d H:i:s'), ); return Response::view($this->theme.'.atom', $data, 200, array( 'Content-Type' => 'application/rss+xml; charset=UTF-8', )); }
[ "public", "function", "index", "(", ")", "{", "$", "posts", "=", "$", "this", "->", "posts", "->", "active", "(", "100", ")", ";", "$", "data", "=", "array", "(", "'posts'", "=>", "$", "posts", ",", "'updated'", "=>", "isset", "(", "$", "posts", ...
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/RssController.php#L34-L46
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.getPushType
protected function getPushType($queue_name) { if ($this->option('push_queue_type')) return $this->option('push_queue_type'); try { return $this->getQueue($queue_name)->push_type; } catch (\Exception $e) { return 'multicast'; } }
php
protected function getPushType($queue_name) { if ($this->option('push_queue_type')) return $this->option('push_queue_type'); try { return $this->getQueue($queue_name)->push_type; } catch (\Exception $e) { return 'multicast'; } }
[ "protected", "function", "getPushType", "(", "$", "queue_name", ")", "{", "if", "(", "$", "this", "->", "option", "(", "'push_queue_type'", ")", ")", "return", "$", "this", "->", "option", "(", "'push_queue_type'", ")", ";", "try", "{", "return", "$", "t...
Get the push type for the queue. @param $queue_name @return string
[ "Get", "the", "push", "type", "for", "the", "queue", "." ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L108-L117
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.getSubscriberList
protected function getSubscriberList($queue_name) { $subscribers = $this->getCurrentSubscribers($queue_name); $subscribers[] = array('url' => $this->subscriber_url); return $subscribers; }
php
protected function getSubscriberList($queue_name) { $subscribers = $this->getCurrentSubscribers($queue_name); $subscribers[] = array('url' => $this->subscriber_url); return $subscribers; }
[ "protected", "function", "getSubscriberList", "(", "$", "queue_name", ")", "{", "$", "subscribers", "=", "$", "this", "->", "getCurrentSubscribers", "(", "$", "queue_name", ")", ";", "$", "subscribers", "[", "]", "=", "array", "(", "'url'", "=>", "$", "thi...
Get the current subscribers for the queue. @param $queue_name @return array
[ "Get", "the", "current", "subscribers", "for", "the", "queue", "." ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L125-L130
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.need_to_update_queue
protected function need_to_update_queue($queue_name) { foreach ($this->getCurrentSubscribers($queue_name) as $subscriber) { if ($subscriber->url == $this->subscriber_url) return false; } return true; }
php
protected function need_to_update_queue($queue_name) { foreach ($this->getCurrentSubscribers($queue_name) as $subscriber) { if ($subscriber->url == $this->subscriber_url) return false; } return true; }
[ "protected", "function", "need_to_update_queue", "(", "$", "queue_name", ")", "{", "foreach", "(", "$", "this", "->", "getCurrentSubscribers", "(", "$", "queue_name", ")", "as", "$", "subscriber", ")", "{", "if", "(", "$", "subscriber", "->", "url", "==", ...
Get list of subscribers and compare it with current subscriber url @param $queue_name @internal param $subscriber_url @return bool
[ "Get", "list", "of", "subscribers", "and", "compare", "it", "with", "current", "subscriber", "url" ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L167-L174
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.upload_worker
protected function upload_worker($worker_name, $worker_file_name) { $this->info("<info>Starting to upload <comment>$worker_name</comment> worker</info>"); @$this->worker->upload(getcwd(), $this->workers_dir . '/' . $worker_file_name, $worker_name, $this->worker_params); $this->info("<info>Worker <comment>$worker_name</comment> uploaded</info>" . PHP_EOL); }
php
protected function upload_worker($worker_name, $worker_file_name) { $this->info("<info>Starting to upload <comment>$worker_name</comment> worker</info>"); @$this->worker->upload(getcwd(), $this->workers_dir . '/' . $worker_file_name, $worker_name, $this->worker_params); $this->info("<info>Worker <comment>$worker_name</comment> uploaded</info>" . PHP_EOL); }
[ "protected", "function", "upload_worker", "(", "$", "worker_name", ",", "$", "worker_file_name", ")", "{", "$", "this", "->", "info", "(", "\"<info>Starting to upload <comment>$worker_name</comment> worker</info>\"", ")", ";", "@", "$", "this", "->", "worker", "->", ...
Upload worker @param $worker_name @param $worker_file_name
[ "Upload", "worker" ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L182-L187
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.update_queue
protected function update_queue($iron, $queue_name) { $this->info("<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>"); $iron->getIron()->updateQueue($queue_name, $this->getQueueOptions($queue_name)); $this->line("<info>Push Queue <comment>$queue_name</comment> with subscriber <comment>$this->subscriber_url</comment> created or updated.</info>" . PHP_EOL); }
php
protected function update_queue($iron, $queue_name) { $this->info("<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>"); $iron->getIron()->updateQueue($queue_name, $this->getQueueOptions($queue_name)); $this->line("<info>Push Queue <comment>$queue_name</comment> with subscriber <comment>$this->subscriber_url</comment> created or updated.</info>" . PHP_EOL); }
[ "protected", "function", "update_queue", "(", "$", "iron", ",", "$", "queue_name", ")", "{", "$", "this", "->", "info", "(", "\"<info>Creating or updating push queue <comment>$this->iron_worker_name</comment></info>\"", ")", ";", "$", "iron", "->", "getIron", "(", ")"...
Update push queue @param $iron @param $queue_name
[ "Update", "push", "queue" ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L195-L200
iron-io/laraworker
commands/UploadWorker.php
UploadWorker.show_workers_queues_list
protected function show_workers_queues_list($workers) { $this->line("<info>Your workers:</info>"); foreach ($workers as $worker_file_name) { if (is_dir(getcwd() . '/' . $this->workers_dir . '/' . $worker_file_name)) continue; $this->line('<comment>' . $this->remove_extension($worker_file_name) . '</comment>'); } }
php
protected function show_workers_queues_list($workers) { $this->line("<info>Your workers:</info>"); foreach ($workers as $worker_file_name) { if (is_dir(getcwd() . '/' . $this->workers_dir . '/' . $worker_file_name)) continue; $this->line('<comment>' . $this->remove_extension($worker_file_name) . '</comment>'); } }
[ "protected", "function", "show_workers_queues_list", "(", "$", "workers", ")", "{", "$", "this", "->", "line", "(", "\"<info>Your workers:</info>\"", ")", ";", "foreach", "(", "$", "workers", "as", "$", "worker_file_name", ")", "{", "if", "(", "is_dir", "(", ...
Show list of the uploaded workers and created/updated queues @param $workers @return mixed
[ "Show", "list", "of", "the", "uploaded", "workers", "and", "created", "/", "updated", "queues" ]
train
https://github.com/iron-io/laraworker/blob/2b3461d31863267abbd74611f25f5f2922585ccf/commands/UploadWorker.php#L220-L228
hollodotme/phpunit-testdox-markdown
src/Markdown.php
Markdown.getRealFilePath
private function getRealFilePath( string $filePath ) : string { $realFilePath = getcwd() . DIRECTORY_SEPARATOR . ltrim( $filePath, '/' ); $outputDir = dirname( $realFilePath ); if ( !@mkdir( $outputDir, 0777, true ) && !is_dir( $outputDir ) ) { throw new InvalidArgumentException( 'Invalid file path: ' . $realFilePath ); } return $realFilePath; }
php
private function getRealFilePath( string $filePath ) : string { $realFilePath = getcwd() . DIRECTORY_SEPARATOR . ltrim( $filePath, '/' ); $outputDir = dirname( $realFilePath ); if ( !@mkdir( $outputDir, 0777, true ) && !is_dir( $outputDir ) ) { throw new InvalidArgumentException( 'Invalid file path: ' . $realFilePath ); } return $realFilePath; }
[ "private", "function", "getRealFilePath", "(", "string", "$", "filePath", ")", ":", "string", "{", "$", "realFilePath", "=", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "filePath", ",", "'/'", ")", ";", "$", "outputDir", "=", ...
@param string $filePath @throws InvalidArgumentException @return string
[ "@param", "string", "$filePath" ]
train
https://github.com/hollodotme/phpunit-testdox-markdown/blob/f45413d90647bcf7244ded293efc7cbbcdf437ab/src/Markdown.php#L94-L104
kaliop-uk/kueueingbundle
Service/MessageConsumer/XmlrpcCall.php
XmlrpcCall.consume
public function consume($body) { // validate members in $body if ( !is_array($body) || empty($body['server']) || empty($body['method']) || (isset($body['arguments']) && !is_array($body['arguments'])) /*|| ( isset( $body['options'] ) && !is_array( $body['options'] ) ) */ ) { throw new \UnexpectedValueException("Message format unsupported. Received: " . json_encode($body)); } $label = trim(ConsumerCommand::getLabel()); if ($label != '') { $label = " '$label'"; } if ($this->logger) { $this->logger->debug("XMLRPC call will be executed from MessageConsumer{$label}: " . $body['method'] . " on server: " . $body['server']); } $encoder = new XE(); $args = array(); foreach ($body['arguments'] as $val) { $args[] = $encoder->encode($val); } $client = new XC($body['server']); $response = $client->send(new XR($body['method'], $args)); if ($response->faultCode() != 0 && $this->logger) { $this->logger->error( "XMLRPC call executed from MessageConsumer{$label} failed. Retcode: " . $response->faultCode() . ", Error message: '" . $response->faultString() . "'", array()); } return $response->faultCode() == 0 ? $encoder->decode($response->value()) : null; }
php
public function consume($body) { // validate members in $body if ( !is_array($body) || empty($body['server']) || empty($body['method']) || (isset($body['arguments']) && !is_array($body['arguments'])) /*|| ( isset( $body['options'] ) && !is_array( $body['options'] ) ) */ ) { throw new \UnexpectedValueException("Message format unsupported. Received: " . json_encode($body)); } $label = trim(ConsumerCommand::getLabel()); if ($label != '') { $label = " '$label'"; } if ($this->logger) { $this->logger->debug("XMLRPC call will be executed from MessageConsumer{$label}: " . $body['method'] . " on server: " . $body['server']); } $encoder = new XE(); $args = array(); foreach ($body['arguments'] as $val) { $args[] = $encoder->encode($val); } $client = new XC($body['server']); $response = $client->send(new XR($body['method'], $args)); if ($response->faultCode() != 0 && $this->logger) { $this->logger->error( "XMLRPC call executed from MessageConsumer{$label} failed. Retcode: " . $response->faultCode() . ", Error message: '" . $response->faultString() . "'", array()); } return $response->faultCode() == 0 ? $encoder->decode($response->value()) : null; }
[ "public", "function", "consume", "(", "$", "body", ")", "{", "// validate members in $body", "if", "(", "!", "is_array", "(", "$", "body", ")", "||", "empty", "(", "$", "body", "[", "'server'", "]", ")", "||", "empty", "(", "$", "body", "[", "'method'"...
@todo add support for options to be set to the xmlrpc client @todo on the other hand, the list of allowed xmlrpc server with options might be stored in settings, just like ggwebservices does... @param array $body @return mixed @throws \UnexpectedValueException
[ "@todo", "add", "support", "for", "options", "to", "be", "set", "to", "the", "xmlrpc", "client", "@todo", "on", "the", "other", "hand", "the", "list", "of", "allowed", "xmlrpc", "server", "with", "options", "might", "be", "stored", "in", "settings", "just"...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/XmlrpcCall.php#L24-L61
wardrobecms/core-archived
src/migrations/2013_05_31_141423_create_tags_table.php
CreateTagsTable.up
public function up() { Schema::create('tags', function($table) { $table->integer('post_id'); $table->string('tag'); $table->unique(array('post_id', 'tag')); }); }
php
public function up() { Schema::create('tags', function($table) { $table->integer('post_id'); $table->string('tag'); $table->unique(array('post_id', 'tag')); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "'tags'", ",", "function", "(", "$", "table", ")", "{", "$", "table", "->", "integer", "(", "'post_id'", ")", ";", "$", "table", "->", "string", "(", "'tag'", ")", ";", "$", ...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/migrations/2013_05_31_141423_create_tags_table.php#L12-L20
meare/juggler
src/Imposter/Stub/Stub.php
Stub.getResponseOfType
public function getResponseOfType($type, $nth = 0) { if (!in_array($type, [IResponse::TYPE_IS, IResponse::TYPE_PROXY, IResponse::TYPE_INJECT])) { throw new \InvalidArgumentException("Unknown response type: '$type'"); } $matches_found = 0; foreach ($this->responses as $response) { if ($response->getType() === $type && $matches_found++ === $nth) { return $response; } } throw new NotFoundException("Unable to find response of type '$type' at position $nth ($matches_found '$type' responses were found)"); }
php
public function getResponseOfType($type, $nth = 0) { if (!in_array($type, [IResponse::TYPE_IS, IResponse::TYPE_PROXY, IResponse::TYPE_INJECT])) { throw new \InvalidArgumentException("Unknown response type: '$type'"); } $matches_found = 0; foreach ($this->responses as $response) { if ($response->getType() === $type && $matches_found++ === $nth) { return $response; } } throw new NotFoundException("Unable to find response of type '$type' at position $nth ($matches_found '$type' responses were found)"); }
[ "public", "function", "getResponseOfType", "(", "$", "type", ",", "$", "nth", "=", "0", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "IResponse", "::", "TYPE_IS", ",", "IResponse", "::", "TYPE_PROXY", ",", "IResponse", "::", "TYPE_...
Returns first or nth response of type ("is", "proxy" or "inject") if exists @param string $type @param int $nth number of $type-response in a list @return IResponse @throws NotFoundException
[ "Returns", "first", "or", "nth", "response", "of", "type", "(", "is", "proxy", "or", "inject", ")", "if", "exists" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Imposter/Stub/Stub.php#L193-L205
baleen/migrations
src/Delta/Collection/Resolver/HeadResolver.php
HeadResolver.doResolve
protected function doResolve($alias, Collection $collection) { if (strtolower($alias) !== self::HEAD) { return null; } $reversed = $collection->getReverse(); foreach ($reversed as $version) { /** @var DeltaInterface $version */ if ($version->isMigrated()) { return $version; } } return null; }
php
protected function doResolve($alias, Collection $collection) { if (strtolower($alias) !== self::HEAD) { return null; } $reversed = $collection->getReverse(); foreach ($reversed as $version) { /** @var DeltaInterface $version */ if ($version->isMigrated()) { return $version; } } return null; }
[ "protected", "function", "doResolve", "(", "$", "alias", ",", "Collection", "$", "collection", ")", "{", "if", "(", "strtolower", "(", "$", "alias", ")", "!==", "self", "::", "HEAD", ")", "{", "return", "null", ";", "}", "$", "reversed", "=", "$", "c...
doResolve @param $alias @param Collection $collection @return DeltaInterface|null
[ "doResolve" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/HeadResolver.php#L41-L55
OpenBuildings/postmark
src/Api.php
Api.send
public function send(array $data) { $curl = curl_init(); curl_setopt_array( $curl, array( CURLOPT_URL => $this->getSendUri(), CURLOPT_POST => true, CURLOPT_HTTPHEADER => $this->getHeaders(), CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_RETURNTRANSFER => true ) ); $response = curl_exec($curl); if (! $response) { $curlError = curl_error($curl) ?: 'unknown cURL error'; throw new \Exception(sprintf( 'Postmark delivery failed: %s', $curlError )); } $response = @json_decode($response, true); if (! $response) { throw new \Exception('Postmark delivery failed: wrong json response'); } $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($responseCode != 200) { throw new Exception( sprintf('Postmark delivery failed: %s', $response['Message']), (int) $response['ErrorCode'] ); } return $response; }
php
public function send(array $data) { $curl = curl_init(); curl_setopt_array( $curl, array( CURLOPT_URL => $this->getSendUri(), CURLOPT_POST => true, CURLOPT_HTTPHEADER => $this->getHeaders(), CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_RETURNTRANSFER => true ) ); $response = curl_exec($curl); if (! $response) { $curlError = curl_error($curl) ?: 'unknown cURL error'; throw new \Exception(sprintf( 'Postmark delivery failed: %s', $curlError )); } $response = @json_decode($response, true); if (! $response) { throw new \Exception('Postmark delivery failed: wrong json response'); } $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($responseCode != 200) { throw new Exception( sprintf('Postmark delivery failed: %s', $response['Message']), (int) $response['ErrorCode'] ); } return $response; }
[ "public", "function", "send", "(", "array", "$", "data", ")", "{", "$", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt_array", "(", "$", "curl", ",", "array", "(", "CURLOPT_URL", "=>", "$", "this", "->", "getSendUri", "(", ")", ",", "CURLOPT_POS...
Send a request to the Postmark Send API. See http://developer.postmarkapp.com/developer-send-api.html @param array $data @return array Postmark API response. @throws Exception If API request failed or JSON returned was invalid. @throws Openbuildings\Postmark\Exception If Postmark API returned an error. @uses Openbuildings\Postmark\Api::getSendUri to determine the request URI @uses Openbuildings\Postmark\Api::getHeaders for the request headers
[ "Send", "a", "request", "to", "the", "Postmark", "Send", "API", ".", "See", "http", ":", "//", "developer", ".", "postmarkapp", ".", "com", "/", "developer", "-", "send", "-", "api", ".", "html" ]
train
https://github.com/OpenBuildings/postmark/blob/8187aee702fb5bb058281f9ac083f223308106f0/src/Api.php#L89-L130
kaliop-uk/kueueingbundle
Service/MessageConsumer/EventListener/StopwatchFilter.php
StopwatchFilter.onMessageReceived
public function onMessageReceived(MessageReceivedEvent $event) { if ($this->received === 0) { $this->started = microtime(true); } else if ($this->received === $this->count) { $time = microtime(true); $elapsed = $time - $this->started; printf("Time spent to receive {$this->count} messages: %.3f secs (%.3f m/s)\n", $elapsed, $this->count / $elapsed); $this->started = $time; $this->received = 0; } $this->received++; }
php
public function onMessageReceived(MessageReceivedEvent $event) { if ($this->received === 0) { $this->started = microtime(true); } else if ($this->received === $this->count) { $time = microtime(true); $elapsed = $time - $this->started; printf("Time spent to receive {$this->count} messages: %.3f secs (%.3f m/s)\n", $elapsed, $this->count / $elapsed); $this->started = $time; $this->received = 0; } $this->received++; }
[ "public", "function", "onMessageReceived", "(", "MessageReceivedEvent", "$", "event", ")", "{", "if", "(", "$", "this", "->", "received", "===", "0", ")", "{", "$", "this", "->", "started", "=", "microtime", "(", "true", ")", ";", "}", "else", "if", "(...
NB: we measure the time consumed for processing of N messages upon receiving the Nth+1 message. This because we only use the before-execution event. @param MessageReceivedEvent $event
[ "NB", ":", "we", "measure", "the", "time", "consumed", "for", "processing", "of", "N", "messages", "upon", "receiving", "the", "Nth", "+", "1", "message", ".", "This", "because", "we", "only", "use", "the", "before", "-", "execution", "event", "." ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/EventListener/StopwatchFilter.php#L35-L47
skrz/meta
gen-src/Google/Protobuf/Meta/OneofDescriptorProtoMeta.php
OneofDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new OneofDescriptorProto(); case 1: return new OneofDescriptorProto(func_get_arg(0)); case 2: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto(); case 1: return new OneofDescriptorProto(func_get_arg(0)); case 2: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new OneofDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new OneofDescriptorProto(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 OneofDescriptorProto(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 OneofDescriptorProto(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", "OneofDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "OneofDescriptorProto", "(", "func_get...
Creates new instance of \Google\Protobuf\OneofDescriptorProto @throws \InvalidArgumentException @return OneofDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "OneofDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/OneofDescriptorProtoMeta.php#L57-L81
yoanm/symfony-jsonrpc-http-server
src/Endpoint/JsonRpcHttpEndpoint.php
JsonRpcHttpEndpoint.httpPost
public function httpPost(Request $request) : Response { $response = new Response(); $response->headers->set('Content-Type', 'application/json'); $response->setContent( $this->sdkEndpoint->index( $request->getContent() ) ); return $response; }
php
public function httpPost(Request $request) : Response { $response = new Response(); $response->headers->set('Content-Type', 'application/json'); $response->setContent( $this->sdkEndpoint->index( $request->getContent() ) ); return $response; }
[ "public", "function", "httpPost", "(", "Request", "$", "request", ")", ":", "Response", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", ...
@param Request $request @return Response
[ "@param", "Request", "$request" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/Endpoint/JsonRpcHttpEndpoint.php#L52-L64
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.create
public function create($first_name, $last_name, $email, $active, $password) { $password = Hash::make($password); return User::create(compact('first_name', 'last_name', 'email', 'password', 'active')); }
php
public function create($first_name, $last_name, $email, $active, $password) { $password = Hash::make($password); return User::create(compact('first_name', 'last_name', 'email', 'password', 'active')); }
[ "public", "function", "create", "(", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ",", "$", "active", ",", "$", "password", ")", "{", "$", "password", "=", "Hash", "::", "make", "(", "$", "password", ")", ";", "return", "User", "::", ...
Create a user @param string $first_name @param string $last_name @param string $email @param int $active @param string $password @return Post
[ "Create", "a", "user" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L44-L49
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.update
public function update($id, $first_name, $last_name, $email, $active, $password = null) { $user = $this->find($id); // Not very clean if (trim($password) != '') { $password = Hash::make($password); } else { unset($password); } $user->fill(compact('first_name', 'last_name', 'email', 'password', 'active'))->save(); return $user; }
php
public function update($id, $first_name, $last_name, $email, $active, $password = null) { $user = $this->find($id); // Not very clean if (trim($password) != '') { $password = Hash::make($password); } else { unset($password); } $user->fill(compact('first_name', 'last_name', 'email', 'password', 'active'))->save(); return $user; }
[ "public", "function", "update", "(", "$", "id", ",", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ",", "$", "active", ",", "$", "password", "=", "null", ")", "{", "$", "user", "=", "$", "this", "->", "find", "(", "$", "id", ")", ...
Update a user @param int $id @param string $first_name @param string $last_name @param string $email @param int $active @param string $password @return Post
[ "Update", "a", "user" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L62-L79
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.validForCreation
public function validForCreation($first_name, $last_name, $email, $password) { return $this->validateUser($first_name, $last_name, $email, $password); }
php
public function validForCreation($first_name, $last_name, $email, $password) { return $this->validateUser($first_name, $last_name, $email, $password); }
[ "public", "function", "validForCreation", "(", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ",", "$", "password", ")", "{", "return", "$", "this", "->", "validateUser", "(", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ","...
Validate that the given user is valid for creation. @param string $first_name @param string $last_name @param string $email @param string $password @return \Illuminate\Support\MessageBag
[ "Validate", "that", "the", "given", "user", "is", "valid", "for", "creation", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L90-L93
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.validForUpdate
public function validForUpdate($id, $first_name, $last_name, $email, $password) { return $this->validateUser($first_name, $last_name, $email, $password, $id); }
php
public function validForUpdate($id, $first_name, $last_name, $email, $password) { return $this->validateUser($first_name, $last_name, $email, $password, $id); }
[ "public", "function", "validForUpdate", "(", "$", "id", ",", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ",", "$", "password", ")", "{", "return", "$", "this", "->", "validateUser", "(", "$", "first_name", ",", "$", "last_name", ",", "...
Validate that the given user is valid for updating. @param int $id @param string $first_name @param string $last_name @param string $email @param string $password @return \Illuminate\Support\MessageBag
[ "Validate", "that", "the", "given", "user", "is", "valid", "for", "updating", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L105-L108
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.validateUser
protected function validateUser($first_name, $last_name, $email, $password, $id = null) { $rules = array( 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'email' => 'required|email|unique:users,email', ); if ($id) { $rules['email'] .= ','.$id; } else { $rules['password'] = 'required|min:6'; } $validator = Validator::make( compact('first_name', 'last_name', 'email', 'password'), $rules ); $validator->passes(); return $validator->errors(); }
php
protected function validateUser($first_name, $last_name, $email, $password, $id = null) { $rules = array( 'first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'email' => 'required|email|unique:users,email', ); if ($id) { $rules['email'] .= ','.$id; } else { $rules['password'] = 'required|min:6'; } $validator = Validator::make( compact('first_name', 'last_name', 'email', 'password'), $rules ); $validator->passes(); return $validator->errors(); }
[ "protected", "function", "validateUser", "(", "$", "first_name", ",", "$", "last_name", ",", "$", "email", ",", "$", "password", ",", "$", "id", "=", "null", ")", "{", "$", "rules", "=", "array", "(", "'first_name'", "=>", "'required|max:255'", ",", "'la...
Validate the given user data. @param string $first_name @param stirng $last_name @param string $email @param string $password @param int $id @return \Illuminate\Support\MessageBag
[ "Validate", "the", "given", "user", "data", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L121-L145
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbUserRepository.php
DbUserRepository.login
public function login($email, $password, $remember = false) { $user = User::where('email', $email)->first(); if ($user and Hash::check($password, $user->password)) { $this->auth->login($user, $remember); return true; } return false; }
php
public function login($email, $password, $remember = false) { $user = User::where('email', $email)->first(); if ($user and Hash::check($password, $user->password)) { $this->auth->login($user, $remember); return true; } return false; }
[ "public", "function", "login", "(", "$", "email", ",", "$", "password", ",", "$", "remember", "=", "false", ")", "{", "$", "user", "=", "User", "::", "where", "(", "'email'", ",", "$", "email", ")", "->", "first", "(", ")", ";", "if", "(", "$", ...
Log the user into the application. If the credentials are invalid, returns false, else returns true. @param string $email @param stirng $password @param bool $remember @return bool
[ "Log", "the", "user", "into", "the", "application", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbUserRepository.php#L157-L169
matrozov/yii2-couchbase
src/Bucket.php
Bucket.batchInsert
public function batchInsert($rows) { $insertedIds = $this->db->batchInsert($this->name, $rows); foreach ($rows as $key => $row) { $rows[$key]['_id'] = $insertedIds[$key]; } return $rows; }
php
public function batchInsert($rows) { $insertedIds = $this->db->batchInsert($this->name, $rows); foreach ($rows as $key => $row) { $rows[$key]['_id'] = $insertedIds[$key]; } return $rows; }
[ "public", "function", "batchInsert", "(", "$", "rows", ")", "{", "$", "insertedIds", "=", "$", "this", "->", "db", "->", "batchInsert", "(", "$", "this", "->", "name", ",", "$", "rows", ")", ";", "foreach", "(", "$", "rows", "as", "$", "key", "=>",...
Inserts several new rows into bucket. @param array $rows array of arrays or objects to be inserted. @return string[] inserted data, each row will have "_id" key assigned to it. @throws Exception @throws \yii\base\InvalidConfigException
[ "Inserts", "several", "new", "rows", "into", "bucket", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L72-L81
matrozov/yii2-couchbase
src/Bucket.php
Bucket.update
public function update($columns, $condition, $params = []) { return $this->db->update($this->name, $columns, $condition, $params); }
php
public function update($columns, $condition, $params = []) { return $this->db->update($this->name, $columns, $condition, $params); }
[ "public", "function", "update", "(", "$", "columns", ",", "$", "condition", ",", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "name", ",", "$", "columns", ",", "$", "condition", ...
Updates the rows, which matches given criteria by given data. Note: for "multi" mode Couchbase requires explicit strategy "$set" or "$inc" to be specified for the "newData". If no strategy is passed "$set" will be used. @param array $columns the object with which to update the matching records. @param array $condition description of the objects to update. @param array $params list of options in format: optionName => optionValue. @return int|bool number of updated documents or whether operation was successful. @throws Exception @throws \yii\base\InvalidConfigException
[ "Updates", "the", "rows", "which", "matches", "given", "criteria", "by", "given", "data", ".", "Note", ":", "for", "multi", "mode", "Couchbase", "requires", "explicit", "strategy", "$set", "or", "$inc", "to", "be", "specified", "for", "the", "newData", ".", ...
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L96-L99
matrozov/yii2-couchbase
src/Bucket.php
Bucket.upsert
public function upsert($id, $data) { return $this->db->upsert($this->name, $id, $data); }
php
public function upsert($id, $data) { return $this->db->upsert($this->name, $id, $data); }
[ "public", "function", "upsert", "(", "$", "id", ",", "$", "data", ")", "{", "return", "$", "this", "->", "db", "->", "upsert", "(", "$", "this", "->", "name", ",", "$", "id", ",", "$", "data", ")", ";", "}" ]
Upsert record. @param string $id the document id. @param array $data the column data (name => value) to be inserted into the bucket or instance. @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Upsert", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L111-L114
matrozov/yii2-couchbase
src/Bucket.php
Bucket.save
public function save($data) { if (empty($data['_id'])) { return $this->insert($data); } $id = $data['_id']; unset($data['_id']); $bucketName = $this->db->quoteBucketName($this->name); $this->update($data, ["META($bucketName).id" => $id]); return $id; }
php
public function save($data) { if (empty($data['_id'])) { return $this->insert($data); } $id = $data['_id']; unset($data['_id']); $bucketName = $this->db->quoteBucketName($this->name); $this->update($data, ["META($bucketName).id" => $id]); return $id; }
[ "public", "function", "save", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", "[", "'_id'", "]", ")", ")", "{", "return", "$", "this", "->", "insert", "(", "$", "data", ")", ";", "}", "$", "id", "=", "$", "data", "[", "'_id'...
Update the existing database data, otherwise insert this data @param array|object $data data to be updated/inserted. @return int|null updated/new record id instance. @throws Exception @throws \yii\base\InvalidConfigException
[ "Update", "the", "existing", "database", "data", "otherwise", "insert", "this", "data" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L125-L140
matrozov/yii2-couchbase
src/Bucket.php
Bucket.delete
public function delete($condition = [], $options = []) { return $this->db->delete($this->name, $condition, $options); }
php
public function delete($condition = [], $options = []) { return $this->db->delete($this->name, $condition, $options); }
[ "public", "function", "delete", "(", "$", "condition", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "db", "->", "delete", "(", "$", "this", "->", "name", ",", "$", "condition", ",", "$", "options", ")"...
Delete data from the bucket. @param array $condition description of records to remove. @param array $options list of options in format: optionName => optionValue. @return int|bool number of updated documents or whether operation was successful. @throws Exception @throws \yii\base\InvalidConfigException
[ "Delete", "data", "from", "the", "bucket", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L152-L155
matrozov/yii2-couchbase
src/Bucket.php
Bucket.count
public function count($condition = [], $params = []) { return $this->db->count($this->name, $condition, $params); }
php
public function count($condition = [], $params = []) { return $this->db->count($this->name, $condition, $params); }
[ "public", "function", "count", "(", "$", "condition", "=", "[", "]", ",", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "db", "->", "count", "(", "$", "this", "->", "name", ",", "$", "condition", ",", "$", "params", ")", ...
Counts records in this bucket. @param array $condition query condition @param array $params list of options in format: optionName => optionValue. @return int records count. @throws Exception @throws \yii\base\InvalidConfigException
[ "Counts", "records", "in", "this", "bucket", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L167-L170
matrozov/yii2-couchbase
src/Bucket.php
Bucket.createPrimaryIndex
public function createPrimaryIndex($indexName = null, $options = []) { return $this->db->createPrimaryIndex($this->name, $indexName, $options); }
php
public function createPrimaryIndex($indexName = null, $options = []) { return $this->db->createPrimaryIndex($this->name, $indexName, $options); }
[ "public", "function", "createPrimaryIndex", "(", "$", "indexName", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "db", "->", "createPrimaryIndex", "(", "$", "this", "->", "name", ",", "$", "indexName", ",", "$"...
Create primary index. @param string|null $indexName name of primary index (optional) @param array $options @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Create", "primary", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L196-L199
matrozov/yii2-couchbase
src/Bucket.php
Bucket.createIndex
public function createIndex($indexName, $columns, $condition = null, &$params = [], $options = []) { return $this->db->createIndex($this->name, $indexName, $columns, $condition, $params, $options); }
php
public function createIndex($indexName, $columns, $condition = null, &$params = [], $options = []) { return $this->db->createIndex($this->name, $indexName, $columns, $condition, $params, $options); }
[ "public", "function", "createIndex", "(", "$", "indexName", ",", "$", "columns", ",", "$", "condition", "=", "null", ",", "&", "$", "params", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "db", "->", "c...
Creates index. @param string $indexName @param array $columns @param array|null $condition @param array $params @param array $options @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Creates", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Bucket.php#L226-L229
yoanm/symfony-jsonrpc-http-server
features/bootstrap/AbstractContext.php
AbstractContext.sendHttpContentTo
public function sendHttpContentTo(string $uri, string $httpMethod, string $content): Response { $kernel = $this->getDemoAppKernel(); $kernel->boot(); $request = Request::create($uri, $httpMethod, [], [], [], [], $content); $response = $kernel->handle($request); $kernel->terminate($request, $response); $kernel->shutdown(); return $response; }
php
public function sendHttpContentTo(string $uri, string $httpMethod, string $content): Response { $kernel = $this->getDemoAppKernel(); $kernel->boot(); $request = Request::create($uri, $httpMethod, [], [], [], [], $content); $response = $kernel->handle($request); $kernel->terminate($request, $response); $kernel->shutdown(); return $response; }
[ "public", "function", "sendHttpContentTo", "(", "string", "$", "uri", ",", "string", "$", "httpMethod", ",", "string", "$", "content", ")", ":", "Response", "{", "$", "kernel", "=", "$", "this", "->", "getDemoAppKernel", "(", ")", ";", "$", "kernel", "->...
@param string $uri @param string $httpMethod @param string $content @return Response @throws \Exception
[ "@param", "string", "$uri", "@param", "string", "$httpMethod", "@param", "string", "$content" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/features/bootstrap/AbstractContext.php#L35-L45
scherersoftware/cake-model-history
src/Model/Transform/ArrayTransform.php
ArrayTransform.display
public function display(string $fieldname, $value, string $model = null) { if (is_array($value)) { $return = ''; foreach ($value as $v) { if ($return == '') { $return .= $v; } else { $return .= ', ' . $v; } } $value = $return; } return $value; }
php
public function display(string $fieldname, $value, string $model = null) { if (is_array($value)) { $return = ''; foreach ($value as $v) { if ($return == '') { $return .= $v; } else { $return .= ', ' . $v; } } $value = $return; } return $value; }
[ "public", "function", "display", "(", "string", "$", "fieldname", ",", "$", "value", ",", "string", "$", "model", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "return", "=", "''", ";", "foreach", "(", "$", ...
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/ArrayTransform.php#L31-L46
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.updateAndGetCacheFileName
protected function updateAndGetCacheFileName($classFile) { $className = $this->className($classFile); if($this->hasChanged($classFile)){ $content = $this->processClass($classFile); $this->writeCache($className, $content); $this->setDateFromClassFile($classFile); } return $this->cacheFile($className); }
php
protected function updateAndGetCacheFileName($classFile) { $className = $this->className($classFile); if($this->hasChanged($classFile)){ $content = $this->processClass($classFile); $this->writeCache($className, $content); $this->setDateFromClassFile($classFile); } return $this->cacheFile($className); }
[ "protected", "function", "updateAndGetCacheFileName", "(", "$", "classFile", ")", "{", "$", "className", "=", "$", "this", "->", "className", "(", "$", "classFile", ")", ";", "if", "(", "$", "this", "->", "hasChanged", "(", "$", "classFile", ")", ")", "{...
Generates new file and return cachefile name @param $classFile @return string
[ "Generates", "new", "file", "and", "return", "cachefile", "name", "@param", "$classFile" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L101-L112
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.hasChanged
protected function hasChanged($classFile) { $className = $this->className($classFile); $cacheFile = $this->cacheFile($className); $cacheDate = file_exists($cacheFile) ? filemtime($cacheFile) : 0; $fileDate = filemtime($classFile); return ($fileDate != $cacheDate); }
php
protected function hasChanged($classFile) { $className = $this->className($classFile); $cacheFile = $this->cacheFile($className); $cacheDate = file_exists($cacheFile) ? filemtime($cacheFile) : 0; $fileDate = filemtime($classFile); return ($fileDate != $cacheDate); }
[ "protected", "function", "hasChanged", "(", "$", "classFile", ")", "{", "$", "className", "=", "$", "this", "->", "className", "(", "$", "classFile", ")", ";", "$", "cacheFile", "=", "$", "this", "->", "cacheFile", "(", "$", "className", ")", ";", "$",...
Indicates if the classfile has a diferent modify time that cache file @param $classFile @return bool
[ "Indicates", "if", "the", "classfile", "has", "a", "diferent", "modify", "time", "that", "cache", "file" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L145-L153
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.setDateFromClassFile
protected function setDateFromClassFile($classFile) { $className = $this->className($classFile); $cacheFile = $this->cacheFile($className); $fileDate = filemtime($classFile); touch($cacheFile, $fileDate); }
php
protected function setDateFromClassFile($classFile) { $className = $this->className($classFile); $cacheFile = $this->cacheFile($className); $fileDate = filemtime($classFile); touch($cacheFile, $fileDate); }
[ "protected", "function", "setDateFromClassFile", "(", "$", "classFile", ")", "{", "$", "className", "=", "$", "this", "->", "className", "(", "$", "classFile", ")", ";", "$", "cacheFile", "=", "$", "this", "->", "cacheFile", "(", "$", "className", ")", "...
Sets the modify time of cache file according to classfile @param $classFile
[ "Sets", "the", "modify", "time", "of", "cache", "file", "according", "to", "classfile" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L167-L173
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.className
protected function className($classFile) { $classFile = str_replace($this->rootDir, "", $classFile); $className = str_replace(array(".php", "/"), array("", "_"), $classFile); return $className; }
php
protected function className($classFile) { $classFile = str_replace($this->rootDir, "", $classFile); $className = str_replace(array(".php", "/"), array("", "_"), $classFile); return $className; }
[ "protected", "function", "className", "(", "$", "classFile", ")", "{", "$", "classFile", "=", "str_replace", "(", "$", "this", "->", "rootDir", ",", "\"\"", ",", "$", "classFile", ")", ";", "$", "className", "=", "str_replace", "(", "array", "(", "\".php...
Extracts the className through the classfile name @param $classFile @return mixed @throws \Exception
[ "Extracts", "the", "className", "through", "the", "classfile", "name" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L183-L189
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.processClass
protected function processClass($classFile) { $className = ''; $content = file_get_contents($classFile); $result = ''; preg_match_all('/class\s+(\w*)\s*(extends\s+)?([^{])*/s', $content, $mclass, PREG_SET_ORDER); $className = $mclass[0][1]; if (!$className){ throw new \Exception(sprintf('class not found in %s', $classFile)); } preg_match_all('|(/\*\*[^{]*?{)|', $content, $match, PREG_PATTERN_ORDER); foreach ($match[0] as $k => $m) { $function = '?'; $comments = ''; if (!substr_count($m, 'class')) { $function = substr_count($m, 'function') ? 'yes' : 'no'; if ($function == 'yes') { preg_match_all('/(\/\*\*.*\*\/)/s', $m, $mc, PREG_PATTERN_ORDER); $comments = nl2br($mc[0][0]); preg_match_all('/\*\/\s+(public\s+)?(static\s+)?function\s+([^\(]*)\(/s', $m, $mf, PREG_SET_ORDER); $functionName = $mf[0][3]; preg_match_all("/\*\s+@Route\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $route = $params[0][1]; preg_match_all("/\*\s+@Method\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $method = isset($params[0][1]) ? strtoupper($params[0][1]) : 'GET'; preg_match_all("/\*\s+@Name\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $name = strtolower($params[0][1]); if ($className != "" && $functionName != "" ) { $result .= sprintf( '$app->map("%s", "%s::___%s")->via("%s")->name("%s");' . PHP_EOL, $route, $className, $functionName, str_replace(',','","',$method), $name ); } } } } return $result; }
php
protected function processClass($classFile) { $className = ''; $content = file_get_contents($classFile); $result = ''; preg_match_all('/class\s+(\w*)\s*(extends\s+)?([^{])*/s', $content, $mclass, PREG_SET_ORDER); $className = $mclass[0][1]; if (!$className){ throw new \Exception(sprintf('class not found in %s', $classFile)); } preg_match_all('|(/\*\*[^{]*?{)|', $content, $match, PREG_PATTERN_ORDER); foreach ($match[0] as $k => $m) { $function = '?'; $comments = ''; if (!substr_count($m, 'class')) { $function = substr_count($m, 'function') ? 'yes' : 'no'; if ($function == 'yes') { preg_match_all('/(\/\*\*.*\*\/)/s', $m, $mc, PREG_PATTERN_ORDER); $comments = nl2br($mc[0][0]); preg_match_all('/\*\/\s+(public\s+)?(static\s+)?function\s+([^\(]*)\(/s', $m, $mf, PREG_SET_ORDER); $functionName = $mf[0][3]; preg_match_all("/\*\s+@Route\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $route = $params[0][1]; preg_match_all("/\*\s+@Method\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $method = isset($params[0][1]) ? strtoupper($params[0][1]) : 'GET'; preg_match_all("/\*\s+@Name\s*\('([^']*)'\)/s", $comments, $params, PREG_SET_ORDER); $name = strtolower($params[0][1]); if ($className != "" && $functionName != "" ) { $result .= sprintf( '$app->map("%s", "%s::___%s")->via("%s")->name("%s");' . PHP_EOL, $route, $className, $functionName, str_replace(',','","',$method), $name ); } } } } return $result; }
[ "protected", "function", "processClass", "(", "$", "classFile", ")", "{", "$", "className", "=", "''", ";", "$", "content", "=", "file_get_contents", "(", "$", "classFile", ")", ";", "$", "result", "=", "''", ";", "preg_match_all", "(", "'/class\\s+(\\w*)\\s...
@param $classFile @return string @throws \Exception
[ "@param", "$classFile" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L197-L239
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.readdir
protected static function readdir($dir) { $entries = array(); foreach (scandir($dir) as $entry) { if(($entry != '.') && ($entry != '..')){ $current = "$dir/$entry"; if($current != $dir){ if(is_dir($current)){ $aux = self::readdir($current); $entries = array_merge($entries, $aux); }else{ if(preg_match("/\w*?Controller.php/", $entry)){ $entries[] = $current; } } } } } return $entries; }
php
protected static function readdir($dir) { $entries = array(); foreach (scandir($dir) as $entry) { if(($entry != '.') && ($entry != '..')){ $current = "$dir/$entry"; if($current != $dir){ if(is_dir($current)){ $aux = self::readdir($current); $entries = array_merge($entries, $aux); }else{ if(preg_match("/\w*?Controller.php/", $entry)){ $entries[] = $current; } } } } } return $entries; }
[ "protected", "static", "function", "readdir", "(", "$", "dir", ")", "{", "$", "entries", "=", "array", "(", ")", ";", "foreach", "(", "scandir", "(", "$", "dir", ")", "as", "$", "entry", ")", "{", "if", "(", "(", "$", "entry", "!=", "'.'", ")", ...
Reads the contents of this dir and returns only dirs that have first letter capitalized @return array
[ "Reads", "the", "contents", "of", "this", "dir", "and", "returns", "only", "dirs", "that", "have", "first", "letter", "capitalized" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L264-L284
yeephp/yeephp
Yee/Managers/RoutingCacheManager.php
RoutingCacheManager.loadPath
protected function loadPath($path) { $controllers = self::readdir($path); if(count($controllers)){ foreach($controllers as $controller){ $this->loadRoute($controller); } } }
php
protected function loadPath($path) { $controllers = self::readdir($path); if(count($controllers)){ foreach($controllers as $controller){ $this->loadRoute($controller); } } }
[ "protected", "function", "loadPath", "(", "$", "path", ")", "{", "$", "controllers", "=", "self", "::", "readdir", "(", "$", "path", ")", ";", "if", "(", "count", "(", "$", "controllers", ")", ")", "{", "foreach", "(", "$", "controllers", "as", "$", ...
Load all Controller classes in an entire path @param $path
[ "Load", "all", "Controller", "classes", "in", "an", "entire", "path" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Managers/RoutingCacheManager.php#L291-L299
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
ClassWithNoPropertyMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ClassWithNoProperty(); case 1: return new ClassWithNoProperty(func_get_arg(0)); case 2: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty(); case 1: return new ClassWithNoProperty(func_get_arg(0)); case 2: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithNoProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithNoProperty(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 ClassWithNoProperty(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 ClassWithNoProperty(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", "ClassWithNoProperty", "(", ")", ";", "case", "1", ":", "return", "new", "ClassWithNoProperty", "(", "func_get_a...
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty @throws \InvalidArgumentException @return ClassWithNoProperty
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithNoProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L64-L88
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
ClassWithNoPropertyMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } 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 (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 \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithNoProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L118-L131
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
ClassWithNoPropertyMeta.toArray
public static function toArray($object, $group = NULL, $filter = NULL) { if ($object === null) { return null; } if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.'); } else { $id = self::$groups[$group]; } if (!($object instanceof ClassWithNoProperty)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.'); } if (Stack::$objects === null) { Stack::$objects = new \SplObjectStorage(); } if (Stack::$objects->contains($object)) { return null; } Stack::$objects->attach($object); try { $output = array(); } catch (\Exception $e) { Stack::$objects->detach($object); throw $e; } Stack::$objects->detach($object); return $output; }
php
public static function toArray($object, $group = NULL, $filter = NULL) { if ($object === null) { return null; } if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.'); } else { $id = self::$groups[$group]; } if (!($object instanceof ClassWithNoProperty)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.'); } if (Stack::$objects === null) { Stack::$objects = new \SplObjectStorage(); } if (Stack::$objects->contains($object)) { return null; } Stack::$objects->attach($object); try { $output = array(); } catch (\Exception $e) { Stack::$objects->detach($object); throw $e; } Stack::$objects->detach($object); return $output; }
[ "public", "static", "function", "toArray", "(", "$", "object", ",", "$", "group", "=", "NULL", ",", "$", "filter", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "isset", "(",...
Serializes \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty to array @param ClassWithNoProperty $object @param string $group @param array $filter @throws \Exception @return array
[ "Serializes", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithNoProperty", "to", "array" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L174-L209
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
ClassWithNoPropertyMeta.fromObject
public static function fromObject($input, $group = NULL, $object = NULL) { $input = (array)$input; if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.'); } else { $id = self::$groups[$group]; } if ($object === null) { $object = new ClassWithNoProperty(); } elseif (!($object instanceof ClassWithNoProperty)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.'); } return $object; }
php
public static function fromObject($input, $group = NULL, $object = NULL) { $input = (array)$input; if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.'); } else { $id = self::$groups[$group]; } if ($object === null) { $object = new ClassWithNoProperty(); } elseif (!($object instanceof ClassWithNoProperty)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.'); } return $object; }
[ "public", "static", "function", "fromObject", "(", "$", "input", ",", "$", "group", "=", "NULL", ",", "$", "object", "=", "NULL", ")", "{", "$", "input", "=", "(", "array", ")", "$", "input", ";", "if", "(", "!", "isset", "(", "self", "::", "$", ...
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty object from object @param object $input @param string $group @param ClassWithNoProperty $object @throws \Exception @return ClassWithNoProperty
[ "Creates", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithNoProperty", "object", "from", "object" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L223-L240
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php
ClassWithNoPropertyMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new ClassWithNoProperty(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { 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 ClassWithNoProperty(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { 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 \Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty object from serialized Protocol Buffers message. @param string $input @param ClassWithNoProperty $object @param int $start @param int $end @throws \Exception @return ClassWithNoProperty
[ "Creates", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithNoProperty", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithNoPropertyMeta.php#L304-L340
kaliop-uk/kueueingbundle
Adapter/RabbitMq/Producer.php
Producer.queueDeclare
protected function queueDeclare() { if (null !== $this->queueOptions['name']) { list($queueName, $msgCount, $consumerCount) = $this->getChannel()->queue_declare($this->queueOptions['name'], $this->queueOptions['passive'], $this->queueOptions['durable'], $this->queueOptions['exclusive'], $this->queueOptions['auto_delete'], $this->queueOptions['nowait'], $this->queueOptions['arguments'], $this->queueOptions['ticket']); if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) { foreach ($this->queueOptions['routing_keys'] as $routingKey) { $this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $routingKey); } } else { $this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $this->routingKey); } $this->queueStats = array( 'message_count' => $msgCount, 'consumer_count' => $consumerCount ); $this->queueDeclared = true; } }
php
protected function queueDeclare() { if (null !== $this->queueOptions['name']) { list($queueName, $msgCount, $consumerCount) = $this->getChannel()->queue_declare($this->queueOptions['name'], $this->queueOptions['passive'], $this->queueOptions['durable'], $this->queueOptions['exclusive'], $this->queueOptions['auto_delete'], $this->queueOptions['nowait'], $this->queueOptions['arguments'], $this->queueOptions['ticket']); if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) { foreach ($this->queueOptions['routing_keys'] as $routingKey) { $this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $routingKey); } } else { $this->getChannel()->queue_bind($queueName, $this->exchangeOptions['name'], $this->routingKey); } $this->queueStats = array( 'message_count' => $msgCount, 'consumer_count' => $consumerCount ); $this->queueDeclared = true; } }
[ "protected", "function", "queueDeclare", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "queueOptions", "[", "'name'", "]", ")", "{", "list", "(", "$", "queueName", ",", "$", "msgCount", ",", "$", "consumerCount", ")", "=", "$", "this", ...
Reimplement the code from BaseAmqp, to save queue stats when we can
[ "Reimplement", "the", "code", "from", "BaseAmqp", "to", "save", "queue", "stats", "when", "we", "can" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Producer.php#L73-L95
yarcode/yii2-email-manager
src/transports/YiiMailer.php
YiiMailer.parseFrom
protected function parseFrom($from) { $parts = explode(' ', $from); if (count($parts) == 1) { return $from; } $email = array_pop($parts); $email = trim($email, '<>'); $name = implode(' ', $parts); return [$email => $name]; }
php
protected function parseFrom($from) { $parts = explode(' ', $from); if (count($parts) == 1) { return $from; } $email = array_pop($parts); $email = trim($email, '<>'); $name = implode(' ', $parts); return [$email => $name]; }
[ "protected", "function", "parseFrom", "(", "$", "from", ")", "{", "$", "parts", "=", "explode", "(", "' '", ",", "$", "from", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "1", ")", "{", "return", "$", "from", ";", "}", "$", "emai...
Quick workaround for sender email @param $from @return string|array
[ "Quick", "workaround", "for", "sender", "email" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/transports/YiiMailer.php#L51-L63
skrz/meta
src/Skrz/Meta/Fields/Fields.php
Fields.fromArray
public static function fromArray($input = []) { $fields = ScalarFields::getInstance(); foreach ($input as $k => $v) { if (is_array($v)) { $fields = $fields->appendFields($k, self::fromArray($v)); } elseif (!!$v) { $fields = $fields->appendField($k); } } return $fields; }
php
public static function fromArray($input = []) { $fields = ScalarFields::getInstance(); foreach ($input as $k => $v) { if (is_array($v)) { $fields = $fields->appendFields($k, self::fromArray($v)); } elseif (!!$v) { $fields = $fields->appendField($k); } } return $fields; }
[ "public", "static", "function", "fromArray", "(", "$", "input", "=", "[", "]", ")", "{", "$", "fields", "=", "ScalarFields", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "input", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "i...
Convert given array into fields. @param array $input @return FieldsBuilderInterface
[ "Convert", "given", "array", "into", "fields", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L28-L41
skrz/meta
src/Skrz/Meta/Fields/Fields.php
Fields.fromString
public static function fromString($input, $start = 0, $end = null) { return self::appendFromString(self::builder(), $input, $start, $end); }
php
public static function fromString($input, $start = 0, $end = null) { return self::appendFromString(self::builder(), $input, $start, $end); }
[ "public", "static", "function", "fromString", "(", "$", "input", ",", "$", "start", "=", "0", ",", "$", "end", "=", "null", ")", "{", "return", "self", "::", "appendFromString", "(", "self", "::", "builder", "(", ")", ",", "$", "input", ",", "$", "...
Parse string into fields. @param $input @param int $start @param null $end @return FieldsBuilderInterface
[ "Parse", "string", "into", "fields", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L51-L54
skrz/meta
src/Skrz/Meta/Fields/Fields.php
Fields.appendFromString
public static function appendFromString(FieldsBuilderInterface $builder, $input, $start = 0, $end = null) { if ($end === null) { $end = strlen($input); } while ($start < $end) { $start = self::ltrim($input, $start, $end); if ($start >= $end) { return $builder; } $p = self::pos($input, $start, $end, ".{,"); if ($p === $end) { $p = self::rtrim($input, $start, $p); $builder = $builder->appendField(substr($input, $start, $p - $start)); $start = $end; } else { $fieldName = substr($input, $start, self::rtrim($input, $start, $p) - $start); switch ($input[$p]) { case ".": for ($q = self::pos($input, $p, $end, "{,"); $q < $end && $input[$q] === "{"; ++$q) { $q = self::findBalancedRightBrace($input, $q, $end); } $builder = $builder->appendFields( $fieldName, self::appendFromString($builder->builder($fieldName), $input, $p + 1, $q) ); $start = $q + 1; break; case "{": $balancedRightBrace = self::findBalancedRightBrace($input, $p, $end); if ($balancedRightBrace + 1 < $end && $input[$balancedRightBrace + 1] !== ",") { throw new \InvalidArgumentException( "Invalid fields string '{$input}' - expected ',' at position " . ($balancedRightBrace + 1) . "." ); } $builder = $builder->appendFields( $fieldName, self::appendFromString($builder->builder($fieldName), $input, $p + 1, $balancedRightBrace) ); $start = $balancedRightBrace + 2; break; case ",": $builder = $builder->appendField($fieldName); $start = $p + 1; break; default: throw new \LogicException("Unhandled char '{$input[$p]}'."); } } } return $builder; }
php
public static function appendFromString(FieldsBuilderInterface $builder, $input, $start = 0, $end = null) { if ($end === null) { $end = strlen($input); } while ($start < $end) { $start = self::ltrim($input, $start, $end); if ($start >= $end) { return $builder; } $p = self::pos($input, $start, $end, ".{,"); if ($p === $end) { $p = self::rtrim($input, $start, $p); $builder = $builder->appendField(substr($input, $start, $p - $start)); $start = $end; } else { $fieldName = substr($input, $start, self::rtrim($input, $start, $p) - $start); switch ($input[$p]) { case ".": for ($q = self::pos($input, $p, $end, "{,"); $q < $end && $input[$q] === "{"; ++$q) { $q = self::findBalancedRightBrace($input, $q, $end); } $builder = $builder->appendFields( $fieldName, self::appendFromString($builder->builder($fieldName), $input, $p + 1, $q) ); $start = $q + 1; break; case "{": $balancedRightBrace = self::findBalancedRightBrace($input, $p, $end); if ($balancedRightBrace + 1 < $end && $input[$balancedRightBrace + 1] !== ",") { throw new \InvalidArgumentException( "Invalid fields string '{$input}' - expected ',' at position " . ($balancedRightBrace + 1) . "." ); } $builder = $builder->appendFields( $fieldName, self::appendFromString($builder->builder($fieldName), $input, $p + 1, $balancedRightBrace) ); $start = $balancedRightBrace + 2; break; case ",": $builder = $builder->appendField($fieldName); $start = $p + 1; break; default: throw new \LogicException("Unhandled char '{$input[$p]}'."); } } } return $builder; }
[ "public", "static", "function", "appendFromString", "(", "FieldsBuilderInterface", "$", "builder", ",", "$", "input", ",", "$", "start", "=", "0", ",", "$", "end", "=", "null", ")", "{", "if", "(", "$", "end", "===", "null", ")", "{", "$", "end", "="...
Add fields from given string to existing field set. @param FieldsBuilderInterface $builder @param string $input @param int $start @param int $end @return FieldsBuilderInterface
[ "Add", "fields", "from", "given", "string", "to", "existing", "field", "set", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/src/Skrz/Meta/Fields/Fields.php#L65-L128
amphp/http-server-session
src/SessionMiddleware.php
SessionMiddleware.handleRequest
public function handleRequest(Request $request, RequestHandler $responder): Promise { return call(function () use ($request, $responder) { $cookie = $request->getCookie($this->cookieName); $originalId = $cookie ? $cookie->getValue() : null; $session = new Session($this->storage, $originalId); $request->setAttribute($this->requestAttribute, $session); try { $response = yield $responder->handleRequest($request); } finally { if ($session->isLocked()) { $session->unlock(); } } if (!$response instanceof Response) { throw new \TypeError("Request handler must resolve to an instance of " . Response::class); } $id = $session->getId(); if ($id === null || !$session->isRead()) { return $response; } if ($session->isEmpty()) { $attributes = $this->cookieAttributes->withExpiry( new \DateTimeImmutable("@0", new \DateTimeZone("UTC")) ); $response->setCookie(new ResponseCookie($this->cookieName, '', $attributes)); return $response; } if ($cookie === null || $cookie->getValue() !== $id) { $response->setCookie(new ResponseCookie($this->cookieName, $id, $this->cookieAttributes)); } $cacheControl = $response->getHeaderArray("cache-control"); if (empty($cacheControl)) { $response->setHeader("cache-control", "private"); } else { foreach ($cacheControl as $key => $value) { $tokens = \array_map("trim", \explode(",", $value)); $tokens = \array_filter($tokens, function ($token) { return $token !== "public"; }); if (!\in_array("private", $tokens, true)) { $tokens[] = "private"; } $cacheControl[$key] = \implode(",", $tokens); } $response->setHeader("cache-control", $cacheControl); } return $response; }); }
php
public function handleRequest(Request $request, RequestHandler $responder): Promise { return call(function () use ($request, $responder) { $cookie = $request->getCookie($this->cookieName); $originalId = $cookie ? $cookie->getValue() : null; $session = new Session($this->storage, $originalId); $request->setAttribute($this->requestAttribute, $session); try { $response = yield $responder->handleRequest($request); } finally { if ($session->isLocked()) { $session->unlock(); } } if (!$response instanceof Response) { throw new \TypeError("Request handler must resolve to an instance of " . Response::class); } $id = $session->getId(); if ($id === null || !$session->isRead()) { return $response; } if ($session->isEmpty()) { $attributes = $this->cookieAttributes->withExpiry( new \DateTimeImmutable("@0", new \DateTimeZone("UTC")) ); $response->setCookie(new ResponseCookie($this->cookieName, '', $attributes)); return $response; } if ($cookie === null || $cookie->getValue() !== $id) { $response->setCookie(new ResponseCookie($this->cookieName, $id, $this->cookieAttributes)); } $cacheControl = $response->getHeaderArray("cache-control"); if (empty($cacheControl)) { $response->setHeader("cache-control", "private"); } else { foreach ($cacheControl as $key => $value) { $tokens = \array_map("trim", \explode(",", $value)); $tokens = \array_filter($tokens, function ($token) { return $token !== "public"; }); if (!\in_array("private", $tokens, true)) { $tokens[] = "private"; } $cacheControl[$key] = \implode(",", $tokens); } $response->setHeader("cache-control", $cacheControl); } return $response; }); }
[ "public", "function", "handleRequest", "(", "Request", "$", "request", ",", "RequestHandler", "$", "responder", ")", ":", "Promise", "{", "return", "call", "(", "function", "(", ")", "use", "(", "$", "request", ",", "$", "responder", ")", "{", "$", "cook...
@param Request $request @param RequestHandler $responder Request responder. @return Promise<\Amp\Http\Server\Response>
[ "@param", "Request", "$request", "@param", "RequestHandler", "$responder", "Request", "responder", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/SessionMiddleware.php#L54-L119
skrz/meta
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
MethodDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new MethodDescriptorProto(); case 1: return new MethodDescriptorProto(func_get_arg(0)); case 2: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto(); case 1: return new MethodDescriptorProto(func_get_arg(0)); case 2: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MethodDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MethodDescriptorProto(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 MethodDescriptorProto(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 MethodDescriptorProto(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", "MethodDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "MethodDescriptorProto", "(", "func_g...
Creates new instance of \Google\Protobuf\MethodDescriptorProto @throws \InvalidArgumentException @return MethodDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "MethodDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L62-L86
skrz/meta
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
MethodDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof MethodDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodDescriptorProto.'); } $object->name = NULL; $object->inputType = NULL; $object->outputType = NULL; $object->options = NULL; $object->clientStreaming = NULL; $object->serverStreaming = NULL; }
php
public static function reset($object) { if (!($object instanceof MethodDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodDescriptorProto.'); } $object->name = NULL; $object->inputType = NULL; $object->outputType = NULL; $object->options = NULL; $object->clientStreaming = NULL; $object->serverStreaming = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "MethodDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobu...
Resets properties of \Google\Protobuf\MethodDescriptorProto to default values @param MethodDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "MethodDescriptorProto", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L99-L110
skrz/meta
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
MethodDescriptorProtoMeta.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->inputType)) { hash_update($ctx, 'inputType'); hash_update($ctx, (string)$object->inputType); } if (isset($object->outputType)) { hash_update($ctx, 'outputType'); hash_update($ctx, (string)$object->outputType); } if (isset($object->options)) { hash_update($ctx, 'options'); MethodOptionsMeta::hash($object->options, $ctx); } if (isset($object->clientStreaming)) { hash_update($ctx, 'clientStreaming'); hash_update($ctx, (string)$object->clientStreaming); } if (isset($object->serverStreaming)) { hash_update($ctx, 'serverStreaming'); hash_update($ctx, (string)$object->serverStreaming); } 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->inputType)) { hash_update($ctx, 'inputType'); hash_update($ctx, (string)$object->inputType); } if (isset($object->outputType)) { hash_update($ctx, 'outputType'); hash_update($ctx, (string)$object->outputType); } if (isset($object->options)) { hash_update($ctx, 'options'); MethodOptionsMeta::hash($object->options, $ctx); } if (isset($object->clientStreaming)) { hash_update($ctx, 'clientStreaming'); hash_update($ctx, (string)$object->clientStreaming); } if (isset($object->serverStreaming)) { hash_update($ctx, 'serverStreaming'); hash_update($ctx, (string)$object->serverStreaming); } 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\MethodDescriptorProto @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "MethodDescriptorProto" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L122-L165
skrz/meta
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
MethodDescriptorProtoMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new MethodDescriptorProto(); } 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 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->inputType = substr($input, $start, $length); $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->outputType = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: 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 = MethodOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->clientStreaming = (bool)Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->serverStreaming = (bool)Binary::decodeVarint($input, $start); 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 MethodDescriptorProto(); } 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 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->inputType = substr($input, $start, $length); $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->outputType = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: 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 = MethodOptionsMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->clientStreaming = (bool)Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->serverStreaming = (bool)Binary::decodeVarint($input, $start); 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\MethodDescriptorProto object from serialized Protocol Buffers message. @param string $input @param MethodDescriptorProto $object @param int $start @param int $end @throws \Exception @return MethodDescriptorProto
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "MethodDescriptorProto", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L180-L287
skrz/meta
gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php
MethodDescriptorProtoMeta.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->inputType) && ($filter === null || isset($filter['inputType']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->inputType)); $output .= $object->inputType; } if (isset($object->outputType) && ($filter === null || isset($filter['outputType']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->outputType)); $output .= $object->outputType; } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x22"; $buffer = MethodOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->clientStreaming) && ($filter === null || isset($filter['clientStreaming']))) { $output .= "\x28"; $output .= Binary::encodeVarint((int)$object->clientStreaming); } if (isset($object->serverStreaming) && ($filter === null || isset($filter['serverStreaming']))) { $output .= "\x30"; $output .= Binary::encodeVarint((int)$object->serverStreaming); } 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->inputType) && ($filter === null || isset($filter['inputType']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->inputType)); $output .= $object->inputType; } if (isset($object->outputType) && ($filter === null || isset($filter['outputType']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->outputType)); $output .= $object->outputType; } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x22"; $buffer = MethodOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } if (isset($object->clientStreaming) && ($filter === null || isset($filter['clientStreaming']))) { $output .= "\x28"; $output .= Binary::encodeVarint((int)$object->clientStreaming); } if (isset($object->serverStreaming) && ($filter === null || isset($filter['serverStreaming']))) { $output .= "\x30"; $output .= Binary::encodeVarint((int)$object->serverStreaming); } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\MethodDescriptorProto to Protocol Buffers message. @param MethodDescriptorProto $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "MethodDescriptorProto", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodDescriptorProtoMeta.php#L300-L340
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
FileDescriptorSetMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FileDescriptorSet(); case 1: return new FileDescriptorSet(func_get_arg(0)); case 2: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet(); case 1: return new FileDescriptorSet(func_get_arg(0)); case 2: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorSet(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorSet(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 FileDescriptorSet(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 FileDescriptorSet(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", "FileDescriptorSet", "(", ")", ";", "case", "1", ":", "return", "new", "FileDescriptorSet", "(", "func_get_arg",...
Creates new instance of \Google\Protobuf\FileDescriptorSet @throws \InvalidArgumentException @return FileDescriptorSet
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorSet" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L57-L81
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
FileDescriptorSetMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FileDescriptorSet(); } 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); } if (!(isset($object->file) && is_array($object->file))) { $object->file = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->file[] = FileDescriptorProtoMeta::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 FileDescriptorSet(); } 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); } if (!(isset($object->file) && is_array($object->file))) { $object->file = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->file[] = FileDescriptorProtoMeta::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\FileDescriptorSet object from serialized Protocol Buffers message. @param string $input @param FileDescriptorSet $object @param int $start @param int $end @throws \Exception @return FileDescriptorSet
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorSet", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L147-L200
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php
FileDescriptorSetMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->file) && ($filter === null || isset($filter['file']))) { foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) { $output .= "\x0a"; $buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['file']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->file) && ($filter === null || isset($filter['file']))) { foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) { $output .= "\x0a"; $buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['file']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "file", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\FileDescriptorSet to Protocol Buffers message. @param FileDescriptorSet $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorSet", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorSetMeta.php#L213-L227
skrz/meta
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
ServiceOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ServiceOptions(); case 1: return new ServiceOptions(func_get_arg(0)); case 2: return new ServiceOptions(func_get_arg(0), func_get_arg(1)); case 3: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ServiceOptions(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 ServiceOptions(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 ServiceOptions(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 ServiceOptions(); case 1: return new ServiceOptions(func_get_arg(0)); case 2: return new ServiceOptions(func_get_arg(0), func_get_arg(1)); case 3: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ServiceOptions(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 ServiceOptions(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 ServiceOptions(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", "ServiceOptions", "(", ")", ";", "case", "1", ":", "return", "new", "ServiceOptions", "(", "func_get_arg", "("...
Creates new instance of \Google\Protobuf\ServiceOptions @throws \InvalidArgumentException @return ServiceOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "ServiceOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
ServiceOptionsMeta.reset
public static function reset($object) { if (!($object instanceof ServiceOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof ServiceOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "ServiceOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Serv...
Resets properties of \Google\Protobuf\ServiceOptions to default values @param ServiceOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "ServiceOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L95-L102
skrz/meta
gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php
ServiceOptionsMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } 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->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } 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\ServiceOptions @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "ServiceOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceOptionsMeta.php#L114-L139
scherersoftware/cake-model-history
src/Model/Transform/HashTransform.php
HashTransform.display
public function display(string $fieldname, $value, string $model = null) { $return = ''; foreach ($value as $k => $v) { $return .= $k . ': ' . $v . '</br>'; } return $return; }
php
public function display(string $fieldname, $value, string $model = null) { $return = ''; foreach ($value as $k => $v) { $return .= $k . ': ' . $v . '</br>'; } return $return; }
[ "public", "function", "display", "(", "string", "$", "fieldname", ",", "$", "value", ",", "string", "$", "model", "=", "null", ")", "{", "$", "return", "=", "''", ";", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", ...
Amend the data before displaying. @param string $fieldname Field name @param mixed $value Value to be amended @param string $model Optional model to be used @return mixed
[ "Amend", "the", "data", "before", "displaying", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Transform/HashTransform.php#L31-L39
louvian/pururin-crawler
src/Pururin/Crawlers/Cover.php
Cover.action
public function action() { $ch = new Curl($this->ins->url); $ch->setOpt( [ CURLOPT_FOLLOWLOCATION => true ] ); $out = $ch->exec(); if ($ch->errno()) { throw new PururinException($ch->error(), 1); } $this->raw = $out; return true; }
php
public function action() { $ch = new Curl($this->ins->url); $ch->setOpt( [ CURLOPT_FOLLOWLOCATION => true ] ); $out = $ch->exec(); if ($ch->errno()) { throw new PururinException($ch->error(), 1); } $this->raw = $out; return true; }
[ "public", "function", "action", "(", ")", "{", "$", "ch", "=", "new", "Curl", "(", "$", "this", "->", "ins", "->", "url", ")", ";", "$", "ch", "->", "setOpt", "(", "[", "CURLOPT_FOLLOWLOCATION", "=>", "true", "]", ")", ";", "$", "out", "=", "$", ...
Action. @throws \Pururin\Exceptions\PururinException @return bool
[ "Action", "." ]
train
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/Crawlers/Cover.php#L37-L51
louvian/pururin-crawler
src/Pururin/Crawlers/Cover.php
Cover.build
public function build() { $a = explode("<span class=\"info\">", $this->raw, 2); if (isset($a[1])) { /** * Get title. */ $b = explode("<div class=\"title\">", $a[1], 2); $b = explode("</div>", $b[1], 2); $this->info['title'] = static::e($b[0]); /** * Table adaptation. */ $a = explode("<tbody>", $a[1], 2); $a = explode("</tbody>", $a[1], 2); /** * Build info. */ $b = explode("<tr", $a[0]); unset($b[0]); if (count($b) > 1) { foreach ($b as $val) { $c = explode("<td>", $val, 2); if (isset($c[1])) { $c = explode("</td>", $c[1], 2); $d = explode("<ul class=\"list-inline gallery-info-list\">", $c[1], 2); if (! isset($d[1])) { $d = explode("<td>", $c[1], 2); $d = explode("</td>", $d[1], 2); $c[0] = static::e($c[0]); $this->info[$c[0]] = $c[0] === "Pages" ? (int) $d[0] : static::e(strip_tags($d[0])); } else { $d = explode("</ul>", $d[1], 2); $d = explode("<li", $d[0]); unset($d[0]); foreach ($d as $vax) { $vax = explode("<a href=\"", $vax); $vax = explode(">", $vax[1], 2); $vax = explode("<", $vax[1], 2); $this->info[static::e($c[0])][] = static::e($vax[0]); } } } } } else { throw new PururinException("Error Building Cover Info", 1); } } $ch = new Curl("http://pururin.us/assets/images/data/".$this->ins->id."/cover.jpg"); $ch->setOpt( [ CURLOPT_FOLLOWLOCATION => true, CURLOPT_REFERER => $this->ins->url ] ); $this->binary = $ch->exec(); return true; }
php
public function build() { $a = explode("<span class=\"info\">", $this->raw, 2); if (isset($a[1])) { /** * Get title. */ $b = explode("<div class=\"title\">", $a[1], 2); $b = explode("</div>", $b[1], 2); $this->info['title'] = static::e($b[0]); /** * Table adaptation. */ $a = explode("<tbody>", $a[1], 2); $a = explode("</tbody>", $a[1], 2); /** * Build info. */ $b = explode("<tr", $a[0]); unset($b[0]); if (count($b) > 1) { foreach ($b as $val) { $c = explode("<td>", $val, 2); if (isset($c[1])) { $c = explode("</td>", $c[1], 2); $d = explode("<ul class=\"list-inline gallery-info-list\">", $c[1], 2); if (! isset($d[1])) { $d = explode("<td>", $c[1], 2); $d = explode("</td>", $d[1], 2); $c[0] = static::e($c[0]); $this->info[$c[0]] = $c[0] === "Pages" ? (int) $d[0] : static::e(strip_tags($d[0])); } else { $d = explode("</ul>", $d[1], 2); $d = explode("<li", $d[0]); unset($d[0]); foreach ($d as $vax) { $vax = explode("<a href=\"", $vax); $vax = explode(">", $vax[1], 2); $vax = explode("<", $vax[1], 2); $this->info[static::e($c[0])][] = static::e($vax[0]); } } } } } else { throw new PururinException("Error Building Cover Info", 1); } } $ch = new Curl("http://pururin.us/assets/images/data/".$this->ins->id."/cover.jpg"); $ch->setOpt( [ CURLOPT_FOLLOWLOCATION => true, CURLOPT_REFERER => $this->ins->url ] ); $this->binary = $ch->exec(); return true; }
[ "public", "function", "build", "(", ")", "{", "$", "a", "=", "explode", "(", "\"<span class=\\\"info\\\">\"", ",", "$", "this", "->", "raw", ",", "2", ")", ";", "if", "(", "isset", "(", "$", "a", "[", "1", "]", ")", ")", "{", "/**\n\t\t\t * Get title...
Build cover information. @throws \Pururin\Exceptions\PururinException @return bool
[ "Build", "cover", "information", "." ]
train
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/Crawlers/Cover.php#L58-L117
budde377/Part
lib/controller/json/JSONFunctionImpl.php
JSONFunctionImpl.getArg
public function getArg($num) { return isset($this->args[$num]) ? $this->args[$num] : null; }
php
public function getArg($num) { return isset($this->args[$num]) ? $this->args[$num] : null; }
[ "public", "function", "getArg", "(", "$", "num", ")", "{", "return", "isset", "(", "$", "this", "->", "args", "[", "$", "num", "]", ")", "?", "$", "this", "->", "args", "[", "$", "num", "]", ":", "null", ";", "}" ]
Will return argument at index given @param $num @return mixed
[ "Will", "return", "argument", "at", "index", "given" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/json/JSONFunctionImpl.php#L58-L61
MW-Peachy/Peachy
Includes/Autoloader.php
AutoLoader.autoload
public static function autoload($class_name) { global $pgIP; if (isset(self::$pgAutoLoader[$class_name]) && is_file($pgIP . self::$pgAutoLoader[$class_name])) { require_once($pgIP . self::$pgAutoLoader[$class_name]); return true; } if (is_file($pgIP . 'Plugins/' . $class_name . '.php')) { Hooks::runHook('LoadPlugin', array(&$class_name)); require_once($pgIP . 'Plugins/' . $class_name . '.php'); return true; } }
php
public static function autoload($class_name) { global $pgIP; if (isset(self::$pgAutoLoader[$class_name]) && is_file($pgIP . self::$pgAutoLoader[$class_name])) { require_once($pgIP . self::$pgAutoLoader[$class_name]); return true; } if (is_file($pgIP . 'Plugins/' . $class_name . '.php')) { Hooks::runHook('LoadPlugin', array(&$class_name)); require_once($pgIP . 'Plugins/' . $class_name . '.php'); return true; } }
[ "public", "static", "function", "autoload", "(", "$", "class_name", ")", "{", "global", "$", "pgIP", ";", "if", "(", "isset", "(", "self", "::", "$", "pgAutoLoader", "[", "$", "class_name", "]", ")", "&&", "is_file", "(", "$", "pgIP", ".", "self", ":...
Takes a class name and attempt to load it. Class name must be found in $pgAutoLoader. @param string $class_name Name of class we're looking for. @return boolean|null Returns true if the function successfully loads the class. Otherwise returns false. Returning false is important on failure as it allows Zend to try and look in other registered autoloaders as well.
[ "Takes", "a", "class", "name", "and", "attempt", "to", "load", "it", ".", "Class", "name", "must", "be", "found", "in", "$pgAutoLoader", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Autoloader.php#L72-L88
budde377/Part
lib/util/file/DumpFileImpl.php
DumpFileImpl.writeSerialized
public function writeSerialized($var) { $data = (($c = $this->getUnSerializedContent()) == ""?[]:$c); $data[] = $var; $this->delete(); $this->write(serialize($data)); }
php
public function writeSerialized($var) { $data = (($c = $this->getUnSerializedContent()) == ""?[]:$c); $data[] = $var; $this->delete(); $this->write(serialize($data)); }
[ "public", "function", "writeSerialized", "(", "$", "var", ")", "{", "$", "data", "=", "(", "(", "$", "c", "=", "$", "this", "->", "getUnSerializedContent", "(", ")", ")", "==", "\"\"", "?", "[", "]", ":", "$", "c", ")", ";", "$", "data", "[", "...
Dumps a variable to the dumpfile using serialize. @param mixed $var @return void
[ "Dumps", "a", "variable", "to", "the", "dumpfile", "using", "serialize", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/DumpFileImpl.php#L18-L25
budde377/Part
lib/controller/ajax/type_handler/ParserTypeHandlerImpl.php
ParserTypeHandlerImpl.canHandle
public function canHandle($type, JSONFunction $function, $instance = null) { if($type != 'Parser'){ return false; } $name = $function->getName(); if($name != 'parseJson' && $name != 'parseFunctionStringArray'){ return false; } $args = $function->getArgs(); if(count($args) < 1){ return false; } if(!is_string($args[0])){ return false; } return true; }
php
public function canHandle($type, JSONFunction $function, $instance = null) { if($type != 'Parser'){ return false; } $name = $function->getName(); if($name != 'parseJson' && $name != 'parseFunctionStringArray'){ return false; } $args = $function->getArgs(); if(count($args) < 1){ return false; } if(!is_string($args[0])){ return false; } return true; }
[ "public", "function", "canHandle", "(", "$", "type", ",", "JSONFunction", "$", "function", ",", "$", "instance", "=", "null", ")", "{", "if", "(", "$", "type", "!=", "'Parser'", ")", "{", "return", "false", ";", "}", "$", "name", "=", "$", "function"...
Checks if handler can handle. If so handle will be called with same arguments, else next suitable handler will be called. @param String $type @param JSONFunction $function @param mixed $instance @return bool
[ "Checks", "if", "handler", "can", "handle", ".", "If", "so", "handle", "will", "be", "called", "with", "same", "arguments", "else", "next", "suitable", "handler", "will", "be", "called", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/ParserTypeHandlerImpl.php#L46-L68
budde377/Part
lib/controller/ajax/ServerImpl.php
ServerImpl.registerHandler
public function registerHandler(TypeHandler $type) { $zeroLength = true; foreach ($type->listTypes() as $t) { $zeroLength = false; $this->handlers[$t][] = $type; $type->setUp($this, $t); } if ($zeroLength) { $type->setUp($this, null); } }
php
public function registerHandler(TypeHandler $type) { $zeroLength = true; foreach ($type->listTypes() as $t) { $zeroLength = false; $this->handlers[$t][] = $type; $type->setUp($this, $t); } if ($zeroLength) { $type->setUp($this, null); } }
[ "public", "function", "registerHandler", "(", "TypeHandler", "$", "type", ")", "{", "$", "zeroLength", "=", "true", ";", "foreach", "(", "$", "type", "->", "listTypes", "(", ")", "as", "$", "t", ")", "{", "$", "zeroLength", "=", "false", ";", "$", "t...
Registers a AJAX type. @param TypeHandler $type @return void
[ "Registers", "a", "AJAX", "type", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/ServerImpl.php#L54-L66
budde377/Part
lib/controller/ajax/ServerImpl.php
ServerImpl.registerHandlersFromConfig
public function registerHandlersFromConfig() { $config = $this->container->getConfigInstance(); foreach ($config->getAJAXTypeHandlers() as $handlerArray) { if (isset($handlerArray['path'])) { $path = $handlerArray['path']; if (!file_exists($path)) { throw new FileNotFoundException($path, "AJAXTypeHandler class file"); } /** @noinspection PhpIncludeInspection */ require_once $path; } $className = $handlerArray['class_name']; if (!class_exists($className)) { throw new ClassNotDefinedException($className); } $handler = new $className($this->container); if($handler instanceof TypeHandlerGenerator){ $handler = $handler->generateTypeHandler(); } if (!($handler instanceof TypeHandler)) { throw new ClassNotInstanceOfException($handler == null ? 'null' : get_class($handler), 'AJAXTypeHandler'); } $this->registerHandler($handler); } }
php
public function registerHandlersFromConfig() { $config = $this->container->getConfigInstance(); foreach ($config->getAJAXTypeHandlers() as $handlerArray) { if (isset($handlerArray['path'])) { $path = $handlerArray['path']; if (!file_exists($path)) { throw new FileNotFoundException($path, "AJAXTypeHandler class file"); } /** @noinspection PhpIncludeInspection */ require_once $path; } $className = $handlerArray['class_name']; if (!class_exists($className)) { throw new ClassNotDefinedException($className); } $handler = new $className($this->container); if($handler instanceof TypeHandlerGenerator){ $handler = $handler->generateTypeHandler(); } if (!($handler instanceof TypeHandler)) { throw new ClassNotInstanceOfException($handler == null ? 'null' : get_class($handler), 'AJAXTypeHandler'); } $this->registerHandler($handler); } }
[ "public", "function", "registerHandlersFromConfig", "(", ")", "{", "$", "config", "=", "$", "this", "->", "container", "->", "getConfigInstance", "(", ")", ";", "foreach", "(", "$", "config", "->", "getAJAXTypeHandlers", "(", ")", "as", "$", "handlerArray", ...
Registers the handlers from config. @throws ClassNotDefinedException @throws FileNotFoundException @throws ClassNotInstanceOfException @return void
[ "Registers", "the", "handlers", "from", "config", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/ServerImpl.php#L75-L107
MW-Peachy/Peachy
Plugins/IRC.php
IRC.joinChan
public function joinChan( $chan = null ) { if( !is_null( $chan ) && !is_array( $chan ) ) { pecho( "Joining $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'JOIN ' . $chan . "\n" ); usleep( 5000 ); } elseif( !is_null( $chan ) ) { foreach( $chan as $channel ){ pecho( "Joining $channel...\n", PECHO_VERBOSE ); fwrite( $this->f, 'JOIN ' . $channel . "\n" ); usleep( 5000 ); } } }
php
public function joinChan( $chan = null ) { if( !is_null( $chan ) && !is_array( $chan ) ) { pecho( "Joining $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'JOIN ' . $chan . "\n" ); usleep( 5000 ); } elseif( !is_null( $chan ) ) { foreach( $chan as $channel ){ pecho( "Joining $channel...\n", PECHO_VERBOSE ); fwrite( $this->f, 'JOIN ' . $channel . "\n" ); usleep( 5000 ); } } }
[ "public", "function", "joinChan", "(", "$", "chan", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "chan", ")", "&&", "!", "is_array", "(", "$", "chan", ")", ")", "{", "pecho", "(", "\"Joining $chan...\\n\"", ",", "PECHO_VERBOSE", ")", "...
Joins a channel, or the locally stored channel(s) @param string $chan Channel to join. Default null. @return void
[ "Joins", "a", "channel", "or", "the", "locally", "stored", "channel", "(", "s", ")" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/IRC.php#L111-L123
MW-Peachy/Peachy
Plugins/IRC.php
IRC.partChan
public function partChan( $chan = null ) { if( !is_null( $chan ) ) { pecho( "Parting $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'PART ' . $chan . "\n" ); usleep( 5000 ); } else { foreach( $this->chan as $chan ){ pecho( "Parting $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'PART ' . $chan . "\n" ); usleep( 5000 ); } } }
php
public function partChan( $chan = null ) { if( !is_null( $chan ) ) { pecho( "Parting $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'PART ' . $chan . "\n" ); usleep( 5000 ); } else { foreach( $this->chan as $chan ){ pecho( "Parting $chan...\n", PECHO_VERBOSE ); fwrite( $this->f, 'PART ' . $chan . "\n" ); usleep( 5000 ); } } }
[ "public", "function", "partChan", "(", "$", "chan", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "chan", ")", ")", "{", "pecho", "(", "\"Parting $chan...\\n\"", ",", "PECHO_VERBOSE", ")", ";", "fwrite", "(", "$", "this", "->", "f", ","...
Leaves a channel, or the locally stored channel(s) @param string $chan Channel to part. Default null @return void
[ "Leaves", "a", "channel", "or", "the", "locally", "stored", "channel", "(", "s", ")" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/IRC.php#L130-L142
MW-Peachy/Peachy
Plugins/IRC.php
IRC.parseLine
public static function parseLine( $line, $trigger, $feed = false ) { $return = array(); $return['trueraw'] = $line; $return['truerawmsg'] = explode( " ", $line ); unset( $return['truerawmsg'][0], $return['truerawmsg'][1], $return['truerawmsg'][2] ); $return['truerawmsg'] = substr( implode( ' ', $return['truerawmsg'] ), 1 ); if( $feed ) { $line = str_replace( array( "\n", "\r", "\002" ), '', $line ); $line = preg_replace( '/\003(\d\d?(,\d\d?)?)?/', '', $line ); } else { $line = str_replace( array( "\n", "\r" ), '', $line ); $line = preg_replace( '/' . chr( 3 ) . '.{2,}/i', '', $line ); } $return['raw'] = $line; /* Data for a privmsg: $d[0] = Nick!User@Host format. $d[1] = Action, e.g. "PRIVMSG", "MODE", etc. If it's a message from the server, it's the numerial code $d[2] = The channel somethign was spoken in $d[3] = The text that was spoken */ $d = $return['message'] = explode( ' ', $line ); $return['n!u@h'] = $d[0]; unset( $return['message'][0], $return['message'][1], $return['message'][2] ); $return['message'] = substr( implode( ' ', $return['message'] ), 1 ); $return['nick'] = substr( $d[0], 1 ); $return['nick'] = explode( '!', $return['nick'] ); $return['nick'] = $return['nick'][0]; $return['cloak'] = explode( '@', $d[0] ); $return['cloak'] = @$return['cloak'][1]; $return['user'] = explode( '!', $d[0] ); $return['user'] = explode( '@', $return['user'][1] ); $return['user'] = $return['user'][0]; $return['chan'] = strtolower( $d[2] ); $return['type'] = $return['payload'] = $d[1]; if( in_array( substr( $return['message'], 0, 1 ), $trigger ) ) { $return['command'] = explode( ' ', substr( strtolower( $return['message'] ), 1 ) ); $return['command'] = $return['command'][0]; //Get the parameters $return['param'] = explode( ' ', $return['message'] ); unset( $return['param'][0] ); $return['param'] = implode( ' ', $return['param'] ); $return['param'] = trim( $return['param'] ); } /* End result: $return['raw'] = Raw data $return['message'] = The text that appears in the channel $return['n!u@h'] = The person who said the line, in N!U@H format $return['nick'] = The nick who said the line $return['cloak'] = The cloak of the person who said the line $return['user'] = The username who said the line $return['chan'] = The channel the line was said in $return['type'] = The action that was done (eg PRIVMSG, MODE) $return['payload'] = For pings, this is $d[1] $return['command'] = The command that was said, eg !status (excuding !) $return['param'] = Parameters of the command */ return $return; }
php
public static function parseLine( $line, $trigger, $feed = false ) { $return = array(); $return['trueraw'] = $line; $return['truerawmsg'] = explode( " ", $line ); unset( $return['truerawmsg'][0], $return['truerawmsg'][1], $return['truerawmsg'][2] ); $return['truerawmsg'] = substr( implode( ' ', $return['truerawmsg'] ), 1 ); if( $feed ) { $line = str_replace( array( "\n", "\r", "\002" ), '', $line ); $line = preg_replace( '/\003(\d\d?(,\d\d?)?)?/', '', $line ); } else { $line = str_replace( array( "\n", "\r" ), '', $line ); $line = preg_replace( '/' . chr( 3 ) . '.{2,}/i', '', $line ); } $return['raw'] = $line; /* Data for a privmsg: $d[0] = Nick!User@Host format. $d[1] = Action, e.g. "PRIVMSG", "MODE", etc. If it's a message from the server, it's the numerial code $d[2] = The channel somethign was spoken in $d[3] = The text that was spoken */ $d = $return['message'] = explode( ' ', $line ); $return['n!u@h'] = $d[0]; unset( $return['message'][0], $return['message'][1], $return['message'][2] ); $return['message'] = substr( implode( ' ', $return['message'] ), 1 ); $return['nick'] = substr( $d[0], 1 ); $return['nick'] = explode( '!', $return['nick'] ); $return['nick'] = $return['nick'][0]; $return['cloak'] = explode( '@', $d[0] ); $return['cloak'] = @$return['cloak'][1]; $return['user'] = explode( '!', $d[0] ); $return['user'] = explode( '@', $return['user'][1] ); $return['user'] = $return['user'][0]; $return['chan'] = strtolower( $d[2] ); $return['type'] = $return['payload'] = $d[1]; if( in_array( substr( $return['message'], 0, 1 ), $trigger ) ) { $return['command'] = explode( ' ', substr( strtolower( $return['message'] ), 1 ) ); $return['command'] = $return['command'][0]; //Get the parameters $return['param'] = explode( ' ', $return['message'] ); unset( $return['param'][0] ); $return['param'] = implode( ' ', $return['param'] ); $return['param'] = trim( $return['param'] ); } /* End result: $return['raw'] = Raw data $return['message'] = The text that appears in the channel $return['n!u@h'] = The person who said the line, in N!U@H format $return['nick'] = The nick who said the line $return['cloak'] = The cloak of the person who said the line $return['user'] = The username who said the line $return['chan'] = The channel the line was said in $return['type'] = The action that was done (eg PRIVMSG, MODE) $return['payload'] = For pings, this is $d[1] $return['command'] = The command that was said, eg !status (excuding !) $return['param'] = Parameters of the command */ return $return; }
[ "public", "static", "function", "parseLine", "(", "$", "line", ",", "$", "trigger", ",", "$", "feed", "=", "false", ")", "{", "$", "return", "=", "array", "(", ")", ";", "$", "return", "[", "'trueraw'", "]", "=", "$", "line", ";", "$", "return", ...
Splits apart the various parts of an IRC line into usable sections, e.g. !commands, cloaks, etc. @param string $line Line that IRC sent @param array $trigger Trigger character for !commands (e.g. !, ., @, etc) @param bool $feed Whether or not the IRC server is a MediaWiki RC channel @return array Parsed line @static
[ "Splits", "apart", "the", "various", "parts", "of", "an", "IRC", "line", "into", "usable", "sections", "e", ".", "g", ".", "!commands", "cloaks", "etc", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/IRC.php#L152-L223
MW-Peachy/Peachy
Plugins/IRC.php
IRC.parseRC
public static function parseRC( $msg ) { if( preg_match( '/^\[\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?(oldid|diff)=(\d*)&(rcid|oldid)=(\d*).*|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S', $msg, $m ) ) { $return = array(); //print_r($m); $return['namespace'] = $m[2]; $return['pagename'] = $m[5]; $return['fullpagename'] = $m[1] . $m[5]; $return['basepagename'] = explode( '/', $return['fullpagename'] ); $return['basepagename'] = $return['basepagename'][0]; $return['subpagename'] = str_replace( $return['basepagename'] . '/', '', $return['fullpagename'] ); $return['flags'] = str_split( $m[6] ); $return['action'] = $m[6]; $return['url'] = $m[7]; $return['revid'] = $m[9]; $return['oldid'] = $m[11]; $return['username'] = $m[12]; $return['len'] = $m[14]; $return['comment'] = $m[15]; $return['timestamp'] = time(); $return['is_new'] = false; $return['is_minor'] = false; $return['is_bot'] = false; $return['is_delete'] = false; $return['actionpage'] = null; if( in_array( 'N', $return['flags'] ) ) { $return['is_new'] = true; } if( in_array( 'M', $return['flags'] ) ) { $return['is_minor'] = true; } if( in_array( 'B', $return['flags'] ) ) { $return['is_bot'] = true; } if( $return['action'] == 'delete' ) { $return['is_delete'] = true; $tmp = explode( '[[', $return['comment'] ); $tmp = explode( ']]', $tmp[1] ); $return['actionpage'] = $tmp[0]; $return['actionpageprefix'] = explode( '/', $return['actionpage'] ); $return['actionpageprefix'] = $return['actionpageprefix'][0]; } return $return; } }
php
public static function parseRC( $msg ) { if( preg_match( '/^\[\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?(oldid|diff)=(\d*)&(rcid|oldid)=(\d*).*|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S', $msg, $m ) ) { $return = array(); //print_r($m); $return['namespace'] = $m[2]; $return['pagename'] = $m[5]; $return['fullpagename'] = $m[1] . $m[5]; $return['basepagename'] = explode( '/', $return['fullpagename'] ); $return['basepagename'] = $return['basepagename'][0]; $return['subpagename'] = str_replace( $return['basepagename'] . '/', '', $return['fullpagename'] ); $return['flags'] = str_split( $m[6] ); $return['action'] = $m[6]; $return['url'] = $m[7]; $return['revid'] = $m[9]; $return['oldid'] = $m[11]; $return['username'] = $m[12]; $return['len'] = $m[14]; $return['comment'] = $m[15]; $return['timestamp'] = time(); $return['is_new'] = false; $return['is_minor'] = false; $return['is_bot'] = false; $return['is_delete'] = false; $return['actionpage'] = null; if( in_array( 'N', $return['flags'] ) ) { $return['is_new'] = true; } if( in_array( 'M', $return['flags'] ) ) { $return['is_minor'] = true; } if( in_array( 'B', $return['flags'] ) ) { $return['is_bot'] = true; } if( $return['action'] == 'delete' ) { $return['is_delete'] = true; $tmp = explode( '[[', $return['comment'] ); $tmp = explode( ']]', $tmp[1] ); $return['actionpage'] = $tmp[0]; $return['actionpageprefix'] = explode( '/', $return['actionpage'] ); $return['actionpageprefix'] = $return['actionpageprefix'][0]; } return $return; } }
[ "public", "static", "function", "parseRC", "(", "$", "msg", ")", "{", "if", "(", "preg_match", "(", "'/^\\[\\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\\x5d]*)\\]\\] (\\S*) (http:\\/\\/en\\.wikipedia\\.org\\/w\\/index\\.php\\?(oldid|diff...
Parses the title, user, etc from a MediaWiki RC feed @link http://www.mediawiki.org/wiki/Manual:IRC_RC_Bot @param string $msg Message from feed @return array Parsed line @static
[ "Parses", "the", "title", "user", "etc", "from", "a", "MediaWiki", "RC", "feed" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/IRC.php#L232-L283
matrozov/yii2-couchbase
src/Connection.php
Connection.getBucket
public function getBucket($bucketName = null, $password = null) { if ($bucketName === null) { $bucketName = $this->defaultBucket; } if (!array_key_exists($bucketName, $this->_buckets)) { $this->_buckets[$bucketName] = $this->selectBucket($bucketName, $password); } return $this->_buckets[$bucketName]; }
php
public function getBucket($bucketName = null, $password = null) { if ($bucketName === null) { $bucketName = $this->defaultBucket; } if (!array_key_exists($bucketName, $this->_buckets)) { $this->_buckets[$bucketName] = $this->selectBucket($bucketName, $password); } return $this->_buckets[$bucketName]; }
[ "public", "function", "getBucket", "(", "$", "bucketName", "=", "null", ",", "$", "password", "=", "null", ")", "{", "if", "(", "$", "bucketName", "===", "null", ")", "{", "$", "bucketName", "=", "$", "this", "->", "defaultBucket", ";", "}", "if", "(...
Returns the Couchbase bucket with the given name. @param string $bucketName bucket name. If string considered as the name of the bucket inside the default database. If array - first element considered as the name of the database, second - as name of bucket inside that database @param string $password bucket password @return Bucket Couchbase basket instance. @throws Exception @throws InvalidConfigException
[ "Returns", "the", "Couchbase", "bucket", "with", "the", "given", "name", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L131-L142
matrozov/yii2-couchbase
src/Connection.php
Connection.selectBucket
protected function selectBucket($name, $password = '') { $this->open(); try { $bucket = $this->cluster->openBucket($name, $password); } catch (\Exception $e) { throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } return Yii::createObject([ 'class' => 'matrozov\couchbase\Bucket', 'db' => $this, 'name' => $name, 'bucket' => $bucket, ]); }
php
protected function selectBucket($name, $password = '') { $this->open(); try { $bucket = $this->cluster->openBucket($name, $password); } catch (\Exception $e) { throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } return Yii::createObject([ 'class' => 'matrozov\couchbase\Bucket', 'db' => $this, 'name' => $name, 'bucket' => $bucket, ]); }
[ "protected", "function", "selectBucket", "(", "$", "name", ",", "$", "password", "=", "''", ")", "{", "$", "this", "->", "open", "(", ")", ";", "try", "{", "$", "bucket", "=", "$", "this", "->", "cluster", "->", "openBucket", "(", "$", "name", ",",...
Selects bucket with given name and password. @param string $name bucket name. @param string $password bucket password. @return Bucket|null bucket instance. @throws Exception @throws InvalidConfigException
[ "Selects", "bucket", "with", "given", "name", "and", "password", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L154-L171
matrozov/yii2-couchbase
src/Connection.php
Connection.open
public function open() { if ($this->cluster !== null) { return; } if (empty($this->dsn)) { throw new InvalidConfigException($this->className() . '::dsn cannot be empty.'); } $token = 'Opening Couchbase connection: ' . $this->dsn; try { Yii::trace($token, __METHOD__); Yii::beginProfile($token, __METHOD__); $this->cluster = new Cluster($this->dsn); $this->initConnection(); Yii::endProfile($token, __METHOD__); } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } }
php
public function open() { if ($this->cluster !== null) { return; } if (empty($this->dsn)) { throw new InvalidConfigException($this->className() . '::dsn cannot be empty.'); } $token = 'Opening Couchbase connection: ' . $this->dsn; try { Yii::trace($token, __METHOD__); Yii::beginProfile($token, __METHOD__); $this->cluster = new Cluster($this->dsn); $this->initConnection(); Yii::endProfile($token, __METHOD__); } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } }
[ "public", "function", "open", "(", ")", "{", "if", "(", "$", "this", "->", "cluster", "!==", "null", ")", "{", "return", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "dsn", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "$",...
Establishes a Couchbase connection. It does nothing if a Couchbase connection has already been established. @throws Exception if connection fails @throws InvalidConfigException
[ "Establishes", "a", "Couchbase", "connection", ".", "It", "does", "nothing", "if", "a", "Couchbase", "connection", "has", "already", "been", "established", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L208-L235
matrozov/yii2-couchbase
src/Connection.php
Connection.openManager
public function openManager() { if ($this->manager !== null) { return; } if ($this->cluster === null) { $this->open(); } if (empty($this->userName) || empty($this->password)) { throw new InvalidConfigException($this->className() . '::userName/password cannot be empty.'); } $token = 'Opening CouchbaseManager: ' . $this->userName; try { Yii::trace($token, __METHOD__); Yii::beginProfile($token, __METHOD__); $this->manager = $this->cluster->manager($this->userName, $this->password); Yii::endProfile($token, __METHOD__); } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } }
php
public function openManager() { if ($this->manager !== null) { return; } if ($this->cluster === null) { $this->open(); } if (empty($this->userName) || empty($this->password)) { throw new InvalidConfigException($this->className() . '::userName/password cannot be empty.'); } $token = 'Opening CouchbaseManager: ' . $this->userName; try { Yii::trace($token, __METHOD__); Yii::beginProfile($token, __METHOD__); $this->manager = $this->cluster->manager($this->userName, $this->password); Yii::endProfile($token, __METHOD__); } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int)$e->getCode(), $e); } }
[ "public", "function", "openManager", "(", ")", "{", "if", "(", "$", "this", "->", "manager", "!==", "null", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "cluster", "===", "null", ")", "{", "$", "this", "->", "open", "(", ")", ";", ...
Open a CouchbaseManager. It does nothing if a CouchbaseManager has already been opened. @throws Exception if open fails @throws InvalidConfigException
[ "Open", "a", "CouchbaseManager", ".", "It", "does", "nothing", "if", "a", "CouchbaseManager", "has", "already", "been", "opened", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L243-L272
matrozov/yii2-couchbase
src/Connection.php
Connection.close
public function close() { if ($this->cluster === null) { return; } Yii::trace('Closing Couchbase connection: ' . $this->dsn, __METHOD__); $this->cluster = null; $this->manager = null; $this->clearBuckets(); }
php
public function close() { if ($this->cluster === null) { return; } Yii::trace('Closing Couchbase connection: ' . $this->dsn, __METHOD__); $this->cluster = null; $this->manager = null; $this->clearBuckets(); }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "cluster", "===", "null", ")", "{", "return", ";", "}", "Yii", "::", "trace", "(", "'Closing Couchbase connection: '", ".", "$", "this", "->", "dsn", ",", "__METHOD__", ")", ";...
Closes the currently active DB connection. It does nothing if the connection is already closed.
[ "Closes", "the", "currently", "active", "DB", "connection", ".", "It", "does", "nothing", "if", "the", "connection", "is", "already", "closed", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L278-L290
matrozov/yii2-couchbase
src/Connection.php
Connection.quoteSql
public function quoteSql($sql) { return preg_replace_callback( '/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/', function ($matches) { if (isset($matches[3])) { return $this->quoteColumnName($matches[3]); } else { return str_replace('%', $this->bucketPrefix, $this->quoteBucketName($matches[2])); } }, $sql ); }
php
public function quoteSql($sql) { return preg_replace_callback( '/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/', function ($matches) { if (isset($matches[3])) { return $this->quoteColumnName($matches[3]); } else { return str_replace('%', $this->bucketPrefix, $this->quoteBucketName($matches[2])); } }, $sql ); }
[ "public", "function", "quoteSql", "(", "$", "sql", ")", "{", "return", "preg_replace_callback", "(", "'/(\\\\{\\\\{(%?[\\w\\-\\. ]+%?)\\\\}\\\\}|\\\\[\\\\[([\\w\\-\\. ]+)\\\\]\\\\])/'", ",", "function", "(", "$", "matches", ")", "{", "if", "(", "isset", "(", "$", "mat...
Processes a SQL statement by quoting bucket and column names that are enclosed within double brackets. Tokens enclosed within double curly brackets are treated as bucket names, while tokens enclosed within double square brackets are column names. They will be quoted accordingly. Also, the percentage character "%" at the beginning or ending of a bucket name will be replaced with [[bucketPrefix]]. @param string $sql the SQL to be quoted @return string the quoted SQL
[ "Processes", "a", "SQL", "statement", "by", "quoting", "bucket", "and", "column", "names", "that", "are", "enclosed", "within", "double", "brackets", ".", "Tokens", "enclosed", "within", "double", "curly", "brackets", "are", "treated", "as", "bucket", "names", ...
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L349-L363
matrozov/yii2-couchbase
src/Connection.php
Connection.createCommand
public function createCommand($sql = null, $params = []) { /** @var Command $command */ $command = new $this->commandClass([ 'db' => $this, 'sql' => $sql, ]); return $command->bindValues($params); }
php
public function createCommand($sql = null, $params = []) { /** @var Command $command */ $command = new $this->commandClass([ 'db' => $this, 'sql' => $sql, ]); return $command->bindValues($params); }
[ "public", "function", "createCommand", "(", "$", "sql", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "/** @var Command $command */", "$", "command", "=", "new", "$", "this", "->", "commandClass", "(", "[", "'db'", "=>", "$", "this", ",", "...
Creates a command for execution. @param string $sql the SQL statement to be executed @param array $params the parameters to be bound to the SQL statement @return Command the DB command
[ "Creates", "a", "command", "for", "execution", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L371-L380
matrozov/yii2-couchbase
src/Connection.php
Connection.createBucket
public function createBucket($bucketName, array $options = []) { $this->openManager(); $this->manager->createBucket($bucketName, $options); // ToDo: https://github.com/matrozov/yii2-couchbase/issues/1 sleep(5); }
php
public function createBucket($bucketName, array $options = []) { $this->openManager(); $this->manager->createBucket($bucketName, $options); // ToDo: https://github.com/matrozov/yii2-couchbase/issues/1 sleep(5); }
[ "public", "function", "createBucket", "(", "$", "bucketName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "openManager", "(", ")", ";", "$", "this", "->", "manager", "->", "createBucket", "(", "$", "bucketName", ",", "$", ...
Creates new bucket in database associated with this command.s @param string $bucketName bucket name @param array $options bucket options in format: "name" => "value" @throws Exception @throws InvalidConfigException
[ "Creates", "new", "bucket", "in", "database", "associated", "with", "this", "command", ".", "s" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L391-L399
matrozov/yii2-couchbase
src/Connection.php
Connection.update
public function update($bucketName, $columns, $condition, $params = []) { return $this->createCommand()->update($bucketName, $columns, $condition, $params)->execute(); }
php
public function update($bucketName, $columns, $condition, $params = []) { return $this->createCommand()->update($bucketName, $columns, $condition, $params)->execute(); }
[ "public", "function", "update", "(", "$", "bucketName", ",", "$", "columns", ",", "$", "condition", ",", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "createCommand", "(", ")", "->", "update", "(", "$", "bucketName", ",", "$",...
Update record. @param string $bucketName the bucket to be updated. @param array $columns the column data (name => value) to be updated. @param string|array $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the parameters to be bound to the command @return int affected rows @throws Exception @throws InvalidConfigException
[ "Update", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L477-L480
matrozov/yii2-couchbase
src/Connection.php
Connection.upsert
public function upsert($bucketName, $id, $data) { return $this->createCommand()->upsert($bucketName, $id, $data)->execute(); }
php
public function upsert($bucketName, $id, $data) { return $this->createCommand()->upsert($bucketName, $id, $data)->execute(); }
[ "public", "function", "upsert", "(", "$", "bucketName", ",", "$", "id", ",", "$", "data", ")", "{", "return", "$", "this", "->", "createCommand", "(", ")", "->", "upsert", "(", "$", "bucketName", ",", "$", "id", ",", "$", "data", ")", "->", "execut...
Upsert record. @param string $bucketName the bucket to be updated. @param string $id the document id. @param array $data the column data (name => value) to be inserted into the bucket or instance. @return bool @throws Exception @throws InvalidConfigException
[ "Upsert", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L493-L496
matrozov/yii2-couchbase
src/Connection.php
Connection.delete
public function delete($bucketName, $condition = '', $params = []) { return $this->createCommand()->delete($bucketName, $condition, $params)->execute(); }
php
public function delete($bucketName, $condition = '', $params = []) { return $this->createCommand()->delete($bucketName, $condition, $params)->execute(); }
[ "public", "function", "delete", "(", "$", "bucketName", ",", "$", "condition", "=", "''", ",", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "createCommand", "(", ")", "->", "delete", "(", "$", "bucketName", ",", "$", "conditio...
Delete record @param string $bucketName the bucket where the data will be deleted from. @param string|array $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the parameters to be bound to the command @return int affected rows @throws Exception @throws InvalidConfigException
[ "Delete", "record" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L510-L513
matrozov/yii2-couchbase
src/Connection.php
Connection.count
public function count($bucketName, $condition = '', $params = []) { return $this->createCommand()->count($bucketName, $condition, $params)->queryScalar(); }
php
public function count($bucketName, $condition = '', $params = []) { return $this->createCommand()->count($bucketName, $condition, $params)->queryScalar(); }
[ "public", "function", "count", "(", "$", "bucketName", ",", "$", "condition", "=", "''", ",", "$", "params", "=", "[", "]", ")", "{", "return", "$", "this", "->", "createCommand", "(", ")", "->", "count", "(", "$", "bucketName", ",", "$", "condition"...
Counts records in this bucket. @param string $bucketName the bucket where the data will be deleted from. @param string $condition query condition @param array $params list of options in format: optionName => optionValue. @return int records count. @throws Exception @throws InvalidConfigException
[ "Counts", "records", "in", "this", "bucket", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L526-L529