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
oscarotero/uploader
src/Adapters/Url.php
Url.fixDestination
public static function fixDestination(Uploader $uploader, $original) { $path = Uploader::parsePath(parse_url($original, PHP_URL_PATH)); if (!$uploader->getFilename()) { $uploader->setFilename($path['filename']); } if (!$uploader->getExtension()) { $uploader->setExtension($path['extension']); } }
php
public static function fixDestination(Uploader $uploader, $original) { $path = Uploader::parsePath(parse_url($original, PHP_URL_PATH)); if (!$uploader->getFilename()) { $uploader->setFilename($path['filename']); } if (!$uploader->getExtension()) { $uploader->setExtension($path['extension']); } }
[ "public", "static", "function", "fixDestination", "(", "Uploader", "$", "uploader", ",", "$", "original", ")", "{", "$", "path", "=", "Uploader", "::", "parsePath", "(", "parse_url", "(", "$", "original", ",", "PHP_URL_PATH", ")", ")", ";", "if", "(", "!...
{@inheritdoc}
[ "{" ]
train
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Adapters/Url.php#L23-L34
nietonfir/GoogleRecaptchaBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('nietonfir_google_recaptcha'); $rootNode ->children() ->scalarNode('sitekey') ->info('The sitekey provided by reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() // sitekey ->scalarNode('secret') ->info('The secret provided by reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() // secret ->arrayNode('validation') ->fixXmlConfig('form') ->isRequired() ->cannotBeEmpty() ->beforeNormalization() ->ifString() ->then(function ($v) { return array('forms' => [['form_name' => $v]]); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && array_key_exists('form_name', $v); }) ->then(function ($v) { @trigger_error('Specifying "validation.form_name" & "validation.field_name" will be removed in future versions. Use the "validation.forms" node for configuration.', E_USER_DEPRECATED); return array('forms' => [$v]); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && !array_key_exists('forms', $v) && !array_key_exists('form', $v); }) ->then(function ($v) { return array('forms' => array_map(function($a) { return ['form_name' => $a]; }, $v)); }) ->end() ->children() ->scalarNode('form_name') ->info('The name of the form that should have a reCAPTCHA.') ->end() ->scalarNode('field_name') ->info('The field name that will hold the reCAPTCHA.') ->defaultValue('recaptcha') ->treatNullLike('recaptcha') ->end() ->arrayNode('forms') ->isRequired() ->cannotBeEmpty() ->prototype('array') ->children() ->scalarNode('form_name') ->info('The name of the form that should have a reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() ->scalarNode('field_name') ->info('The field name that will hold the reCAPTCHA.') ->defaultValue('recaptcha') ->treatNullLike('recaptcha') ->end() ->end() ->end() ->end() // forms ->end() ->end() // validation ->end() ; return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('nietonfir_google_recaptcha'); $rootNode ->children() ->scalarNode('sitekey') ->info('The sitekey provided by reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() // sitekey ->scalarNode('secret') ->info('The secret provided by reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() // secret ->arrayNode('validation') ->fixXmlConfig('form') ->isRequired() ->cannotBeEmpty() ->beforeNormalization() ->ifString() ->then(function ($v) { return array('forms' => [['form_name' => $v]]); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && array_key_exists('form_name', $v); }) ->then(function ($v) { @trigger_error('Specifying "validation.form_name" & "validation.field_name" will be removed in future versions. Use the "validation.forms" node for configuration.', E_USER_DEPRECATED); return array('forms' => [$v]); }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && !array_key_exists('forms', $v) && !array_key_exists('form', $v); }) ->then(function ($v) { return array('forms' => array_map(function($a) { return ['form_name' => $a]; }, $v)); }) ->end() ->children() ->scalarNode('form_name') ->info('The name of the form that should have a reCAPTCHA.') ->end() ->scalarNode('field_name') ->info('The field name that will hold the reCAPTCHA.') ->defaultValue('recaptcha') ->treatNullLike('recaptcha') ->end() ->arrayNode('forms') ->isRequired() ->cannotBeEmpty() ->prototype('array') ->children() ->scalarNode('form_name') ->info('The name of the form that should have a reCAPTCHA.') ->isRequired() ->cannotBeEmpty() ->end() ->scalarNode('field_name') ->info('The field name that will hold the reCAPTCHA.') ->defaultValue('recaptcha') ->treatNullLike('recaptcha') ->end() ->end() ->end() ->end() // forms ->end() ->end() // validation ->end() ; return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'nietonfir_google_recaptcha'", ")", ";", "$", "rootNode", "->", "children",...
{@inheritdoc}
[ "{" ]
train
https://github.com/nietonfir/GoogleRecaptchaBundle/blob/defc8d8040937df032aae4ab75d993efa83e6e34/DependencyInjection/Configuration.php#L18-L92
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder.encode
public static function encode($value, $cycleCheck = false, $options = array()) { $encoder = new self(($cycleCheck) ? true : false, $options); return $encoder->_encodeValue($value); }
php
public static function encode($value, $cycleCheck = false, $options = array()) { $encoder = new self(($cycleCheck) ? true : false, $options); return $encoder->_encodeValue($value); }
[ "public", "static", "function", "encode", "(", "$", "value", ",", "$", "cycleCheck", "=", "false", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "encoder", "=", "new", "self", "(", "(", "$", "cycleCheck", ")", "?", "true", ":", "false...
Use the JSON encoding scheme for the value specified @param mixed $value The value to be encoded @param boolean $cycleCheck Whether or not to check for possible object recursion when encoding @param array $options Additional options used during encoding @return string The encoded value
[ "Use", "the", "JSON", "encoding", "scheme", "for", "the", "value", "specified" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L80-L85
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeValue
protected function _encodeValue(&$value) { if (is_object($value)) { return $this->_encodeObject($value); } else if (is_array($value)) { return $this->_encodeArray($value); } return $this->_encodeDatum($value); }
php
protected function _encodeValue(&$value) { if (is_object($value)) { return $this->_encodeObject($value); } else if (is_array($value)) { return $this->_encodeArray($value); } return $this->_encodeDatum($value); }
[ "protected", "function", "_encodeValue", "(", "&", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "_encodeObject", "(", "$", "value", ")", ";", "}", "else", "if", "(", "is_array", "(", ...
Recursive driver which determines the type of value to be encoded and then dispatches to the appropriate method. $values are either - objects (returns from {@link _encodeObject()}) - arrays (returns from {@link _encodeArray()}) - basic datums (e.g. numbers or strings) (returns from {@link _encodeDatum()}) @param $value mixed The value to be encoded @return string Encoded value
[ "Recursive", "driver", "which", "determines", "the", "type", "of", "value", "to", "be", "encoded", "and", "then", "dispatches", "to", "the", "appropriate", "method", ".", "$values", "are", "either", "-", "objects", "(", "returns", "from", "{", "@link", "_enc...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L97-L106
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeObject
protected function _encodeObject(&$value) { if ($this->_cycleCheck) { if ($this->_wasVisited($value)) { if (isset($this->_options['silenceCyclicalExceptions']) && $this->_options['silenceCyclicalExceptions']===true ) { return '"* RECURSION (' . get_class($value) . ') *"'; } else { throw new Zend_Json_Exception( 'Cycles not supported in JSON encoding, cycle introduced by ' . 'class "' . get_class($value) . '"' ); } } $this->_visited[] = $value; } $props = ''; foreach (get_object_vars($value) as $name => $propValue) { if (isset($propValue)) { $props .= ',' . $this->_encodeValue($name) . ':' . $this->_encodeValue($propValue); } } return '{"__className":"' . get_class($value) . '"' . $props . '}'; }
php
protected function _encodeObject(&$value) { if ($this->_cycleCheck) { if ($this->_wasVisited($value)) { if (isset($this->_options['silenceCyclicalExceptions']) && $this->_options['silenceCyclicalExceptions']===true ) { return '"* RECURSION (' . get_class($value) . ') *"'; } else { throw new Zend_Json_Exception( 'Cycles not supported in JSON encoding, cycle introduced by ' . 'class "' . get_class($value) . '"' ); } } $this->_visited[] = $value; } $props = ''; foreach (get_object_vars($value) as $name => $propValue) { if (isset($propValue)) { $props .= ',' . $this->_encodeValue($name) . ':' . $this->_encodeValue($propValue); } } return '{"__className":"' . get_class($value) . '"' . $props . '}'; }
[ "protected", "function", "_encodeObject", "(", "&", "$", "value", ")", "{", "if", "(", "$", "this", "->", "_cycleCheck", ")", "{", "if", "(", "$", "this", "->", "_wasVisited", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "this", ...
Encode an object to JSON by encoding each of the public properties A special property is added to the JSON object called '__className' that contains the name of the class of $value. This is used to decode the object on the client into a specific class. @param $value object @return string @throws Zend_Json_Exception If recursive checks are enabled and the object has been serialized previously
[ "Encode", "an", "object", "to", "JSON", "by", "encoding", "each", "of", "the", "public", "properties" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L121-L155
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeArray
protected function _encodeArray(&$array) { $tmpArray = array(); // Check for associative array if (!empty($array) && (array_keys($array) !== range(0, count($array) - 1))) { // Associative array $result = '{'; foreach ($array as $key => $value) { $key = (string) $key; $tmpArray[] = $this->_encodeString($key) . ':' . $this->_encodeValue($value); } $result .= implode(',', $tmpArray); $result .= '}'; } else { // Indexed array $result = '['; $length = count($array); for ($i = 0; $i < $length; $i++) { $tmpArray[] = $this->_encodeValue($array[$i]); } $result .= implode(',', $tmpArray); $result .= ']'; } return $result; }
php
protected function _encodeArray(&$array) { $tmpArray = array(); // Check for associative array if (!empty($array) && (array_keys($array) !== range(0, count($array) - 1))) { // Associative array $result = '{'; foreach ($array as $key => $value) { $key = (string) $key; $tmpArray[] = $this->_encodeString($key) . ':' . $this->_encodeValue($value); } $result .= implode(',', $tmpArray); $result .= '}'; } else { // Indexed array $result = '['; $length = count($array); for ($i = 0; $i < $length; $i++) { $tmpArray[] = $this->_encodeValue($array[$i]); } $result .= implode(',', $tmpArray); $result .= ']'; } return $result; }
[ "protected", "function", "_encodeArray", "(", "&", "$", "array", ")", "{", "$", "tmpArray", "=", "array", "(", ")", ";", "// Check for associative array", "if", "(", "!", "empty", "(", "$", "array", ")", "&&", "(", "array_keys", "(", "$", "array", ")", ...
JSON encode an array value Recursively encodes each value of an array and returns a JSON encoded array string. Arrays are defined as integer-indexed arrays starting at index 0, where the last index is (count($array) -1); any deviation from that is considered an associative array, and will be encoded as such. @param $array array @return string
[ "JSON", "encode", "an", "array", "value" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L187-L215
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeDatum
protected function _encodeDatum(&$value) { $result = 'null'; if (is_int($value) || is_float($value)) { $result = (string)$value; } elseif (is_string($value)) { $result = $this->_encodeString($value); } elseif (is_bool($value)) { $result = $value ? 'true' : 'false'; } return $result; }
php
protected function _encodeDatum(&$value) { $result = 'null'; if (is_int($value) || is_float($value)) { $result = (string)$value; } elseif (is_string($value)) { $result = $this->_encodeString($value); } elseif (is_bool($value)) { $result = $value ? 'true' : 'false'; } return $result; }
[ "protected", "function", "_encodeDatum", "(", "&", "$", "value", ")", "{", "$", "result", "=", "'null'", ";", "if", "(", "is_int", "(", "$", "value", ")", "||", "is_float", "(", "$", "value", ")", ")", "{", "$", "result", "=", "(", "string", ")", ...
JSON encode a basic data type (string, number, boolean, null) If value type is not a string, number, boolean, or null, the string 'null' is returned. @param $value mixed @return string
[ "JSON", "encode", "a", "basic", "data", "type", "(", "string", "number", "boolean", "null", ")" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L227-L240
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeString
protected function _encodeString(&$string) { // Escape these characters with a backslash: // " \ / \n \r \t \b \f $search = array('\\', "\n", "\t", "\r", "\b", "\f", '"'); $replace = array('\\\\', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'); $string = str_replace($search, $replace, $string); // Escape certain ASCII characters: // 0x08 => \b // 0x0c => \f $string = str_replace(array(chr(0x08), chr(0x0C)), array('\b', '\f'), $string); return '"' . $string . '"'; }
php
protected function _encodeString(&$string) { // Escape these characters with a backslash: // " \ / \n \r \t \b \f $search = array('\\', "\n", "\t", "\r", "\b", "\f", '"'); $replace = array('\\\\', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'); $string = str_replace($search, $replace, $string); // Escape certain ASCII characters: // 0x08 => \b // 0x0c => \f $string = str_replace(array(chr(0x08), chr(0x0C)), array('\b', '\f'), $string); return '"' . $string . '"'; }
[ "protected", "function", "_encodeString", "(", "&", "$", "string", ")", "{", "// Escape these characters with a backslash:", "// \" \\ / \\n \\r \\t \\b \\f", "$", "search", "=", "array", "(", "'\\\\'", ",", "\"\\n\"", ",", "\"\\t\"", ",", "\"\\r\"", ",", "\"\\b\"", ...
JSON encode a string value by escaping characters as necessary @param $value string @return string
[ "JSON", "encode", "a", "string", "value", "by", "escaping", "characters", "as", "necessary" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L249-L263
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeMethods
private static function _encodeMethods(ReflectionClass $cls) { $methods = $cls->getMethods(); $result = 'methods:{'; $started = false; foreach ($methods as $method) { if (! $method->isPublic() || !$method->isUserDefined()) { continue; } if ($started) { $result .= ','; } $started = true; $result .= '' . $method->getName(). ':function('; if ('__construct' != $method->getName()) { $parameters = $method->getParameters(); $paramCount = count($parameters); $argsStarted = false; $argNames = "var argNames=["; foreach ($parameters as $param) { if ($argsStarted) { $result .= ','; } $result .= $param->getName(); if ($argsStarted) { $argNames .= ','; } $argNames .= '"' . $param->getName() . '"'; $argsStarted = true; } $argNames .= "];"; $result .= "){" . $argNames . 'var result = ZAjaxEngine.invokeRemoteMethod(' . "this, '" . $method->getName() . "',argNames,arguments);" . 'return(result);}'; } else { $result .= "){}"; } } return $result . "}"; }
php
private static function _encodeMethods(ReflectionClass $cls) { $methods = $cls->getMethods(); $result = 'methods:{'; $started = false; foreach ($methods as $method) { if (! $method->isPublic() || !$method->isUserDefined()) { continue; } if ($started) { $result .= ','; } $started = true; $result .= '' . $method->getName(). ':function('; if ('__construct' != $method->getName()) { $parameters = $method->getParameters(); $paramCount = count($parameters); $argsStarted = false; $argNames = "var argNames=["; foreach ($parameters as $param) { if ($argsStarted) { $result .= ','; } $result .= $param->getName(); if ($argsStarted) { $argNames .= ','; } $argNames .= '"' . $param->getName() . '"'; $argsStarted = true; } $argNames .= "];"; $result .= "){" . $argNames . 'var result = ZAjaxEngine.invokeRemoteMethod(' . "this, '" . $method->getName() . "',argNames,arguments);" . 'return(result);}'; } else { $result .= "){}"; } } return $result . "}"; }
[ "private", "static", "function", "_encodeMethods", "(", "ReflectionClass", "$", "cls", ")", "{", "$", "methods", "=", "$", "cls", "->", "getMethods", "(", ")", ";", "$", "result", "=", "'methods:{'", ";", "$", "started", "=", "false", ";", "foreach", "("...
Encode the public methods of the ReflectionClass in the class2 format @param $cls ReflectionClass @return string Encoded method fragment
[ "Encode", "the", "public", "methods", "of", "the", "ReflectionClass", "in", "the", "class2", "format" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L298-L351
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder._encodeVariables
private static function _encodeVariables(ReflectionClass $cls) { $properties = $cls->getProperties(); $propValues = get_class_vars($cls->getName()); $result = "variables:{"; $cnt = 0; $tmpArray = array(); foreach ($properties as $prop) { if (! $prop->isPublic()) { continue; } $tmpArray[] = $prop->getName() . ':' . self::encode($propValues[$prop->getName()]); } $result .= implode(',', $tmpArray); return $result . "}"; }
php
private static function _encodeVariables(ReflectionClass $cls) { $properties = $cls->getProperties(); $propValues = get_class_vars($cls->getName()); $result = "variables:{"; $cnt = 0; $tmpArray = array(); foreach ($properties as $prop) { if (! $prop->isPublic()) { continue; } $tmpArray[] = $prop->getName() . ':' . self::encode($propValues[$prop->getName()]); } $result .= implode(',', $tmpArray); return $result . "}"; }
[ "private", "static", "function", "_encodeVariables", "(", "ReflectionClass", "$", "cls", ")", "{", "$", "properties", "=", "$", "cls", "->", "getProperties", "(", ")", ";", "$", "propValues", "=", "get_class_vars", "(", "$", "cls", "->", "getName", "(", ")...
Encode the public properties of the ReflectionClass in the class2 format. @param $cls ReflectionClass @return string Encode properties list
[ "Encode", "the", "public", "properties", "of", "the", "ReflectionClass", "in", "the", "class2", "format", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L361-L381
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder.encodeClass
public static function encodeClass($className, $package = '') { $cls = new ReflectionClass($className); if (! $cls->isInstantiable()) { throw new Zend_Json_Exception("$className must be instantiable"); } return "Class.create('$package$className',{" . self::_encodeConstants($cls) ."," . self::_encodeMethods($cls) ."," . self::_encodeVariables($cls) .'});'; }
php
public static function encodeClass($className, $package = '') { $cls = new ReflectionClass($className); if (! $cls->isInstantiable()) { throw new Zend_Json_Exception("$className must be instantiable"); } return "Class.create('$package$className',{" . self::_encodeConstants($cls) ."," . self::_encodeMethods($cls) ."," . self::_encodeVariables($cls) .'});'; }
[ "public", "static", "function", "encodeClass", "(", "$", "className", ",", "$", "package", "=", "''", ")", "{", "$", "cls", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "!", "$", "cls", "->", "isInstantiable", "(", ")", ...
Encodes the given $className into the class2 model of encoding PHP classes into JavaScript class2 classes. NOTE: Currently only public methods and variables are proxied onto the client machine @param $className string The name of the class, the class must be instantiable using a null constructor @param $package string Optional package name appended to JavaScript proxy class name @return string The class2 (JavaScript) encoding of the class @throws Zend_Json_Exception
[ "Encodes", "the", "given", "$className", "into", "the", "class2", "model", "of", "encoding", "PHP", "classes", "into", "JavaScript", "class2", "classes", ".", "NOTE", ":", "Currently", "only", "public", "methods", "and", "variables", "are", "proxied", "onto", ...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L396-L407
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
Zend_Json_Encoder.encodeClasses
public static function encodeClasses(array $classNames, $package = '') { $result = ''; foreach ($classNames as $className) { $result .= self::encodeClass($className, $package); } return $result; }
php
public static function encodeClasses(array $classNames, $package = '') { $result = ''; foreach ($classNames as $className) { $result .= self::encodeClass($className, $package); } return $result; }
[ "public", "static", "function", "encodeClasses", "(", "array", "$", "classNames", ",", "$", "package", "=", "''", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "$", "classNames", "as", "$", "className", ")", "{", "$", "result", ".=", "self",...
Encode several classes at once Returns JSON encoded classes, using {@link encodeClass()}. @param array $classNames @param string $package @return string
[ "Encode", "several", "classes", "at", "once" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L419-L427
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/ImageField.php
ImageField.render
public function render() { switch ($this->getContext()) { case BaseField::CONTEXT_LIST: return '<img src="' . asset($this->getValue()). '" width="10%">'; break; case BaseField::CONTEXT_FILTER: case BaseField::CONTEXT_FORM: return View::make('krafthaus/bauhaus::models.fields._image') ->with('field', $this); break; } }
php
public function render() { switch ($this->getContext()) { case BaseField::CONTEXT_LIST: return '<img src="' . asset($this->getValue()). '" width="10%">'; break; case BaseField::CONTEXT_FILTER: case BaseField::CONTEXT_FORM: return View::make('krafthaus/bauhaus::models.fields._image') ->with('field', $this); break; } }
[ "public", "function", "render", "(", ")", "{", "switch", "(", "$", "this", "->", "getContext", "(", ")", ")", "{", "case", "BaseField", "::", "CONTEXT_LIST", ":", "return", "'<img src=\"'", ".", "asset", "(", "$", "this", "->", "getValue", "(", ")", ")...
Render the field. @access public @return mixed|string
[ "Render", "the", "field", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/ImageField.php#L64-L76
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/ImageField.php
ImageField.postUpdate
public function postUpdate($input) { foreach ($this->getSizes() as $size) { $name = $this->getName(); try { $image = Image::make(sprintf('%s/%s', $this->getLocation(), $name)); } catch (NotReadableException $e) { continue; } switch ($size[2]) { case 'resize': $image->resize($size[0], $size[1], function ($constraint) { $constraint->aspectRatio(); }); break; case 'resizeCanvas': $image->resizeCanvas($size[0], $size[1], 'center'); break; case 'fit': $image->fit($size[0], $size[1]); break; } $image->save(sprintf('%s/%s', $this->getLocation(), $size[3] . '-' . $name)); } parent::postUpdate($input); }
php
public function postUpdate($input) { foreach ($this->getSizes() as $size) { $name = $this->getName(); try { $image = Image::make(sprintf('%s/%s', $this->getLocation(), $name)); } catch (NotReadableException $e) { continue; } switch ($size[2]) { case 'resize': $image->resize($size[0], $size[1], function ($constraint) { $constraint->aspectRatio(); }); break; case 'resizeCanvas': $image->resizeCanvas($size[0], $size[1], 'center'); break; case 'fit': $image->fit($size[0], $size[1]); break; } $image->save(sprintf('%s/%s', $this->getLocation(), $size[3] . '-' . $name)); } parent::postUpdate($input); }
[ "public", "function", "postUpdate", "(", "$", "input", ")", "{", "foreach", "(", "$", "this", "->", "getSizes", "(", ")", "as", "$", "size", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "try", "{", "$", "image", "=", ...
Upload the image. @param array $input @access public @return void
[ "Upload", "the", "image", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/ImageField.php#L86-L115
damonjones/Vebra-PHP-API-Wrapper
lib/YDD/Vebra/Model/AttributedModel.php
AttributedModel.setAttribute
public function setAttribute($key, $value) { if (array_key_exists($key, static::$attributeTypeMapping)) { $type = strtolower(static::$attributeTypeMapping[$key]); switch ($type) { case 'boolean': case 'bool': $value = (bool) filter_var($value, FILTER_VALIDATE_BOOLEAN); break; case 'integer': case 'int': $value = (int) $value; break; case 'float': $value = (float) $value; break; case 'string': default: $value = (string) $value; break; } $this->attributes[$key] = $value; } else { throw new \InvalidArgumentException("Unexpected attribute '$key'."); } return $this; }
php
public function setAttribute($key, $value) { if (array_key_exists($key, static::$attributeTypeMapping)) { $type = strtolower(static::$attributeTypeMapping[$key]); switch ($type) { case 'boolean': case 'bool': $value = (bool) filter_var($value, FILTER_VALIDATE_BOOLEAN); break; case 'integer': case 'int': $value = (int) $value; break; case 'float': $value = (float) $value; break; case 'string': default: $value = (string) $value; break; } $this->attributes[$key] = $value; } else { throw new \InvalidArgumentException("Unexpected attribute '$key'."); } return $this; }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "static", "::", "$", "attributeTypeMapping", ")", ")", "{", "$", "type", "=", "strtolower", "(", "static", "::", "$...
set Attribute @param string $key The attribute name @param \SimpleXMLElement $value The attribute value @return object
[ "set", "Attribute" ]
train
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/Model/AttributedModel.php#L52-L80
txj123/zilf
src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
PdoSessionHandler.write
public function write($sessionId, $data) { $maxlifetime = (int) ini_get('session.gc_maxlifetime'); try { // We use a single MERGE SQL query when supported by the database. $mergeStmt = $this->getMergeStatement($sessionId, $data, $maxlifetime); if (null !== $mergeStmt) { $mergeStmt->execute(); return true; } $updateStmt = $this->pdo->prepare( "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id" ); $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $updateStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); $updateStmt->execute(); // When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in // duplicate key errors when the same session is written simultaneously (given the LOCK_NONE behavior). // We can just catch such an error and re-execute the update. This is similar to a serializable // transaction with retry logic on serialization failures but without the overhead and without possible // false positives due to longer gap locking. if (!$updateStmt->rowCount()) { try { $insertStmt = $this->pdo->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" ); $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $insertStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); } catch (\PDOException $e) { // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys if (0 === strpos($e->getCode(), '23')) { $updateStmt->execute(); } else { throw $e; } } } } catch (\PDOException $e) { $this->rollback(); throw $e; } return true; }
php
public function write($sessionId, $data) { $maxlifetime = (int) ini_get('session.gc_maxlifetime'); try { // We use a single MERGE SQL query when supported by the database. $mergeStmt = $this->getMergeStatement($sessionId, $data, $maxlifetime); if (null !== $mergeStmt) { $mergeStmt->execute(); return true; } $updateStmt = $this->pdo->prepare( "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id" ); $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $updateStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); $updateStmt->execute(); // When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in // duplicate key errors when the same session is written simultaneously (given the LOCK_NONE behavior). // We can just catch such an error and re-execute the update. This is similar to a serializable // transaction with retry logic on serialization failures but without the overhead and without possible // false positives due to longer gap locking. if (!$updateStmt->rowCount()) { try { $insertStmt = $this->pdo->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" ); $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $insertStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); } catch (\PDOException $e) { // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys if (0 === strpos($e->getCode(), '23')) { $updateStmt->execute(); } else { throw $e; } } } } catch (\PDOException $e) { $this->rollback(); throw $e; } return true; }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "data", ")", "{", "$", "maxlifetime", "=", "(", "int", ")", "ini_get", "(", "'session.gc_maxlifetime'", ")", ";", "try", "{", "// We use a single MERGE SQL query when supported by the database.", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L322-L375
txj123/zilf
src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
PdoSessionHandler.doRead
private function doRead($sessionId) { $this->sessionExpired = false; if (self::LOCK_ADVISORY === $this->lockMode) { $this->unlockStatements[] = $this->doAdvisoryLock($sessionId); } $selectSql = $this->getSelectSql(); $selectStmt = $this->pdo->prepare($selectSql); $selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); do { $selectStmt->execute(); $sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM); if ($sessionRows) { if ($sessionRows[0][1] + $sessionRows[0][2] < time()) { $this->sessionExpired = true; return ''; } return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0]; } if (self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block // until other connections to the session are committed. try { $insertStmt = $this->pdo->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" ); $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $insertStmt->bindValue(':data', '', \PDO::PARAM_LOB); $insertStmt->bindValue(':lifetime', 0, \PDO::PARAM_INT); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); } catch (\PDOException $e) { // Catch duplicate key error because other connection created the session already. // It would only not be the case when the other connection destroyed the session. if (0 === strpos($e->getCode(), '23')) { // Retrieve finished session data written by concurrent connection by restarting the loop. // We have to start a new transaction as a failed query will mark the current transaction as // aborted in PostgreSQL and disallow further queries within it. $this->rollback(); $this->beginTransaction(); continue; } throw $e; } } return ''; } while (true); }
php
private function doRead($sessionId) { $this->sessionExpired = false; if (self::LOCK_ADVISORY === $this->lockMode) { $this->unlockStatements[] = $this->doAdvisoryLock($sessionId); } $selectSql = $this->getSelectSql(); $selectStmt = $this->pdo->prepare($selectSql); $selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); do { $selectStmt->execute(); $sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM); if ($sessionRows) { if ($sessionRows[0][1] + $sessionRows[0][2] < time()) { $this->sessionExpired = true; return ''; } return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0]; } if (self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block // until other connections to the session are committed. try { $insertStmt = $this->pdo->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" ); $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $insertStmt->bindValue(':data', '', \PDO::PARAM_LOB); $insertStmt->bindValue(':lifetime', 0, \PDO::PARAM_INT); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); } catch (\PDOException $e) { // Catch duplicate key error because other connection created the session already. // It would only not be the case when the other connection destroyed the session. if (0 === strpos($e->getCode(), '23')) { // Retrieve finished session data written by concurrent connection by restarting the loop. // We have to start a new transaction as a failed query will mark the current transaction as // aborted in PostgreSQL and disallow further queries within it. $this->rollback(); $this->beginTransaction(); continue; } throw $e; } } return ''; } while (true); }
[ "private", "function", "doRead", "(", "$", "sessionId", ")", "{", "$", "this", "->", "sessionExpired", "=", "false", ";", "if", "(", "self", "::", "LOCK_ADVISORY", "===", "$", "this", "->", "lockMode", ")", "{", "$", "this", "->", "unlockStatements", "["...
Reads the session data in respect to the different locking strategies. We need to make sure we do not return session data that is already considered garbage according to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes. @param string $sessionId Session ID @return string The session data
[ "Reads", "the", "session", "data", "in", "respect", "to", "the", "different", "locking", "strategies", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L496-L552
txj123/zilf
src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
PdoSessionHandler.getMergeStatement
private function getMergeStatement($sessionId, $data, $maxlifetime) { $mergeSql = null; switch (true) { case 'mysql' === $this->driver: $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; break; case 'oci' === $this->driver: // DUAL is Oracle specific dummy table $mergeSql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?"; break; case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx $mergeSql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; break; case 'sqlite' === $this->driver: $mergeSql = "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; break; case 'pgsql' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '9.5', '>='): $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; break; } if (null !== $mergeSql) { $mergeStmt = $this->pdo->prepare($mergeSql); if ('sqlsrv' === $this->driver || 'oci' === $this->driver) { $mergeStmt->bindParam(1, $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(4, $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(5, time(), \PDO::PARAM_INT); $mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(7, $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(8, time(), \PDO::PARAM_INT); } else { $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); } return $mergeStmt; } }
php
private function getMergeStatement($sessionId, $data, $maxlifetime) { $mergeSql = null; switch (true) { case 'mysql' === $this->driver: $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; break; case 'oci' === $this->driver: // DUAL is Oracle specific dummy table $mergeSql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?"; break; case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx $mergeSql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; break; case 'sqlite' === $this->driver: $mergeSql = "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; break; case 'pgsql' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '9.5', '>='): $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; break; } if (null !== $mergeSql) { $mergeStmt = $this->pdo->prepare($mergeSql); if ('sqlsrv' === $this->driver || 'oci' === $this->driver) { $mergeStmt->bindParam(1, $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(4, $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(5, time(), \PDO::PARAM_INT); $mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(7, $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(8, time(), \PDO::PARAM_INT); } else { $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB); $mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); } return $mergeStmt; } }
[ "private", "function", "getMergeStatement", "(", "$", "sessionId", ",", "$", "data", ",", "$", "maxlifetime", ")", "{", "$", "mergeSql", "=", "null", ";", "switch", "(", "true", ")", "{", "case", "'mysql'", "===", "$", "this", "->", "driver", ":", "$",...
Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data. @param string $sessionId Session ID @param string $data Encoded session data @param int $maxlifetime session.gc_maxlifetime @return \PDOStatement|null The merge statement or null when not supported
[ "Returns", "a", "merge", "/", "upsert", "(", "i", ".", "e", ".", "insert", "or", "update", ")", "statement", "when", "supported", "by", "the", "database", "for", "writing", "session", "data", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L655-L706
white-frame/dynatable
src/Dynatable.php
Dynatable.search
public function search() { $numargs = func_num_args(); if ($numargs == 1) { $this->search = func_get_arg(0); } elseif ($numargs == 2) { $this->columnSearchs[func_get_arg(0)] = func_get_arg(1); } return $this; }
php
public function search() { $numargs = func_num_args(); if ($numargs == 1) { $this->search = func_get_arg(0); } elseif ($numargs == 2) { $this->columnSearchs[func_get_arg(0)] = func_get_arg(1); } return $this; }
[ "public", "function", "search", "(", ")", "{", "$", "numargs", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "numargs", "==", "1", ")", "{", "$", "this", "->", "search", "=", "func_get_arg", "(", "0", ")", ";", "}", "elseif", "(", "$", "nu...
Define the search handler for the table @return $this
[ "Define", "the", "search", "handler", "for", "the", "table" ]
train
https://github.com/white-frame/dynatable/blob/823bcab67e0dc890a4545361dfdc22f48065b2f6/src/Dynatable.php#L119-L129
white-frame/dynatable
src/Dynatable.php
Dynatable.getRecords
protected function getRecords() { $records = []; foreach ($this->query->get() as $row) { $record = []; foreach ($this->columns as $name => $handler) { $record[$name] = $handler($row); } $records[] = $record; } return $records; }
php
protected function getRecords() { $records = []; foreach ($this->query->get() as $row) { $record = []; foreach ($this->columns as $name => $handler) { $record[$name] = $handler($row); } $records[] = $record; } return $records; }
[ "protected", "function", "getRecords", "(", ")", "{", "$", "records", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "query", "->", "get", "(", ")", "as", "$", "row", ")", "{", "$", "record", "=", "[", "]", ";", "foreach", "(", "$", "th...
Passing Fluent records into the column handler for making the real record list @return array
[ "Passing", "Fluent", "records", "into", "the", "column", "handler", "for", "making", "the", "real", "record", "list" ]
train
https://github.com/white-frame/dynatable/blob/823bcab67e0dc890a4545361dfdc22f48065b2f6/src/Dynatable.php#L202-L215
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php
SelectPolymorphicField.render
public function render() { $baseModel = $this->getAdmin()->getModel(); $baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier()); if (!$baseModel) { $baseModel = $this->getAdmin()->getModel(); $baseModel = new $baseModel; } $relatedModel = $baseModel->{$this->getName()}()->getRelated(); if (isset($baseModel->{$this->getName()}[0])) { $this->setValue($baseModel->{$this->getName()}[0]->id); } $options = []; foreach ($relatedModel::all() as $option) { $options[$option->id] = $option->path; } $this->options($options); return parent::render(); }
php
public function render() { $baseModel = $this->getAdmin()->getModel(); $baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier()); if (!$baseModel) { $baseModel = $this->getAdmin()->getModel(); $baseModel = new $baseModel; } $relatedModel = $baseModel->{$this->getName()}()->getRelated(); if (isset($baseModel->{$this->getName()}[0])) { $this->setValue($baseModel->{$this->getName()}[0]->id); } $options = []; foreach ($relatedModel::all() as $option) { $options[$option->id] = $option->path; } $this->options($options); return parent::render(); }
[ "public", "function", "render", "(", ")", "{", "$", "baseModel", "=", "$", "this", "->", "getAdmin", "(", ")", "->", "getModel", "(", ")", ";", "$", "baseModel", "=", "$", "baseModel", "::", "find", "(", "$", "this", "->", "getAdmin", "(", ")", "->...
Override the parent renderer to set the polymorphic options. @access public @return mixed|string
[ "Override", "the", "parent", "renderer", "to", "set", "the", "polymorphic", "options", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php#L63-L87
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php
SelectPolymorphicField.postUpdate
public function postUpdate($input) { $baseModel = $this->getAdmin()->getModel(); $baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier()); $morphType = $baseModel->{$this->getName()}()->getMorphType(); $morphType = str_replace(sprintf('%s.', $this->getName()), '', $morphType); $foreignKey = $baseModel->{$this->getName()}()->getForeignKey(); $foreignKey = str_replace(sprintf('%s.', $this->getName()), '', $foreignKey); // remove old polymorphic relations foreach ($baseModel->{$this->getName()} as $item) { $item->update([ $foreignKey => 0, $morphType => '', ]); } // update new item with polymorphic relation $baseModel->{$this->getName()}() ->getRelated() ->where($items->getKeyName(), $input[$this->getName()]) ->update([ $foreignKey => $this->getAdmin()->getFormBuilder()->getIdentifier(), $morphType => get_class($baseModel), ]); }
php
public function postUpdate($input) { $baseModel = $this->getAdmin()->getModel(); $baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier()); $morphType = $baseModel->{$this->getName()}()->getMorphType(); $morphType = str_replace(sprintf('%s.', $this->getName()), '', $morphType); $foreignKey = $baseModel->{$this->getName()}()->getForeignKey(); $foreignKey = str_replace(sprintf('%s.', $this->getName()), '', $foreignKey); // remove old polymorphic relations foreach ($baseModel->{$this->getName()} as $item) { $item->update([ $foreignKey => 0, $morphType => '', ]); } // update new item with polymorphic relation $baseModel->{$this->getName()}() ->getRelated() ->where($items->getKeyName(), $input[$this->getName()]) ->update([ $foreignKey => $this->getAdmin()->getFormBuilder()->getIdentifier(), $morphType => get_class($baseModel), ]); }
[ "public", "function", "postUpdate", "(", "$", "input", ")", "{", "$", "baseModel", "=", "$", "this", "->", "getAdmin", "(", ")", "->", "getModel", "(", ")", ";", "$", "baseModel", "=", "$", "baseModel", "::", "find", "(", "$", "this", "->", "getAdmin...
Post update hook. @param array $input @access public @return void
[ "Post", "update", "hook", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php#L97-L124
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Data/DropdownDivider.php
DropdownDivider.render
public function render($customAttributes = null) { if (MenuHelper::getConfig()->getCustomDropdownDividerRenderFunction() != null) { return MenuHelper::getConfig()->getCustomDropdownDividerRenderFunction()(); } return null; }
php
public function render($customAttributes = null) { if (MenuHelper::getConfig()->getCustomDropdownDividerRenderFunction() != null) { return MenuHelper::getConfig()->getCustomDropdownDividerRenderFunction()(); } return null; }
[ "public", "function", "render", "(", "$", "customAttributes", "=", "null", ")", "{", "if", "(", "MenuHelper", "::", "getConfig", "(", ")", "->", "getCustomDropdownDividerRenderFunction", "(", ")", "!=", "null", ")", "{", "return", "MenuHelper", "::", "getConfi...
Get the evaluated contents of the object. @param null|array $customAttributes @return null
[ "Get", "the", "evaluated", "contents", "of", "the", "object", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Data/DropdownDivider.php#L30-L37
txj123/zilf
src/Zilf/Db/DbServiceProvider.php
DbServiceProvider.register
public function register() { $params = Zilf::$container->getShare('config')->get('databases'); foreach ($params as $key => $row) { Zilf::$container->register( 'db.' . $key, function () use ($row) { $connect = new Connection($row); $connect->open(); return $connect; } ); } }
php
public function register() { $params = Zilf::$container->getShare('config')->get('databases'); foreach ($params as $key => $row) { Zilf::$container->register( 'db.' . $key, function () use ($row) { $connect = new Connection($row); $connect->open(); return $connect; } ); } }
[ "public", "function", "register", "(", ")", "{", "$", "params", "=", "Zilf", "::", "$", "container", "->", "getShare", "(", "'config'", ")", "->", "get", "(", "'databases'", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "row",...
Register the service provider. @throws \Exception
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/DbServiceProvider.php#L22-L34
crysalead/sql-dialect
src/Statement/Behavior/HasFlags.php
HasFlags.getFlag
public function getFlag($flag) { return isset($this->_parts['flags'][$flag]) ? $this->_parts['flags'][$flag] : null; }
php
public function getFlag($flag) { return isset($this->_parts['flags'][$flag]) ? $this->_parts['flags'][$flag] : null; }
[ "public", "function", "getFlag", "(", "$", "flag", ")", "{", "return", "isset", "(", "$", "this", "->", "_parts", "[", "'flags'", "]", "[", "$", "flag", "]", ")", "?", "$", "this", "->", "_parts", "[", "'flags'", "]", "[", "$", "flag", "]", ":", ...
Gets a flag. @param string $name The name of the flag to get. @return boolean The flag value.
[ "Gets", "a", "flag", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasFlags.php#L24-L27
txj123/zilf
src/Zilf/Config/BaseConfig.php
BaseConfig.getEnvValue
protected function getEnvValue(string $property, string $prefix, string $shortPrefix) { if (($value = getenv("{$shortPrefix}.{$property}")) !== false) { return $value; } elseif (($value = getenv("{$prefix}.{$property}")) !== false) { return $value; } elseif (($value = getenv($property)) !== false && $property != 'path') { return $value; } return null; }
php
protected function getEnvValue(string $property, string $prefix, string $shortPrefix) { if (($value = getenv("{$shortPrefix}.{$property}")) !== false) { return $value; } elseif (($value = getenv("{$prefix}.{$property}")) !== false) { return $value; } elseif (($value = getenv($property)) !== false && $property != 'path') { return $value; } return null; }
[ "protected", "function", "getEnvValue", "(", "string", "$", "property", ",", "string", "$", "prefix", ",", "string", "$", "shortPrefix", ")", "{", "if", "(", "(", "$", "value", "=", "getenv", "(", "\"{$shortPrefix}.{$property}\"", ")", ")", "!==", "false", ...
Retrieve an environment-specific configuration setting @param string $property @param string $prefix @param string $shortPrefix @return type
[ "Retrieve", "an", "environment", "-", "specific", "configuration", "setting" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Config/BaseConfig.php#L67-L80
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
FormMapper.getTabs
public function getTabs() { $tabs = []; foreach ($this->getFields() as $field) { if ($field->getTab() === null) { continue; } $tabs[Str::slug($field->getTab())] = $field->getTab(); } return $tabs; }
php
public function getTabs() { $tabs = []; foreach ($this->getFields() as $field) { if ($field->getTab() === null) { continue; } $tabs[Str::slug($field->getTab())] = $field->getTab(); } return $tabs; }
[ "public", "function", "getTabs", "(", ")", "{", "$", "tabs", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getTab", "(", ")", "===", "null", ")", "{",...
Get the mapper tabs. @access public @return array
[ "Get", "the", "mapper", "tabs", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L77-L89
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
FormMapper.tab
public function tab($name, $mapper) { $this->tab = $name; if ($mapper instanceof Closure) { $mapper($this); } }
php
public function tab($name, $mapper) { $this->tab = $name; if ($mapper instanceof Closure) { $mapper($this); } }
[ "public", "function", "tab", "(", "$", "name", ",", "$", "mapper", ")", "{", "$", "this", "->", "tab", "=", "$", "name", ";", "if", "(", "$", "mapper", "instanceof", "Closure", ")", "{", "$", "mapper", "(", "$", "this", ")", ";", "}", "}" ]
Set the mapper current tab. @param string $name @param string|callable $mapper @access public @return void
[ "Set", "the", "mapper", "current", "tab", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L100-L107
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
FormMapper.hasFieldsOnPosition
public function hasFieldsOnPosition($position) { $fieldsOnPosition = false; foreach ($this->getFields() as $field) { if ($field->getPosition() == $position) { $fieldsOnPosition = true; } } return $fieldsOnPosition; }
php
public function hasFieldsOnPosition($position) { $fieldsOnPosition = false; foreach ($this->getFields() as $field) { if ($field->getPosition() == $position) { $fieldsOnPosition = true; } } return $fieldsOnPosition; }
[ "public", "function", "hasFieldsOnPosition", "(", "$", "position", ")", "{", "$", "fieldsOnPosition", "=", "false", ";", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getPosition",...
Check for fields on a specific position. @param string $position @access public @return bool
[ "Check", "for", "fields", "on", "a", "specific", "position", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L148-L159
despark/image-purify
src/Commands/Command.php
Command.getArguments
public function getArguments(): array { // We will need to process the arguments and merge them. $arguments = array_map([$this, 'processArgument'], $this->arguments); return array_merge($arguments, $this->rawArguments); }
php
public function getArguments(): array { // We will need to process the arguments and merge them. $arguments = array_map([$this, 'processArgument'], $this->arguments); return array_merge($arguments, $this->rawArguments); }
[ "public", "function", "getArguments", "(", ")", ":", "array", "{", "// We will need to process the arguments and merge them.", "$", "arguments", "=", "array_map", "(", "[", "$", "this", ",", "'processArgument'", "]", ",", "$", "this", "->", "arguments", ")", ";", ...
Gets all the arguments @return array
[ "Gets", "all", "the", "arguments" ]
train
https://github.com/despark/image-purify/blob/63066df047145a32ed11579439d0a2b085ce0484/src/Commands/Command.php#L114-L120
oxygen-cms/core
src/Html/Form/StaticField.php
StaticField.fromEntity
public static function fromEntity(FieldMetadata $meta, $entity) { $instance = new static($meta, $entity->getAttribute($meta->name)); return $instance; }
php
public static function fromEntity(FieldMetadata $meta, $entity) { $instance = new static($meta, $entity->getAttribute($meta->name)); return $instance; }
[ "public", "static", "function", "fromEntity", "(", "FieldMetadata", "$", "meta", ",", "$", "entity", ")", "{", "$", "instance", "=", "new", "static", "(", "$", "meta", ",", "$", "entity", "->", "getAttribute", "(", "$", "meta", "->", "name", ")", ")", ...
Create a field from meta and a model @param FieldMetadata $meta @param object $entity @return FieldMetadata
[ "Create", "a", "field", "from", "meta", "and", "a", "model" ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Form/StaticField.php#L104-L108
phug-php/compiler
src/Phug/Compiler.php
Compiler.reset
public function reset() { $this->layout = null; $this->namedCompilers = []; $this->importPaths = []; $this->importNodeYielded = false; $this->importNode = null; $this->parentCompiler = null; }
php
public function reset() { $this->layout = null; $this->namedCompilers = []; $this->importPaths = []; $this->importNodeYielded = false; $this->importNode = null; $this->parentCompiler = null; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "layout", "=", "null", ";", "$", "this", "->", "namedCompilers", "=", "[", "]", ";", "$", "this", "->", "importPaths", "=", "[", "]", ";", "$", "this", "->", "importNodeYielded", "=", ...
Reset layout and compilers cache on clone.
[ "Reset", "layout", "and", "compilers", "cache", "on", "clone", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L265-L273
phug-php/compiler
src/Phug/Compiler.php
Compiler.locate
public function locate($path, $paths = null) { $paths = $paths ?: $this->getOption('paths'); return $this->locator->locate( $path, $paths, $this->getOption('extensions') ); }
php
public function locate($path, $paths = null) { $paths = $paths ?: $this->getOption('paths'); return $this->locator->locate( $path, $paths, $this->getOption('extensions') ); }
[ "public", "function", "locate", "(", "$", "path", ",", "$", "paths", "=", "null", ")", "{", "$", "paths", "=", "$", "paths", "?", ":", "$", "this", "->", "getOption", "(", "'paths'", ")", ";", "return", "$", "this", "->", "locator", "->", "locate",...
Locate a file for a given path. Returns null if not found. @param string $path @param array $paths @return string|null
[ "Locate", "a", "file", "for", "a", "given", "path", ".", "Returns", "null", "if", "not", "found", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L304-L313
phug-php/compiler
src/Phug/Compiler.php
Compiler.resolve
public function resolve($path, $paths = null) { $resolvePath = $this->locate($path, $paths); $this->assert( $resolvePath || $this->hasOption('not_found_template'), sprintf( "Source file %s not found \nPaths: %s \nExtensions: %s", $path, implode(', ', $this->getOption('paths')), implode(', ', $this->getOption('extensions')) ) ); return $resolvePath; }
php
public function resolve($path, $paths = null) { $resolvePath = $this->locate($path, $paths); $this->assert( $resolvePath || $this->hasOption('not_found_template'), sprintf( "Source file %s not found \nPaths: %s \nExtensions: %s", $path, implode(', ', $this->getOption('paths')), implode(', ', $this->getOption('extensions')) ) ); return $resolvePath; }
[ "public", "function", "resolve", "(", "$", "path", ",", "$", "paths", "=", "null", ")", "{", "$", "resolvePath", "=", "$", "this", "->", "locate", "(", "$", "path", ",", "$", "paths", ")", ";", "$", "this", "->", "assert", "(", "$", "resolvePath", ...
Resolve a path using the base directories. Throw an exception if not found. @param string $path @param array $paths @throws CompilerException @return string
[ "Resolve", "a", "path", "using", "the", "base", "directories", ".", "Throw", "an", "exception", "if", "not", "found", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L326-L341
phug-php/compiler
src/Phug/Compiler.php
Compiler.getFormatter
public function getFormatter() { $debug = $this->getOption('debug'); return isset($this->formatters[$debug]) ? $this->formatters[$debug] : $this->initializeFormatter(); }
php
public function getFormatter() { $debug = $this->getOption('debug'); return isset($this->formatters[$debug]) ? $this->formatters[$debug] : $this->initializeFormatter(); }
[ "public", "function", "getFormatter", "(", ")", "{", "$", "debug", "=", "$", "this", "->", "getOption", "(", "'debug'", ")", ";", "return", "isset", "(", "$", "this", "->", "formatters", "[", "$", "debug", "]", ")", "?", "$", "this", "->", "formatter...
Returns the currently used Formatter instance. @return Formatter
[ "Returns", "the", "currently", "used", "Formatter", "instance", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L398-L405
phug-php/compiler
src/Phug/Compiler.php
Compiler.setNodeCompiler
public function setNodeCompiler($className, $handler) { if (!is_subclass_of($handler, NodeCompilerInterface::class)) { throw new \InvalidArgumentException( 'Passed node compiler needs to implement '. NodeCompilerInterface::class.'. '. (is_object($handler) ? get_class($handler) : $handler). ' given.' ); } $this->nodeCompilers[$className] = $handler; return $this; }
php
public function setNodeCompiler($className, $handler) { if (!is_subclass_of($handler, NodeCompilerInterface::class)) { throw new \InvalidArgumentException( 'Passed node compiler needs to implement '. NodeCompilerInterface::class.'. '. (is_object($handler) ? get_class($handler) : $handler). ' given.' ); } $this->nodeCompilers[$className] = $handler; return $this; }
[ "public", "function", "setNodeCompiler", "(", "$", "className", ",", "$", "handler", ")", "{", "if", "(", "!", "is_subclass_of", "(", "$", "handler", ",", "NodeCompilerInterface", "::", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", ...
Set the node compiler for a given node class name. @param string $className node class name @param NodeCompilerInterface|string $handler handler @return $this
[ "Set", "the", "node", "compiler", "for", "a", "given", "node", "class", "name", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L415-L429
phug-php/compiler
src/Phug/Compiler.php
Compiler.getNamedCompiler
private function getNamedCompiler($compiler) { if (!isset($this->namedCompilers[$compiler])) { $this->namedCompilers[$compiler] = new $compiler($this); } return $this->namedCompilers[$compiler]; }
php
private function getNamedCompiler($compiler) { if (!isset($this->namedCompilers[$compiler])) { $this->namedCompilers[$compiler] = new $compiler($this); } return $this->namedCompilers[$compiler]; }
[ "private", "function", "getNamedCompiler", "(", "$", "compiler", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "namedCompilers", "[", "$", "compiler", "]", ")", ")", "{", "$", "this", "->", "namedCompilers", "[", "$", "compiler", "]", "=",...
Create a new compiler instance by name or return the previous instance with the same name. @param string $compiler name @return NodeCompilerInterface
[ "Create", "a", "new", "compiler", "instance", "by", "name", "or", "return", "the", "previous", "instance", "with", "the", "same", "name", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L439-L446
phug-php/compiler
src/Phug/Compiler.php
Compiler.&
public function &getBlocksByName($name) { if (!isset($this->namedBlocks[$name])) { $this->namedBlocks[$name] = []; } return $this->namedBlocks[$name]; }
php
public function &getBlocksByName($name) { if (!isset($this->namedBlocks[$name])) { $this->namedBlocks[$name] = []; } return $this->namedBlocks[$name]; }
[ "public", "function", "&", "getBlocksByName", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "namedBlocks", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "namedBlocks", "[", "$", "name", "]", "=", "[", "]"...
Return list of blocks for a given name. @param $name @return mixed
[ "Return", "list", "of", "blocks", "for", "a", "given", "name", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L455-L462
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileNode
public function compileNode(NodeInterface $node, ElementInterface $parent = null) { $nodeEvent = new NodeEvent($node); $this->trigger($nodeEvent); $node = $nodeEvent->getNode(); $this->currentNode = $node; foreach ($this->nodeCompilers as $className => $compiler) { if (is_a($node, $className)) { if (!($compiler instanceof NodeCompilerInterface)) { $compiler = $this->getNamedCompiler($compiler); } $element = $compiler->compileNode($node, $parent); if ($element instanceof ElementInterface && !($element instanceof BlockElement)) { $elementEvent = new ElementEvent($nodeEvent, $element); $this->trigger($elementEvent); $element = $elementEvent->getElement(); } return $element; } } $this->throwException( 'No compiler found able to compile '.get_class($node), $node ); }
php
public function compileNode(NodeInterface $node, ElementInterface $parent = null) { $nodeEvent = new NodeEvent($node); $this->trigger($nodeEvent); $node = $nodeEvent->getNode(); $this->currentNode = $node; foreach ($this->nodeCompilers as $className => $compiler) { if (is_a($node, $className)) { if (!($compiler instanceof NodeCompilerInterface)) { $compiler = $this->getNamedCompiler($compiler); } $element = $compiler->compileNode($node, $parent); if ($element instanceof ElementInterface && !($element instanceof BlockElement)) { $elementEvent = new ElementEvent($nodeEvent, $element); $this->trigger($elementEvent); $element = $elementEvent->getElement(); } return $element; } } $this->throwException( 'No compiler found able to compile '.get_class($node), $node ); }
[ "public", "function", "compileNode", "(", "NodeInterface", "$", "node", ",", "ElementInterface", "$", "parent", "=", "null", ")", "{", "$", "nodeEvent", "=", "new", "NodeEvent", "(", "$", "node", ")", ";", "$", "this", "->", "trigger", "(", "$", "nodeEve...
Returns PHTML from pug node input. @param NodeInterface $node input @param ElementInterface $parent optional parent element @throws CompilerException @return ElementInterface
[ "Returns", "PHTML", "from", "pug", "node", "input", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L484-L514
phug-php/compiler
src/Phug/Compiler.php
Compiler.replaceBlock
public function replaceBlock(BlockElement $block, array $children = null) { if ($parent = $block->getParent()) { foreach (array_reverse($children ?: $block->getChildren()) as $child) { $parent->insertAfter($block, $child); } $previous = $block->getPreviousSibling(); if ($previous instanceof TextElement) { $previous->setEnd(true); } $block->remove(); } }
php
public function replaceBlock(BlockElement $block, array $children = null) { if ($parent = $block->getParent()) { foreach (array_reverse($children ?: $block->getChildren()) as $child) { $parent->insertAfter($block, $child); } $previous = $block->getPreviousSibling(); if ($previous instanceof TextElement) { $previous->setEnd(true); } $block->remove(); } }
[ "public", "function", "replaceBlock", "(", "BlockElement", "$", "block", ",", "array", "$", "children", "=", "null", ")", "{", "if", "(", "$", "parent", "=", "$", "block", "->", "getParent", "(", ")", ")", "{", "foreach", "(", "array_reverse", "(", "$"...
Replace a block by its nodes. @param BlockElement $block @param array $children
[ "Replace", "a", "block", "by", "its", "nodes", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L522-L534
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileBlocks
public function compileBlocks() { do { $blockProceeded = 0; foreach ($this->getBlocks() as $name => $blocks) { foreach ($blocks as $block) { $this->assert( $block instanceof BlockElement, 'Unexpected block for the name '.$name, $block instanceof AbstractElement ? $block->getOriginNode() : null ); /** @var BlockElement $block */ if ($block->hasParent()) { $this->replaceBlock($block); $blockProceeded++; } } } } while ($blockProceeded); return $this; }
php
public function compileBlocks() { do { $blockProceeded = 0; foreach ($this->getBlocks() as $name => $blocks) { foreach ($blocks as $block) { $this->assert( $block instanceof BlockElement, 'Unexpected block for the name '.$name, $block instanceof AbstractElement ? $block->getOriginNode() : null ); /** @var BlockElement $block */ if ($block->hasParent()) { $this->replaceBlock($block); $blockProceeded++; } } } } while ($blockProceeded); return $this; }
[ "public", "function", "compileBlocks", "(", ")", "{", "do", "{", "$", "blockProceeded", "=", "0", ";", "foreach", "(", "$", "this", "->", "getBlocks", "(", ")", "as", "$", "name", "=>", "$", "blocks", ")", "{", "foreach", "(", "$", "blocks", "as", ...
Replace each block by its compiled children. @throws CompilerException @return $this
[ "Replace", "each", "block", "by", "its", "compiled", "children", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L543-L564
phug-php/compiler
src/Phug/Compiler.php
Compiler.importBlocks
public function importBlocks(array $blocks) { foreach ($blocks as $name => $list) { foreach ($list as $block) { /* @var BlockElement $block */ $block->addCompiler($this); } } return $this; }
php
public function importBlocks(array $blocks) { foreach ($blocks as $name => $list) { foreach ($list as $block) { /* @var BlockElement $block */ $block->addCompiler($this); } } return $this; }
[ "public", "function", "importBlocks", "(", "array", "$", "blocks", ")", "{", "foreach", "(", "$", "blocks", "as", "$", "name", "=>", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "block", ")", "{", "/* @var BlockElement $block */", "$", ...
Import blocks named lists into the compiler. @param array $blocks @return $this
[ "Import", "blocks", "named", "lists", "into", "the", "compiler", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L573-L583
phug-php/compiler
src/Phug/Compiler.php
Compiler.registerImportPath
public function registerImportPath($path) { $current = $this->getPath(); if (!isset($this->importPaths[$current])) { $this->importPaths[$current] = []; } $this->importPaths[$current][] = $path; if ($this->parentCompiler) { $this->parentCompiler->registerImportPath($path); } return $this; }
php
public function registerImportPath($path) { $current = $this->getPath(); if (!isset($this->importPaths[$current])) { $this->importPaths[$current] = []; } $this->importPaths[$current][] = $path; if ($this->parentCompiler) { $this->parentCompiler->registerImportPath($path); } return $this; }
[ "public", "function", "registerImportPath", "(", "$", "path", ")", "{", "$", "current", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "importPaths", "[", "$", "current", "]", ")", ")", "{", "$", ...
Register a path as an imported path of the current compiling path. @param $path
[ "Register", "a", "path", "as", "an", "imported", "path", "of", "the", "current", "compiling", "path", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L591-L605
phug-php/compiler
src/Phug/Compiler.php
Compiler.getImportPaths
public function getImportPaths($path = null) { if ($path === null) { return $this->importPaths; } return isset($this->importPaths[$path]) ? $this->importPaths[$path] : []; }
php
public function getImportPaths($path = null) { if ($path === null) { return $this->importPaths; } return isset($this->importPaths[$path]) ? $this->importPaths[$path] : []; }
[ "public", "function", "getImportPaths", "(", "$", "path", "=", "null", ")", "{", "if", "(", "$", "path", "===", "null", ")", "{", "return", "$", "this", "->", "importPaths", ";", "}", "return", "isset", "(", "$", "this", "->", "importPaths", "[", "$"...
@param string|null $path @return array
[ "@param", "string|null", "$path" ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L612-L621
phug-php/compiler
src/Phug/Compiler.php
Compiler.dump
public function dump($input, $path = null) { $element = $this->compileDocument($input, $path); return $element instanceof ElementInterface ? $element->dump() : var_export($element, true); }
php
public function dump($input, $path = null) { $element = $this->compileDocument($input, $path); return $element instanceof ElementInterface ? $element->dump() : var_export($element, true); }
[ "public", "function", "dump", "(", "$", "input", ",", "$", "path", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "compileDocument", "(", "$", "input", ",", "$", "path", ")", ";", "return", "$", "element", "instanceof", "ElementInterfac...
Dump a debug tre for a given pug input. @param string $input pug input @param string $path optional path of the compiled source @return string
[ "Dump", "a", "debug", "tre", "for", "a", "given", "pug", "input", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L639-L646
phug-php/compiler
src/Phug/Compiler.php
Compiler.dumpFile
public function dumpFile($path) { $path = $this->resolve($path); return $this->dump($this->getFileContents($path), $path); }
php
public function dumpFile($path) { $path = $this->resolve($path); return $this->dump($this->getFileContents($path), $path); }
[ "public", "function", "dumpFile", "(", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "resolve", "(", "$", "path", ")", ";", "return", "$", "this", "->", "dump", "(", "$", "this", "->", "getFileContents", "(", "$", "path", ")", ",", ...
Dump a debug tre for a given pug input. @param string $path pug input file @return string
[ "Dump", "a", "debug", "tre", "for", "a", "given", "pug", "input", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L655-L660
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileDocument
public function compileDocument($input, $path = null) { $element = $this->compileIntoElement($input, $path); $layout = $this->getLayout(); $blocksCompiler = $this; if ($layout) { $element = $layout->getDocument(); $blocksCompiler = $layout->getCompiler(); } $blocksCompiler->compileBlocks(); return $element; }
php
public function compileDocument($input, $path = null) { $element = $this->compileIntoElement($input, $path); $layout = $this->getLayout(); $blocksCompiler = $this; if ($layout) { $element = $layout->getDocument(); $blocksCompiler = $layout->getCompiler(); } $blocksCompiler->compileBlocks(); return $element; }
[ "public", "function", "compileDocument", "(", "$", "input", ",", "$", "path", "=", "null", ")", "{", "$", "element", "=", "$", "this", "->", "compileIntoElement", "(", "$", "input", ",", "$", "path", ")", ";", "$", "layout", "=", "$", "this", "->", ...
Returns ElementInterface from pug input with all layouts and blocks compiled. @param string $input pug input @param string $path optional path of the compiled source @throws CompilerException @return null|ElementInterface
[ "Returns", "ElementInterface", "from", "pug", "input", "with", "all", "layouts", "and", "blocks", "compiled", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L673-L685
phug-php/compiler
src/Phug/Compiler.php
Compiler.compile
public function compile($input, $path = null) { $compileEvent = new CompileEvent($input, $path ?: $this->getOption('filename')); $this->trigger($compileEvent); $input = $compileEvent->getInput(); $path = $compileEvent->getPath(); $this->importPaths = []; $includes = []; foreach ($this->getOption('includes') as $include) { $includes[] = $this->compileDocument(file_get_contents($include), $include); } $element = $this->compileDocument($input, $path); foreach (array_reverse($includes) as $include) { $element->prependChild($include); } $output = $this->getFormatter()->format($element); $output = $this->getFormatter()->formatDependencies().$output; $outputEvent = new OutputEvent($compileEvent, $output); $this->trigger($outputEvent); return $outputEvent->getOutput(); }
php
public function compile($input, $path = null) { $compileEvent = new CompileEvent($input, $path ?: $this->getOption('filename')); $this->trigger($compileEvent); $input = $compileEvent->getInput(); $path = $compileEvent->getPath(); $this->importPaths = []; $includes = []; foreach ($this->getOption('includes') as $include) { $includes[] = $this->compileDocument(file_get_contents($include), $include); } $element = $this->compileDocument($input, $path); foreach (array_reverse($includes) as $include) { $element->prependChild($include); } $output = $this->getFormatter()->format($element); $output = $this->getFormatter()->formatDependencies().$output; $outputEvent = new OutputEvent($compileEvent, $output); $this->trigger($outputEvent); return $outputEvent->getOutput(); }
[ "public", "function", "compile", "(", "$", "input", ",", "$", "path", "=", "null", ")", "{", "$", "compileEvent", "=", "new", "CompileEvent", "(", "$", "input", ",", "$", "path", "?", ":", "$", "this", "->", "getOption", "(", "'filename'", ")", ")", ...
Returns PHTML from pug input. @param string $input pug input @param string $path optional path of the compiled source @return string
[ "Returns", "PHTML", "from", "pug", "input", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L695-L721
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileFile
public function compileFile($path) { $path = $this->resolve($path); return $this->compile($this->getFileContents($path), $path); }
php
public function compileFile($path) { $path = $this->resolve($path); return $this->compile($this->getFileContents($path), $path); }
[ "public", "function", "compileFile", "(", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "resolve", "(", "$", "path", ")", ";", "return", "$", "this", "->", "compile", "(", "$", "this", "->", "getFileContents", "(", "$", "path", ")", "...
Returns PHTML from pug input file. @param string $path path of the compiled source @return string
[ "Returns", "PHTML", "from", "pug", "input", "file", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L730-L735
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileIntoElement
public function compileIntoElement($input, $path = null) { $this->path = $path; $this->namedBlocks = []; $node = $this->parser->parse($input, $path); //Let exceptions fall through $element = $this->compileNode($node); if ($element && !($element instanceof ElementInterface)) { $this->throwException( get_class($node). ' compiled into a value that does not implement ElementInterface: '. (is_object($element) ? get_class($element) : gettype($element)), $node ); } // @codeCoverageIgnore return $element; }
php
public function compileIntoElement($input, $path = null) { $this->path = $path; $this->namedBlocks = []; $node = $this->parser->parse($input, $path); //Let exceptions fall through $element = $this->compileNode($node); if ($element && !($element instanceof ElementInterface)) { $this->throwException( get_class($node). ' compiled into a value that does not implement ElementInterface: '. (is_object($element) ? get_class($element) : gettype($element)), $node ); } // @codeCoverageIgnore return $element; }
[ "public", "function", "compileIntoElement", "(", "$", "input", ",", "$", "path", "=", "null", ")", "{", "$", "this", "->", "path", "=", "$", "path", ";", "$", "this", "->", "namedBlocks", "=", "[", "]", ";", "$", "node", "=", "$", "this", "->", "...
Returns ElementInterface from pug input. @param string $input pug input @param string $path optional path of the compiled source @throws \Exception @return null|ElementInterface
[ "Returns", "ElementInterface", "from", "pug", "input", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L747-L766
phug-php/compiler
src/Phug/Compiler.php
Compiler.compileFileIntoElement
public function compileFileIntoElement($path) { $path = $this->resolve($path); return $this->compileIntoElement($this->getFileContents($path), $path); }
php
public function compileFileIntoElement($path) { $path = $this->resolve($path); return $this->compileIntoElement($this->getFileContents($path), $path); }
[ "public", "function", "compileFileIntoElement", "(", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "resolve", "(", "$", "path", ")", ";", "return", "$", "this", "->", "compileIntoElement", "(", "$", "this", "->", "getFileContents", "(", "$"...
Returns ElementInterface from pug input file. @param string $path path of the compiled source @return ElementInterface
[ "Returns", "ElementInterface", "from", "pug", "input", "file", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L775-L780
phug-php/compiler
src/Phug/Compiler.php
Compiler.throwException
public function throwException($message, $node = null, $code = 0, $previous = null) { $pattern = "Failed to compile: %s \nLine: %s \nOffset: %s"; $location = $node ? $node->getSourceLocation() : null; $path = $location ? $location->getPath() : $this->getPath(); $line = $location ? $location->getLine() : 0; $offset = $location ? $location->getOffset() : 0; $offsetLength = $location ? $location->getOffsetLength() : 0; if ($path) { $pattern .= "\nPath: $path"; } throw new CompilerException( new SourceLocation($path, $line, $offset, $offsetLength), vsprintf($pattern, [ $message, $line, $offset, ]), $code, $previous ); }
php
public function throwException($message, $node = null, $code = 0, $previous = null) { $pattern = "Failed to compile: %s \nLine: %s \nOffset: %s"; $location = $node ? $node->getSourceLocation() : null; $path = $location ? $location->getPath() : $this->getPath(); $line = $location ? $location->getLine() : 0; $offset = $location ? $location->getOffset() : 0; $offsetLength = $location ? $location->getOffsetLength() : 0; if ($path) { $pattern .= "\nPath: $path"; } throw new CompilerException( new SourceLocation($path, $line, $offset, $offsetLength), vsprintf($pattern, [ $message, $line, $offset, ]), $code, $previous ); }
[ "public", "function", "throwException", "(", "$", "message", ",", "$", "node", "=", "null", ",", "$", "code", "=", "0", ",", "$", "previous", "=", "null", ")", "{", "$", "pattern", "=", "\"Failed to compile: %s \\nLine: %s \\nOffset: %s\"", ";", "$", "locati...
Throws a compiler-exception. The current file, line and offset of the exception get automatically appended to the exception @param string $message A meaningful error message @param NodeInterface $node Node generating the error @param int $code Error code @param \Throwable $previous Source error @throws CompilerException
[ "Throws", "a", "compiler", "-", "exception", "." ]
train
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L841-L866
txj123/zilf
src/Zilf/HttpFoundation/ResponseHeaderBag.php
ResponseHeaderBag.allPreserveCase
public function allPreserveCase() { $headers = array(); foreach ($this->all() as $name => $value) { $headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value; } return $headers; }
php
public function allPreserveCase() { $headers = array(); foreach ($this->all() as $name => $value) { $headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value; } return $headers; }
[ "public", "function", "allPreserveCase", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "headers", "[", "isset", "(", "$", "thi...
Returns the headers, with original capitalizations. @return array An array of headers
[ "Returns", "the", "headers", "with", "original", "capitalizations", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/ResponseHeaderBag.php#L61-L69
txj123/zilf
src/Zilf/HttpFoundation/ResponseHeaderBag.php
ResponseHeaderBag.set
public function set($key, $values, $replace = true) { $uniqueKey = str_replace('_', '-', strtolower($key)); if ('set-cookie' === $uniqueKey) { if ($replace) { $this->cookies = array(); } foreach ((array) $values as $cookie) { $this->setCookie(Cookie::fromString($cookie)); } $this->headerNames[$uniqueKey] = $key; return; } $this->headerNames[$uniqueKey] = $key; parent::set($key, $values, $replace); // ensure the cache-control header has sensible defaults if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) { $computed = $this->computeCacheControlValue(); $this->headers['cache-control'] = array($computed); $this->headerNames['cache-control'] = 'Cache-Control'; $this->computedCacheControl = $this->parseCacheControl($computed); } }
php
public function set($key, $values, $replace = true) { $uniqueKey = str_replace('_', '-', strtolower($key)); if ('set-cookie' === $uniqueKey) { if ($replace) { $this->cookies = array(); } foreach ((array) $values as $cookie) { $this->setCookie(Cookie::fromString($cookie)); } $this->headerNames[$uniqueKey] = $key; return; } $this->headerNames[$uniqueKey] = $key; parent::set($key, $values, $replace); // ensure the cache-control header has sensible defaults if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) { $computed = $this->computeCacheControlValue(); $this->headers['cache-control'] = array($computed); $this->headerNames['cache-control'] = 'Cache-Control'; $this->computedCacheControl = $this->parseCacheControl($computed); } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "values", ",", "$", "replace", "=", "true", ")", "{", "$", "uniqueKey", "=", "str_replace", "(", "'_'", ",", "'-'", ",", "strtolower", "(", "$", "key", ")", ")", ";", "if", "(", "'set-cookie'"...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/ResponseHeaderBag.php#L111-L138
txj123/zilf
src/Zilf/HttpFoundation/ResponseHeaderBag.php
ResponseHeaderBag.clearCookie
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true) { $this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly)); }
php
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true) { $this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly)); }
[ "public", "function", "clearCookie", "(", "$", "name", ",", "$", "path", "=", "'/'", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "true", ")", "{", "$", "this", "->", "setCookie", "(", "new", "Cookie...
Clears a cookie in the browser. @param string $name @param string $path @param string $domain @param bool $secure @param bool $httpOnly
[ "Clears", "a", "cookie", "in", "the", "browser", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/ResponseHeaderBag.php#L256-L259
marcioAlmada/uptime
src/Runtime/Windows/Boottime.php
Boottime.read
public function read($command = 'wmic os get lastbootuptime') { $wmicString = trim(explode("\n", shell_exec($command))[1]); $dateTime = \DateTime::createFromFormat( 'YmdHis.uO', $this->convertWmicOffset($wmicString) ); return $dateTime->getTimestamp(); }
php
public function read($command = 'wmic os get lastbootuptime') { $wmicString = trim(explode("\n", shell_exec($command))[1]); $dateTime = \DateTime::createFromFormat( 'YmdHis.uO', $this->convertWmicOffset($wmicString) ); return $dateTime->getTimestamp(); }
[ "public", "function", "read", "(", "$", "command", "=", "'wmic os get lastbootuptime'", ")", "{", "$", "wmicString", "=", "trim", "(", "explode", "(", "\"\\n\"", ",", "shell_exec", "(", "$", "command", ")", ")", "[", "1", "]", ")", ";", "$", "dateTime", ...
Reads the wmic command which returns the last bootup time and converts it to a unix timestamp @param string $command wmic command @return int
[ "Reads", "the", "wmic", "command", "which", "returns", "the", "last", "bootup", "time", "and", "converts", "it", "to", "a", "unix", "timestamp" ]
train
https://github.com/marcioAlmada/uptime/blob/1f5e5b63850c2342e42366c184fc74445fa2d929/src/Runtime/Windows/Boottime.php#L15-L24
marcioAlmada/uptime
src/Runtime/Windows/Boottime.php
Boottime.convertWmicOffset
private function convertWmicOffset($wmicString) { $offset = substr($wmicString, -3); $hours = floor($offset / 60); $minutes = ($offset % 60); return substr($wmicString, 0, -3) . sprintf('%02d%02d', $hours, $minutes); }
php
private function convertWmicOffset($wmicString) { $offset = substr($wmicString, -3); $hours = floor($offset / 60); $minutes = ($offset % 60); return substr($wmicString, 0, -3) . sprintf('%02d%02d', $hours, $minutes); }
[ "private", "function", "convertWmicOffset", "(", "$", "wmicString", ")", "{", "$", "offset", "=", "substr", "(", "$", "wmicString", ",", "-", "3", ")", ";", "$", "hours", "=", "floor", "(", "$", "offset", "/", "60", ")", ";", "$", "minutes", "=", "...
Takes the output of wmic os get lastbootuptime and converts the offset given in minutes to an HHMM offset acceptable by PHP createFromFormat 'O' @param string $wmicString string output given by wmic command @return string
[ "Takes", "the", "output", "of", "wmic", "os", "get", "lastbootuptime", "and", "converts", "the", "offset", "given", "in", "minutes", "to", "an", "HHMM", "offset", "acceptable", "by", "PHP", "createFromFormat", "O" ]
train
https://github.com/marcioAlmada/uptime/blob/1f5e5b63850c2342e42366c184fc74445fa2d929/src/Runtime/Windows/Boottime.php#L32-L38
crysalead/sql-dialect
src/Statement/PostgreSql/Insert.php
Insert.returning
public function returning($fields) { $this->_parts['returning'] = array_merge($this->_parts['returning'], is_array($fields) ? $fields : func_get_args()); return $this; }
php
public function returning($fields) { $this->_parts['returning'] = array_merge($this->_parts['returning'], is_array($fields) ? $fields : func_get_args()); return $this; }
[ "public", "function", "returning", "(", "$", "fields", ")", "{", "$", "this", "->", "_parts", "[", "'returning'", "]", "=", "array_merge", "(", "$", "this", "->", "_parts", "[", "'returning'", "]", ",", "is_array", "(", "$", "fields", ")", "?", "$", ...
Sets some fields to the `RETURNING` clause. @param string|array $fields The fields. @return string Formatted fields list.
[ "Sets", "some", "fields", "to", "the", "RETURNING", "clause", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/PostgreSql/Insert.php#L15-L19
hfcorriez/pagon
app/src/Api/User.php
User.get
public function get() { $id = $this->params['id']; $post = \Model\User::dispense()->find_one($id); if (!$post) { $this->error('Unknown User'); } $this->data = $post->as_array(); }
php
public function get() { $id = $this->params['id']; $post = \Model\User::dispense()->find_one($id); if (!$post) { $this->error('Unknown User'); } $this->data = $post->as_array(); }
[ "public", "function", "get", "(", ")", "{", "$", "id", "=", "$", "this", "->", "params", "[", "'id'", "]", ";", "$", "post", "=", "\\", "Model", "\\", "User", "::", "dispense", "(", ")", "->", "find_one", "(", "$", "id", ")", ";", "if", "(", ...
GET /
[ "GET", "/" ]
train
https://github.com/hfcorriez/pagon/blob/c847a59c4ce4876887c65d35880ded8bb559cc48/app/src/Api/User.php#L15-L26
l3l0/php-travis-client
src/Travis/Client/Entity/Collection.php
Collection.fromArray
public function fromArray($objects) { $this->clear(); foreach ($objects as $objectData) { $this->add($objectData); } }
php
public function fromArray($objects) { $this->clear(); foreach ($objects as $objectData) { $this->add($objectData); } }
[ "public", "function", "fromArray", "(", "$", "objects", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "foreach", "(", "$", "objects", "as", "$", "objectData", ")", "{", "$", "this", "->", "add", "(", "$", "objectData", ")", ";", "}", "}" ]
Fill in collection from array @param array $objectData
[ "Fill", "in", "collection", "from", "array" ]
train
https://github.com/l3l0/php-travis-client/blob/1a20ad66b9ee49b8a1601ba1dd69762720ce7609/src/Travis/Client/Entity/Collection.php#L33-L39
l3l0/php-travis-client
src/Travis/Client/Entity/Collection.php
Collection.convertArrayToObject
protected function convertArrayToObject($objectData) { $objectName = $this->getCollectedObjectName(); if (is_array($objectData)) { $object = new $objectName(); $object->fromArray($objectData); $objectData = $object; } if (!($objectData instanceof $objectName)) { throw new InvalidArgumentException(sprintf('%s collection can handle %s objects only', $objectName, $objectName)); } return $objectData; }
php
protected function convertArrayToObject($objectData) { $objectName = $this->getCollectedObjectName(); if (is_array($objectData)) { $object = new $objectName(); $object->fromArray($objectData); $objectData = $object; } if (!($objectData instanceof $objectName)) { throw new InvalidArgumentException(sprintf('%s collection can handle %s objects only', $objectName, $objectName)); } return $objectData; }
[ "protected", "function", "convertArrayToObject", "(", "$", "objectData", ")", "{", "$", "objectName", "=", "$", "this", "->", "getCollectedObjectName", "(", ")", ";", "if", "(", "is_array", "(", "$", "objectData", ")", ")", "{", "$", "object", "=", "new", ...
Converts array to build or throw exception Converts array to build or throw exception when build argument have incompatibile type @param mixed $objectData @throws \InvalidArgumentException @return Build
[ "Converts", "array", "to", "build", "or", "throw", "exception" ]
train
https://github.com/l3l0/php-travis-client/blob/1a20ad66b9ee49b8a1601ba1dd69762720ce7609/src/Travis/Client/Entity/Collection.php#L86-L101
mikelgoig/laravel-spotify-wrapper
src/SpotifyWrapperServiceProvider.php
SpotifyWrapperServiceProvider.register
public function register() { $this->app->singleton('SpotifyWrapper', function ($app, $parameters = []) { $session = new Session( config('services.spotify.client_id'), config('services.spotify.client_secret'), array_key_exists('callback', $parameters) ? config('app.url').$parameters['callback'] : '' ); return new SpotifyWrapper($session, new SpotifyWebAPI(), $parameters); }); }
php
public function register() { $this->app->singleton('SpotifyWrapper', function ($app, $parameters = []) { $session = new Session( config('services.spotify.client_id'), config('services.spotify.client_secret'), array_key_exists('callback', $parameters) ? config('app.url').$parameters['callback'] : '' ); return new SpotifyWrapper($session, new SpotifyWebAPI(), $parameters); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'SpotifyWrapper'", ",", "function", "(", "$", "app", ",", "$", "parameters", "=", "[", "]", ")", "{", "$", "session", "=", "new", "Session", "(", "con...
Register the application services.
[ "Register", "the", "application", "services", "." ]
train
https://github.com/mikelgoig/laravel-spotify-wrapper/blob/0f93b561ec1a590c3568c47f901f5f7ac4e61cf1/src/SpotifyWrapperServiceProvider.php#L23-L35
txj123/zilf
src/Zilf/HttpFoundation/File/File.php
File.guessExtension
public function guessExtension() { $type = $this->getMimeType(); $guesser = ExtensionGuesser::getInstance(); return $guesser->guess($type); }
php
public function guessExtension() { $type = $this->getMimeType(); $guesser = ExtensionGuesser::getInstance(); return $guesser->guess($type); }
[ "public", "function", "guessExtension", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getMimeType", "(", ")", ";", "$", "guesser", "=", "ExtensionGuesser", "::", "getInstance", "(", ")", ";", "return", "$", "guesser", "->", "guess", "(", "$", "t...
Returns the extension based on the mime type. If the mime type is unknown, returns null. This method uses the mime type as guessed by getMimeType() to guess the file extension. @return string|null The guessed extension or null if it cannot be guessed @see ExtensionGuesser @see getMimeType()
[ "Returns", "the", "extension", "based", "on", "the", "mime", "type", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/File.php#L56-L62
txj123/zilf
src/Zilf/HttpFoundation/File/File.php
File.move
public function move($directory, $name = null) { $target = $this->getTargetFile($directory, $name); if (!@rename($this->getPathname(), $target)) { $error = error_get_last(); throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); } @chmod($target, 0666 & ~umask()); return $target; }
php
public function move($directory, $name = null) { $target = $this->getTargetFile($directory, $name); if (!@rename($this->getPathname(), $target)) { $error = error_get_last(); throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); } @chmod($target, 0666 & ~umask()); return $target; }
[ "public", "function", "move", "(", "$", "directory", ",", "$", "name", "=", "null", ")", "{", "$", "target", "=", "$", "this", "->", "getTargetFile", "(", "$", "directory", ",", "$", "name", ")", ";", "if", "(", "!", "@", "rename", "(", "$", "thi...
Moves the file to a new location. @param string $directory The destination folder @param string $name The new file name @return self A File object representing the new file @throws FileException if the target file could not be created
[ "Moves", "the", "file", "to", "a", "new", "location", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/File.php#L92-L104
oxygen-cms/core
src/Action/Action.php
Action.getPattern
public function getPattern() { return ($this->group->hasPattern() ? $this->group->getPattern() . ($this->pattern === '/' ? '' : '/') : '') . $this->pattern; }
php
public function getPattern() { return ($this->group->hasPattern() ? $this->group->getPattern() . ($this->pattern === '/' ? '' : '/') : '') . $this->pattern; }
[ "public", "function", "getPattern", "(", ")", "{", "return", "(", "$", "this", "->", "group", "->", "hasPattern", "(", ")", "?", "$", "this", "->", "group", "->", "getPattern", "(", ")", ".", "(", "$", "this", "->", "pattern", "===", "'/'", "?", "'...
Returns the pattern to match with. @return string
[ "Returns", "the", "pattern", "to", "match", "with", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Action.php#L136-L138
oxygen-cms/core
src/Action/Action.php
Action.getMiddleware
public function getMiddleware() { $middleware = $this->middleware; if($this->usesPermissions()) { $middleware[] = self::PERMISSIONS_FILTER_NAME . ':' . $this->getPermissions(); } return $middleware; }
php
public function getMiddleware() { $middleware = $this->middleware; if($this->usesPermissions()) { $middleware[] = self::PERMISSIONS_FILTER_NAME . ':' . $this->getPermissions(); } return $middleware; }
[ "public", "function", "getMiddleware", "(", ")", "{", "$", "middleware", "=", "$", "this", "->", "middleware", ";", "if", "(", "$", "this", "->", "usesPermissions", "(", ")", ")", "{", "$", "middleware", "[", "]", "=", "self", "::", "PERMISSIONS_FILTER_N...
Returns the middleware array. @return array
[ "Returns", "the", "middleware", "array", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Action.php#L163-L170
phpmath/bignumber
src/BigNumber.php
BigNumber.setScale
public function setScale($scale) { if (!$this->isMutable()) { throw new RuntimeException(sprintf( 'Cannot set the scale to "%s" since the numbere is immutable.', $scale )); } // Convert to a string to make sure that the __toString method is called for objects. $scaleValue = (string)$scale; if (!ctype_digit($scaleValue)) { throw new InvalidArgumentException(sprintf( 'Cannot set the scale to "%s". Invalid value.', $scaleValue )); } $this->scale = (int)$scaleValue; return $this; }
php
public function setScale($scale) { if (!$this->isMutable()) { throw new RuntimeException(sprintf( 'Cannot set the scale to "%s" since the numbere is immutable.', $scale )); } // Convert to a string to make sure that the __toString method is called for objects. $scaleValue = (string)$scale; if (!ctype_digit($scaleValue)) { throw new InvalidArgumentException(sprintf( 'Cannot set the scale to "%s". Invalid value.', $scaleValue )); } $this->scale = (int)$scaleValue; return $this; }
[ "public", "function", "setScale", "(", "$", "scale", ")", "{", "if", "(", "!", "$", "this", "->", "isMutable", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Cannot set the scale to \"%s\" since the numbere is immutable.'", ",", "...
Sets the scale of this number. @param int $scale The scale to set. @return BigNumber
[ "Sets", "the", "scale", "of", "this", "number", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L97-L118
phpmath/bignumber
src/BigNumber.php
BigNumber.add
public function add($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcadd($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function add($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcadd($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "add", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "self", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";", "...
Adds the given value to this value. @param float|int|string|BigNumber $value The value to add. @return BigNumber
[ "Adds", "the", "given", "value", "to", "this", "value", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L136-L145
phpmath/bignumber
src/BigNumber.php
BigNumber.divide
public function divide($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $rawValue = $value->getValue(); if ($rawValue == 0) { throw new InvalidArgumentException('Cannot divide by zero.'); } $newValue = bcdiv($this->getValue(), $rawValue, $this->getScale()); return $this->assignValue($newValue); }
php
public function divide($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $rawValue = $value->getValue(); if ($rawValue == 0) { throw new InvalidArgumentException('Cannot divide by zero.'); } $newValue = bcdiv($this->getValue(), $rawValue, $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "divide", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "self", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";", ...
Divides this value by the given value. @param float|int|string|BigNumber $value The value to divide by. @return BigNumber
[ "Divides", "this", "value", "by", "the", "given", "value", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L153-L167
phpmath/bignumber
src/BigNumber.php
BigNumber.multiply
public function multiply($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcmul($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function multiply($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcmul($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "multiply", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "self", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";"...
Multiplies the given value with this value. @param float|int|string|BigNumber $value The value to multiply with. @return BigNumber
[ "Multiplies", "the", "given", "value", "with", "this", "value", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L175-L184
phpmath/bignumber
src/BigNumber.php
BigNumber.mod
public function mod($value) { $bigNumber = new self($value, 0, false); $newValue = bcmod($this->getValue(), $bigNumber->getValue()); return $this->assignValue($newValue); }
php
public function mod($value) { $bigNumber = new self($value, 0, false); $newValue = bcmod($this->getValue(), $bigNumber->getValue()); return $this->assignValue($newValue); }
[ "public", "function", "mod", "(", "$", "value", ")", "{", "$", "bigNumber", "=", "new", "self", "(", "$", "value", ",", "0", ",", "false", ")", ";", "$", "newValue", "=", "bcmod", "(", "$", "this", "->", "getValue", "(", ")", ",", "$", "bigNumber...
Performs a modulo operation with the given number. @param float|int|string|BigNumber $value The value to perform a modulo operation with. @return BigNumber
[ "Performs", "a", "modulo", "operation", "with", "the", "given", "number", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L192-L199
phpmath/bignumber
src/BigNumber.php
BigNumber.pow
public function pow($value) { if (!is_int($value) && !ctype_digit($value)) { throw new InvalidArgumentException(sprintf( 'Invalid exponent "%s" provided. Only integers are allowed.', $value )); } $newValue = bcpow($this->getValue(), $value, $this->getScale()); return $this->assignValue($newValue); }
php
public function pow($value) { if (!is_int($value) && !ctype_digit($value)) { throw new InvalidArgumentException(sprintf( 'Invalid exponent "%s" provided. Only integers are allowed.', $value )); } $newValue = bcpow($this->getValue(), $value, $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "pow", "(", "$", "value", ")", "{", "if", "(", "!", "is_int", "(", "$", "value", ")", "&&", "!", "ctype_digit", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid exponent \"...
Performs a power operation with the given number. @param int|string $value The value to perform a power operation with. Should be an integer (or an int-string). @return BigNumber
[ "Performs", "a", "power", "operation", "with", "the", "given", "number", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L207-L219
phpmath/bignumber
src/BigNumber.php
BigNumber.sqrt
public function sqrt() { $newValue = bcsqrt($this->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function sqrt() { $newValue = bcsqrt($this->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "sqrt", "(", ")", "{", "$", "newValue", "=", "bcsqrt", "(", "$", "this", "->", "getValue", "(", ")", ",", "$", "this", "->", "getScale", "(", ")", ")", ";", "return", "$", "this", "->", "assignValue", "(", "$", "newValue", ")"...
Performs a square root operation with the given number. @return BigNumber
[ "Performs", "a", "square", "root", "operation", "with", "the", "given", "number", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L226-L231
phpmath/bignumber
src/BigNumber.php
BigNumber.subtract
public function subtract($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcsub($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function subtract($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcsub($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "subtract", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "self", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";"...
Subtracts the given value from this value. @param float|int|string|BigNumber $value The value to subtract. @return BigNumber
[ "Subtracts", "the", "given", "value", "from", "this", "value", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L239-L248
phpmath/bignumber
src/BigNumber.php
BigNumber.assignValue
private function assignValue($value) { if ($this->isMutable()) { $result = $this->internalSetValue($value); } else { $result = new BigNumber($value, $this->getScale(), false); } return $result; }
php
private function assignValue($value) { if ($this->isMutable()) { $result = $this->internalSetValue($value); } else { $result = new BigNumber($value, $this->getScale(), false); } return $result; }
[ "private", "function", "assignValue", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isMutable", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "internalSetValue", "(", "$", "value", ")", ";", "}", "else", "{", "$", "result...
A helper method to assign the given value. @param int|string|BigNumber $value The value to assign. @return BigNumber
[ "A", "helper", "method", "to", "assign", "the", "given", "value", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L286-L295
phpmath/bignumber
src/BigNumber.php
BigNumber.internalSetValue
private function internalSetValue($value) { if (is_float($value)) { $valueToSet = Utils::convertExponentialToString($value); } else { $valueToSet = (string)$value; } if (!is_numeric($valueToSet)) { throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet); } // We use a slick trick to make sure the scale is respected. $this->value = bcadd(0, $valueToSet, $this->getScale()); return $this; }
php
private function internalSetValue($value) { if (is_float($value)) { $valueToSet = Utils::convertExponentialToString($value); } else { $valueToSet = (string)$value; } if (!is_numeric($valueToSet)) { throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet); } // We use a slick trick to make sure the scale is respected. $this->value = bcadd(0, $valueToSet, $this->getScale()); return $this; }
[ "private", "function", "internalSetValue", "(", "$", "value", ")", "{", "if", "(", "is_float", "(", "$", "value", ")", ")", "{", "$", "valueToSet", "=", "Utils", "::", "convertExponentialToString", "(", "$", "value", ")", ";", "}", "else", "{", "$", "v...
A helper method to set the value on this class. @param int|string|BigNumber $value The value to assign. @return BigNumber
[ "A", "helper", "method", "to", "set", "the", "value", "on", "this", "class", "." ]
train
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L303-L319
oxygen-cms/core
src/Form/FieldMetadata.php
FieldMetadata.getType
public function getType() { if($this->typeInstance !== null) { return $this->typeInstance; } if(isset(static::$types[$this->type])) { $this->typeInstance = static::$types[$this->type]; return static::$types[$this->type]; } else { if(static::$defaultType !== null) { $this->typeInstance = static::$defaultType; return static::$defaultType; } else { throw new Exception('No `FieldType` Object Set For Field Type "' . $this->type . '" And No Default Set'); } } }
php
public function getType() { if($this->typeInstance !== null) { return $this->typeInstance; } if(isset(static::$types[$this->type])) { $this->typeInstance = static::$types[$this->type]; return static::$types[$this->type]; } else { if(static::$defaultType !== null) { $this->typeInstance = static::$defaultType; return static::$defaultType; } else { throw new Exception('No `FieldType` Object Set For Field Type "' . $this->type . '" And No Default Set'); } } }
[ "public", "function", "getType", "(", ")", "{", "if", "(", "$", "this", "->", "typeInstance", "!==", "null", ")", "{", "return", "$", "this", "->", "typeInstance", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "types", "[", "$", "this", "...
Returns the type. @return FieldType @throws Exception if the type doesn't exist
[ "Returns", "the", "type", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldMetadata.php#L144-L162
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.doRouteAfter
protected function doRouteAfter() { // 记录匹配的路由信息 $option = $this->rule->getOption(); $matches = $this->rule->getVars(); // 绑定模型数据 if (!empty($option['model'])) { $this->createBindModel($option['model'], $matches); } // 指定Header数据 if (!empty($option['header'])) { $header = $option['header']; $this->app['hook']->add('response_send', function ($response) use ($header) { $response->header($header); }); } // 指定Response响应数据 if (!empty($option['response'])) { foreach ($option['response'] as $response) { $this->app['hook']->add('response_send', $response); } } // 开启请求缓存 if (isset($option['cache']) && $this->request->isGet()) { $this->parseRequestCache($option['cache']); } if (!empty($option['append'])) { $this->request->setRouteVars($option['append']); } }
php
protected function doRouteAfter() { // 记录匹配的路由信息 $option = $this->rule->getOption(); $matches = $this->rule->getVars(); // 绑定模型数据 if (!empty($option['model'])) { $this->createBindModel($option['model'], $matches); } // 指定Header数据 if (!empty($option['header'])) { $header = $option['header']; $this->app['hook']->add('response_send', function ($response) use ($header) { $response->header($header); }); } // 指定Response响应数据 if (!empty($option['response'])) { foreach ($option['response'] as $response) { $this->app['hook']->add('response_send', $response); } } // 开启请求缓存 if (isset($option['cache']) && $this->request->isGet()) { $this->parseRequestCache($option['cache']); } if (!empty($option['append'])) { $this->request->setRouteVars($option['append']); } }
[ "protected", "function", "doRouteAfter", "(", ")", "{", "// 记录匹配的路由信息", "$", "option", "=", "$", "this", "->", "rule", "->", "getOption", "(", ")", ";", "$", "matches", "=", "$", "this", "->", "rule", "->", "getVars", "(", ")", ";", "// 绑定模型数据", "if", ...
检查路由后置操作 @access protected @return void
[ "检查路由后置操作" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L89-L123
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.run
public function run() { $option = $this->rule->getOption(); // 检测路由after行为 if (!empty($option['after'])) { $dispatch = $this->checkAfter($option['after']); if ($dispatch instanceof Response) { return $dispatch; } } // 数据自动验证 if (isset($option['validate'])) { $this->autoValidate($option['validate']); } $data = $this->exec(); return $this->autoResponse($data); }
php
public function run() { $option = $this->rule->getOption(); // 检测路由after行为 if (!empty($option['after'])) { $dispatch = $this->checkAfter($option['after']); if ($dispatch instanceof Response) { return $dispatch; } } // 数据自动验证 if (isset($option['validate'])) { $this->autoValidate($option['validate']); } $data = $this->exec(); return $this->autoResponse($data); }
[ "public", "function", "run", "(", ")", "{", "$", "option", "=", "$", "this", "->", "rule", "->", "getOption", "(", ")", ";", "// 检测路由after行为", "if", "(", "!", "empty", "(", "$", "option", "[", "'after'", "]", ")", ")", "{", "$", "dispatch", "=", ...
执行路由调度 @access public @return mixed
[ "执行路由调度" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L130-L151
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.checkAfter
protected function checkAfter($after) { $this->app['log']->notice('路由后置行为建议使用中间件替代!'); $hook = $this->app['hook']; $result = null; foreach ((array)$after as $behavior) { $result = $hook->exec($behavior); if (!is_null($result)) { break; } } // 路由规则重定向 if ($result instanceof Response) { return $result; } return false; }
php
protected function checkAfter($after) { $this->app['log']->notice('路由后置行为建议使用中间件替代!'); $hook = $this->app['hook']; $result = null; foreach ((array)$after as $behavior) { $result = $hook->exec($behavior); if (!is_null($result)) { break; } } // 路由规则重定向 if ($result instanceof Response) { return $result; } return false; }
[ "protected", "function", "checkAfter", "(", "$", "after", ")", "{", "$", "this", "->", "app", "[", "'log'", "]", "->", "notice", "(", "'路由后置行为建议使用中间件替代!');", "", "", "$", "hook", "=", "$", "this", "->", "app", "[", "'hook'", "]", ";", "$", "result", ...
检查路由后置行为 @access protected @param mixed $after 后置行为 @return mixed
[ "检查路由后置行为" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L179-L201
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.autoValidate
protected function autoValidate($option) { list($validate, $scene, $message, $batch) = $option; if (is_array($validate)) { // 指定验证规则 $v = $this->app->validate(); $v->rule($validate); } else { // 调用验证器 $v = $this->app->validate($validate); if (!empty($scene)) { $v->scene($scene); } } if (!empty($message)) { $v->message($message); } // 批量验证 if ($batch) { $v->batch(true); } if (!$v->check($this->request->param())) { throw new ValidateException($v->getError()); } }
php
protected function autoValidate($option) { list($validate, $scene, $message, $batch) = $option; if (is_array($validate)) { // 指定验证规则 $v = $this->app->validate(); $v->rule($validate); } else { // 调用验证器 $v = $this->app->validate($validate); if (!empty($scene)) { $v->scene($scene); } } if (!empty($message)) { $v->message($message); } // 批量验证 if ($batch) { $v->batch(true); } if (!$v->check($this->request->param())) { throw new ValidateException($v->getError()); } }
[ "protected", "function", "autoValidate", "(", "$", "option", ")", "{", "list", "(", "$", "validate", ",", "$", "scene", ",", "$", "message", ",", "$", "batch", ")", "=", "$", "option", ";", "if", "(", "is_array", "(", "$", "validate", ")", ")", "{"...
验证数据 @access protected @param array $option @return void @throws ValidateException
[ "验证数据" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L210-L238
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.parseRequestCache
protected function parseRequestCache($cache) { if (is_array($cache)) { list($key, $expire, $tag) = array_pad($cache, 3, null); } else { $key = str_replace('|', '/', $this->request->url()); $expire = $cache; $tag = null; } $cache = $this->request->cache($key, $expire, $tag); $this->app->setResponseCache($cache); }
php
protected function parseRequestCache($cache) { if (is_array($cache)) { list($key, $expire, $tag) = array_pad($cache, 3, null); } else { $key = str_replace('|', '/', $this->request->url()); $expire = $cache; $tag = null; } $cache = $this->request->cache($key, $expire, $tag); $this->app->setResponseCache($cache); }
[ "protected", "function", "parseRequestCache", "(", "$", "cache", ")", "{", "if", "(", "is_array", "(", "$", "cache", ")", ")", "{", "list", "(", "$", "key", ",", "$", "expire", ",", "$", "tag", ")", "=", "array_pad", "(", "$", "cache", ",", "3", ...
处理路由请求缓存 @access protected @param Request $request 请求对象 @param string|array $cache 路由缓存 @return void
[ "处理路由请求缓存" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L247-L259
txj123/zilf
src/Zilf/Routing/Dispatch.php
Dispatch.createBindModel
protected function createBindModel($bindModel, $matches) { foreach ($bindModel as $key => $val) { if ($val instanceof \Closure) { $result = $this->app->invokeFunction($val, $matches); } else { $fields = explode('&', $key); if (is_array($val)) { list($model, $exception) = $val; } else { $model = $val; $exception = true; } $where = []; $match = true; foreach ($fields as $field) { if (!isset($matches[$field])) { $match = false; break; } else { $where[] = [$field, '=', $matches[$field]]; } } if ($match) { $query = strpos($model, '\\') ? $model::where($where) : $this->app->model($model)->where($where); $result = $query->failException($exception)->find(); } } if (!empty($result)) { // 注入容器 $this->app->instance(get_class($result), $result); } } }
php
protected function createBindModel($bindModel, $matches) { foreach ($bindModel as $key => $val) { if ($val instanceof \Closure) { $result = $this->app->invokeFunction($val, $matches); } else { $fields = explode('&', $key); if (is_array($val)) { list($model, $exception) = $val; } else { $model = $val; $exception = true; } $where = []; $match = true; foreach ($fields as $field) { if (!isset($matches[$field])) { $match = false; break; } else { $where[] = [$field, '=', $matches[$field]]; } } if ($match) { $query = strpos($model, '\\') ? $model::where($where) : $this->app->model($model)->where($where); $result = $query->failException($exception)->find(); } } if (!empty($result)) { // 注入容器 $this->app->instance(get_class($result), $result); } } }
[ "protected", "function", "createBindModel", "(", "$", "bindModel", ",", "$", "matches", ")", "{", "foreach", "(", "$", "bindModel", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "$", "val", "instanceof", "\\", "Closure", ")", "{", "$", "re...
路由绑定模型实例 @access protected @param array|\Clousre $bindModel 绑定模型 @param array $matches 路由变量 @return void
[ "路由绑定模型实例" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch.php#L268-L306
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/plugins/Scripts.php
phpQueryObjectPlugin_Scripts.script
public static function script($self, $arg1) { $params = func_get_args(); $params = array_slice($params, 2); $return = null; $config = self::$config; if (phpQueryPlugin_Scripts::$scriptMethods[$arg1]) { phpQuery::callbackRun( phpQueryPlugin_Scripts::$scriptMethods[$arg1], array($self, $params, &$return, $config) ); } else if ($arg1 != '__config' && file_exists(dirname(__FILE__)."/Scripts/$arg1.php")) { phpQuery::debug("Loading script '$arg1'"); include dirname(__FILE__)."/Scripts/$arg1.php"; } else { phpQuery::debug("Requested script '$arg1' doesn't exist"); } return $return ? $return : $self; }
php
public static function script($self, $arg1) { $params = func_get_args(); $params = array_slice($params, 2); $return = null; $config = self::$config; if (phpQueryPlugin_Scripts::$scriptMethods[$arg1]) { phpQuery::callbackRun( phpQueryPlugin_Scripts::$scriptMethods[$arg1], array($self, $params, &$return, $config) ); } else if ($arg1 != '__config' && file_exists(dirname(__FILE__)."/Scripts/$arg1.php")) { phpQuery::debug("Loading script '$arg1'"); include dirname(__FILE__)."/Scripts/$arg1.php"; } else { phpQuery::debug("Requested script '$arg1' doesn't exist"); } return $return ? $return : $self; }
[ "public", "static", "function", "script", "(", "$", "self", ",", "$", "arg1", ")", "{", "$", "params", "=", "func_get_args", "(", ")", ";", "$", "params", "=", "array_slice", "(", "$", "params", ",", "2", ")", ";", "$", "return", "=", "null", ";", ...
Enter description here... @param phpQueryObject $self
[ "Enter", "description", "here", "..." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/plugins/Scripts.php#L25-L45
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/plugins/Scripts.php
phpQueryPlugin_Scripts.script
public static function script($name, $callback) { if (phpQueryPlugin_Scripts::$scriptMethods[$name]) { throw new Exception("Script name conflict - '$name'"); } phpQueryPlugin_Scripts::$scriptMethods[$name] = $callback; }
php
public static function script($name, $callback) { if (phpQueryPlugin_Scripts::$scriptMethods[$name]) { throw new Exception("Script name conflict - '$name'"); } phpQueryPlugin_Scripts::$scriptMethods[$name] = $callback; }
[ "public", "static", "function", "script", "(", "$", "name", ",", "$", "callback", ")", "{", "if", "(", "phpQueryPlugin_Scripts", "::", "$", "scriptMethods", "[", "$", "name", "]", ")", "{", "throw", "new", "Exception", "(", "\"Script name conflict - '$name'\""...
Extend scripts' namespace with $name related with $callback. Callback parameter order looks like this: - $this - $params - &$return - $config @param $name @param $callback @return bool
[ "Extend", "scripts", "namespace", "with", "$name", "related", "with", "$callback", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/plugins/Scripts.php#L70-L76
oxygen-cms/core
src/Console/BlueprintDetailCommand.php
BlueprintDetailCommand.handle
public function handle(BlueprintManager $blueprints) { $blueprint = $blueprints->get($this->argument('name')); $this->heading('General Information'); $this->table($this->generalHeaders, [$this->getGeneralInformation($blueprint)]); $this->heading('Toolbars'); foreach($blueprint->getToolbarOrders() as $name => $contents) { $this->output->writeln($name . ': ' . Formatter::keyedArray($contents)); } $this->heading('Actions'); $actions = []; foreach($blueprint->getActions() as $action) { $actions[] = $this->getActionInformation($action); } $this->table($this->actionHeaders, $actions); }
php
public function handle(BlueprintManager $blueprints) { $blueprint = $blueprints->get($this->argument('name')); $this->heading('General Information'); $this->table($this->generalHeaders, [$this->getGeneralInformation($blueprint)]); $this->heading('Toolbars'); foreach($blueprint->getToolbarOrders() as $name => $contents) { $this->output->writeln($name . ': ' . Formatter::keyedArray($contents)); } $this->heading('Actions'); $actions = []; foreach($blueprint->getActions() as $action) { $actions[] = $this->getActionInformation($action); } $this->table($this->actionHeaders, $actions); }
[ "public", "function", "handle", "(", "BlueprintManager", "$", "blueprints", ")", "{", "$", "blueprint", "=", "$", "blueprints", "->", "get", "(", "$", "this", "->", "argument", "(", "'name'", ")", ")", ";", "$", "this", "->", "heading", "(", "'General In...
Execute the console command. @param \Oxygen\Core\Blueprint\BlueprintManager $blueprints @return mixed @throws \Exception
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintDetailCommand.php#L53-L73
oxygen-cms/core
src/Console/BlueprintDetailCommand.php
BlueprintDetailCommand.getGeneralInformation
protected function getGeneralInformation(Blueprint $blueprint) { return [ Formatter::shortArray([$blueprint->getName(), $blueprint->getPluralName()]), Formatter::shortArray([$blueprint->getDisplayName(), $blueprint->getPluralDisplayName()]), $blueprint->getRouteName(), $blueprint->getRoutePattern(), $blueprint->getController(), $blueprint->hasPrimaryToolbarItem() ? $blueprint->getPrimaryToolbarItem()->getIdentifier() : 'None', $blueprint->getIcon() ]; }
php
protected function getGeneralInformation(Blueprint $blueprint) { return [ Formatter::shortArray([$blueprint->getName(), $blueprint->getPluralName()]), Formatter::shortArray([$blueprint->getDisplayName(), $blueprint->getPluralDisplayName()]), $blueprint->getRouteName(), $blueprint->getRoutePattern(), $blueprint->getController(), $blueprint->hasPrimaryToolbarItem() ? $blueprint->getPrimaryToolbarItem()->getIdentifier() : 'None', $blueprint->getIcon() ]; }
[ "protected", "function", "getGeneralInformation", "(", "Blueprint", "$", "blueprint", ")", "{", "return", "[", "Formatter", "::", "shortArray", "(", "[", "$", "blueprint", "->", "getName", "(", ")", ",", "$", "blueprint", "->", "getPluralName", "(", ")", "]"...
Get the blueprint information. @param Blueprint $blueprint @return array
[ "Get", "the", "blueprint", "information", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintDetailCommand.php#L82-L92
oxygen-cms/core
src/Console/BlueprintDetailCommand.php
BlueprintDetailCommand.getActionInformation
protected function getActionInformation(Action $action) { return [ $action->getPattern(), $action->getName(), $action->getMethod(), $action->group->getName() . ', ' . $action->group->getPattern(), Formatter::shortArray($action->getMiddleware()), $action->getUses(), Formatter::boolean($action->register), Formatter::boolean($action->useSmoothState) ]; }
php
protected function getActionInformation(Action $action) { return [ $action->getPattern(), $action->getName(), $action->getMethod(), $action->group->getName() . ', ' . $action->group->getPattern(), Formatter::shortArray($action->getMiddleware()), $action->getUses(), Formatter::boolean($action->register), Formatter::boolean($action->useSmoothState) ]; }
[ "protected", "function", "getActionInformation", "(", "Action", "$", "action", ")", "{", "return", "[", "$", "action", "->", "getPattern", "(", ")", ",", "$", "action", "->", "getName", "(", ")", ",", "$", "action", "->", "getMethod", "(", ")", ",", "$...
Get information about an Action. @param Action $action @return array
[ "Get", "information", "about", "an", "Action", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintDetailCommand.php#L101-L112
txj123/zilf
src/Zilf/Cache/RedisTaggedCache.php
RedisTaggedCache.put
public function put($key, $value, $minutes = null) { $this->pushStandardKeys($this->tags->getNamespace(), $key); parent::put($key, $value, $minutes); }
php
public function put($key, $value, $minutes = null) { $this->pushStandardKeys($this->tags->getNamespace(), $key); parent::put($key, $value, $minutes); }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", "=", "null", ")", "{", "$", "this", "->", "pushStandardKeys", "(", "$", "this", "->", "tags", "->", "getNamespace", "(", ")", ",", "$", "key", ")", ";", "parent",...
Store an item in the cache. @param string $key @param mixed $value @param \DateTime|float|int $minutes @return void
[ "Store", "an", "item", "in", "the", "cache", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RedisTaggedCache.php#L28-L33
crysalead/sql-dialect
src/Statement/Truncate.php
Truncate.toString
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `TRUNCATE` statement, missing `TABLE` clause."); } return 'TRUNCATE' . $this->_buildClause('TABLE', $this->dialect()->names($this->_parts['table'])); }
php
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `TRUNCATE` statement, missing `TABLE` clause."); } return 'TRUNCATE' . $this->_buildClause('TABLE', $this->dialect()->names($this->_parts['table'])); }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_parts", "[", "'table'", "]", ")", "{", "throw", "new", "SqlException", "(", "\"Invalid `TRUNCATE` statement, missing `TABLE` clause.\"", ")", ";", "}", "return", "'TRUNCATE'", ...
Render the SQL statement @return string The generated SQL string. @throws SqlException
[ "Render", "the", "SQL", "statement" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Truncate.php#L38-L45
xutl/qcloud-cmq
src/Requests/SetSubscriptionAttributeRequest.php
SetSubscriptionAttributeRequest.setBindingKeys
public function setBindingKeys($bindingKeys) { if (is_array($bindingKeys) && !empty($bindingKeys)) { $n = 1; foreach ($bindingKeys as $bindingKey) { $key = 'bindingKey.' . $n; $this->setParameter($key, $bindingKey); $n += 1; } } return $this; }
php
public function setBindingKeys($bindingKeys) { if (is_array($bindingKeys) && !empty($bindingKeys)) { $n = 1; foreach ($bindingKeys as $bindingKey) { $key = 'bindingKey.' . $n; $this->setParameter($key, $bindingKey); $n += 1; } } return $this; }
[ "public", "function", "setBindingKeys", "(", "$", "bindingKeys", ")", "{", "if", "(", "is_array", "(", "$", "bindingKeys", ")", "&&", "!", "empty", "(", "$", "bindingKeys", ")", ")", "{", "$", "n", "=", "1", ";", "foreach", "(", "$", "bindingKeys", "...
bindingKey 数量不超过 5 个, 每个 bindingKey 长度不超过 64 字节,该字段表示订阅接收消息的过滤策略,每个 bindingKey 最多含有 15 个“.”, 即最多 16 个词组。 @param array $bindingKeys @return BaseRequest
[ "bindingKey", "数量不超过", "5", "个,", "每个", "bindingKey", "长度不超过", "64", "字节,该字段表示订阅接收消息的过滤策略,每个", "bindingKey", "最多含有", "15", "个“", ".", "”,", "即最多", "16", "个词组。" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Requests/SetSubscriptionAttributeRequest.php#L93-L104
hfcorriez/pagon
app/src/Web/Web.php
Web.after
protected function after() { if (!$this->app->output->body && $this->_tpl) { $this->render($this->_tpl); } }
php
protected function after() { if (!$this->app->output->body && $this->_tpl) { $this->render($this->_tpl); } }
[ "protected", "function", "after", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "output", "->", "body", "&&", "$", "this", "->", "_tpl", ")", "{", "$", "this", "->", "render", "(", "$", "this", "->", "_tpl", ")", ";", "}", "}" ...
After
[ "After" ]
train
https://github.com/hfcorriez/pagon/blob/c847a59c4ce4876887c65d35880ded8bb559cc48/app/src/Web/Web.php#L43-L48
hfcorriez/pagon
app/src/Web/Web.php
Web.render
protected function render($tpl) { $body = new View( $tpl, get_object_vars($this) + $this->app->locals, array('dir' => $this->app->views) ); $this->app->render($this->_tpl_layout, array('body' => $body->render()) + get_object_vars($this)); }
php
protected function render($tpl) { $body = new View( $tpl, get_object_vars($this) + $this->app->locals, array('dir' => $this->app->views) ); $this->app->render($this->_tpl_layout, array('body' => $body->render()) + get_object_vars($this)); }
[ "protected", "function", "render", "(", "$", "tpl", ")", "{", "$", "body", "=", "new", "View", "(", "$", "tpl", ",", "get_object_vars", "(", "$", "this", ")", "+", "$", "this", "->", "app", "->", "locals", ",", "array", "(", "'dir'", "=>", "$", "...
Render template @param $tpl
[ "Render", "template" ]
train
https://github.com/hfcorriez/pagon/blob/c847a59c4ce4876887c65d35880ded8bb559cc48/app/src/Web/Web.php#L55-L64
edvler/yii2-accounting
models/db/AccountSearch.php
AccountSearch.search
public function search($params) { $query = Account::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'account_id' => $this->account_id, 'balance_debit' => $this->balance_debit, 'balance_credit' => $this->balance_credit, 'balance' => $this->balance, ]); $query->andFilterWhere(['like', 'accounttype', $this->accounttype]) ->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
php
public function search($params) { $query = Account::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'account_id' => $this->account_id, 'balance_debit' => $this->balance_debit, 'balance_credit' => $this->balance_credit, 'balance' => $this->balance, ]); $query->andFilterWhere(['like', 'accounttype', $this->accounttype]) ->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "query", "=", "Account", "::", "find", "(", ")", ";", "// add conditions that should always apply here", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "...
Creates data provider instance with search query applied @param array $params @return ActiveDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/models/db/AccountSearch.php#L43-L73
qloog/yaf-library
src/Validators/RequiredValidator.php
RequiredValidator.validator
public function validator($field, array $data) { if (!isset($data[$field]) || $data[$field] === '') { return $this->message('{fieldName}不能为空!', [ '{fieldName}' => $this->getName($field), ]); } return true; }
php
public function validator($field, array $data) { if (!isset($data[$field]) || $data[$field] === '') { return $this->message('{fieldName}不能为空!', [ '{fieldName}' => $this->getName($field), ]); } return true; }
[ "public", "function", "validator", "(", "$", "field", ",", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "field", "]", ")", "||", "$", "data", "[", "$", "field", "]", "===", "''", ")", "{", "return", "$", ...
检查是否为空 @param string $field @param array $data @return bool|string
[ "检查是否为空" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/RequiredValidator.php#L17-L26
accompli/accompli
src/DataCollector/ProfilerDataCollector.php
ProfilerDataCollector.collect
public function collect(Event $event, $eventName) { if ($eventName === AccompliEvents::INITIALIZE) { $this->start = new DateTime('now'); } elseif (in_array($eventName, array(AccompliEvents::INSTALL_COMMAND_COMPLETE, AccompliEvents::DEPLOY_COMMAND_COMPLETE))) { $this->end = new DateTime('now'); $this->peakMemoryUsage = memory_get_peak_usage(true); } }
php
public function collect(Event $event, $eventName) { if ($eventName === AccompliEvents::INITIALIZE) { $this->start = new DateTime('now'); } elseif (in_array($eventName, array(AccompliEvents::INSTALL_COMMAND_COMPLETE, AccompliEvents::DEPLOY_COMMAND_COMPLETE))) { $this->end = new DateTime('now'); $this->peakMemoryUsage = memory_get_peak_usage(true); } }
[ "public", "function", "collect", "(", "Event", "$", "event", ",", "$", "eventName", ")", "{", "if", "(", "$", "eventName", "===", "AccompliEvents", "::", "INITIALIZE", ")", "{", "$", "this", "->", "start", "=", "new", "DateTime", "(", "'now'", ")", ";"...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/DataCollector/ProfilerDataCollector.php#L41-L49
accompli/accompli
src/DataCollector/ProfilerDataCollector.php
ProfilerDataCollector.getData
public function getData($verbosity = OutputInterface::VERBOSITY_NORMAL) { $data = array(); if ($verbosity >= OutputInterface::VERBOSITY_VERBOSE) { $executionTime = 'Unknown'; if ($this->start instanceof DateTime !== false && $this->end instanceof DateTime !== false) { $durationInterval = $this->start->diff($this->end); $durationInterval->h = $durationInterval->d * 24; $durationInterval->i = $durationInterval->h * 60; if ($durationInterval->i === 0 && $durationInterval->s === 0) { ++$durationInterval->s; } $executionTime = $durationInterval->format('%i minute(s) and %s second(s)'); } $data['Execution time'] = $executionTime; } if ($verbosity >= OutputInterface::VERBOSITY_DEBUG) { $data['Peak memory usage'] = round($this->peakMemoryUsage / 1024 / 1024, 2).' MB'; } return $data; }
php
public function getData($verbosity = OutputInterface::VERBOSITY_NORMAL) { $data = array(); if ($verbosity >= OutputInterface::VERBOSITY_VERBOSE) { $executionTime = 'Unknown'; if ($this->start instanceof DateTime !== false && $this->end instanceof DateTime !== false) { $durationInterval = $this->start->diff($this->end); $durationInterval->h = $durationInterval->d * 24; $durationInterval->i = $durationInterval->h * 60; if ($durationInterval->i === 0 && $durationInterval->s === 0) { ++$durationInterval->s; } $executionTime = $durationInterval->format('%i minute(s) and %s second(s)'); } $data['Execution time'] = $executionTime; } if ($verbosity >= OutputInterface::VERBOSITY_DEBUG) { $data['Peak memory usage'] = round($this->peakMemoryUsage / 1024 / 1024, 2).' MB'; } return $data; }
[ "public", "function", "getData", "(", "$", "verbosity", "=", "OutputInterface", "::", "VERBOSITY_NORMAL", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "verbosity", ">=", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", "{", "$", "e...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/DataCollector/ProfilerDataCollector.php#L54-L79
jonnnnyw/craft-awss3assets
src/JonnyW/AWSS3Assets/Validation/RegionValidator.php
RegionValidator.validateAttribute
protected function validateAttribute($object, $attribute) { $value = $object->$attribute; if ($value) { if (!preg_match('/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/', $value)) { $this->addError($object, $attribute, 'Please enter a valid AWS region e.g us-east-1.'); } } }
php
protected function validateAttribute($object, $attribute) { $value = $object->$attribute; if ($value) { if (!preg_match('/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/', $value)) { $this->addError($object, $attribute, 'Please enter a valid AWS region e.g us-east-1.'); } } }
[ "protected", "function", "validateAttribute", "(", "$", "object", ",", "$", "attribute", ")", "{", "$", "value", "=", "$", "object", "->", "$", "attribute", ";", "if", "(", "$", "value", ")", "{", "if", "(", "!", "preg_match", "(", "'/^(us|sa|eu|ap)-(nor...
Validate AWS region. @access protected @param \CModel $object @param string $attribute @return void
[ "Validate", "AWS", "region", "." ]
train
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/src/JonnyW/AWSS3Assets/Validation/RegionValidator.php#L28-L38
makinacorpus/drupal-ucms
ucms_layout/src/Controller/LayoutAjaxController.php
LayoutAjaxController.addItemAction
public function addItemAction(Request $request, Layout $layout) { $this->guard($layout, 'update'); $region = $this->validateInputAndGetRegionName($request); $nid = $request->get('nid'); if (empty($nid)) { throw $this->createNotFoundException(); } if (!$node = $this->getNodeStorage()->load($nid)) { throw $this->createNotFoundException(); } if (!$node->access('view')) { throw $this->createAccessDeniedException(); } $viewmode = $request->get('view_mode', 'teaser'); $position = $request->get('position'); $manager = $this->getContextManager(); $site = $this->getSiteContext(); $item = new Item($nid, $viewmode); $region = $layout->getRegion($region); $region->addAt($item, $position); if ($manager->isPageContextRegion($region->getName(), $site->theme)) { $manager->getPageContext()->getStorage()->save($layout); } else if ($manager->isTransversalContextRegion($region->getName(), $site->theme)) { $manager->getSiteContext()->getStorage()->save($layout); } else { throw $this->createAccessDeniedException(); } return new JsonResponse(['success' => true, 'output' => $this->renderNode($node, $region, $viewmode)]); }
php
public function addItemAction(Request $request, Layout $layout) { $this->guard($layout, 'update'); $region = $this->validateInputAndGetRegionName($request); $nid = $request->get('nid'); if (empty($nid)) { throw $this->createNotFoundException(); } if (!$node = $this->getNodeStorage()->load($nid)) { throw $this->createNotFoundException(); } if (!$node->access('view')) { throw $this->createAccessDeniedException(); } $viewmode = $request->get('view_mode', 'teaser'); $position = $request->get('position'); $manager = $this->getContextManager(); $site = $this->getSiteContext(); $item = new Item($nid, $viewmode); $region = $layout->getRegion($region); $region->addAt($item, $position); if ($manager->isPageContextRegion($region->getName(), $site->theme)) { $manager->getPageContext()->getStorage()->save($layout); } else if ($manager->isTransversalContextRegion($region->getName(), $site->theme)) { $manager->getSiteContext()->getStorage()->save($layout); } else { throw $this->createAccessDeniedException(); } return new JsonResponse(['success' => true, 'output' => $this->renderNode($node, $region, $viewmode)]); }
[ "public", "function", "addItemAction", "(", "Request", "$", "request", ",", "Layout", "$", "layout", ")", "{", "$", "this", "->", "guard", "(", "$", "layout", ",", "'update'", ")", ";", "$", "region", "=", "$", "this", "->", "validateInputAndGetRegionName"...
Add item to a a region callback
[ "Add", "item", "to", "a", "a", "region", "callback" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Controller/LayoutAjaxController.php#L107-L142
makinacorpus/drupal-ucms
ucms_layout/src/Controller/LayoutAjaxController.php
LayoutAjaxController.removeItemAction
public function removeItemAction(Request $request, Layout $layout) { $this->guard($layout, 'update'); $region = $this->validateInputAndGetRegionName($request); $position = $request->get('position', 0); $manager = $this->getContextManager(); $site = $this->getSiteContext(); $region = $layout->getRegion($region); $region->removeAt($position); if ($manager->isPageContextRegion($region->getName(), $site->theme)) { $manager->getPageContext()->getStorage()->save($layout); } else if ($manager->isTransversalContextRegion($region->getName(), $site->theme)) { $manager->getSiteContext()->getStorage()->save($layout); } else { throw $this->createAccessDeniedException(); } return new JsonResponse(['success' => true]); }
php
public function removeItemAction(Request $request, Layout $layout) { $this->guard($layout, 'update'); $region = $this->validateInputAndGetRegionName($request); $position = $request->get('position', 0); $manager = $this->getContextManager(); $site = $this->getSiteContext(); $region = $layout->getRegion($region); $region->removeAt($position); if ($manager->isPageContextRegion($region->getName(), $site->theme)) { $manager->getPageContext()->getStorage()->save($layout); } else if ($manager->isTransversalContextRegion($region->getName(), $site->theme)) { $manager->getSiteContext()->getStorage()->save($layout); } else { throw $this->createAccessDeniedException(); } return new JsonResponse(['success' => true]); }
[ "public", "function", "removeItemAction", "(", "Request", "$", "request", ",", "Layout", "$", "layout", ")", "{", "$", "this", "->", "guard", "(", "$", "layout", ",", "'update'", ")", ";", "$", "region", "=", "$", "this", "->", "validateInputAndGetRegionNa...
Add item to a a region callback
[ "Add", "item", "to", "a", "a", "region", "callback" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Controller/LayoutAjaxController.php#L147-L168