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
willmorgan/silverstripe-cropperfield
code/Cropper/GenericCropper.php
GenericCropper.getCropDimensions
public function getCropDimensions() { $x = $this->getCropX(); $y = $this->getCropY(); $cropWidth = $this->getCropWidth(); $cropHeight = $this->getCropHeight(); $width = $cropWidth; $height = $cropHeight; // Normalise the width/height with respect to the aspect ratio $maxWidth = $this->getMaxWidth(); $maxHeight = $this->getMaxHeight(); $aspectRatio = $this->getAspectRatio(); if($width < 1 || $height < 1) { throw new \InvalidArgumentException('Values must be over 1'); } // Fix the aspect ratio if the crop is wrong // This must happen first so invalid values can be compensated for if($width / $height != $aspectRatio) { $height = $width / $aspectRatio; } if($width > $maxWidth) { $scaleDownRatio = $cropWidth / $maxWidth; $height = $height / $scaleDownRatio; $width = $maxWidth; } if($height > $maxHeight) { $scaleDownRatio = $cropHeight / $maxHeight; $width = $width / $scaleDownRatio; $height = $maxHeight; } return array( // src_x, src_y 'x' => $x, 'y' => $y, // dst_w, dst_h 'width' => ceil($width), 'height' => ceil($height), // src_w, src_h 'crop_width' => $cropWidth, 'crop_height' => $cropHeight, ); }
php
public function getCropDimensions() { $x = $this->getCropX(); $y = $this->getCropY(); $cropWidth = $this->getCropWidth(); $cropHeight = $this->getCropHeight(); $width = $cropWidth; $height = $cropHeight; // Normalise the width/height with respect to the aspect ratio $maxWidth = $this->getMaxWidth(); $maxHeight = $this->getMaxHeight(); $aspectRatio = $this->getAspectRatio(); if($width < 1 || $height < 1) { throw new \InvalidArgumentException('Values must be over 1'); } // Fix the aspect ratio if the crop is wrong // This must happen first so invalid values can be compensated for if($width / $height != $aspectRatio) { $height = $width / $aspectRatio; } if($width > $maxWidth) { $scaleDownRatio = $cropWidth / $maxWidth; $height = $height / $scaleDownRatio; $width = $maxWidth; } if($height > $maxHeight) { $scaleDownRatio = $cropHeight / $maxHeight; $width = $width / $scaleDownRatio; $height = $maxHeight; } return array( // src_x, src_y 'x' => $x, 'y' => $y, // dst_w, dst_h 'width' => ceil($width), 'height' => ceil($height), // src_w, src_h 'crop_width' => $cropWidth, 'crop_height' => $cropHeight, ); }
[ "public", "function", "getCropDimensions", "(", ")", "{", "$", "x", "=", "$", "this", "->", "getCropX", "(", ")", ";", "$", "y", "=", "$", "this", "->", "getCropY", "(", ")", ";", "$", "cropWidth", "=", "$", "this", "->", "getCropWidth", "(", ")", ...
Ensure the aspect ratio is respected regardless of any dodgy data. The aspect ratio is otherwise
[ "Ensure", "the", "aspect", "ratio", "is", "respected", "regardless", "of", "any", "dodgy", "data", ".", "The", "aspect", "ratio", "is", "otherwise" ]
train
https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/Cropper/GenericCropper.php#L176-L224
willmorgan/silverstripe-cropperfield
code/Cropper/GenericCropper.php
GenericCropper.normaliseFilename
protected function normaliseFilename($absolutePath) { $regex = sprintf( '#^%s#', addslashes(BASE_PATH) . DIRECTORY_SEPARATOR ); return preg_replace($regex, '', $absolutePath); }
php
protected function normaliseFilename($absolutePath) { $regex = sprintf( '#^%s#', addslashes(BASE_PATH) . DIRECTORY_SEPARATOR ); return preg_replace($regex, '', $absolutePath); }
[ "protected", "function", "normaliseFilename", "(", "$", "absolutePath", ")", "{", "$", "regex", "=", "sprintf", "(", "'#^%s#'", ",", "addslashes", "(", "BASE_PATH", ")", ".", "DIRECTORY_SEPARATOR", ")", ";", "return", "preg_replace", "(", "$", "regex", ",", ...
Convert an absolute path to one relative to the base path @return string
[ "Convert", "an", "absolute", "path", "to", "one", "relative", "to", "the", "base", "path" ]
train
https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/Cropper/GenericCropper.php#L257-L263
budde377/Part
lib/view/page_element/LoginFormulaPageElementImpl.php
LoginFormulaPageElementImpl.setUpElement
public function setUpElement() { parent::setUpElement(); if ($this->userLibrary->getUserLoggedIn() !== null) { HTTPHeaderHelper::redirectToLocation("/"); } if(count($this->userLibrary->listUsers()) == 0){ $config = $this->container->getConfigInstance(); $owner = $config->getOwner(); $user = $this->userLibrary->createUser($owner['username'], "password", $owner['mail']); $user->getUserPrivileges()->addRootPrivileges(); } }
php
public function setUpElement() { parent::setUpElement(); if ($this->userLibrary->getUserLoggedIn() !== null) { HTTPHeaderHelper::redirectToLocation("/"); } if(count($this->userLibrary->listUsers()) == 0){ $config = $this->container->getConfigInstance(); $owner = $config->getOwner(); $user = $this->userLibrary->createUser($owner['username'], "password", $owner['mail']); $user->getUserPrivileges()->addRootPrivileges(); } }
[ "public", "function", "setUpElement", "(", ")", "{", "parent", "::", "setUpElement", "(", ")", ";", "if", "(", "$", "this", "->", "userLibrary", "->", "getUserLoggedIn", "(", ")", "!==", "null", ")", "{", "HTTPHeaderHelper", "::", "redirectToLocation", "(", ...
Will set up the page element. If you want to ensure that you register some files, this would be the place to do this. This should always be called before generateContent, at the latest right before. @return void
[ "Will", "set", "up", "the", "page", "element", ".", "If", "you", "want", "to", "ensure", "that", "you", "register", "some", "files", "this", "would", "be", "the", "place", "to", "do", "this", ".", "This", "should", "always", "be", "called", "before", "...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/page_element/LoginFormulaPageElementImpl.php#L89-L101
yarcode/yii2-email-manager
src/EmailManager.php
EmailManager.queue
public function queue($from, $to, $subject, $text, $priority = 0, $files = [], $bcc = null) { if (is_array($bcc)) { $bcc = implode(', ', $bcc); } $model = new Message(); $model->from = $from; $model->to = $to; $model->subject = $subject; $model->text = $text; $model->priority = $priority; $model->files = $files; $model->bcc = $bcc; return $model->save(); }
php
public function queue($from, $to, $subject, $text, $priority = 0, $files = [], $bcc = null) { if (is_array($bcc)) { $bcc = implode(', ', $bcc); } $model = new Message(); $model->from = $from; $model->to = $to; $model->subject = $subject; $model->text = $text; $model->priority = $priority; $model->files = $files; $model->bcc = $bcc; return $model->save(); }
[ "public", "function", "queue", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "text", ",", "$", "priority", "=", "0", ",", "$", "files", "=", "[", "]", ",", "$", "bcc", "=", "null", ")", "{", "if", "(", "is_array", "(", "$",...
Queues email message @param $from @param $to @param $subject @param $text @param int $priority @param array $files @param null $bcc @return bool
[ "Queues", "email", "message" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/EmailManager.php#L70-L86
yarcode/yii2-email-manager
src/EmailManager.php
EmailManager.send
public function send($from, $to, $subject, $text, $files = [], $bcc = null) { $files = $files === null ? [] : $files; return $this->transports[$this->defaultTransport]->send($from, $to, $subject, $text, $files, $bcc); }
php
public function send($from, $to, $subject, $text, $files = [], $bcc = null) { $files = $files === null ? [] : $files; return $this->transports[$this->defaultTransport]->send($from, $to, $subject, $text, $files, $bcc); }
[ "public", "function", "send", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "text", ",", "$", "files", "=", "[", "]", ",", "$", "bcc", "=", "null", ")", "{", "$", "files", "=", "$", "files", "===", "null", "?", "[", "]", ...
Sends email message immediately using default transport @param string $from @param string $to @param string $subject @param string $text @param array $files @param array|string $bcc @return bool
[ "Sends", "email", "message", "immediately", "using", "default", "transport" ]
train
https://github.com/yarcode/yii2-email-manager/blob/4e83eae67199fc2b9eca9f08dcf59cc0440c385a/src/EmailManager.php#L99-L104
skrz/meta
gen-src/Google/Protobuf/Meta/FileOptionsMeta.php
FileOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FileOptions(); case 1: return new FileOptions(func_get_arg(0)); case 2: return new FileOptions(func_get_arg(0), func_get_arg(1)); case 3: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileOptions(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 FileOptions(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 FileOptions(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 FileOptions(); case 1: return new FileOptions(func_get_arg(0)); case 2: return new FileOptions(func_get_arg(0), func_get_arg(1)); case 3: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileOptions(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 FileOptions(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 FileOptions(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", "FileOptions", "(", ")", ";", "case", "1", ":", "return", "new", "FileOptions", "(", "func_get_arg", "(", "0...
Creates new instance of \Google\Protobuf\FileOptions @throws \InvalidArgumentException @return FileOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileOptionsMeta.php#L72-L96
skrz/meta
gen-src/Google/Protobuf/Meta/FileOptionsMeta.php
FileOptionsMeta.reset
public static function reset($object) { if (!($object instanceof FileOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileOptions.'); } $object->javaPackage = NULL; $object->javaOuterClassname = NULL; $object->javaMultipleFiles = NULL; $object->javaGenerateEqualsAndHash = NULL; $object->javaStringCheckUtf8 = NULL; $object->optimizeFor = NULL; $object->goPackage = NULL; $object->ccGenericServices = NULL; $object->javaGenericServices = NULL; $object->pyGenericServices = NULL; $object->deprecated = NULL; $object->ccEnableArenas = NULL; $object->objcClassPrefix = NULL; $object->csharpNamespace = NULL; $object->javananoUseDeprecatedPackage = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof FileOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileOptions.'); } $object->javaPackage = NULL; $object->javaOuterClassname = NULL; $object->javaMultipleFiles = NULL; $object->javaGenerateEqualsAndHash = NULL; $object->javaStringCheckUtf8 = NULL; $object->optimizeFor = NULL; $object->goPackage = NULL; $object->ccGenericServices = NULL; $object->javaGenericServices = NULL; $object->pyGenericServices = NULL; $object->deprecated = NULL; $object->ccEnableArenas = NULL; $object->objcClassPrefix = NULL; $object->csharpNamespace = NULL; $object->javananoUseDeprecatedPackage = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "FileOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\FileOpt...
Resets properties of \Google\Protobuf\FileOptions to default values @param FileOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileOptionsMeta.php#L109-L130
skrz/meta
gen-src/Google/Protobuf/Meta/FileOptionsMeta.php
FileOptionsMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->javaPackage)) { hash_update($ctx, 'javaPackage'); hash_update($ctx, (string)$object->javaPackage); } if (isset($object->javaOuterClassname)) { hash_update($ctx, 'javaOuterClassname'); hash_update($ctx, (string)$object->javaOuterClassname); } if (isset($object->javaMultipleFiles)) { hash_update($ctx, 'javaMultipleFiles'); hash_update($ctx, (string)$object->javaMultipleFiles); } if (isset($object->javaGenerateEqualsAndHash)) { hash_update($ctx, 'javaGenerateEqualsAndHash'); hash_update($ctx, (string)$object->javaGenerateEqualsAndHash); } if (isset($object->javaStringCheckUtf8)) { hash_update($ctx, 'javaStringCheckUtf8'); hash_update($ctx, (string)$object->javaStringCheckUtf8); } if (isset($object->optimizeFor)) { hash_update($ctx, 'optimizeFor'); hash_update($ctx, (string)$object->optimizeFor); } if (isset($object->goPackage)) { hash_update($ctx, 'goPackage'); hash_update($ctx, (string)$object->goPackage); } if (isset($object->ccGenericServices)) { hash_update($ctx, 'ccGenericServices'); hash_update($ctx, (string)$object->ccGenericServices); } if (isset($object->javaGenericServices)) { hash_update($ctx, 'javaGenericServices'); hash_update($ctx, (string)$object->javaGenericServices); } if (isset($object->pyGenericServices)) { hash_update($ctx, 'pyGenericServices'); hash_update($ctx, (string)$object->pyGenericServices); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->ccEnableArenas)) { hash_update($ctx, 'ccEnableArenas'); hash_update($ctx, (string)$object->ccEnableArenas); } if (isset($object->objcClassPrefix)) { hash_update($ctx, 'objcClassPrefix'); hash_update($ctx, (string)$object->objcClassPrefix); } if (isset($object->csharpNamespace)) { hash_update($ctx, 'csharpNamespace'); hash_update($ctx, (string)$object->csharpNamespace); } if (isset($object->javananoUseDeprecatedPackage)) { hash_update($ctx, 'javananoUseDeprecatedPackage'); hash_update($ctx, (string)$object->javananoUseDeprecatedPackage); } 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->javaPackage)) { hash_update($ctx, 'javaPackage'); hash_update($ctx, (string)$object->javaPackage); } if (isset($object->javaOuterClassname)) { hash_update($ctx, 'javaOuterClassname'); hash_update($ctx, (string)$object->javaOuterClassname); } if (isset($object->javaMultipleFiles)) { hash_update($ctx, 'javaMultipleFiles'); hash_update($ctx, (string)$object->javaMultipleFiles); } if (isset($object->javaGenerateEqualsAndHash)) { hash_update($ctx, 'javaGenerateEqualsAndHash'); hash_update($ctx, (string)$object->javaGenerateEqualsAndHash); } if (isset($object->javaStringCheckUtf8)) { hash_update($ctx, 'javaStringCheckUtf8'); hash_update($ctx, (string)$object->javaStringCheckUtf8); } if (isset($object->optimizeFor)) { hash_update($ctx, 'optimizeFor'); hash_update($ctx, (string)$object->optimizeFor); } if (isset($object->goPackage)) { hash_update($ctx, 'goPackage'); hash_update($ctx, (string)$object->goPackage); } if (isset($object->ccGenericServices)) { hash_update($ctx, 'ccGenericServices'); hash_update($ctx, (string)$object->ccGenericServices); } if (isset($object->javaGenericServices)) { hash_update($ctx, 'javaGenericServices'); hash_update($ctx, (string)$object->javaGenericServices); } if (isset($object->pyGenericServices)) { hash_update($ctx, 'pyGenericServices'); hash_update($ctx, (string)$object->pyGenericServices); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->ccEnableArenas)) { hash_update($ctx, 'ccEnableArenas'); hash_update($ctx, (string)$object->ccEnableArenas); } if (isset($object->objcClassPrefix)) { hash_update($ctx, 'objcClassPrefix'); hash_update($ctx, (string)$object->objcClassPrefix); } if (isset($object->csharpNamespace)) { hash_update($ctx, 'csharpNamespace'); hash_update($ctx, (string)$object->csharpNamespace); } if (isset($object->javananoUseDeprecatedPackage)) { hash_update($ctx, 'javananoUseDeprecatedPackage'); hash_update($ctx, (string)$object->javananoUseDeprecatedPackage); } 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\FileOptions @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileOptionsMeta.php#L142-L237
skrz/meta
gen-src/Google/Protobuf/Meta/FileOptionsMeta.php
FileOptionsMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FileOptions(); } 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->javaPackage = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->javaOuterClassname = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaMultipleFiles = (bool)Binary::decodeVarint($input, $start); break; case 20: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaGenerateEqualsAndHash = (bool)Binary::decodeVarint($input, $start); break; case 27: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaStringCheckUtf8 = (bool)Binary::decodeVarint($input, $start); break; case 9: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->optimizeFor = Binary::decodeVarint($input, $start); break; case 11: 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->goPackage = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 16: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ccGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 17: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 18: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->pyGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 23: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 31: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ccEnableArenas = (bool)Binary::decodeVarint($input, $start); break; case 36: 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->objcClassPrefix = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 37: 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->csharpNamespace = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 38: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javananoUseDeprecatedPackage = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FileOptions(); } 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->javaPackage = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 8: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->javaOuterClassname = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaMultipleFiles = (bool)Binary::decodeVarint($input, $start); break; case 20: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaGenerateEqualsAndHash = (bool)Binary::decodeVarint($input, $start); break; case 27: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaStringCheckUtf8 = (bool)Binary::decodeVarint($input, $start); break; case 9: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->optimizeFor = Binary::decodeVarint($input, $start); break; case 11: 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->goPackage = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 16: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ccGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 17: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javaGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 18: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->pyGenericServices = (bool)Binary::decodeVarint($input, $start); break; case 23: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 31: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ccEnableArenas = (bool)Binary::decodeVarint($input, $start); break; case 36: 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->objcClassPrefix = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 37: 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->csharpNamespace = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 38: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->javananoUseDeprecatedPackage = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\FileOptions object from serialized Protocol Buffers message. @param string $input @param FileOptions $object @param int $start @param int $end @throws \Exception @return FileOptions
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "FileOptions", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileOptionsMeta.php#L252-L440
skrz/meta
gen-src/Google/Protobuf/Meta/FileOptionsMeta.php
FileOptionsMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->javaPackage) && ($filter === null || isset($filter['javaPackage']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->javaPackage)); $output .= $object->javaPackage; } if (isset($object->javaOuterClassname) && ($filter === null || isset($filter['javaOuterClassname']))) { $output .= "\x42"; $output .= Binary::encodeVarint(strlen($object->javaOuterClassname)); $output .= $object->javaOuterClassname; } if (isset($object->javaMultipleFiles) && ($filter === null || isset($filter['javaMultipleFiles']))) { $output .= "\x50"; $output .= Binary::encodeVarint((int)$object->javaMultipleFiles); } if (isset($object->javaGenerateEqualsAndHash) && ($filter === null || isset($filter['javaGenerateEqualsAndHash']))) { $output .= "\xa0\x01"; $output .= Binary::encodeVarint((int)$object->javaGenerateEqualsAndHash); } if (isset($object->javaStringCheckUtf8) && ($filter === null || isset($filter['javaStringCheckUtf8']))) { $output .= "\xd8\x01"; $output .= Binary::encodeVarint((int)$object->javaStringCheckUtf8); } if (isset($object->optimizeFor) && ($filter === null || isset($filter['optimizeFor']))) { $output .= "\x48"; $output .= Binary::encodeVarint($object->optimizeFor); } if (isset($object->goPackage) && ($filter === null || isset($filter['goPackage']))) { $output .= "\x5a"; $output .= Binary::encodeVarint(strlen($object->goPackage)); $output .= $object->goPackage; } if (isset($object->ccGenericServices) && ($filter === null || isset($filter['ccGenericServices']))) { $output .= "\x80\x01"; $output .= Binary::encodeVarint((int)$object->ccGenericServices); } if (isset($object->javaGenericServices) && ($filter === null || isset($filter['javaGenericServices']))) { $output .= "\x88\x01"; $output .= Binary::encodeVarint((int)$object->javaGenericServices); } if (isset($object->pyGenericServices) && ($filter === null || isset($filter['pyGenericServices']))) { $output .= "\x90\x01"; $output .= Binary::encodeVarint((int)$object->pyGenericServices); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\xb8\x01"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->ccEnableArenas) && ($filter === null || isset($filter['ccEnableArenas']))) { $output .= "\xf8\x01"; $output .= Binary::encodeVarint((int)$object->ccEnableArenas); } if (isset($object->objcClassPrefix) && ($filter === null || isset($filter['objcClassPrefix']))) { $output .= "\xa2\x02"; $output .= Binary::encodeVarint(strlen($object->objcClassPrefix)); $output .= $object->objcClassPrefix; } if (isset($object->csharpNamespace) && ($filter === null || isset($filter['csharpNamespace']))) { $output .= "\xaa\x02"; $output .= Binary::encodeVarint(strlen($object->csharpNamespace)); $output .= $object->csharpNamespace; } if (isset($object->javananoUseDeprecatedPackage) && ($filter === null || isset($filter['javananoUseDeprecatedPackage']))) { $output .= "\xb0\x02"; $output .= Binary::encodeVarint((int)$object->javananoUseDeprecatedPackage); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->javaPackage) && ($filter === null || isset($filter['javaPackage']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->javaPackage)); $output .= $object->javaPackage; } if (isset($object->javaOuterClassname) && ($filter === null || isset($filter['javaOuterClassname']))) { $output .= "\x42"; $output .= Binary::encodeVarint(strlen($object->javaOuterClassname)); $output .= $object->javaOuterClassname; } if (isset($object->javaMultipleFiles) && ($filter === null || isset($filter['javaMultipleFiles']))) { $output .= "\x50"; $output .= Binary::encodeVarint((int)$object->javaMultipleFiles); } if (isset($object->javaGenerateEqualsAndHash) && ($filter === null || isset($filter['javaGenerateEqualsAndHash']))) { $output .= "\xa0\x01"; $output .= Binary::encodeVarint((int)$object->javaGenerateEqualsAndHash); } if (isset($object->javaStringCheckUtf8) && ($filter === null || isset($filter['javaStringCheckUtf8']))) { $output .= "\xd8\x01"; $output .= Binary::encodeVarint((int)$object->javaStringCheckUtf8); } if (isset($object->optimizeFor) && ($filter === null || isset($filter['optimizeFor']))) { $output .= "\x48"; $output .= Binary::encodeVarint($object->optimizeFor); } if (isset($object->goPackage) && ($filter === null || isset($filter['goPackage']))) { $output .= "\x5a"; $output .= Binary::encodeVarint(strlen($object->goPackage)); $output .= $object->goPackage; } if (isset($object->ccGenericServices) && ($filter === null || isset($filter['ccGenericServices']))) { $output .= "\x80\x01"; $output .= Binary::encodeVarint((int)$object->ccGenericServices); } if (isset($object->javaGenericServices) && ($filter === null || isset($filter['javaGenericServices']))) { $output .= "\x88\x01"; $output .= Binary::encodeVarint((int)$object->javaGenericServices); } if (isset($object->pyGenericServices) && ($filter === null || isset($filter['pyGenericServices']))) { $output .= "\x90\x01"; $output .= Binary::encodeVarint((int)$object->pyGenericServices); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\xb8\x01"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->ccEnableArenas) && ($filter === null || isset($filter['ccEnableArenas']))) { $output .= "\xf8\x01"; $output .= Binary::encodeVarint((int)$object->ccEnableArenas); } if (isset($object->objcClassPrefix) && ($filter === null || isset($filter['objcClassPrefix']))) { $output .= "\xa2\x02"; $output .= Binary::encodeVarint(strlen($object->objcClassPrefix)); $output .= $object->objcClassPrefix; } if (isset($object->csharpNamespace) && ($filter === null || isset($filter['csharpNamespace']))) { $output .= "\xaa\x02"; $output .= Binary::encodeVarint(strlen($object->csharpNamespace)); $output .= $object->csharpNamespace; } if (isset($object->javananoUseDeprecatedPackage) && ($filter === null || isset($filter['javananoUseDeprecatedPackage']))) { $output .= "\xb0\x02"; $output .= Binary::encodeVarint((int)$object->javananoUseDeprecatedPackage); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "javaPackage", ")", "&&", "(", "$", "filter", "===", "null", "...
Serialized \Google\Protobuf\FileOptions to Protocol Buffers message. @param FileOptions $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "FileOptions", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileOptionsMeta.php#L453-L547
yeephp/yeephp
Yee/Router.php
Router.map
public function map(\Yee\Route $route) { list($groupPattern, $groupMiddleware) = $this->processGroups(); $route->setPattern($groupPattern . $route->getPattern()); $this->routes[] = $route; foreach ($groupMiddleware as $middleware) { $route->setMiddleware($middleware); } }
php
public function map(\Yee\Route $route) { list($groupPattern, $groupMiddleware) = $this->processGroups(); $route->setPattern($groupPattern . $route->getPattern()); $this->routes[] = $route; foreach ($groupMiddleware as $middleware) { $route->setMiddleware($middleware); } }
[ "public", "function", "map", "(", "\\", "Yee", "\\", "Route", "$", "route", ")", "{", "list", "(", "$", "groupPattern", ",", "$", "groupMiddleware", ")", "=", "$", "this", "->", "processGroups", "(", ")", ";", "$", "route", "->", "setPattern", "(", "...
Add a route object to the router @param \Yee\Route $route The Yee Route
[ "Add", "a", "route", "object", "to", "the", "router" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Router.php#L126-L137
yeephp/yeephp
Yee/Router.php
Router.addNamedRoute
public function addNamedRoute($name, \Yee\Route $route) { if ($this->hasNamedRoute($name)) { throw new \RuntimeException('Named route already exists with name: ' . $name); } $this->namedRoutes[(string) $name] = $route; }
php
public function addNamedRoute($name, \Yee\Route $route) { if ($this->hasNamedRoute($name)) { throw new \RuntimeException('Named route already exists with name: ' . $name); } $this->namedRoutes[(string) $name] = $route; }
[ "public", "function", "addNamedRoute", "(", "$", "name", ",", "\\", "Yee", "\\", "Route", "$", "route", ")", "{", "if", "(", "$", "this", "->", "hasNamedRoute", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Named rou...
Add named route @param string $name The route name @param \Yee\Route $route The route object @throws \RuntimeException If a named route already exists with the same name
[ "Add", "named", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Router.php#L205-L211
yeephp/yeephp
Yee/Router.php
Router.getNamedRoute
public function getNamedRoute($name) { $this->getNamedRoutes(); if ($this->hasNamedRoute($name)) { return $this->namedRoutes[(string) $name]; } else { return null; } }
php
public function getNamedRoute($name) { $this->getNamedRoutes(); if ($this->hasNamedRoute($name)) { return $this->namedRoutes[(string) $name]; } else { return null; } }
[ "public", "function", "getNamedRoute", "(", "$", "name", ")", "{", "$", "this", "->", "getNamedRoutes", "(", ")", ";", "if", "(", "$", "this", "->", "hasNamedRoute", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "namedRoutes", "[", "(...
Get named route @param string $name @return \Yee\Route|null
[ "Get", "named", "route" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Router.php#L230-L238
bigwhoop/sentence-breaker
src/Rules/Rules.php
Rules.getRule
public function getRule($tokenName) { if (!array_key_exists($tokenName, $this->rules)) { throw new ConfigurationException("No rule for {$tokenName} defined."); } return $this->rules[$tokenName]; }
php
public function getRule($tokenName) { if (!array_key_exists($tokenName, $this->rules)) { throw new ConfigurationException("No rule for {$tokenName} defined."); } return $this->rules[$tokenName]; }
[ "public", "function", "getRule", "(", "$", "tokenName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "tokenName", ",", "$", "this", "->", "rules", ")", ")", "{", "throw", "new", "ConfigurationException", "(", "\"No rule for {$tokenName} defined.\"", ...
@param string $tokenName @return Rule @throws ConfigurationException
[ "@param", "string", "$tokenName" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/Rules/Rules.php#L73-L80
marvin255/bxcodegen
src/service/filesystem/Copier.php
Copier.copyFile
public function copyFile(FileInterface $source, FileInterface $destination) { if (!$this->transform($source, $destination)) { $res = copy($source->getPathname(), $destination->getPathname()); if ($res === false) { throw new InvalidArgumentException( "Can't copy " . $source->getPathname() . ' to ' . $destination->getPathname() ); } } return $this; }
php
public function copyFile(FileInterface $source, FileInterface $destination) { if (!$this->transform($source, $destination)) { $res = copy($source->getPathname(), $destination->getPathname()); if ($res === false) { throw new InvalidArgumentException( "Can't copy " . $source->getPathname() . ' to ' . $destination->getPathname() ); } } return $this; }
[ "public", "function", "copyFile", "(", "FileInterface", "$", "source", ",", "FileInterface", "$", "destination", ")", "{", "if", "(", "!", "$", "this", "->", "transform", "(", "$", "source", ",", "$", "destination", ")", ")", "{", "$", "res", "=", "cop...
{@inheritdoc} @throws \InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/Copier.php#L43-L55
marvin255/bxcodegen
src/service/filesystem/Copier.php
Copier.transform
protected function transform($from, $to) { $return = false; foreach ($this->transformers as $transformer) { $res = call_user_func_array($transformer, [$from, $to]); if ($res === true) { $return = true; break; } } return $return; }
php
protected function transform($from, $to) { $return = false; foreach ($this->transformers as $transformer) { $res = call_user_func_array($transformer, [$from, $to]); if ($res === true) { $return = true; break; } } return $return; }
[ "protected", "function", "transform", "(", "$", "from", ",", "$", "to", ")", "{", "$", "return", "=", "false", ";", "foreach", "(", "$", "this", "->", "transformers", "as", "$", "transformer", ")", "{", "$", "res", "=", "call_user_func_array", "(", "$"...
Запускает события для того, чтобы изменить содержимое файлов при копировании или отменить копирование какого-нибудь каталога совсем. Если функция вернет правду, то, значит, сработало одно из событий и стандартное копирование будет отменено. @param mixed $from @param mixed $to @return bool
[ "Запускает", "события", "для", "того", "чтобы", "изменить", "содержимое", "файлов", "при", "копировании", "или", "отменить", "копирование", "какого", "-", "нибудь", "каталога", "совсем", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/Copier.php#L97-L110
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/SafeLocalAdapterFactory.php
SafeLocalAdapterFactory.create
function create(ContainerBuilder $container, $id, array $config) { $container->setDefinition($id, new Definition("Gaufrette\\Adapter\\SafeLocal", array( $config['directory'], $config['create'] ))); }
php
function create(ContainerBuilder $container, $id, array $config) { $container->setDefinition($id, new Definition("Gaufrette\\Adapter\\SafeLocal", array( $config['directory'], $config['create'] ))); }
[ "function", "create", "(", "ContainerBuilder", "$", "container", ",", "$", "id", ",", "array", "$", "config", ")", "{", "$", "container", "->", "setDefinition", "(", "$", "id", ",", "new", "Definition", "(", "\"Gaufrette\\\\Adapter\\\\SafeLocal\"", ",", "array...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/SafeLocalAdapterFactory.php#L14-L20
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/SafeLocalAdapterFactory.php
SafeLocalAdapterFactory.addConfiguration
function addConfiguration(NodeDefinition $builder) { $builder ->children() ->scalarNode('directory')->isRequired()->end() ->booleanNode('create')->defaultTrue()->end() ->end() ; }
php
function addConfiguration(NodeDefinition $builder) { $builder ->children() ->scalarNode('directory')->isRequired()->end() ->booleanNode('create')->defaultTrue()->end() ->end() ; }
[ "function", "addConfiguration", "(", "NodeDefinition", "$", "builder", ")", "{", "$", "builder", "->", "children", "(", ")", "->", "scalarNode", "(", "'directory'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'creat...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/SafeLocalAdapterFactory.php#L33-L41
baleen/migrations
src/Delta/Collection/Resolver/AbstractResolver.php
AbstractResolver.resolve
final public function resolve($alias, Collection $collection) { $alias = (string) $alias; $result = $this->cacheGet($alias, $collection); if (false === $result) { $result = $this->doResolve($alias, $collection); if (null !== $result && !$result instanceof DeltaInterface) { throw new ResolverException('Expected result to be either a DeltaInterface object or null.'); } $this->cacheSet($alias, $collection, $result); } return $result; }
php
final public function resolve($alias, Collection $collection) { $alias = (string) $alias; $result = $this->cacheGet($alias, $collection); if (false === $result) { $result = $this->doResolve($alias, $collection); if (null !== $result && !$result instanceof DeltaInterface) { throw new ResolverException('Expected result to be either a DeltaInterface object or null.'); } $this->cacheSet($alias, $collection, $result); } return $result; }
[ "final", "public", "function", "resolve", "(", "$", "alias", ",", "Collection", "$", "collection", ")", "{", "$", "alias", "=", "(", "string", ")", "$", "alias", ";", "$", "result", "=", "$", "this", "->", "cacheGet", "(", "$", "alias", ",", "$", "...
Resolves an alias into a Delta. @param string $alias @param Collection $collection @return DeltaInterface|null @throws ResolverException
[ "Resolves", "an", "alias", "into", "a", "Delta", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/AbstractResolver.php#L56-L71
baleen/migrations
src/Delta/Collection/Resolver/AbstractResolver.php
AbstractResolver.cacheGet
private function cacheGet($alias, Collection $collection) { $result = false; if ($this->cacheEnabled) { $hash = spl_object_hash($collection); if (isset($this->cache[$hash]) && array_key_exists($alias, $this->cache[$hash])) { $result = $this->cache[$hash][$alias]; } } return $result; }
php
private function cacheGet($alias, Collection $collection) { $result = false; if ($this->cacheEnabled) { $hash = spl_object_hash($collection); if (isset($this->cache[$hash]) && array_key_exists($alias, $this->cache[$hash])) { $result = $this->cache[$hash][$alias]; } } return $result; }
[ "private", "function", "cacheGet", "(", "$", "alias", ",", "Collection", "$", "collection", ")", "{", "$", "result", "=", "false", ";", "if", "(", "$", "this", "->", "cacheEnabled", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "collection", ...
Gets an alias from the cache. Returns false if nothing could be found, a Delta if the alias was previously resolved to a version, and null if the alias couldn't be resolved in a previous call. @param string $alias @param Collection $collection @return bool|null|DeltaInterface
[ "Gets", "an", "alias", "from", "the", "cache", ".", "Returns", "false", "if", "nothing", "could", "be", "found", "a", "Delta", "if", "the", "alias", "was", "previously", "resolved", "to", "a", "version", "and", "null", "if", "the", "alias", "couldn", "t"...
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/AbstractResolver.php#L82-L94
baleen/migrations
src/Delta/Collection/Resolver/AbstractResolver.php
AbstractResolver.cacheSet
private function cacheSet($alias, $collection, $result) { if (!$this->cacheEnabled) { return null; } $hash = spl_object_hash($collection); if (!isset($this->cache[$hash])) { $this->cache[$hash] = []; // initialize the collection's cache } $this->cache[$hash][$alias] = $result; }
php
private function cacheSet($alias, $collection, $result) { if (!$this->cacheEnabled) { return null; } $hash = spl_object_hash($collection); if (!isset($this->cache[$hash])) { $this->cache[$hash] = []; // initialize the collection's cache } $this->cache[$hash][$alias] = $result; }
[ "private", "function", "cacheSet", "(", "$", "alias", ",", "$", "collection", ",", "$", "result", ")", "{", "if", "(", "!", "$", "this", "->", "cacheEnabled", ")", "{", "return", "null", ";", "}", "$", "hash", "=", "spl_object_hash", "(", "$", "colle...
Saves the result of resolving an alias against a given collection into the cache. @param string $alias @param \Baleen\Migrations\Delta\Collection\Collection $collection @param null|DeltaInterface $result @return void
[ "Saves", "the", "result", "of", "resolving", "an", "alias", "against", "a", "given", "collection", "into", "the", "cache", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/AbstractResolver.php#L105-L116
skrz/meta
gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php
FieldOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FieldOptions(); case 1: return new FieldOptions(func_get_arg(0)); case 2: return new FieldOptions(func_get_arg(0), func_get_arg(1)); case 3: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FieldOptions(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 FieldOptions(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 FieldOptions(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 FieldOptions(); case 1: return new FieldOptions(func_get_arg(0)); case 2: return new FieldOptions(func_get_arg(0), func_get_arg(1)); case 3: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FieldOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FieldOptions(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 FieldOptions(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 FieldOptions(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", "FieldOptions", "(", ")", ";", "case", "1", ":", "return", "new", "FieldOptions", "(", "func_get_arg", "(", ...
Creates new instance of \Google\Protobuf\FieldOptions @throws \InvalidArgumentException @return FieldOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php#L63-L87
skrz/meta
gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php
FieldOptionsMeta.reset
public static function reset($object) { if (!($object instanceof FieldOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldOptions.'); } $object->ctype = NULL; $object->packed = NULL; $object->jstype = NULL; $object->lazy = NULL; $object->deprecated = NULL; $object->weak = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof FieldOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldOptions.'); } $object->ctype = NULL; $object->packed = NULL; $object->jstype = NULL; $object->lazy = NULL; $object->deprecated = NULL; $object->weak = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "FieldOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\FieldO...
Resets properties of \Google\Protobuf\FieldOptions to default values @param FieldOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php#L100-L112
skrz/meta
gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php
FieldOptionsMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->ctype)) { hash_update($ctx, 'ctype'); hash_update($ctx, (string)$object->ctype); } if (isset($object->packed)) { hash_update($ctx, 'packed'); hash_update($ctx, (string)$object->packed); } if (isset($object->jstype)) { hash_update($ctx, 'jstype'); hash_update($ctx, (string)$object->jstype); } if (isset($object->lazy)) { hash_update($ctx, 'lazy'); hash_update($ctx, (string)$object->lazy); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->weak)) { hash_update($ctx, 'weak'); hash_update($ctx, (string)$object->weak); } 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->ctype)) { hash_update($ctx, 'ctype'); hash_update($ctx, (string)$object->ctype); } if (isset($object->packed)) { hash_update($ctx, 'packed'); hash_update($ctx, (string)$object->packed); } if (isset($object->jstype)) { hash_update($ctx, 'jstype'); hash_update($ctx, (string)$object->jstype); } if (isset($object->lazy)) { hash_update($ctx, 'lazy'); hash_update($ctx, (string)$object->lazy); } if (isset($object->deprecated)) { hash_update($ctx, 'deprecated'); hash_update($ctx, (string)$object->deprecated); } if (isset($object->weak)) { hash_update($ctx, 'weak'); hash_update($ctx, (string)$object->weak); } 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\FieldOptions @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "FieldOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php#L124-L174
skrz/meta
gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php
FieldOptionsMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FieldOptions(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ctype = Binary::decodeVarint($input, $start); break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->packed = (bool)Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->jstype = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->lazy = (bool)Binary::decodeVarint($input, $start); break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->weak = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new FieldOptions(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->ctype = Binary::decodeVarint($input, $start); break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->packed = (bool)Binary::decodeVarint($input, $start); break; case 6: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->jstype = Binary::decodeVarint($input, $start); break; case 5: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->lazy = (bool)Binary::decodeVarint($input, $start); break; case 3: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->deprecated = (bool)Binary::decodeVarint($input, $start); break; case 10: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->weak = (bool)Binary::decodeVarint($input, $start); break; case 999: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) { $object->uninterpretedOption = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\FieldOptions object from serialized Protocol Buffers message. @param string $input @param FieldOptions $object @param int $start @param int $end @throws \Exception @return FieldOptions
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "FieldOptions", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php#L189-L278
skrz/meta
gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php
FieldOptionsMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->ctype) && ($filter === null || isset($filter['ctype']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->ctype); } if (isset($object->packed) && ($filter === null || isset($filter['packed']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->packed); } if (isset($object->jstype) && ($filter === null || isset($filter['jstype']))) { $output .= "\x30"; $output .= Binary::encodeVarint($object->jstype); } if (isset($object->lazy) && ($filter === null || isset($filter['lazy']))) { $output .= "\x28"; $output .= Binary::encodeVarint((int)$object->lazy); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->weak) && ($filter === null || isset($filter['weak']))) { $output .= "\x50"; $output .= Binary::encodeVarint((int)$object->weak); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->ctype) && ($filter === null || isset($filter['ctype']))) { $output .= "\x08"; $output .= Binary::encodeVarint($object->ctype); } if (isset($object->packed) && ($filter === null || isset($filter['packed']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->packed); } if (isset($object->jstype) && ($filter === null || isset($filter['jstype']))) { $output .= "\x30"; $output .= Binary::encodeVarint($object->jstype); } if (isset($object->lazy) && ($filter === null || isset($filter['lazy']))) { $output .= "\x28"; $output .= Binary::encodeVarint((int)$object->lazy); } if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) { $output .= "\x18"; $output .= Binary::encodeVarint((int)$object->deprecated); } if (isset($object->weak) && ($filter === null || isset($filter['weak']))) { $output .= "\x50"; $output .= Binary::encodeVarint((int)$object->weak); } if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) { foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) { $output .= "\xba\x3e"; $buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "ctype", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\FieldOptions to Protocol Buffers message. @param FieldOptions $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "FieldOptions", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldOptionsMeta.php#L291-L335
nymo/silex-twig-breadcrumb-extension
src/nymo/Resources/Library/BreadCrumbCollection.php
BreadCrumbCollection.addItem
public function addItem($linkName, $target = null) { if (is_array($target)) { $target = isset($target['params']) ? $this->urlGen->generate( $target['route'], $target['params'] ) : $this->urlGen->generate($target['route']); } $this->items[] = ["linkName" => $linkName, "target" => $target]; }
php
public function addItem($linkName, $target = null) { if (is_array($target)) { $target = isset($target['params']) ? $this->urlGen->generate( $target['route'], $target['params'] ) : $this->urlGen->generate($target['route']); } $this->items[] = ["linkName" => $linkName, "target" => $target]; }
[ "public", "function", "addItem", "(", "$", "linkName", ",", "$", "target", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "target", ")", ")", "{", "$", "target", "=", "isset", "(", "$", "target", "[", "'params'", "]", ")", "?", "$", "thi...
Add new breadcrumb item @param string $linkName @param string|null $target @deprecated since 3.0 will be removed in 3.1 use function addSimpleItem or addRouteItem instead @return void
[ "Add", "new", "breadcrumb", "item" ]
train
https://github.com/nymo/silex-twig-breadcrumb-extension/blob/9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56/src/nymo/Resources/Library/BreadCrumbCollection.php#L38-L47
nymo/silex-twig-breadcrumb-extension
src/nymo/Resources/Library/BreadCrumbCollection.php
BreadCrumbCollection.addSimpleItem
public function addSimpleItem(string $linkName, string $target = null): void { $this->items[] = ["linkName" => $linkName, "target" => $target]; }
php
public function addSimpleItem(string $linkName, string $target = null): void { $this->items[] = ["linkName" => $linkName, "target" => $target]; }
[ "public", "function", "addSimpleItem", "(", "string", "$", "linkName", ",", "string", "$", "target", "=", "null", ")", ":", "void", "{", "$", "this", "->", "items", "[", "]", "=", "[", "\"linkName\"", "=>", "$", "linkName", ",", "\"target\"", "=>", "$"...
Adds new simple breadcrumb item. Leave target empty to create a breadcrumb item without a link. @param string $linkName @param string|null $target @return void
[ "Adds", "new", "simple", "breadcrumb", "item", ".", "Leave", "target", "empty", "to", "create", "a", "breadcrumb", "item", "without", "a", "link", "." ]
train
https://github.com/nymo/silex-twig-breadcrumb-extension/blob/9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56/src/nymo/Resources/Library/BreadCrumbCollection.php#L55-L58
nymo/silex-twig-breadcrumb-extension
src/nymo/Resources/Library/BreadCrumbCollection.php
BreadCrumbCollection.addRouteItem
public function addRouteItem(string $linkName, array $route): void { $url = isset($route['params']) ? $this->urlGen->generate($route['route'], $route['params']) : $this->urlGen->generate($route['route']); $this->addSimpleItem($linkName, $url); }
php
public function addRouteItem(string $linkName, array $route): void { $url = isset($route['params']) ? $this->urlGen->generate($route['route'], $route['params']) : $this->urlGen->generate($route['route']); $this->addSimpleItem($linkName, $url); }
[ "public", "function", "addRouteItem", "(", "string", "$", "linkName", ",", "array", "$", "route", ")", ":", "void", "{", "$", "url", "=", "isset", "(", "$", "route", "[", "'params'", "]", ")", "?", "$", "this", "->", "urlGen", "->", "generate", "(", ...
Adds new breadcrumb item where target is being generated by the url generator @param string $linkName @param array $route @return void
[ "Adds", "new", "breadcrumb", "item", "where", "target", "is", "being", "generated", "by", "the", "url", "generator" ]
train
https://github.com/nymo/silex-twig-breadcrumb-extension/blob/9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56/src/nymo/Resources/Library/BreadCrumbCollection.php#L66-L72
Flowpack/jobqueue-beanstalkd
Classes/Queue/BeanstalkdQueue.php
BeanstalkdQueue.peek
public function peek(int $limit = 1): array { if ($limit !== 1) { throw new JobQueueException('The beanstalkd Jobqueue implementation currently only supports to peek one job at a time', 1352717703); } try { $pheanstalkJob = $this->client->peekReady($this->name); } catch (ServerException $exception) { return []; } if ($pheanstalkJob === null || $pheanstalkJob === false) { return []; } return [new Message((string)$pheanstalkJob->getId(), json_decode($pheanstalkJob->getData(), true))]; }
php
public function peek(int $limit = 1): array { if ($limit !== 1) { throw new JobQueueException('The beanstalkd Jobqueue implementation currently only supports to peek one job at a time', 1352717703); } try { $pheanstalkJob = $this->client->peekReady($this->name); } catch (ServerException $exception) { return []; } if ($pheanstalkJob === null || $pheanstalkJob === false) { return []; } return [new Message((string)$pheanstalkJob->getId(), json_decode($pheanstalkJob->getData(), true))]; }
[ "public", "function", "peek", "(", "int", "$", "limit", "=", "1", ")", ":", "array", "{", "if", "(", "$", "limit", "!==", "1", ")", "{", "throw", "new", "JobQueueException", "(", "'The beanstalkd Jobqueue implementation currently only supports to peek one job at a t...
@inheritdoc NOTE: The beanstalkd implementation only supports to peek the UPCOMING job, so this will throw an exception for $limit != 1. @throws JobQueueException
[ "@inheritdoc", "NOTE", ":", "The", "beanstalkd", "implementation", "only", "supports", "to", "peek", "the", "UPCOMING", "job", "so", "this", "will", "throw", "an", "exception", "for", "$limit", "!", "=", "1", "." ]
train
https://github.com/Flowpack/jobqueue-beanstalkd/blob/13338e2649edae23d47f0f117ab32a3d956cd63a/Classes/Queue/BeanstalkdQueue.php#L153-L168
kss-php/kss-php
lib/Section.php
Section.getTitle
public function getTitle() { $title = ''; $titleComment = $this->getTitleComment(); if (preg_match('/^\s*#+\s*(.+)/', $titleComment, $matches)) { $title = $matches[1]; } elseif (self::isReferenceNumeric($this->getReference())) { return $this->getReference(); } else { $reference = $this->getReferenceParts(); return end($reference); } return $title; }
php
public function getTitle() { $title = ''; $titleComment = $this->getTitleComment(); if (preg_match('/^\s*#+\s*(.+)/', $titleComment, $matches)) { $title = $matches[1]; } elseif (self::isReferenceNumeric($this->getReference())) { return $this->getReference(); } else { $reference = $this->getReferenceParts(); return end($reference); } return $title; }
[ "public", "function", "getTitle", "(", ")", "{", "$", "title", "=", "''", ";", "$", "titleComment", "=", "$", "this", "->", "getTitleComment", "(", ")", ";", "if", "(", "preg_match", "(", "'/^\\s*#+\\s*(.+)/'", ",", "$", "titleComment", ",", "$", "matche...
Returns the title of the section @return string
[ "Returns", "the", "title", "of", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L108-L123
kss-php/kss-php
lib/Section.php
Section.getDescription
public function getDescription() { $descriptionSections = array(); foreach ($this->getCommentSections() as $commentSection) { // Anything that is not the section comment or modifiers comment // must be the description comment if ($commentSection != $this->getReferenceComment() && $commentSection != $this->getTitleComment() && $commentSection != $this->getMarkupComment() && $commentSection != $this->getDeprecatedComment() && $commentSection != $this->getExperimentalComment() && $commentSection != $this->getCompatibilityComment() && $commentSection != $this->getModifiersComment() && $commentSection != $this->getParametersComment() ) { $descriptionSections[] = $commentSection; } } return implode("\n\n", $descriptionSections); }
php
public function getDescription() { $descriptionSections = array(); foreach ($this->getCommentSections() as $commentSection) { // Anything that is not the section comment or modifiers comment // must be the description comment if ($commentSection != $this->getReferenceComment() && $commentSection != $this->getTitleComment() && $commentSection != $this->getMarkupComment() && $commentSection != $this->getDeprecatedComment() && $commentSection != $this->getExperimentalComment() && $commentSection != $this->getCompatibilityComment() && $commentSection != $this->getModifiersComment() && $commentSection != $this->getParametersComment() ) { $descriptionSections[] = $commentSection; } } return implode("\n\n", $descriptionSections); }
[ "public", "function", "getDescription", "(", ")", "{", "$", "descriptionSections", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Anything that is not the section comment o...
Returns the description for the section @return string
[ "Returns", "the", "description", "for", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L130-L151
kss-php/kss-php
lib/Section.php
Section.getMarkup
public function getMarkup() { if ($this->markup === null) { if ($markupComment = $this->getMarkupComment()) { $this->markup = trim(preg_replace('/^\s*Markup:/i', '', $markupComment)); } } return $this->markup; }
php
public function getMarkup() { if ($this->markup === null) { if ($markupComment = $this->getMarkupComment()) { $this->markup = trim(preg_replace('/^\s*Markup:/i', '', $markupComment)); } } return $this->markup; }
[ "public", "function", "getMarkup", "(", ")", "{", "if", "(", "$", "this", "->", "markup", "===", "null", ")", "{", "if", "(", "$", "markupComment", "=", "$", "this", "->", "getMarkupComment", "(", ")", ")", "{", "$", "this", "->", "markup", "=", "t...
Returns the markup defined in the section @return string
[ "Returns", "the", "markup", "defined", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L158-L167
kss-php/kss-php
lib/Section.php
Section.getDeprecated
public function getDeprecated() { if ($this->deprecated === null) { if ($deprecatedComment = $this->getDeprecatedComment()) { $this->deprecated = trim(preg_replace('/^\s*Deprecated:/i', '', $deprecatedComment)); } } return $this->deprecated; }
php
public function getDeprecated() { if ($this->deprecated === null) { if ($deprecatedComment = $this->getDeprecatedComment()) { $this->deprecated = trim(preg_replace('/^\s*Deprecated:/i', '', $deprecatedComment)); } } return $this->deprecated; }
[ "public", "function", "getDeprecated", "(", ")", "{", "if", "(", "$", "this", "->", "deprecated", "===", "null", ")", "{", "if", "(", "$", "deprecatedComment", "=", "$", "this", "->", "getDeprecatedComment", "(", ")", ")", "{", "$", "this", "->", "depr...
Returns the deprecation notice defined in the section @return string
[ "Returns", "the", "deprecation", "notice", "defined", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L195-L204
kss-php/kss-php
lib/Section.php
Section.getExperimental
public function getExperimental() { if ($this->experimental === null) { if ($experimentalComment = $this->getExperimentalComment()) { $this->experimental = trim(preg_replace('/^\s*Experimental:/i', '', $experimentalComment)); } } return $this->experimental; }
php
public function getExperimental() { if ($this->experimental === null) { if ($experimentalComment = $this->getExperimentalComment()) { $this->experimental = trim(preg_replace('/^\s*Experimental:/i', '', $experimentalComment)); } } return $this->experimental; }
[ "public", "function", "getExperimental", "(", ")", "{", "if", "(", "$", "this", "->", "experimental", "===", "null", ")", "{", "if", "(", "$", "experimentalComment", "=", "$", "this", "->", "getExperimentalComment", "(", ")", ")", "{", "$", "this", "->",...
Returns the experimental notice defined in the section @return string
[ "Returns", "the", "experimental", "notice", "defined", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L211-L220
kss-php/kss-php
lib/Section.php
Section.getCompatibility
public function getCompatibility() { if ($this->compatibility === null) { if ($compatibilityComment = $this->getCompatibilityComment()) { $this->compatibility = trim($compatibilityComment); } } return $this->compatibility; }
php
public function getCompatibility() { if ($this->compatibility === null) { if ($compatibilityComment = $this->getCompatibilityComment()) { $this->compatibility = trim($compatibilityComment); } } return $this->compatibility; }
[ "public", "function", "getCompatibility", "(", ")", "{", "if", "(", "$", "this", "->", "compatibility", "===", "null", ")", "{", "if", "(", "$", "compatibilityComment", "=", "$", "this", "->", "getCompatibilityComment", "(", ")", ")", "{", "$", "this", "...
Returns the compatibility notice defined in the section @return string
[ "Returns", "the", "compatibility", "notice", "defined", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L227-L236
kss-php/kss-php
lib/Section.php
Section.getModifiers
public function getModifiers() { $lastIndent = null; $modifiers = array(); if ($modiferComment = $this->getModifiersComment()) { $modifierLines = explode("\n", $modiferComment); foreach ($modifierLines as $line) { if (empty($line)) { continue; } preg_match('/^\s*/', $line, $matches); $indent = strlen($matches[0]); if ($lastIndent && $indent > $lastIndent) { $modifier = end($modifiers); $modifier->setDescription($modifier->getDescription() + trim($line)); } else { $lineParts = explode(' - ', $line); $name = trim(array_shift($lineParts)); $description = ''; if (!empty($lineParts)) { $description = trim(implode(' - ', $lineParts)); } $modifier = new Modifier($name, $description); // If the CSS has a markup, pass it to the modifier for the example HTML if ($markup = $this->getMarkup()) { $modifier->setMarkup($markup); } $modifiers[] = $modifier; } } } return $modifiers; }
php
public function getModifiers() { $lastIndent = null; $modifiers = array(); if ($modiferComment = $this->getModifiersComment()) { $modifierLines = explode("\n", $modiferComment); foreach ($modifierLines as $line) { if (empty($line)) { continue; } preg_match('/^\s*/', $line, $matches); $indent = strlen($matches[0]); if ($lastIndent && $indent > $lastIndent) { $modifier = end($modifiers); $modifier->setDescription($modifier->getDescription() + trim($line)); } else { $lineParts = explode(' - ', $line); $name = trim(array_shift($lineParts)); $description = ''; if (!empty($lineParts)) { $description = trim(implode(' - ', $lineParts)); } $modifier = new Modifier($name, $description); // If the CSS has a markup, pass it to the modifier for the example HTML if ($markup = $this->getMarkup()) { $modifier->setMarkup($markup); } $modifiers[] = $modifier; } } } return $modifiers; }
[ "public", "function", "getModifiers", "(", ")", "{", "$", "lastIndent", "=", "null", ";", "$", "modifiers", "=", "array", "(", ")", ";", "if", "(", "$", "modiferComment", "=", "$", "this", "->", "getModifiersComment", "(", ")", ")", "{", "$", "modifier...
Returns the modifiers used in the section @return array
[ "Returns", "the", "modifiers", "used", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L243-L282
kss-php/kss-php
lib/Section.php
Section.getParameters
public function getParameters() { $lastIndent = null; $parameters = array(); if ($parameterComment = $this->getParametersComment()) { $parameterLines = explode("\n", $parameterComment); foreach ($parameterLines as $line) { if (empty($line)) { continue; } $lineParts = explode(' - ', $line); $name = trim(array_shift($lineParts)); $description = ''; if (!empty($lineParts)) { $description = trim(implode(' - ', $lineParts)); } $parameter = new Parameter($name, $description); $parameters[] = $parameter; } } return $parameters; }
php
public function getParameters() { $lastIndent = null; $parameters = array(); if ($parameterComment = $this->getParametersComment()) { $parameterLines = explode("\n", $parameterComment); foreach ($parameterLines as $line) { if (empty($line)) { continue; } $lineParts = explode(' - ', $line); $name = trim(array_shift($lineParts)); $description = ''; if (!empty($lineParts)) { $description = trim(implode(' - ', $lineParts)); } $parameter = new Parameter($name, $description); $parameters[] = $parameter; } } return $parameters; }
[ "public", "function", "getParameters", "(", ")", "{", "$", "lastIndent", "=", "null", ";", "$", "parameters", "=", "array", "(", ")", ";", "if", "(", "$", "parameterComment", "=", "$", "this", "->", "getParametersComment", "(", ")", ")", "{", "$", "par...
Returns the $parameters used in the section @return array
[ "Returns", "the", "$parameters", "used", "in", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L289-L316
kss-php/kss-php
lib/Section.php
Section.getReference
public function getReference($trimmed = false) { if ($this->reference === null) { $referenceComment = $this->getReferenceComment(); $referenceComment = preg_replace('/\.$/', '', $referenceComment); if (preg_match('/^\s*Styleguide\s+(.*)/i', $referenceComment, $matches)) { $this->reference = trim($matches[1]); } } return ($trimmed && $this->reference !== null) ? self::trimReference($this->reference) : $this->reference; }
php
public function getReference($trimmed = false) { if ($this->reference === null) { $referenceComment = $this->getReferenceComment(); $referenceComment = preg_replace('/\.$/', '', $referenceComment); if (preg_match('/^\s*Styleguide\s+(.*)/i', $referenceComment, $matches)) { $this->reference = trim($matches[1]); } } return ($trimmed && $this->reference !== null) ? self::trimReference($this->reference) : $this->reference; }
[ "public", "function", "getReference", "(", "$", "trimmed", "=", "false", ")", "{", "if", "(", "$", "this", "->", "reference", "===", "null", ")", "{", "$", "referenceComment", "=", "$", "this", "->", "getReferenceComment", "(", ")", ";", "$", "referenceC...
Returns the reference number for the section @param boolean $trimmed OPTIONAL @return string
[ "Returns", "the", "reference", "number", "for", "the", "section" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L337-L351
kss-php/kss-php
lib/Section.php
Section.getReferenceDotDelimited
protected function getReferenceDotDelimited() { if (empty($this->referenceDotDelimited)) { $this->referenceDotDelimited = self::normalizeReference($this->getReference()); } return $this->referenceDotDelimited; }
php
protected function getReferenceDotDelimited() { if (empty($this->referenceDotDelimited)) { $this->referenceDotDelimited = self::normalizeReference($this->getReference()); } return $this->referenceDotDelimited; }
[ "protected", "function", "getReferenceDotDelimited", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "referenceDotDelimited", ")", ")", "{", "$", "this", "->", "referenceDotDelimited", "=", "self", "::", "normalizeReference", "(", "$", "this", "->",...
Returns the reference dot delimited @return string
[ "Returns", "the", "reference", "dot", "delimited" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L358-L364
kss-php/kss-php
lib/Section.php
Section.trimReference
public static function trimReference($reference) { if (substr($reference, -1) == '.' || substr($reference, -1) == '-') { $reference = trim(substr($reference, 0, -1)); } while (preg_match('/(\.0+)$/', $reference, $matches)) { $reference = substr($reference, 0, strlen($matches[1]) * -1); } return $reference; }
php
public static function trimReference($reference) { if (substr($reference, -1) == '.' || substr($reference, -1) == '-') { $reference = trim(substr($reference, 0, -1)); } while (preg_match('/(\.0+)$/', $reference, $matches)) { $reference = substr($reference, 0, strlen($matches[1]) * -1); } return $reference; }
[ "public", "static", "function", "trimReference", "(", "$", "reference", ")", "{", "if", "(", "substr", "(", "$", "reference", ",", "-", "1", ")", "==", "'.'", "||", "substr", "(", "$", "reference", ",", "-", "1", ")", "==", "'-'", ")", "{", "$", ...
Trims off all trailing zeros and periods on a reference @param string $reference @return string
[ "Trims", "off", "all", "trailing", "zeros", "and", "periods", "on", "a", "reference" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L405-L414
kss-php/kss-php
lib/Section.php
Section.belongsToReference
public function belongsToReference($reference) { $reference = self::trimReference($reference); $reference = self::normalizeReference($reference); return stripos($this->getReferenceDotDelimited() . '.', $reference . '.') === 0; }
php
public function belongsToReference($reference) { $reference = self::trimReference($reference); $reference = self::normalizeReference($reference); return stripos($this->getReferenceDotDelimited() . '.', $reference . '.') === 0; }
[ "public", "function", "belongsToReference", "(", "$", "reference", ")", "{", "$", "reference", "=", "self", "::", "trimReference", "(", "$", "reference", ")", ";", "$", "reference", "=", "self", "::", "normalizeReference", "(", "$", "reference", ")", ";", ...
Checks to see if a section belongs to a specified reference @param string $reference @return boolean
[ "Checks", "to", "see", "if", "a", "section", "belongs", "to", "a", "specified", "reference" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L435-L440
kss-php/kss-php
lib/Section.php
Section.calcDepth
public static function calcDepth($reference) { $reference = self::trimReference($reference); $reference = self::normalizeReference($reference); return substr_count($reference, '.'); }
php
public static function calcDepth($reference) { $reference = self::trimReference($reference); $reference = self::normalizeReference($reference); return substr_count($reference, '.'); }
[ "public", "static", "function", "calcDepth", "(", "$", "reference", ")", "{", "$", "reference", "=", "self", "::", "trimReference", "(", "$", "reference", ")", ";", "$", "reference", "=", "self", "::", "normalizeReference", "(", "$", "reference", ")", ";",...
Calculates and returns the depth of a section reference @param string $reference @return int
[ "Calculates", "and", "returns", "the", "depth", "of", "a", "section", "reference" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L459-L464
kss-php/kss-php
lib/Section.php
Section.calcDepthScore
public static function calcDepthScore($reference) { if (!self::isReferenceNumeric($reference)) { return null; } $reference = self::trimReference($reference); $sectionParts = explode('.', $reference); $score = 0; foreach ($sectionParts as $level => $part) { $score += $part * (1 / pow(10, $level)); } return $score; }
php
public static function calcDepthScore($reference) { if (!self::isReferenceNumeric($reference)) { return null; } $reference = self::trimReference($reference); $sectionParts = explode('.', $reference); $score = 0; foreach ($sectionParts as $level => $part) { $score += $part * (1 / pow(10, $level)); } return $score; }
[ "public", "static", "function", "calcDepthScore", "(", "$", "reference", ")", "{", "if", "(", "!", "self", "::", "isReferenceNumeric", "(", "$", "reference", ")", ")", "{", "return", "null", ";", "}", "$", "reference", "=", "self", "::", "trimReference", ...
Calculates and returns the depth score for the section. Useful for sorting sections correctly by their section reference numbers @return int|null
[ "Calculates", "and", "returns", "the", "depth", "score", "for", "the", "section", ".", "Useful", "for", "sorting", "sections", "correctly", "by", "their", "section", "reference", "numbers" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L482-L494
kss-php/kss-php
lib/Section.php
Section.depthSort
public static function depthSort(Section $a, Section $b) { if ($a->getDepth() == $b->getDepth()) { return self::alphaDepthScoreSort($a, $b); } return $a->getDepth() > $b->getDepth(); }
php
public static function depthSort(Section $a, Section $b) { if ($a->getDepth() == $b->getDepth()) { return self::alphaDepthScoreSort($a, $b); } return $a->getDepth() > $b->getDepth(); }
[ "public", "static", "function", "depthSort", "(", "Section", "$", "a", ",", "Section", "$", "b", ")", "{", "if", "(", "$", "a", "->", "getDepth", "(", ")", "==", "$", "b", "->", "getDepth", "(", ")", ")", "{", "return", "self", "::", "alphaDepthSco...
Function to help sort sections by depth and then depth score or alphabetically @param Section $a @param Section $b @return int
[ "Function", "to", "help", "sort", "sections", "by", "depth", "and", "then", "depth", "score", "or", "alphabetically" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L504-L510
kss-php/kss-php
lib/Section.php
Section.alphaDepthScoreSort
public static function alphaDepthScoreSort(Section $a, Section $b) { $aNumeric = self::isReferenceNumeric($a->getReference()); $bNumeric = self::isReferenceNumeric($b->getReference()); if ($aNumeric && $bNumeric) { return self::depthScoreSort($a, $b); } elseif ($aNumeric) { return -1; } elseif ($bNumeric) { return 1; } else { return strnatcmp( $a->getReferenceDotDelimited(), $b->getReferenceDotDelimited() ); } }
php
public static function alphaDepthScoreSort(Section $a, Section $b) { $aNumeric = self::isReferenceNumeric($a->getReference()); $bNumeric = self::isReferenceNumeric($b->getReference()); if ($aNumeric && $bNumeric) { return self::depthScoreSort($a, $b); } elseif ($aNumeric) { return -1; } elseif ($bNumeric) { return 1; } else { return strnatcmp( $a->getReferenceDotDelimited(), $b->getReferenceDotDelimited() ); } }
[ "public", "static", "function", "alphaDepthScoreSort", "(", "Section", "$", "a", ",", "Section", "$", "b", ")", "{", "$", "aNumeric", "=", "self", "::", "isReferenceNumeric", "(", "$", "a", "->", "getReference", "(", ")", ")", ";", "$", "bNumeric", "=", ...
Function to help sort sections either by their depth score if numeric or alphabetically if non-numeric. @param Section $a @param Section $b @return int
[ "Function", "to", "help", "sort", "sections", "either", "by", "their", "depth", "score", "if", "numeric", "or", "alphabetically", "if", "non", "-", "numeric", "." ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L534-L551
kss-php/kss-php
lib/Section.php
Section.getCommentSections
protected function getCommentSections() { if (empty($this->commentSections) && $this->rawComment) { $this->commentSections = explode("\n\n", $this->rawComment); } return $this->commentSections; }
php
protected function getCommentSections() { if (empty($this->commentSections) && $this->rawComment) { $this->commentSections = explode("\n\n", $this->rawComment); } return $this->commentSections; }
[ "protected", "function", "getCommentSections", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "commentSections", ")", "&&", "$", "this", "->", "rawComment", ")", "{", "$", "this", "->", "commentSections", "=", "explode", "(", "\"\\n\\n\"", ",",...
Returns the comment block used when creating the section as an array of paragraphs within the comment block @return array
[ "Returns", "the", "comment", "block", "used", "when", "creating", "the", "section", "as", "an", "array", "of", "paragraphs", "within", "the", "comment", "block" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L559-L566
kss-php/kss-php
lib/Section.php
Section.getTitleComment
protected function getTitleComment() { $titleComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the title by the # markdown header syntax if (preg_match('/^\s*#/i', $commentSection)) { $titleComment = $commentSection; break; } } return $titleComment; }
php
protected function getTitleComment() { $titleComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the title by the # markdown header syntax if (preg_match('/^\s*#/i', $commentSection)) { $titleComment = $commentSection; break; } } return $titleComment; }
[ "protected", "function", "getTitleComment", "(", ")", "{", "$", "titleComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Identify the title by the # markdown header syntax", "if",...
Gets the title part of the KSS Comment Block @return string
[ "Gets", "the", "title", "part", "of", "the", "KSS", "Comment", "Block" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L573-L586
kss-php/kss-php
lib/Section.php
Section.getMarkupComment
protected function getMarkupComment() { $markupComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the markup comment by the Markup: marker if (preg_match('/^\s*Markup:/i', $commentSection)) { $markupComment = $commentSection; break; } } return $markupComment; }
php
protected function getMarkupComment() { $markupComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the markup comment by the Markup: marker if (preg_match('/^\s*Markup:/i', $commentSection)) { $markupComment = $commentSection; break; } } return $markupComment; }
[ "protected", "function", "getMarkupComment", "(", ")", "{", "$", "markupComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Identify the markup comment by the Markup: marker", "if"...
Returns the part of the KSS Comment Block that contains the markup @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "markup" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L593-L606
kss-php/kss-php
lib/Section.php
Section.getDeprecatedComment
protected function getDeprecatedComment() { $deprecatedComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the deprecation notice by the Deprecated: marker if (preg_match('/^\s*Deprecated:/i', $commentSection)) { $deprecatedComment = $commentSection; break; } } return $deprecatedComment; }
php
protected function getDeprecatedComment() { $deprecatedComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the deprecation notice by the Deprecated: marker if (preg_match('/^\s*Deprecated:/i', $commentSection)) { $deprecatedComment = $commentSection; break; } } return $deprecatedComment; }
[ "protected", "function", "getDeprecatedComment", "(", ")", "{", "$", "deprecatedComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Identify the deprecation notice by the Deprecated:...
Returns the part of the KSS Comment Block that contains the deprecated notice @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "deprecated", "notice" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L614-L627
kss-php/kss-php
lib/Section.php
Section.getExperimentalComment
protected function getExperimentalComment() { $experimentalComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the experimental notice by the Experimental: marker if (preg_match('/^\s*Experimental:/i', $commentSection)) { $experimentalComment = $commentSection; break; } } return $experimentalComment; }
php
protected function getExperimentalComment() { $experimentalComment = null; foreach ($this->getCommentSections() as $commentSection) { // Identify the experimental notice by the Experimental: marker if (preg_match('/^\s*Experimental:/i', $commentSection)) { $experimentalComment = $commentSection; break; } } return $experimentalComment; }
[ "protected", "function", "getExperimentalComment", "(", ")", "{", "$", "experimentalComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Identify the experimental notice by the Experi...
Returns the part of the KSS Comment Block that contains the experimental notice @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "experimental", "notice" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L635-L648
kss-php/kss-php
lib/Section.php
Section.getCompatibilityComment
protected function getCompatibilityComment() { $compatibilityComment = null; foreach ($this->getCommentSections() as $commentSection) { // Compatible in IE6+, Firefox 2+, Safari 4+. // Compatibility: IE6+, Firefox 2+, Safari 4+. // Compatibility untested. if (preg_match('/^\s*Compatib(le|ility):?\s+/i', $commentSection)) { $compatibilityComment = $commentSection; break; } } return $compatibilityComment; }
php
protected function getCompatibilityComment() { $compatibilityComment = null; foreach ($this->getCommentSections() as $commentSection) { // Compatible in IE6+, Firefox 2+, Safari 4+. // Compatibility: IE6+, Firefox 2+, Safari 4+. // Compatibility untested. if (preg_match('/^\s*Compatib(le|ility):?\s+/i', $commentSection)) { $compatibilityComment = $commentSection; break; } } return $compatibilityComment; }
[ "protected", "function", "getCompatibilityComment", "(", ")", "{", "$", "compatibilityComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Compatible in IE6+, Firefox 2+, Safari 4+.",...
Returns the part of the KSS Comment Block that contains the compatibility notice @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "compatibility", "notice" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L656-L671
kss-php/kss-php
lib/Section.php
Section.getReferenceComment
protected function getReferenceComment() { $referenceComment = null; $commentSections = $this->getCommentSections(); $lastLine = end($commentSections); if (preg_match('/^\s*Styleguide \w/i', $lastLine) || preg_match('/^\s*No styleguide reference/i', $lastLine) ) { $referenceComment = $lastLine; } return $referenceComment; }
php
protected function getReferenceComment() { $referenceComment = null; $commentSections = $this->getCommentSections(); $lastLine = end($commentSections); if (preg_match('/^\s*Styleguide \w/i', $lastLine) || preg_match('/^\s*No styleguide reference/i', $lastLine) ) { $referenceComment = $lastLine; } return $referenceComment; }
[ "protected", "function", "getReferenceComment", "(", ")", "{", "$", "referenceComment", "=", "null", ";", "$", "commentSections", "=", "$", "this", "->", "getCommentSections", "(", ")", ";", "$", "lastLine", "=", "end", "(", "$", "commentSections", ")", ";",...
Gets the part of the KSS Comment Block that contains the section reference @return string
[ "Gets", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "section", "reference" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L678-L691
kss-php/kss-php
lib/Section.php
Section.getModifiersComment
protected function getModifiersComment() { $modifiersComment = null; foreach ($this->getCommentSections() as $commentSection) { // Assume that the modifiers section starts with either a class or a // pseudo class if (preg_match('/^\s*(?:\.|:)/', $commentSection)) { $modifiersComment = $commentSection; break; } } return $modifiersComment; }
php
protected function getModifiersComment() { $modifiersComment = null; foreach ($this->getCommentSections() as $commentSection) { // Assume that the modifiers section starts with either a class or a // pseudo class if (preg_match('/^\s*(?:\.|:)/', $commentSection)) { $modifiersComment = $commentSection; break; } } return $modifiersComment; }
[ "protected", "function", "getModifiersComment", "(", ")", "{", "$", "modifiersComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Assume that the modifiers section starts with either...
Returns the part of the KSS Comment Block that contains the modifiers @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "modifiers" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L698-L712
kss-php/kss-php
lib/Section.php
Section.getParametersComment
protected function getParametersComment() { $parametersComment = null; foreach ($this->getCommentSections() as $commentSection) { // Assume that the parameters section starts with $,%,@ if (preg_match('/^\s*(\$|@|%)/', $commentSection)) { $parametersComment = $commentSection; break; } } return $parametersComment; }
php
protected function getParametersComment() { $parametersComment = null; foreach ($this->getCommentSections() as $commentSection) { // Assume that the parameters section starts with $,%,@ if (preg_match('/^\s*(\$|@|%)/', $commentSection)) { $parametersComment = $commentSection; break; } } return $parametersComment; }
[ "protected", "function", "getParametersComment", "(", ")", "{", "$", "parametersComment", "=", "null", ";", "foreach", "(", "$", "this", "->", "getCommentSections", "(", ")", "as", "$", "commentSection", ")", "{", "// Assume that the parameters section starts with $,%...
Returns the part of the KSS Comment Block that contains the $parameters @return string
[ "Returns", "the", "part", "of", "the", "KSS", "Comment", "Block", "that", "contains", "the", "$parameters" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Section.php#L719-L732
kss-php/kss-php
lib/Parser.php
Parser.addSection
protected function addSection($comment, \splFileObject $file) { $section = new Section($comment, $file); $this->sections[$section->getReference(true)] = $section; $this->sectionsSortedByReference = false; }
php
protected function addSection($comment, \splFileObject $file) { $section = new Section($comment, $file); $this->sections[$section->getReference(true)] = $section; $this->sectionsSortedByReference = false; }
[ "protected", "function", "addSection", "(", "$", "comment", ",", "\\", "splFileObject", "$", "file", ")", "{", "$", "section", "=", "new", "Section", "(", "$", "comment", ",", "$", "file", ")", ";", "$", "this", "->", "sections", "[", "$", "section", ...
Adds a section to the Sections collection @param string $comment @param \splFileObject $file
[ "Adds", "a", "section", "to", "the", "Sections", "collection" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Parser.php#L61-L66
kss-php/kss-php
lib/Parser.php
Parser.getSection
public function getSection($reference) { $reference = Section::trimReference($reference); $reference = strtolower(Section::normalizeReference($reference)); foreach ($this->sections as $sectionKey => $section) { $potentialMatch = strtolower(Section::normalizeReference($sectionKey)); if ($reference === $potentialMatch) { return $section; } } throw new UnexpectedValueException('Section with a reference of ' . $reference . ' cannot be found!'); }
php
public function getSection($reference) { $reference = Section::trimReference($reference); $reference = strtolower(Section::normalizeReference($reference)); foreach ($this->sections as $sectionKey => $section) { $potentialMatch = strtolower(Section::normalizeReference($sectionKey)); if ($reference === $potentialMatch) { return $section; } } throw new UnexpectedValueException('Section with a reference of ' . $reference . ' cannot be found!'); }
[ "public", "function", "getSection", "(", "$", "reference", ")", "{", "$", "reference", "=", "Section", "::", "trimReference", "(", "$", "reference", ")", ";", "$", "reference", "=", "strtolower", "(", "Section", "::", "normalizeReference", "(", "$", "referen...
Returns a Section object matching the requested reference. If reference is not found, an empty Section object is returned instead @param string $reference @return Section @throws UnexepectedValueException if reference does not exist
[ "Returns", "a", "Section", "object", "matching", "the", "requested", "reference", ".", "If", "reference", "is", "not", "found", "an", "empty", "Section", "object", "is", "returned", "instead" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Parser.php#L78-L91
kss-php/kss-php
lib/Parser.php
Parser.getTopLevelSections
public function getTopLevelSections() { $this->sortSectionsByDepth(); $topLevelSections = array(); foreach ($this->sections as $section) { if ($section->getDepth() != 0) { break; } $topLevelSections[] = $section; } return $topLevelSections; }
php
public function getTopLevelSections() { $this->sortSectionsByDepth(); $topLevelSections = array(); foreach ($this->sections as $section) { if ($section->getDepth() != 0) { break; } $topLevelSections[] = $section; } return $topLevelSections; }
[ "public", "function", "getTopLevelSections", "(", ")", "{", "$", "this", "->", "sortSectionsByDepth", "(", ")", ";", "$", "topLevelSections", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "sections", "as", "$", "section", ")", "{", "if"...
Returns only the top level sections (i.e. 1.0, 2.0, 3.0, etc.) @return array
[ "Returns", "only", "the", "top", "level", "sections", "(", "i", ".", "e", ".", "1", ".", "0", "2", ".", "0", "3", ".", "0", "etc", ".", ")" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Parser.php#L109-L122
kss-php/kss-php
lib/Parser.php
Parser.getSectionChildren
public function getSectionChildren($reference, $levelsDown = null) { $reference = strtolower(Section::normalizeReference($reference)); $this->sortSections(); $sectionKeys = array_keys($this->sections); $sections = array(); $maxDepth = null; if ($levelsDown !== null) { $maxDepth = Section::calcDepth($reference) + $levelsDown; } $reference = Section::trimReference($reference); $reference .= '.'; foreach ($sectionKeys as $sectionKey) { $testSectionKey = strtolower(Section::normalizeReference($sectionKey)); // Only get sections within that level. Do not get the level itself if (strpos($testSectionKey . '.', $reference) === 0 && $testSectionKey . '.' != $reference ) { $section = $this->sections[$sectionKey]; if ($maxDepth !== null && $section->getDepth() > $maxDepth) { continue; } $sections[$sectionKey] = $section; } } return $sections; }
php
public function getSectionChildren($reference, $levelsDown = null) { $reference = strtolower(Section::normalizeReference($reference)); $this->sortSections(); $sectionKeys = array_keys($this->sections); $sections = array(); $maxDepth = null; if ($levelsDown !== null) { $maxDepth = Section::calcDepth($reference) + $levelsDown; } $reference = Section::trimReference($reference); $reference .= '.'; foreach ($sectionKeys as $sectionKey) { $testSectionKey = strtolower(Section::normalizeReference($sectionKey)); // Only get sections within that level. Do not get the level itself if (strpos($testSectionKey . '.', $reference) === 0 && $testSectionKey . '.' != $reference ) { $section = $this->sections[$sectionKey]; if ($maxDepth !== null && $section->getDepth() > $maxDepth) { continue; } $sections[$sectionKey] = $section; } } return $sections; }
[ "public", "function", "getSectionChildren", "(", "$", "reference", ",", "$", "levelsDown", "=", "null", ")", "{", "$", "reference", "=", "strtolower", "(", "Section", "::", "normalizeReference", "(", "$", "reference", ")", ")", ";", "$", "this", "->", "sor...
Returns an array of children for a specified section reference @param string $reference @param int $levelsDown OPTIONAL @return array
[ "Returns", "an", "array", "of", "children", "for", "a", "specified", "section", "reference" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Parser.php#L132-L163
kss-php/kss-php
lib/Parser.php
Parser.isKssBlock
public static function isKssBlock($comment) { $commentLines = explode("\n\n", $comment); $lastLine = end($commentLines); return preg_match('/^\s*Styleguide \w/i', $lastLine) || preg_match('/^\s*No styleguide reference/i', $lastLine); }
php
public static function isKssBlock($comment) { $commentLines = explode("\n\n", $comment); $lastLine = end($commentLines); return preg_match('/^\s*Styleguide \w/i', $lastLine) || preg_match('/^\s*No styleguide reference/i', $lastLine); }
[ "public", "static", "function", "isKssBlock", "(", "$", "comment", ")", "{", "$", "commentLines", "=", "explode", "(", "\"\\n\\n\"", ",", "$", "comment", ")", ";", "$", "lastLine", "=", "end", "(", "$", "commentLines", ")", ";", "return", "preg_match", "...
Checks to see if a comment block is a KSS Comment block @param string $comment @return boolean
[ "Checks", "to", "see", "if", "a", "comment", "block", "is", "a", "KSS", "Comment", "block" ]
train
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Parser.php#L198-L204
matrozov/yii2-couchbase
src/console/controllers/MigrateController.php
MigrateController.ensureBaseMigrationHistory
protected function ensureBaseMigrationHistory() { if ($this->baseMigrationEnsured) { return; } try { $this->db->getBucket($this->migrationBucket); } catch (Exception $e) { if (($e->getPrevious() instanceof \Couchbase\Exception) && ($e->getPrevious()->getCode() == 2)) { $this->db->createBucket($this->migrationBucket); } else { throw $e; } } $row = (new Query)->select(['version']) ->from($this->migrationBucket) ->andWhere(['version' => self::BASE_MIGRATION]) ->limit(1) ->one($this->db); if (empty($row)) { $this->addMigrationHistory(self::BASE_MIGRATION); } $this->baseMigrationEnsured = true; }
php
protected function ensureBaseMigrationHistory() { if ($this->baseMigrationEnsured) { return; } try { $this->db->getBucket($this->migrationBucket); } catch (Exception $e) { if (($e->getPrevious() instanceof \Couchbase\Exception) && ($e->getPrevious()->getCode() == 2)) { $this->db->createBucket($this->migrationBucket); } else { throw $e; } } $row = (new Query)->select(['version']) ->from($this->migrationBucket) ->andWhere(['version' => self::BASE_MIGRATION]) ->limit(1) ->one($this->db); if (empty($row)) { $this->addMigrationHistory(self::BASE_MIGRATION); } $this->baseMigrationEnsured = true; }
[ "protected", "function", "ensureBaseMigrationHistory", "(", ")", "{", "if", "(", "$", "this", "->", "baseMigrationEnsured", ")", "{", "return", ";", "}", "try", "{", "$", "this", "->", "db", "->", "getBucket", "(", "$", "this", "->", "migrationBucket", ")"...
Ensures migration history contains at least base migration entry.
[ "Ensures", "migration", "history", "contains", "at", "least", "base", "migration", "entry", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/console/controllers/MigrateController.php#L168-L197
MW-Peachy/Peachy
HTTP.php
HTTP.get
public function get( $url, $data = null, $headers = array(), $verifyssl = null ) { global $argv, $displayGetOutData; if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); curl_setopt( $this->curl_instance, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 0 ); /*if( !is_null( $this->use_cookie ) ) { curl_setopt($this->curl_instance,CURLOPT_COOKIE, $this->use_cookie); }*/ if( !is_null( $data ) && is_array( $data ) && !empty( $data ) ) { $url .= '?' . http_build_query( $data ); } curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { if( $displayGetOutData ) { pecho( "GET: $url\n", PECHO_NORMAL ); } } Hooks::runHook( 'HTTPGet', array( &$this, &$url, &$data ) ); return $this->doCurlExecWithRetrys(); }
php
public function get( $url, $data = null, $headers = array(), $verifyssl = null ) { global $argv, $displayGetOutData; if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); curl_setopt( $this->curl_instance, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 0 ); /*if( !is_null( $this->use_cookie ) ) { curl_setopt($this->curl_instance,CURLOPT_COOKIE, $this->use_cookie); }*/ if( !is_null( $data ) && is_array( $data ) && !empty( $data ) ) { $url .= '?' . http_build_query( $data ); } curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { if( $displayGetOutData ) { pecho( "GET: $url\n", PECHO_NORMAL ); } } Hooks::runHook( 'HTTPGet', array( &$this, &$url, &$data ) ); return $this->doCurlExecWithRetrys(); }
[ "public", "function", "get", "(", "$", "url", ",", "$", "data", "=", "null", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "verifyssl", "=", "null", ")", "{", "global", "$", "argv", ",", "$", "displayGetOutData", ";", "if", "(", "is_string...
Get an url with HTTP GET @access public @param string $url URL to get @param array|null $data Array of data to pass. Gets transformed into the URL inside the function. Default null. @param array $headers Array of headers to pass to curl @param bool $verifyssl override for the global verifyssl value @return bool|string Result
[ "Get", "an", "url", "with", "HTTP", "GET" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/HTTP.php#L230-L261
MW-Peachy/Peachy
HTTP.php
HTTP.post
public function post($url, $data, $headers = array(), $verifyssl = null) { global $argv, $displayPostOutData; if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); curl_setopt( $this->curl_instance, CURLOPT_FOLLOWLOCATION, 0 ); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 0 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POSTFIELDS, $data ); /*if( !is_null( $this->use_cookie ) ) { curl_setopt($this->curl_instance,CURLOPT_COOKIE, $this->use_cookie); }*/ curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { if( $displayPostOutData ) { pecho( "POST: $url\n", PECHO_NORMAL ); } } Hooks::runHook( 'HTTPPost', array( &$this, &$url, &$data ) ); return $this->doCurlExecWithRetrys(); }
php
public function post($url, $data, $headers = array(), $verifyssl = null) { global $argv, $displayPostOutData; if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); curl_setopt( $this->curl_instance, CURLOPT_FOLLOWLOCATION, 0 ); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 0 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POSTFIELDS, $data ); /*if( !is_null( $this->use_cookie ) ) { curl_setopt($this->curl_instance,CURLOPT_COOKIE, $this->use_cookie); }*/ curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { if( $displayPostOutData ) { pecho( "POST: $url\n", PECHO_NORMAL ); } } Hooks::runHook( 'HTTPPost', array( &$this, &$url, &$data ) ); return $this->doCurlExecWithRetrys(); }
[ "public", "function", "post", "(", "$", "url", ",", "$", "data", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "verifyssl", "=", "null", ")", "{", "global", "$", "argv", ",", "$", "displayPostOutData", ";", "if", "(", "is_string", "(", "$"...
Sends data via HTTP POST @access public @param string $url URL to send @param array $data Array of data to pass. @param array $headers Array of headers to pass to curl @param bool|null $verifyssl override for global verifyssl value @return bool|string Result
[ "Sends", "data", "via", "HTTP", "POST" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/HTTP.php#L288-L316
MW-Peachy/Peachy
HTTP.php
HTTP.download
function download( $url, $local, $headers = array(), $verifyssl = null ) { global $argv; $out = fopen( $local, 'wb' ); if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); // curl_setopt($this->curl_instance, CURLOPT_FILE, $out); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 0 ); curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); curl_setopt( $this->curl_instance, CURLOPT_HEADER, 0 ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { pecho( "DLOAD: $url\n", PECHO_NORMAL ); } Hooks::runHook( 'HTTPDownload', array( &$this, &$url, &$local ) ); fwrite( $out, $this->doCurlExecWithRetrys() ); fclose( $out ); return true; }
php
function download( $url, $local, $headers = array(), $verifyssl = null ) { global $argv; $out = fopen( $local, 'wb' ); if( is_string( $headers ) ) curl_setopt( $this->curl_instance, CURLOPT_HTTPHEADER, array( $headers ) ); else $this->setCurlHeaders( $headers ); $this->setVerifySSL( $verifyssl ); // curl_setopt($this->curl_instance, CURLOPT_FILE, $out); curl_setopt( $this->curl_instance, CURLOPT_HTTPGET, 1 ); curl_setopt( $this->curl_instance, CURLOPT_POST, 0 ); curl_setopt( $this->curl_instance, CURLOPT_URL, $url ); curl_setopt( $this->curl_instance, CURLOPT_HEADER, 0 ); if( ( !is_null( $argv ) && in_array( 'peachyecho', $argv ) ) || $this->echo ) { pecho( "DLOAD: $url\n", PECHO_NORMAL ); } Hooks::runHook( 'HTTPDownload', array( &$this, &$url, &$local ) ); fwrite( $out, $this->doCurlExecWithRetrys() ); fclose( $out ); return true; }
[ "function", "download", "(", "$", "url", ",", "$", "local", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "verifyssl", "=", "null", ")", "{", "global", "$", "argv", ";", "$", "out", "=", "fopen", "(", "$", "local", ",", "'wb'", ")", ";...
Downloads an URL to the local disk @access public @param string $url URL to get @param string $local Local filename to download to @param array $headers Array of headers to pass to curl @param bool|null $verifyssl @return bool
[ "Downloads", "an", "URL", "to", "the", "local", "disk" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/HTTP.php#L330-L356
fab2s/NodalFlow
src/Nodes/NodeAbstract.php
NodeAbstract.sendTo
public function sendTo($flowId, $nodeId = null, $param = null) { if (!($flow = $this->registry->getFlow($flowId))) { throw new NodalFlowException('Cannot sendTo without valid Flow target', 1, null, [ 'flowId' => $flowId, 'nodeId' => $nodeId, ]); } return $flow->sendTo($nodeId, $param); }
php
public function sendTo($flowId, $nodeId = null, $param = null) { if (!($flow = $this->registry->getFlow($flowId))) { throw new NodalFlowException('Cannot sendTo without valid Flow target', 1, null, [ 'flowId' => $flowId, 'nodeId' => $nodeId, ]); } return $flow->sendTo($nodeId, $param); }
[ "public", "function", "sendTo", "(", "$", "flowId", ",", "$", "nodeId", "=", "null", ",", "$", "param", "=", "null", ")", "{", "if", "(", "!", "(", "$", "flow", "=", "$", "this", "->", "registry", "->", "getFlow", "(", "$", "flowId", ")", ")", ...
@param string $flowId @param string|null $nodeId @param string|null $param @throws NodalFlowException @return mixed
[ "@param", "string", "$flowId", "@param", "string|null", "$nodeId", "@param", "string|null", "$param" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Nodes/NodeAbstract.php#L170-L180
fab2s/NodalFlow
src/Nodes/NodeAbstract.php
NodeAbstract.enforceIsATraversable
protected function enforceIsATraversable() { if ($this->isFlow()) { if ($this->isATraversable) { throw new NodalFlowException('Cannot Traverse a Branch'); } return $this; } if ($this->isATraversable) { if (!($this instanceof TraversableNodeInterface)) { throw new NodalFlowException('Cannot Traverse a Node that does not implement TraversableNodeInterface'); } return $this; } if (!($this instanceof ExecNodeInterface)) { throw new NodalFlowException('Cannot Exec a Node that does not implement ExecNodeInterface'); } return $this; }
php
protected function enforceIsATraversable() { if ($this->isFlow()) { if ($this->isATraversable) { throw new NodalFlowException('Cannot Traverse a Branch'); } return $this; } if ($this->isATraversable) { if (!($this instanceof TraversableNodeInterface)) { throw new NodalFlowException('Cannot Traverse a Node that does not implement TraversableNodeInterface'); } return $this; } if (!($this instanceof ExecNodeInterface)) { throw new NodalFlowException('Cannot Exec a Node that does not implement ExecNodeInterface'); } return $this; }
[ "protected", "function", "enforceIsATraversable", "(", ")", "{", "if", "(", "$", "this", "->", "isFlow", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isATraversable", ")", "{", "throw", "new", "NodalFlowException", "(", "'Cannot Traverse a Branch'", ")...
Make sure this Node is consistent @throws NodalFlowException @return $this
[ "Make", "sure", "this", "Node", "is", "consistent" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Nodes/NodeAbstract.php#L189-L212
budde377/Part
lib/ConfigImpl.php
ConfigImpl.getPostTasks
public function getPostTasks() { if ($this->postTasks != null) { return $this->postTasks; } /** @noinspection PhpUndefinedFieldInspection */ return $this->postTasks = $this->getScripts($this->configFile->postTasks); }
php
public function getPostTasks() { if ($this->postTasks != null) { return $this->postTasks; } /** @noinspection PhpUndefinedFieldInspection */ return $this->postTasks = $this->getScripts($this->configFile->postTasks); }
[ "public", "function", "getPostTasks", "(", ")", "{", "if", "(", "$", "this", "->", "postTasks", "!=", "null", ")", "{", "return", "$", "this", "->", "postTasks", ";", "}", "/** @noinspection PhpUndefinedFieldInspection */", "return", "$", "this", "->", "postTa...
Will return PostTasks as an array, with the ClassName as key and the link as value. The link should be relative to a root path provided. @return array
[ "Will", "return", "PostTasks", "as", "an", "array", "with", "the", "ClassName", "as", "key", "and", "the", "link", "as", "value", ".", "The", "link", "should", "be", "relative", "to", "a", "root", "path", "provided", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L104-L112
budde377/Part
lib/ConfigImpl.php
ConfigImpl.getPreTasks
public function getPreTasks() { if ($this->preTasks != null) { return $this->preTasks; } /** @noinspection PhpUndefinedFieldInspection */ return $this->preTasks = $this->getScripts($this->configFile->preTasks); }
php
public function getPreTasks() { if ($this->preTasks != null) { return $this->preTasks; } /** @noinspection PhpUndefinedFieldInspection */ return $this->preTasks = $this->getScripts($this->configFile->preTasks); }
[ "public", "function", "getPreTasks", "(", ")", "{", "if", "(", "$", "this", "->", "preTasks", "!=", "null", ")", "{", "return", "$", "this", "->", "preTasks", ";", "}", "/** @noinspection PhpUndefinedFieldInspection */", "return", "$", "this", "->", "preTasks"...
Will return pre tasks as an array, with the ClassName as key and the link as value. The link should be relative to a root path provided. @return array
[ "Will", "return", "pre", "tasks", "as", "an", "array", "with", "the", "ClassName", "as", "key", "and", "the", "link", "as", "value", ".", "The", "link", "should", "be", "relative", "to", "a", "root", "path", "provided", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L135-L143
budde377/Part
lib/ConfigImpl.php
ConfigImpl.listTemplateNames
public function listTemplateNames() { $this->setUpTemplate(); $ret = array(); foreach ($this->templates as $key => $val) { $ret[] = $key; } return $ret; }
php
public function listTemplateNames() { $this->setUpTemplate(); $ret = array(); foreach ($this->templates as $key => $val) { $ret[] = $key; } return $ret; }
[ "public", "function", "listTemplateNames", "(", ")", "{", "$", "this", "->", "setUpTemplate", "(", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "templates", "as", "$", "key", "=>", "$", "val", ")", "{", "$",...
Will return a array containing all possible templates by name. @return array
[ "Will", "return", "a", "array", "containing", "all", "possible", "templates", "by", "name", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L222-L230
budde377/Part
lib/ConfigImpl.php
ConfigImpl.getDefaultPages
public function getDefaultPages() { if ($this->defaultPages != null) { return $this->defaultPages; } $this->defaultPages = []; /** @noinspection PhpUndefinedFieldInspection */ if ($this->configFile->defaultPages->getName()) { /** @noinspection PhpUndefinedFieldInspection */ foreach ($this->configFile->defaultPages->page as $page) { $title = (string)$page; $this->defaultPages[$title]["template"] = (string)$page["template"]; $this->defaultPages[$title]["alias"] = (string)$page["alias"]; $this->defaultPages[$title]["id"] = (string)$page["id"]; } } return $this->defaultPages; }
php
public function getDefaultPages() { if ($this->defaultPages != null) { return $this->defaultPages; } $this->defaultPages = []; /** @noinspection PhpUndefinedFieldInspection */ if ($this->configFile->defaultPages->getName()) { /** @noinspection PhpUndefinedFieldInspection */ foreach ($this->configFile->defaultPages->page as $page) { $title = (string)$page; $this->defaultPages[$title]["template"] = (string)$page["template"]; $this->defaultPages[$title]["alias"] = (string)$page["alias"]; $this->defaultPages[$title]["id"] = (string)$page["id"]; } } return $this->defaultPages; }
[ "public", "function", "getDefaultPages", "(", ")", "{", "if", "(", "$", "this", "->", "defaultPages", "!=", "null", ")", "{", "return", "$", "this", "->", "defaultPages", ";", "}", "$", "this", "->", "defaultPages", "=", "[", "]", ";", "/** @noinspection...
Will return an array with default pages. Pages hardcoded into the website. The array will have the page title as key and another array, containing alias', as value. @return array
[ "Will", "return", "an", "array", "with", "default", "pages", ".", "Pages", "hardcoded", "into", "the", "website", ".", "The", "array", "will", "have", "the", "page", "title", "as", "key", "and", "another", "array", "containing", "alias", "as", "value", "."...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L238-L257
budde377/Part
lib/ConfigImpl.php
ConfigImpl.getAJAXTypeHandlers
public function getAJAXTypeHandlers() { if ($this->ajaxTypeHandlers != null) { return $this->ajaxTypeHandlers; } $this->ajaxTypeHandlers = array(); /** @noinspection PhpUndefinedFieldInspection */ if (!$this->configFile->AJAXTypeHandlers->getName()) { return $this->ajaxTypeHandlers; } /** @noinspection PhpUndefinedFieldInspection */ foreach ($this->configFile->AJAXTypeHandlers->class as $handler) { $class_array = array("class_name" => (string)$handler); if (isset($handler['link'])) { $class_array['link'] = $this->rootPath . "/" . $handler['link']; } $this->ajaxTypeHandlers[] = $class_array; } return $this->ajaxTypeHandlers; }
php
public function getAJAXTypeHandlers() { if ($this->ajaxTypeHandlers != null) { return $this->ajaxTypeHandlers; } $this->ajaxTypeHandlers = array(); /** @noinspection PhpUndefinedFieldInspection */ if (!$this->configFile->AJAXTypeHandlers->getName()) { return $this->ajaxTypeHandlers; } /** @noinspection PhpUndefinedFieldInspection */ foreach ($this->configFile->AJAXTypeHandlers->class as $handler) { $class_array = array("class_name" => (string)$handler); if (isset($handler['link'])) { $class_array['link'] = $this->rootPath . "/" . $handler['link']; } $this->ajaxTypeHandlers[] = $class_array; } return $this->ajaxTypeHandlers; }
[ "public", "function", "getAJAXTypeHandlers", "(", ")", "{", "if", "(", "$", "this", "->", "ajaxTypeHandlers", "!=", "null", ")", "{", "return", "$", "this", "->", "ajaxTypeHandlers", ";", "}", "$", "this", "->", "ajaxTypeHandlers", "=", "array", "(", ")", ...
Will return AJAXTypeHandlers as an array, with the num key and an array containing "class_name" and "path" as value. The link should be relative to a root path provided. @return array
[ "Will", "return", "AJAXTypeHandlers", "as", "an", "array", "with", "the", "num", "key", "and", "an", "array", "containing", "class_name", "and", "path", "as", "value", ".", "The", "link", "should", "be", "relative", "to", "a", "root", "path", "provided", "...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L408-L431
budde377/Part
lib/ConfigImpl.php
ConfigImpl.listTemplateFolders
public function listTemplateFolders() { $this->setUpTemplate(); $result = []; foreach ($this->templateNamespace as $ns => $paths) { foreach ($paths as $path) { $path = $this->getRootPath() . "/" . $path; if ($ns == "") { $result[] = $path; } else { $result[] = ['path' => $path, 'namespace' => $ns]; } } } return $result; }
php
public function listTemplateFolders() { $this->setUpTemplate(); $result = []; foreach ($this->templateNamespace as $ns => $paths) { foreach ($paths as $path) { $path = $this->getRootPath() . "/" . $path; if ($ns == "") { $result[] = $path; } else { $result[] = ['path' => $path, 'namespace' => $ns]; } } } return $result; }
[ "public", "function", "listTemplateFolders", "(", ")", "{", "$", "this", "->", "setUpTemplate", "(", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "templateNamespace", "as", "$", "ns", "=>", "$", "paths", ")", "{", "...
Lists the folders where to look for other templates. @return string[]
[ "Lists", "the", "folders", "where", "to", "look", "for", "other", "templates", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/ConfigImpl.php#L525-L542
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/PageController.php
PageController.show
public function show($slug) { try { return View::make($this->theme.'/pages/'.$slug); } catch (\InvalidArgumentException $e) { return App::abort(404, 'Page not found'); } }
php
public function show($slug) { try { return View::make($this->theme.'/pages/'.$slug); } catch (\InvalidArgumentException $e) { return App::abort(404, 'Page not found'); } }
[ "public", "function", "show", "(", "$", "slug", ")", "{", "try", "{", "return", "View", "::", "make", "(", "$", "this", "->", "theme", ".", "'/pages/'", ".", "$", "slug", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", ...
Display the specified resource. @param string $slug @return Response
[ "Display", "the", "specified", "resource", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PageController.php#L25-L35
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueOptionsMeta.php
EnumValueOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new EnumValueOptions(); case 1: return new EnumValueOptions(func_get_arg(0)); case 2: return new EnumValueOptions(func_get_arg(0), func_get_arg(1)); case 3: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumValueOptions(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 EnumValueOptions(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 EnumValueOptions(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 EnumValueOptions(); case 1: return new EnumValueOptions(func_get_arg(0)); case 2: return new EnumValueOptions(func_get_arg(0), func_get_arg(1)); case 3: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumValueOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumValueOptions(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 EnumValueOptions(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 EnumValueOptions(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", "EnumValueOptions", "(", ")", ";", "case", "1", ":", "return", "new", "EnumValueOptions", "(", "func_get_arg", ...
Creates new instance of \Google\Protobuf\EnumValueOptions @throws \InvalidArgumentException @return EnumValueOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueOptionsMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/Meta/EnumValueOptionsMeta.php
EnumValueOptionsMeta.reset
public static function reset($object) { if (!($object instanceof EnumValueOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof EnumValueOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumValueOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "EnumValueOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\En...
Resets properties of \Google\Protobuf\EnumValueOptions to default values @param EnumValueOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumValueOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumValueOptionsMeta.php#L95-L102
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.setGlobalOptions
public function setGlobalOptions($options = null) { if(!$options) { $css = BASE_PATH . '/themes/' . SSViewer::current_theme() . '/css/pdf.css'; $header = BASE_PATH . '/mysite/templates/Pdf/header.html'; $footer = BASE_PATH . '/mysite/templates/Pdf/footer.html'; $options = array( 'no-outline', 'enable-javascript', 'enable-smart-shrinking', 'encoding' => 'UTF-8', 'dpi' => 150, 'image-dpi' => 150, 'image-quality' => 100, 'user-style-sheet' => $css, 'orientation' => 'Portrait', 'page-height' => '297mm', 'page-width' => '210mm', 'page-size' => 'A4', 'margin-bottom' => 30, 'margin-left' => 10, 'margin-right' => 10, 'margin-top' => 30, 'header-html' => $header, 'footer-html' => $footer, 'binary' => '/usr/local/bin/wkhtmltopdf' ); } $this->globalOptions = $options; $this->pdf = new Pdf($this->globalOptions); }
php
public function setGlobalOptions($options = null) { if(!$options) { $css = BASE_PATH . '/themes/' . SSViewer::current_theme() . '/css/pdf.css'; $header = BASE_PATH . '/mysite/templates/Pdf/header.html'; $footer = BASE_PATH . '/mysite/templates/Pdf/footer.html'; $options = array( 'no-outline', 'enable-javascript', 'enable-smart-shrinking', 'encoding' => 'UTF-8', 'dpi' => 150, 'image-dpi' => 150, 'image-quality' => 100, 'user-style-sheet' => $css, 'orientation' => 'Portrait', 'page-height' => '297mm', 'page-width' => '210mm', 'page-size' => 'A4', 'margin-bottom' => 30, 'margin-left' => 10, 'margin-right' => 10, 'margin-top' => 30, 'header-html' => $header, 'footer-html' => $footer, 'binary' => '/usr/local/bin/wkhtmltopdf' ); } $this->globalOptions = $options; $this->pdf = new Pdf($this->globalOptions); }
[ "public", "function", "setGlobalOptions", "(", "$", "options", "=", "null", ")", "{", "if", "(", "!", "$", "options", ")", "{", "$", "css", "=", "BASE_PATH", ".", "'/themes/'", ".", "SSViewer", "::", "current_theme", "(", ")", ".", "'/css/pdf.css'", ";",...
Set the global options for all pdfs @param array $options A list with all possible options can be found here http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
[ "Set", "the", "global", "options", "for", "all", "pdfs" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L24-L55
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.setOption
public function setOption($key, $value = null) { $globalOptions = $this->globalOptions; if($value) { $globalOptions[$key] = $value; } else { $globalOptions[] = $key; } $this->setGlobalOptions($globalOptions); $this->pdf = new Pdf($this->globalOptions); }
php
public function setOption($key, $value = null) { $globalOptions = $this->globalOptions; if($value) { $globalOptions[$key] = $value; } else { $globalOptions[] = $key; } $this->setGlobalOptions($globalOptions); $this->pdf = new Pdf($this->globalOptions); }
[ "public", "function", "setOption", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "$", "globalOptions", "=", "$", "this", "->", "globalOptions", ";", "if", "(", "$", "value", ")", "{", "$", "globalOptions", "[", "$", "key", "]", "=", "$...
Set a specific option for the pdf you are creating @param string $key The name of the option you want to set. A list with all possible options can be found here http://wkhtmltopdf.org/usage/wkhtmltopdf.txt @param string|array $value The value of the option you want to set. Can be left blank.
[ "Set", "a", "specific", "option", "for", "the", "pdf", "you", "are", "creating" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L65-L76
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.removeOption
public function removeOption($key) { $globalOptions = $this->globalOptions; if(array_key_exists($key, $globalOptions)) { unset($globalOptions[$key]); } else if($key = array_search($key, $globalOptions)) { unset($globalOptions[$key]); } $this->setGlobalOptions($globalOptions); $this->pdf = new Pdf($this->globalOptions); }
php
public function removeOption($key) { $globalOptions = $this->globalOptions; if(array_key_exists($key, $globalOptions)) { unset($globalOptions[$key]); } else if($key = array_search($key, $globalOptions)) { unset($globalOptions[$key]); } $this->setGlobalOptions($globalOptions); $this->pdf = new Pdf($this->globalOptions); }
[ "public", "function", "removeOption", "(", "$", "key", ")", "{", "$", "globalOptions", "=", "$", "this", "->", "globalOptions", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "globalOptions", ")", ")", "{", "unset", "(", "$", "globalOptio...
Remove a specific option for the pdf you are creating @param string $key The name of the option you want to set.
[ "Remove", "a", "specific", "option", "for", "the", "pdf", "you", "are", "creating" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L83-L94
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.setFolderName
public function setFolderName($folder = null) { if($folder) { $folder = Folder::find_or_make($folder); $this->folderID = $folder->ID; $folder = str_replace('assets/', '', $folder->Filename); $this->folder = rtrim($this->folder . $folder, '/') . '/'; } }
php
public function setFolderName($folder = null) { if($folder) { $folder = Folder::find_or_make($folder); $this->folderID = $folder->ID; $folder = str_replace('assets/', '', $folder->Filename); $this->folder = rtrim($this->folder . $folder, '/') . '/'; } }
[ "public", "function", "setFolderName", "(", "$", "folder", "=", "null", ")", "{", "if", "(", "$", "folder", ")", "{", "$", "folder", "=", "Folder", "::", "find_or_make", "(", "$", "folder", ")", ";", "$", "this", "->", "folderID", "=", "$", "folder",...
Specify the pdf location @param string $folder The name of the desired folder. Creates a new one if folder doesn't exist.
[ "Specify", "the", "pdf", "location" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L101-L108
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.getHtml
static function getHtml($obj, $variables = null, $template = null) { Requirements::clear(); if(!$template) { $template = sprintf("%s_pdf", $obj->ClassName); } $viewer = new SSViewer($template); $html = $viewer->process($obj, $variables); return $html; }
php
static function getHtml($obj, $variables = null, $template = null) { Requirements::clear(); if(!$template) { $template = sprintf("%s_pdf", $obj->ClassName); } $viewer = new SSViewer($template); $html = $viewer->process($obj, $variables); return $html; }
[ "static", "function", "getHtml", "(", "$", "obj", ",", "$", "variables", "=", "null", ",", "$", "template", "=", "null", ")", "{", "Requirements", "::", "clear", "(", ")", ";", "if", "(", "!", "$", "template", ")", "{", "$", "template", "=", "sprin...
Generates the html code you need for the pdf @param DataObject $obj The base DataObject for your pdf @param array $variables Array with customisation for your data. @param string $template If submitted the name of the template used to generate the html. If not, the script will look for a template based on your DataObject class e.g. Trainer_pdf @return string The html code for your pdf
[ "Generates", "the", "html", "code", "you", "need", "for", "the", "pdf" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L119-L129
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.add
public function add($content, $type = 'Page', $options = array()) { if($type == 'Page') { $this->pdf->addPage($content, $options); } else if($type == 'Cover') { $this->pdf->addCover($content, $options); } }
php
public function add($content, $type = 'Page', $options = array()) { if($type == 'Page') { $this->pdf->addPage($content, $options); } else if($type == 'Cover') { $this->pdf->addCover($content, $options); } }
[ "public", "function", "add", "(", "$", "content", ",", "$", "type", "=", "'Page'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "type", "==", "'Page'", ")", "{", "$", "this", "->", "pdf", "->", "addPage", "(", "$", "co...
Adds a normale page or cover to your pdf @param string $content The html code from your DataObject, a pdf file or any website url @param string $type "Page" for a normal page or if you want to add an cover "Cover" @param array $options Specific options only for that page A list with all possible options can be found here http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
[ "Adds", "a", "normale", "page", "or", "cover", "to", "your", "pdf" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L139-L145
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.save
public function save($filename, $class = 'File') { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $filename = rtrim($class::create()->setName($filename), '.pdf') . '.pdf'; $this->pdf->saveAs($this->folder . $filename); return $this->createFile($filename, $class); } }
php
public function save($filename, $class = 'File') { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $filename = rtrim($class::create()->setName($filename), '.pdf') . '.pdf'; $this->pdf->saveAs($this->folder . $filename); return $this->createFile($filename, $class); } }
[ "public", "function", "save", "(", "$", "filename", ",", "$", "class", "=", "'File'", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "pdf", "->", "getError", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not create PD...
Saves the pdf file @param string $filename The desired name of the pdf file @param string $class Dataobject class of file @return DataObject The new created pdf file
[ "Saves", "the", "pdf", "file" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L154-L162
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.createFile
protected function createFile($filename, $class) { $filename = trim($filename); $file = $class::create(); $file->setName($filename); $file->Filename = $this->folder . $filename; $file->ParentID = $this->folderID; $file->write(); return $file; }
php
protected function createFile($filename, $class) { $filename = trim($filename); $file = $class::create(); $file->setName($filename); $file->Filename = $this->folder . $filename; $file->ParentID = $this->folderID; $file->write(); return $file; }
[ "protected", "function", "createFile", "(", "$", "filename", ",", "$", "class", ")", "{", "$", "filename", "=", "trim", "(", "$", "filename", ")", ";", "$", "file", "=", "$", "class", "::", "create", "(", ")", ";", "$", "file", "->", "setName", "("...
Creates an File DataObject from the pdf @param string $filename The desired name of the pdf file @param string $class Dataobject class of file @return DataObject Pdf file
[ "Creates", "an", "File", "DataObject", "from", "the", "pdf" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L171-L179
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.preview
public function preview() { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $this->pdf->send(); } die(); }
php
public function preview() { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $this->pdf->send(); } die(); }
[ "public", "function", "preview", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "pdf", "->", "getError", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not create PDF: '", ".", "$", "this", "->", "pdf", "->", "get...
Streams the pdf to your browser to preview it
[ "Streams", "the", "pdf", "to", "your", "browser", "to", "preview", "it" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L184-L192
bhofstaetter/silverstripe-wkhtmltopdf
code/SS_PDF.php
SS_PDF.download
public function download($filename) { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf'; $this->pdf->send($filename); } }
php
public function download($filename) { if(!empty($this->pdf->getError())) { throw new Exception('Could not create PDF: ' . $this->pdf->getError()); } else { $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf'; $this->pdf->send($filename); } }
[ "public", "function", "download", "(", "$", "filename", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "pdf", "->", "getError", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not create PDF: '", ".", "$", "this", "->", ...
Forces the download of the pdf
[ "Forces", "the", "download", "of", "the", "pdf" ]
train
https://github.com/bhofstaetter/silverstripe-wkhtmltopdf/blob/47a972c205fdb5f5708c37de1637c5911e0edbe5/code/SS_PDF.php#L197-L204
malahierba-lab/public-id
src/PublicId.php
PublicId.publicIdDecode
static public function publicIdDecode($public_id) { $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet()); $id = $hashids->decode($public_id); if (is_array($id) && isset($id[0])) return $id[0]; return null; }
php
static public function publicIdDecode($public_id) { $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet()); $id = $hashids->decode($public_id); if (is_array($id) && isset($id[0])) return $id[0]; return null; }
[ "static", "public", "function", "publicIdDecode", "(", "$", "public_id", ")", "{", "$", "hashids", "=", "new", "Hashids", "(", "self", "::", "getSalt", "(", ")", ",", "self", "::", "getMinLength", "(", ")", ",", "self", "::", "getAlphabet", "(", ")", "...
Decode public id to real id @access public @param string $public_id @return integer|null
[ "Decode", "public", "id", "to", "real", "id" ]
train
https://github.com/malahierba-lab/public-id/blob/6a39d2c19401edbf3eeac60e88e93c17f202bd0e/src/PublicId.php#L16-L26
malahierba-lab/public-id
src/PublicId.php
PublicId.getPublicIdAttribute
public function getPublicIdAttribute() { $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet()); $primaryKey = $this->primaryKey; return $hashids->encode($this->$primaryKey); }
php
public function getPublicIdAttribute() { $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet()); $primaryKey = $this->primaryKey; return $hashids->encode($this->$primaryKey); }
[ "public", "function", "getPublicIdAttribute", "(", ")", "{", "$", "hashids", "=", "new", "Hashids", "(", "self", "::", "getSalt", "(", ")", ",", "self", "::", "getMinLength", "(", ")", ",", "self", "::", "getAlphabet", "(", ")", ")", ";", "$", "primary...
Accessor for get the public id from a real id as attribute. Simply use: $model->public_id to get the public id value. @access public @param integer $id @return string
[ "Accessor", "for", "get", "the", "public", "id", "from", "a", "real", "id", "as", "attribute", ".", "Simply", "use", ":", "$model", "-", ">", "public_id", "to", "get", "the", "public", "id", "value", "." ]
train
https://github.com/malahierba-lab/public-id/blob/6a39d2c19401edbf3eeac60e88e93c17f202bd0e/src/PublicId.php#L37-L44
xylemical/php-expressions
src/Token.php
Token.hasHigherPriority
public function hasHigherPriority(Token $token) { // Left associativity precedence. if ($this->getAssociativity() === Operator::LEFT_ASSOCIATIVE && $this->getPrecedence() <= $token->getPrecedence()) { return true; } // Right associativity precedence. if ($this->getAssociativity() === Operator:: RIGHT_ASSOCIATIVE && $this->getPrecedence() < $token->getPrecedence()) { return true; } return false; }
php
public function hasHigherPriority(Token $token) { // Left associativity precedence. if ($this->getAssociativity() === Operator::LEFT_ASSOCIATIVE && $this->getPrecedence() <= $token->getPrecedence()) { return true; } // Right associativity precedence. if ($this->getAssociativity() === Operator:: RIGHT_ASSOCIATIVE && $this->getPrecedence() < $token->getPrecedence()) { return true; } return false; }
[ "public", "function", "hasHigherPriority", "(", "Token", "$", "token", ")", "{", "// Left associativity precedence.", "if", "(", "$", "this", "->", "getAssociativity", "(", ")", "===", "Operator", "::", "LEFT_ASSOCIATIVE", "&&", "$", "this", "->", "getPrecedence",...
Indicate this token has a lower priority than $token. @param \Xylemical\Expressions\Token $token @return bool
[ "Indicate", "this", "token", "has", "a", "lower", "priority", "than", "$token", "." ]
train
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Token.php#L112-L122
xylemical/php-expressions
src/Evaluator.php
Evaluator.evaluate
public function evaluate(array $tokens, Context $context) { $results = new \SplStack(); // for each token in the postfix expression: foreach ($tokens as $token) { // if token is an operator: if (is_null($token->getOperator())) { throw new ExpressionException('Unexpected token.'); } // Get the operator, as this works relative $op = $token->getOperator(); // Check there are enough operands. if ($op->getOperands() > $results->count()) { throw new ExpressionException('Improperly constructed expression.', $op); } // Get the operands from the stack in reverse order. $operands = []; for ($i = 0; $i < $op->getOperands(); $i++) { $operands[] = $results->pop(); } $operands = array_reverse($operands); // result ← evaluate token with operand_1 and operand_2 $result = $op->evaluate($operands, $context, $token); // push result back onto the stack $results->push($result); } // Check the expression has been properly constructed. if ($results->count() !== 1) { throw new ExpressionException('Improperly constructed expression.'); } // Get the final result. return $results->pop(); }
php
public function evaluate(array $tokens, Context $context) { $results = new \SplStack(); // for each token in the postfix expression: foreach ($tokens as $token) { // if token is an operator: if (is_null($token->getOperator())) { throw new ExpressionException('Unexpected token.'); } // Get the operator, as this works relative $op = $token->getOperator(); // Check there are enough operands. if ($op->getOperands() > $results->count()) { throw new ExpressionException('Improperly constructed expression.', $op); } // Get the operands from the stack in reverse order. $operands = []; for ($i = 0; $i < $op->getOperands(); $i++) { $operands[] = $results->pop(); } $operands = array_reverse($operands); // result ← evaluate token with operand_1 and operand_2 $result = $op->evaluate($operands, $context, $token); // push result back onto the stack $results->push($result); } // Check the expression has been properly constructed. if ($results->count() !== 1) { throw new ExpressionException('Improperly constructed expression.'); } // Get the final result. return $results->pop(); }
[ "public", "function", "evaluate", "(", "array", "$", "tokens", ",", "Context", "$", "context", ")", "{", "$", "results", "=", "new", "\\", "SplStack", "(", ")", ";", "// for each token in the postfix expression:", "foreach", "(", "$", "tokens", "as", "$", "t...
Evaluates the series of tokens in Reverse Polish Notation Format. @param \Xylemical\Expressions\Token[] $tokens @param \Xylemical\Expressions\Context $context @return string @throws \Xylemical\Expressions\ExpressionException @see https://en.wikipedia.org/wiki/Reverse_Polish_notation
[ "Evaluates", "the", "series", "of", "tokens", "in", "Reverse", "Polish", "Notation", "Format", "." ]
train
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Evaluator.php#L29-L69
jkphl/dom-factory
src/Domfactory/Domain/HtmlParser.php
HtmlParser.loadHTML
public function loadHTML($html) { $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_NOWARNING); $errors = libxml_get_errors(); libxml_use_internal_errors(false); // Run through all errors /** @var \LibXMLError $error */ foreach ($errors as $error) { throw new InvalidArgumentException( sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)), InvalidArgumentException::INVALID_HTML ); } return $dom; }
php
public function loadHTML($html) { $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_NOWARNING); $errors = libxml_get_errors(); libxml_use_internal_errors(false); // Run through all errors /** @var \LibXMLError $error */ foreach ($errors as $error) { throw new InvalidArgumentException( sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)), InvalidArgumentException::INVALID_HTML ); } return $dom; }
[ "public", "function", "loadHTML", "(", "$", "html", ")", "{", "$", "dom", "=", "new", "\\", "DOMDocument", "(", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "dom", "->", "loadHTML", "(", "$", "html", ",", "LIBXML_NOWARNING", ")", ...
Load an HTML document @param string $html HTML document @return \DOMDocument DOM Document @throws InvalidArgumentException If the HTML source is invalid
[ "Load", "an", "HTML", "document" ]
train
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Domain/HtmlParser.php#L54-L73
budde377/Part
lib/view/page_element/TitlePageElementImpl.php
TitlePageElementImpl.generateContent
public function generateContent() { parent::generateContent(); $pathArray = $this->currentPageStrategy->getCurrentPagePath(); $titleString = ''; foreach ($pathArray as $page) { /** @var $page Page */ $titleString .= ' - ' . (($t = $page->getTitle()) == '_404' ? 'Siden blev ikke fundet' : $t); } return $titleString; }
php
public function generateContent() { parent::generateContent(); $pathArray = $this->currentPageStrategy->getCurrentPagePath(); $titleString = ''; foreach ($pathArray as $page) { /** @var $page Page */ $titleString .= ' - ' . (($t = $page->getTitle()) == '_404' ? 'Siden blev ikke fundet' : $t); } return $titleString; }
[ "public", "function", "generateContent", "(", ")", "{", "parent", "::", "generateContent", "(", ")", ";", "$", "pathArray", "=", "$", "this", "->", "currentPageStrategy", "->", "getCurrentPagePath", "(", ")", ";", "$", "titleString", "=", "''", ";", "foreach...
This will return content from page element as a string. The format can be xml, xhtml, html etc. but return type must be string @return string
[ "This", "will", "return", "content", "from", "page", "element", "as", "a", "string", ".", "The", "format", "can", "be", "xml", "xhtml", "html", "etc", ".", "but", "return", "type", "must", "be", "string" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/page_element/TitlePageElementImpl.php#L31-L43
baleen/migrations
src/Exception/BaleenException.php
BaleenException.invalidObjectException
public static function invalidObjectException($object, $expected) { return new static(sprintf( 'Expected an object of type "%s", but got "%s" instead.', $expected, is_object($object) ? get_class($object) : gettype($object) )); }
php
public static function invalidObjectException($object, $expected) { return new static(sprintf( 'Expected an object of type "%s", but got "%s" instead.', $expected, is_object($object) ? get_class($object) : gettype($object) )); }
[ "public", "static", "function", "invalidObjectException", "(", "$", "object", ",", "$", "expected", ")", "{", "return", "new", "static", "(", "sprintf", "(", "'Expected an object of type \"%s\", but got \"%s\" instead.'", ",", "$", "expected", ",", "is_object", "(", ...
invalidObjectException @param $object @param $expected @return static
[ "invalidObjectException" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Exception/BaleenException.php#L36-L43
budde377/Part
lib/model/updater/GitUpdaterImpl.php
GitUpdaterImpl.checkForUpdates
public function checkForUpdates($quick = false) { if (!$this->subModuleUpdater) { $this->site->getVariables()->setValue("last_checked", time()); } if ($this->canBeUpdated === null) { $this->canBeUpdated = $this->site->getVariables()->getValue("can_be_updated") == 1; } if ($this->canBeUpdated) { return true; } if($quick){ return false; } $this->exec("git fetch"); $updateAvailable = ($this->getRevision('HEAD') != $this->getRevision("origin/" . $this->currentBranch()) || array_reduce($this->subUpdaters, function ($result, Updater $input) { return $result || $input->checkForUpdates(); }, false)); if ($this->canBeUpdated != $updateAvailable) { $this->site->getVariables()->setValue("can_be_updated", $updateAvailable ? 1 : 0); } return $this->canBeUpdated = $updateAvailable; }
php
public function checkForUpdates($quick = false) { if (!$this->subModuleUpdater) { $this->site->getVariables()->setValue("last_checked", time()); } if ($this->canBeUpdated === null) { $this->canBeUpdated = $this->site->getVariables()->getValue("can_be_updated") == 1; } if ($this->canBeUpdated) { return true; } if($quick){ return false; } $this->exec("git fetch"); $updateAvailable = ($this->getRevision('HEAD') != $this->getRevision("origin/" . $this->currentBranch()) || array_reduce($this->subUpdaters, function ($result, Updater $input) { return $result || $input->checkForUpdates(); }, false)); if ($this->canBeUpdated != $updateAvailable) { $this->site->getVariables()->setValue("can_be_updated", $updateAvailable ? 1 : 0); } return $this->canBeUpdated = $updateAvailable; }
[ "public", "function", "checkForUpdates", "(", "$", "quick", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "subModuleUpdater", ")", "{", "$", "this", "->", "site", "->", "getVariables", "(", ")", "->", "setValue", "(", "\"last_checked\"", ","...
Will check if there exists a new update. This must be blocking if using external program such as git. @param bool $quick If TRUE will do a quick check. May contain false positives. @return bool Return TRUE on existing new update, else FALSE
[ "Will", "check", "if", "there", "exists", "a", "new", "update", ".", "This", "must", "be", "blocking", "if", "using", "external", "program", "such", "as", "git", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/updater/GitUpdaterImpl.php#L48-L75
budde377/Part
lib/model/updater/GitUpdaterImpl.php
GitUpdaterImpl.update
public function update() { if (!$this->checkForUpdates()) { return; } if (!$this->subModuleUpdater) { $this->site->getVariables()->setValue("last_updated", time()); } $this->exec("git fetch origin"); $this->exec("git reset --hard origin/{$this->currentBranch()}"); /** @var $updater Updater */ foreach ($this->subUpdaters as $updater) { $updater->update(); } $this->exec("make update"); $this->canBeUpdated = false; $this->site->getVariables()->setValue("can_be_updated", 0); $this->site->modify(); $this->currentVersion = null; }
php
public function update() { if (!$this->checkForUpdates()) { return; } if (!$this->subModuleUpdater) { $this->site->getVariables()->setValue("last_updated", time()); } $this->exec("git fetch origin"); $this->exec("git reset --hard origin/{$this->currentBranch()}"); /** @var $updater Updater */ foreach ($this->subUpdaters as $updater) { $updater->update(); } $this->exec("make update"); $this->canBeUpdated = false; $this->site->getVariables()->setValue("can_be_updated", 0); $this->site->modify(); $this->currentVersion = null; }
[ "public", "function", "update", "(", ")", "{", "if", "(", "!", "$", "this", "->", "checkForUpdates", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "subModuleUpdater", ")", "{", "$", "this", "->", "site", "->", "getVaria...
Will update the system. As checkForUpdates() this must also be blocking. @return void
[ "Will", "update", "the", "system", ".", "As", "checkForUpdates", "()", "this", "must", "also", "be", "blocking", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/updater/GitUpdaterImpl.php#L82-L102
yeephp/yeephp
Yee/Route.php
Route.via
public function via() { $args = func_get_args(); $this->methods = array_merge($this->methods, $args); return $this; }
php
public function via() { $args = func_get_args(); $this->methods = array_merge($this->methods, $args); return $this; }
[ "public", "function", "via", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "methods", "=", "array_merge", "(", "$", "this", "->", "methods", ",", "$", "args", ")", ";", "return", "$", "this", ";", "}" ]
Append supported HTTP methods (alias for Route::appendHttpMethods) @return \Yee\Route
[ "Append", "supported", "HTTP", "methods", "(", "alias", "for", "Route", "::", "appendHttpMethods", ")" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Route.php#L298-L304
joetannenbaum/phpushbullet
src/Device.php
Device.getFieldValue
protected function getFieldValue(array $attr, $field) { $method = 'set' . ucwords($field); if (method_exists($this, $method)) { // If there is a setter for this field, use that return $this->{$method}($attr[$field]); } // Otherwise just set the property return (isset($attr[$field])) ? $attr[$field] : null; }
php
protected function getFieldValue(array $attr, $field) { $method = 'set' . ucwords($field); if (method_exists($this, $method)) { // If there is a setter for this field, use that return $this->{$method}($attr[$field]); } // Otherwise just set the property return (isset($attr[$field])) ? $attr[$field] : null; }
[ "protected", "function", "getFieldValue", "(", "array", "$", "attr", ",", "$", "field", ")", "{", "$", "method", "=", "'set'", ".", "ucwords", "(", "$", "field", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", ...
@param array $attr @param string $field @return string
[ "@param", "array", "$attr", "@param", "string", "$field" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/Device.php#L37-L48
budde377/Part
lib/WebsiteImpl.php
WebsiteImpl.generateSite
public function generateSite() { $template = new TemplateImpl($this->backendContainer); $pageStrategy = $this->backendContainer->getCurrentPageStrategyInstance(); $cacheControl = $this->backendContainer->getCacheControlInstance(); if ($this->config->isDebugMode()) { $cacheControl->disableCache(); $template->setTwigDebug(true); } $currentPage = $pageStrategy->getCurrentPage(); $template->setTemplateFromConfig($currentPage->getTemplate(), "_main"); $ajaxServer = $this->backendContainer->getAJAXServerInstance(); $id = null; if (($id = $this->GETValueOfIndexIfSetElseDefault('ajax')) !== null) { $template->onlyInitialize(); $ajaxServer->registerHandlersFromConfig(); } //Decide output mode if ($id !== null) { echo json_encode($ajaxServer->handleFromFunctionString($id, $this->GETValueOfIndexIfSetElseDefault('token')), $this->config->isDebugMode()?JSON_PRETTY_PRINT:0); } else if (!$cacheControl->setUpCache()) { echo $template->render(); } }
php
public function generateSite() { $template = new TemplateImpl($this->backendContainer); $pageStrategy = $this->backendContainer->getCurrentPageStrategyInstance(); $cacheControl = $this->backendContainer->getCacheControlInstance(); if ($this->config->isDebugMode()) { $cacheControl->disableCache(); $template->setTwigDebug(true); } $currentPage = $pageStrategy->getCurrentPage(); $template->setTemplateFromConfig($currentPage->getTemplate(), "_main"); $ajaxServer = $this->backendContainer->getAJAXServerInstance(); $id = null; if (($id = $this->GETValueOfIndexIfSetElseDefault('ajax')) !== null) { $template->onlyInitialize(); $ajaxServer->registerHandlersFromConfig(); } //Decide output mode if ($id !== null) { echo json_encode($ajaxServer->handleFromFunctionString($id, $this->GETValueOfIndexIfSetElseDefault('token')), $this->config->isDebugMode()?JSON_PRETTY_PRINT:0); } else if (!$cacheControl->setUpCache()) { echo $template->render(); } }
[ "public", "function", "generateSite", "(", ")", "{", "$", "template", "=", "new", "TemplateImpl", "(", "$", "this", "->", "backendContainer", ")", ";", "$", "pageStrategy", "=", "$", "this", "->", "backendContainer", "->", "getCurrentPageStrategyInstance", "(", ...
Generate site and output it in browser.
[ "Generate", "site", "and", "output", "it", "in", "browser", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/WebsiteImpl.php#L35-L67
skeeks-semenov/yii2-ckeditor
src/CKEditorWidget.php
CKEditorWidget._initOptions
protected function _initOptions() { $options = []; if ($this->preset) { $options = CKEditorPresets::getPresets($this->preset); } $this->clientOptions = ArrayHelper::merge((array) $options, $this->clientOptions); }
php
protected function _initOptions() { $options = []; if ($this->preset) { $options = CKEditorPresets::getPresets($this->preset); } $this->clientOptions = ArrayHelper::merge((array) $options, $this->clientOptions); }
[ "protected", "function", "_initOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "preset", ")", "{", "$", "options", "=", "CKEditorPresets", "::", "getPresets", "(", "$", "this", "->", "preset", ")", ";", "}",...
Initializes the widget options. This method sets the default values for various options.
[ "Initializes", "the", "widget", "options", ".", "This", "method", "sets", "the", "default", "values", "for", "various", "options", "." ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/CKEditorWidget.php#L47-L56
skeeks-semenov/yii2-ckeditor
src/CKEditorWidget.php
CKEditorWidget._registerPlugin
protected function _registerPlugin() { $view = $this->getView(); $id = $this->options['id']; $options = $this->clientOptions !== false && !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '{}'; $js[] = "CKEDITOR.replace('$id', $options);"; $js[] = "skeeks.ckEditorWidget.registerOnChangeHandler('$id');"; if (isset($this->clientOptions['filebrowserUploadUrl'])) { $js[] = "skeeks.ckEditorWidget.registerCsrfImageUploadHandler();"; } $view->registerJs(implode("\n", $js)); }
php
protected function _registerPlugin() { $view = $this->getView(); $id = $this->options['id']; $options = $this->clientOptions !== false && !empty($this->clientOptions) ? Json::encode($this->clientOptions) : '{}'; $js[] = "CKEDITOR.replace('$id', $options);"; $js[] = "skeeks.ckEditorWidget.registerOnChangeHandler('$id');"; if (isset($this->clientOptions['filebrowserUploadUrl'])) { $js[] = "skeeks.ckEditorWidget.registerCsrfImageUploadHandler();"; } $view->registerJs(implode("\n", $js)); }
[ "protected", "function", "_registerPlugin", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "$", "options", "=", "$", "this", "->", "clientOptions", ...
Registers CKEditor plugin
[ "Registers", "CKEditor", "plugin" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/CKEditorWidget.php#L86-L103
skrz/meta
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
UninterpretedOptionMeta.create
public static function create() { switch (func_num_args()) { case 0: return new UninterpretedOption(); case 1: return new UninterpretedOption(func_get_arg(0)); case 2: return new UninterpretedOption(func_get_arg(0), func_get_arg(1)); case 3: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new UninterpretedOption(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 UninterpretedOption(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 UninterpretedOption(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 UninterpretedOption(); case 1: return new UninterpretedOption(func_get_arg(0)); case 2: return new UninterpretedOption(func_get_arg(0), func_get_arg(1)); case 3: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new UninterpretedOption(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 UninterpretedOption(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 UninterpretedOption(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", "UninterpretedOption", "(", ")", ";", "case", "1", ":", "return", "new", "UninterpretedOption", "(", "func_get_a...
Creates new instance of \Google\Protobuf\UninterpretedOption @throws \InvalidArgumentException @return UninterpretedOption
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L64-L88