id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
23,500
heidelpay/PhpDoc
src/phpDocumentor/Translator/Translator.php
Translator.addTranslations
public function addTranslations($filename, $locale = self::DEFAULT_LOCALE, $textDomain = self::DEFAULT_DOMAIN) { parent::addTranslationFile(self::TRANSLATION_FILE_TYPE, $filename, $textDomain, $locale); $this->messages = array(); return $this; }
php
public function addTranslations($filename, $locale = self::DEFAULT_LOCALE, $textDomain = self::DEFAULT_DOMAIN) { parent::addTranslationFile(self::TRANSLATION_FILE_TYPE, $filename, $textDomain, $locale); $this->messages = array(); return $this; }
[ "public", "function", "addTranslations", "(", "$", "filename", ",", "$", "locale", "=", "self", "::", "DEFAULT_LOCALE", ",", "$", "textDomain", "=", "self", "::", "DEFAULT_DOMAIN", ")", "{", "parent", "::", "addTranslationFile", "(", "self", "::", "TRANSLATION_FILE_TYPE", ",", "$", "filename", ",", "$", "textDomain", ",", "$", "locale", ")", ";", "$", "this", "->", "messages", "=", "array", "(", ")", ";", "return", "$", "this", ";", "}" ]
Adds a translation file for a specific locale, or the default locale when none is provided. @param string $filename Name of the file to add. @param string|null $locale The locale to assign to, matches {@link http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO-639-1} and defaults to en (English). @param string $textDomain Translations may be divided into separate files / domains; this represents in which domain the translation should be. @api @return $this
[ "Adds", "a", "translation", "file", "for", "a", "specific", "locale", "or", "the", "default", "locale", "when", "none", "is", "provided", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/Translator.php#L103-L110
23,501
heidelpay/PhpDoc
src/phpDocumentor/Translator/Translator.php
Translator.addTranslationFolder
public function addTranslationFolder($folder, array $domains = array()) { if (empty($domains)) { $domains = array(self::DEFAULT_DOMAIN); } foreach ($domains as $domain) { $this->addTranslationsUsingPattern($folder, $domain); } return $this; }
php
public function addTranslationFolder($folder, array $domains = array()) { if (empty($domains)) { $domains = array(self::DEFAULT_DOMAIN); } foreach ($domains as $domain) { $this->addTranslationsUsingPattern($folder, $domain); } return $this; }
[ "public", "function", "addTranslationFolder", "(", "$", "folder", ",", "array", "$", "domains", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "domains", ")", ")", "{", "$", "domains", "=", "array", "(", "self", "::", "DEFAULT_DOMAIN", ")", ";", "}", "foreach", "(", "$", "domains", "as", "$", "domain", ")", "{", "$", "this", "->", "addTranslationsUsingPattern", "(", "$", "folder", ",", "$", "domain", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a folder with files containing translation sources. This method scans the provided folder for any file matching the following format: `[domain].[locale].php` If the domain matches the {@see self::DEFAULT_DOMAIN default domain} then that part is omitted and the filename should match: `[locale].php` @link http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for a list of ISO-639-1 locale codes as used by this method. @param string $folder Name of the folder, it is recommended to use an absolute path. @param string[] $domains One or more domains to load, when none is provided only the default is added. @api @return $this
[ "Adds", "a", "folder", "with", "files", "containing", "translation", "sources", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/Translator.php#L134-L145
23,502
heidelpay/PhpDoc
src/phpDocumentor/Translator/Translator.php
Translator.addTranslationsUsingPattern
public function addTranslationsUsingPattern( $baseDir, $textDomain = self::DEFAULT_DOMAIN, $pattern = self::DEFAULT_PATTERN ) { if ($textDomain !== self::DEFAULT_DOMAIN && $pattern === self::DEFAULT_PATTERN) { $pattern = $textDomain . '.' . $pattern; } parent::addTranslationFilePattern(self::TRANSLATION_FILE_TYPE, $baseDir, $pattern, $textDomain); $this->messages = array(); return $this; }
php
public function addTranslationsUsingPattern( $baseDir, $textDomain = self::DEFAULT_DOMAIN, $pattern = self::DEFAULT_PATTERN ) { if ($textDomain !== self::DEFAULT_DOMAIN && $pattern === self::DEFAULT_PATTERN) { $pattern = $textDomain . '.' . $pattern; } parent::addTranslationFilePattern(self::TRANSLATION_FILE_TYPE, $baseDir, $pattern, $textDomain); $this->messages = array(); return $this; }
[ "public", "function", "addTranslationsUsingPattern", "(", "$", "baseDir", ",", "$", "textDomain", "=", "self", "::", "DEFAULT_DOMAIN", ",", "$", "pattern", "=", "self", "::", "DEFAULT_PATTERN", ")", "{", "if", "(", "$", "textDomain", "!==", "self", "::", "DEFAULT_DOMAIN", "&&", "$", "pattern", "===", "self", "::", "DEFAULT_PATTERN", ")", "{", "$", "pattern", "=", "$", "textDomain", ".", "'.'", ".", "$", "pattern", ";", "}", "parent", "::", "addTranslationFilePattern", "(", "self", "::", "TRANSLATION_FILE_TYPE", ",", "$", "baseDir", ",", "$", "pattern", ",", "$", "textDomain", ")", ";", "$", "this", "->", "messages", "=", "array", "(", ")", ";", "return", "$", "this", ";", "}" ]
Adds a series of translation files given a pattern. This method will search the base directory for a series of files matching the given pattern (where %s is replaces by the two-letter locale shorthand) and adds any translations to the translation table. @param string $baseDir Directory to search in (not-recursive) @param string $textDomain The domain to assign the translation messages to. @param string $pattern The pattern used to load files for all languages, one variable `%s` is supported and is replaced with the {@link http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO-639-1 code} for each locale that is requested by the translate method. @internal this method is not to be used by consumers; it is an extension of the Zend Translator component and is overridden to clear the messages caching array so it may be rebuild. @see self::addTranslationFolder() to provide a series of translation files. @return $this|ZendTranslator
[ "Adds", "a", "series", "of", "translation", "files", "given", "a", "pattern", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/Translator.php#L166-L180
23,503
heidelpay/PhpDoc
src/phpDocumentor/Translator/Translator.php
Translator.translate
public function translate($message, $textDomain = self::DEFAULT_DOMAIN, $locale = null) { return parent::translate($message, $textDomain, $locale); }
php
public function translate($message, $textDomain = self::DEFAULT_DOMAIN, $locale = null) { return parent::translate($message, $textDomain, $locale); }
[ "public", "function", "translate", "(", "$", "message", ",", "$", "textDomain", "=", "self", "::", "DEFAULT_DOMAIN", ",", "$", "locale", "=", "null", ")", "{", "return", "parent", "::", "translate", "(", "$", "message", ",", "$", "textDomain", ",", "$", "locale", ")", ";", "}" ]
Attempts to translate the given message or code into the provided locale. @param string $message The message or code to translate. @param string $textDomain A message may be located in a domain, here you can provide in which. @param null $locale The locale to translate to or the default if not set. @return string
[ "Attempts", "to", "translate", "the", "given", "message", "or", "code", "into", "the", "provided", "locale", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/Translator.php#L191-L194
23,504
oroinc/OroLayoutComponent
Extension/Theme/Visitor/ImportVisitor.php
ImportVisitor.insertUpdate
private function insertUpdate($parentUpdate, $update) { $el = $update instanceof ElementDependentLayoutUpdateInterface ? $update->getElement() : 'root'; $parentUpdateIndex = array_search($parentUpdate, $this->updates[$el]); $this->updates[$el] = array_merge( array_slice($this->updates[$el], 0, $parentUpdateIndex, true), [$update], array_slice($this->updates[$el], $parentUpdateIndex, null, true) ); }
php
private function insertUpdate($parentUpdate, $update) { $el = $update instanceof ElementDependentLayoutUpdateInterface ? $update->getElement() : 'root'; $parentUpdateIndex = array_search($parentUpdate, $this->updates[$el]); $this->updates[$el] = array_merge( array_slice($this->updates[$el], 0, $parentUpdateIndex, true), [$update], array_slice($this->updates[$el], $parentUpdateIndex, null, true) ); }
[ "private", "function", "insertUpdate", "(", "$", "parentUpdate", ",", "$", "update", ")", "{", "$", "el", "=", "$", "update", "instanceof", "ElementDependentLayoutUpdateInterface", "?", "$", "update", "->", "getElement", "(", ")", ":", "'root'", ";", "$", "parentUpdateIndex", "=", "array_search", "(", "$", "parentUpdate", ",", "$", "this", "->", "updates", "[", "$", "el", "]", ")", ";", "$", "this", "->", "updates", "[", "$", "el", "]", "=", "array_merge", "(", "array_slice", "(", "$", "this", "->", "updates", "[", "$", "el", "]", ",", "0", ",", "$", "parentUpdateIndex", ",", "true", ")", ",", "[", "$", "update", "]", ",", "array_slice", "(", "$", "this", "->", "updates", "[", "$", "el", "]", ",", "$", "parentUpdateIndex", ",", "null", ",", "true", ")", ")", ";", "}" ]
Insert import update right after its parent update @param ImportsAwareLayoutUpdateInterface $parentUpdate @param LayoutUpdateImportInterface $update
[ "Insert", "import", "update", "right", "after", "its", "parent", "update" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/Theme/Visitor/ImportVisitor.php#L122-L135
23,505
luniki/trails
lib/trails.php
Trails_Dispatcher.dispatch
function dispatch($uri) { # E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_RECOVERABLE_ERROR = 5888 $old_handler = set_error_handler(array($this, 'error_handler'), 5888); ob_start(); $level = ob_get_level(); $this->map_uri_to_response($this->clean_request_uri((string) $uri))->output(); while (ob_get_level() >= $level) { ob_end_flush(); } if (isset($old_handler)) { set_error_handler($old_handler); } }
php
function dispatch($uri) { # E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_RECOVERABLE_ERROR = 5888 $old_handler = set_error_handler(array($this, 'error_handler'), 5888); ob_start(); $level = ob_get_level(); $this->map_uri_to_response($this->clean_request_uri((string) $uri))->output(); while (ob_get_level() >= $level) { ob_end_flush(); } if (isset($old_handler)) { set_error_handler($old_handler); } }
[ "function", "dispatch", "(", "$", "uri", ")", "{", "# E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_RECOVERABLE_ERROR = 5888", "$", "old_handler", "=", "set_error_handler", "(", "array", "(", "$", "this", ",", "'error_handler'", ")", ",", "5888", ")", ";", "ob_start", "(", ")", ";", "$", "level", "=", "ob_get_level", "(", ")", ";", "$", "this", "->", "map_uri_to_response", "(", "$", "this", "->", "clean_request_uri", "(", "(", "string", ")", "$", "uri", ")", ")", "->", "output", "(", ")", ";", "while", "(", "ob_get_level", "(", ")", ">=", "$", "level", ")", "{", "ob_end_flush", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "old_handler", ")", ")", "{", "set_error_handler", "(", "$", "old_handler", ")", ";", "}", "}" ]
Maps a string to a response which is then rendered. @param string The requested URI. @return void
[ "Maps", "a", "string", "to", "a", "response", "which", "is", "then", "rendered", "." ]
ade6e3aa6bb543fb66e3295acc74f32121085c16
https://github.com/luniki/trails/blob/ade6e3aa6bb543fb66e3295acc74f32121085c16/lib/trails.php#L113-L130
23,506
luniki/trails
lib/trails.php
Trails_Controller.perform
function perform($unconsumed) { list($action, $args, $format) = $this->extract_action_and_args($unconsumed); # set format $this->format = isset($format) ? $format : 'html'; # call before filter $before_filter_result = $this->before_filter($action, $args); # send action to controller # TODO (mlunzena) shouldn't the after filter be triggered too? if (!(FALSE === $before_filter_result || $this->performed)) { $mapped_action = $this->map_action($action); # is action callable? if (method_exists($this, $mapped_action)) { call_user_func_array(array(&$this, $mapped_action), $args); } else { $this->does_not_understand($action, $args); } if (!$this->performed) { $this->render_action($action); } # call after filter $this->after_filter($action, $args); } return $this->response; }
php
function perform($unconsumed) { list($action, $args, $format) = $this->extract_action_and_args($unconsumed); # set format $this->format = isset($format) ? $format : 'html'; # call before filter $before_filter_result = $this->before_filter($action, $args); # send action to controller # TODO (mlunzena) shouldn't the after filter be triggered too? if (!(FALSE === $before_filter_result || $this->performed)) { $mapped_action = $this->map_action($action); # is action callable? if (method_exists($this, $mapped_action)) { call_user_func_array(array(&$this, $mapped_action), $args); } else { $this->does_not_understand($action, $args); } if (!$this->performed) { $this->render_action($action); } # call after filter $this->after_filter($action, $args); } return $this->response; }
[ "function", "perform", "(", "$", "unconsumed", ")", "{", "list", "(", "$", "action", ",", "$", "args", ",", "$", "format", ")", "=", "$", "this", "->", "extract_action_and_args", "(", "$", "unconsumed", ")", ";", "# set format", "$", "this", "->", "format", "=", "isset", "(", "$", "format", ")", "?", "$", "format", ":", "'html'", ";", "# call before filter", "$", "before_filter_result", "=", "$", "this", "->", "before_filter", "(", "$", "action", ",", "$", "args", ")", ";", "# send action to controller", "# TODO (mlunzena) shouldn't the after filter be triggered too?", "if", "(", "!", "(", "FALSE", "===", "$", "before_filter_result", "||", "$", "this", "->", "performed", ")", ")", "{", "$", "mapped_action", "=", "$", "this", "->", "map_action", "(", "$", "action", ")", ";", "# is action callable?", "if", "(", "method_exists", "(", "$", "this", ",", "$", "mapped_action", ")", ")", "{", "call_user_func_array", "(", "array", "(", "&", "$", "this", ",", "$", "mapped_action", ")", ",", "$", "args", ")", ";", "}", "else", "{", "$", "this", "->", "does_not_understand", "(", "$", "action", ",", "$", "args", ")", ";", "}", "if", "(", "!", "$", "this", "->", "performed", ")", "{", "$", "this", "->", "render_action", "(", "$", "action", ")", ";", "}", "# call after filter", "$", "this", "->", "after_filter", "(", "$", "action", ",", "$", "args", ")", ";", "}", "return", "$", "this", "->", "response", ";", "}" ]
This method extracts an action string and further arguments from it's parameter. The action string is mapped to a method being called afterwards using the said arguments. That method is called and a response object is generated, populated and sent back to the dispatcher. @param type <description> @return type <description>
[ "This", "method", "extracts", "an", "action", "string", "and", "further", "arguments", "from", "it", "s", "parameter", ".", "The", "action", "string", "is", "mapped", "to", "a", "method", "being", "called", "afterwards", "using", "the", "said", "arguments", ".", "That", "method", "is", "called", "and", "a", "response", "object", "is", "generated", "populated", "and", "sent", "back", "to", "the", "dispatcher", "." ]
ade6e3aa6bb543fb66e3295acc74f32121085c16
https://github.com/luniki/trails/blob/ade6e3aa6bb543fb66e3295acc74f32121085c16/lib/trails.php#L536-L569
23,507
luniki/trails
lib/trails.php
Trails_Controller.extract_action_and_args
function extract_action_and_args($string) { if ('' === $string) { return array('index', array(), NULL); } // find optional file extension $format = NULL; if (preg_match('/^(.*[^\/.])\.(\w+)$/', $string, $matches)) { list($_, $string, $format) = $matches; } // TODO this should possibly remove empty tokens $args = explode('/', $string); $action = array_shift($args); return array($action, $args, $format); }
php
function extract_action_and_args($string) { if ('' === $string) { return array('index', array(), NULL); } // find optional file extension $format = NULL; if (preg_match('/^(.*[^\/.])\.(\w+)$/', $string, $matches)) { list($_, $string, $format) = $matches; } // TODO this should possibly remove empty tokens $args = explode('/', $string); $action = array_shift($args); return array($action, $args, $format); }
[ "function", "extract_action_and_args", "(", "$", "string", ")", "{", "if", "(", "''", "===", "$", "string", ")", "{", "return", "array", "(", "'index'", ",", "array", "(", ")", ",", "NULL", ")", ";", "}", "// find optional file extension", "$", "format", "=", "NULL", ";", "if", "(", "preg_match", "(", "'/^(.*[^\\/.])\\.(\\w+)$/'", ",", "$", "string", ",", "$", "matches", ")", ")", "{", "list", "(", "$", "_", ",", "$", "string", ",", "$", "format", ")", "=", "$", "matches", ";", "}", "// TODO this should possibly remove empty tokens", "$", "args", "=", "explode", "(", "'/'", ",", "$", "string", ")", ";", "$", "action", "=", "array_shift", "(", "$", "args", ")", ";", "return", "array", "(", "$", "action", ",", "$", "args", ",", "$", "format", ")", ";", "}" ]
Extracts action and args from a string. @param string the processed string @return array an array with two elements - a string containing the action and an array of strings representing the args
[ "Extracts", "action", "and", "args", "from", "a", "string", "." ]
ade6e3aa6bb543fb66e3295acc74f32121085c16
https://github.com/luniki/trails/blob/ade6e3aa6bb543fb66e3295acc74f32121085c16/lib/trails.php#L580-L596
23,508
luniki/trails
lib/trails.php
Trails_Controller.url_for
function url_for($to/*, ...*/) { # urlencode all but the first argument $args = func_get_args(); $args = array_map('urlencode', $args); $args[0] = $to; return $this->dispatcher->trails_uri . '/' . join('/', $args); }
php
function url_for($to/*, ...*/) { # urlencode all but the first argument $args = func_get_args(); $args = array_map('urlencode', $args); $args[0] = $to; return $this->dispatcher->trails_uri . '/' . join('/', $args); }
[ "function", "url_for", "(", "$", "to", "/*, ...*/", ")", "{", "# urlencode all but the first argument", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "args", "=", "array_map", "(", "'urlencode'", ",", "$", "args", ")", ";", "$", "args", "[", "0", "]", "=", "$", "to", ";", "return", "$", "this", "->", "dispatcher", "->", "trails_uri", ".", "'/'", ".", "join", "(", "'/'", ",", "$", "args", ")", ";", "}" ]
Returns a URL to a specified route to your Trails application. Example: Your Trails application is located at 'http://example.com/dispatch.php'. So your dispatcher's trails_uri is set to 'http://example.com/dispatch.php' If you want the URL to your 'wiki' controller with action 'show' and parameter 'page' you should send: $url = $controller->url_for('wiki/show', 'page'); $url should then contain 'http://example.com/dispatch.php/wiki/show/page'. The first parameter is a string containing the controller and optionally an action: - "{controller}/{action}" - "path/to/controller/action" - "controller" This "controller/action" string is not url encoded. You may provide additional parameter which will be urlencoded and concatenated with slashes: $controller->url_for('wiki/show', 'page'); -> 'wiki/show/page' $controller->url_for('wiki/show', 'page', 'one and a half'); -> 'wiki/show/page/one+and+a+half' @param string a string containing a controller and optionally an action @param strings optional arguments @return string a URL to this route
[ "Returns", "a", "URL", "to", "a", "specified", "route", "to", "your", "Trails", "application", "." ]
ade6e3aa6bb543fb66e3295acc74f32121085c16
https://github.com/luniki/trails/blob/ade6e3aa6bb543fb66e3295acc74f32121085c16/lib/trails.php#L825-L833
23,509
zicht/z
src/Zicht/Tool/Container/ContainerCompiler.php
ContainerCompiler.getContainer
public function getContainer() { $mutex = new Mutex($this->file . '.lock', true); $ret = $mutex->run( function () { if ($this->needsRecompile()) { file_put_contents($this->file, $this->compileContainerCode()); } return include $this->file; } ); if (!($ret instanceof Container)) { throw new \LogicException("The container must be returned by the compiler"); } foreach ($this->plugins as $plugin) { $ret->addPlugin($plugin); } return $ret; }
php
public function getContainer() { $mutex = new Mutex($this->file . '.lock', true); $ret = $mutex->run( function () { if ($this->needsRecompile()) { file_put_contents($this->file, $this->compileContainerCode()); } return include $this->file; } ); if (!($ret instanceof Container)) { throw new \LogicException("The container must be returned by the compiler"); } foreach ($this->plugins as $plugin) { $ret->addPlugin($plugin); } return $ret; }
[ "public", "function", "getContainer", "(", ")", "{", "$", "mutex", "=", "new", "Mutex", "(", "$", "this", "->", "file", ".", "'.lock'", ",", "true", ")", ";", "$", "ret", "=", "$", "mutex", "->", "run", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "needsRecompile", "(", ")", ")", "{", "file_put_contents", "(", "$", "this", "->", "file", ",", "$", "this", "->", "compileContainerCode", "(", ")", ")", ";", "}", "return", "include", "$", "this", "->", "file", ";", "}", ")", ";", "if", "(", "!", "(", "$", "ret", "instanceof", "Container", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"The container must be returned by the compiler\"", ")", ";", "}", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "$", "ret", "->", "addPlugin", "(", "$", "plugin", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Writes the code to a temporary file and returns the resulting Container object. @return mixed @throws \LogicException
[ "Writes", "the", "code", "to", "a", "temporary", "file", "and", "returns", "the", "resulting", "Container", "object", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerCompiler.php#L48-L68
23,510
zicht/z
src/Zicht/Tool/Container/ContainerCompiler.php
ContainerCompiler.needsRecompile
protected function needsRecompile() { clearstatcache(); return !is_file($this->file) || ( (!empty($this->configTree['z']['sources']) && max(array_map('filemtime', $this->configTree['z']['sources'])) >= filemtime($this->file)) ); }
php
protected function needsRecompile() { clearstatcache(); return !is_file($this->file) || ( (!empty($this->configTree['z']['sources']) && max(array_map('filemtime', $this->configTree['z']['sources'])) >= filemtime($this->file)) ); }
[ "protected", "function", "needsRecompile", "(", ")", "{", "clearstatcache", "(", ")", ";", "return", "!", "is_file", "(", "$", "this", "->", "file", ")", "||", "(", "(", "!", "empty", "(", "$", "this", "->", "configTree", "[", "'z'", "]", "[", "'sources'", "]", ")", "&&", "max", "(", "array_map", "(", "'filemtime'", ",", "$", "this", "->", "configTree", "[", "'z'", "]", "[", "'sources'", "]", ")", ")", ">=", "filemtime", "(", "$", "this", "->", "file", ")", ")", ")", ";", "}" ]
Crude check for whether a recompile is needed. @return bool
[ "Crude", "check", "for", "whether", "a", "recompile", "is", "needed", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerCompiler.php#L88-L95
23,511
zicht/z
src/Zicht/Tool/Container/ContainerCompiler.php
ContainerCompiler.compileContainerCode
public function compileContainerCode() { $builder = new ContainerBuilder($this->configTree); foreach ($this->plugins as $name => $plugin) { $plugin->setContainerBuilder($builder); } $containerNode = $builder->build(); $buffer = new Buffer(); $buffer->write('<?php')->eol(); $containerNode->compile($buffer); $buffer->writeln('return $z;'); $code = $buffer->getResult(); return $code; }
php
public function compileContainerCode() { $builder = new ContainerBuilder($this->configTree); foreach ($this->plugins as $name => $plugin) { $plugin->setContainerBuilder($builder); } $containerNode = $builder->build(); $buffer = new Buffer(); $buffer->write('<?php')->eol(); $containerNode->compile($buffer); $buffer->writeln('return $z;'); $code = $buffer->getResult(); return $code; }
[ "public", "function", "compileContainerCode", "(", ")", "{", "$", "builder", "=", "new", "ContainerBuilder", "(", "$", "this", "->", "configTree", ")", ";", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "name", "=>", "$", "plugin", ")", "{", "$", "plugin", "->", "setContainerBuilder", "(", "$", "builder", ")", ";", "}", "$", "containerNode", "=", "$", "builder", "->", "build", "(", ")", ";", "$", "buffer", "=", "new", "Buffer", "(", ")", ";", "$", "buffer", "->", "write", "(", "'<?php'", ")", "->", "eol", "(", ")", ";", "$", "containerNode", "->", "compile", "(", "$", "buffer", ")", ";", "$", "buffer", "->", "writeln", "(", "'return $z;'", ")", ";", "$", "code", "=", "$", "buffer", "->", "getResult", "(", ")", ";", "return", "$", "code", ";", "}" ]
Returns the code for initializing the container. @return string
[ "Returns", "the", "code", "for", "initializing", "the", "container", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerCompiler.php#L103-L116
23,512
wenbinye/PhalconX
src/Enum/Enum.php
Enum.instances
public static function instances() { $all = []; foreach (static::getNames() as $name => $val) { $all[] = new static($name, $val); } return $all; }
php
public static function instances() { $all = []; foreach (static::getNames() as $name => $val) { $all[] = new static($name, $val); } return $all; }
[ "public", "static", "function", "instances", "(", ")", "{", "$", "all", "=", "[", "]", ";", "foreach", "(", "static", "::", "getNames", "(", ")", "as", "$", "name", "=>", "$", "val", ")", "{", "$", "all", "[", "]", "=", "new", "static", "(", "$", "name", ",", "$", "val", ")", ";", "}", "return", "$", "all", ";", "}" ]
Gets all enums @return Enum[]
[ "Gets", "all", "enums" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Enum/Enum.php#L120-L127
23,513
wenbinye/PhalconX
src/Enum/Enum.php
Enum.nameOf
public static function nameOf($value) { $values = static::getValues(); return isset($values[$value]) ? $values[$value] : null; }
php
public static function nameOf($value) { $values = static::getValues(); return isset($values[$value]) ? $values[$value] : null; }
[ "public", "static", "function", "nameOf", "(", "$", "value", ")", "{", "$", "values", "=", "static", "::", "getValues", "(", ")", ";", "return", "isset", "(", "$", "values", "[", "$", "value", "]", ")", "?", "$", "values", "[", "$", "value", "]", ":", "null", ";", "}" ]
Gets the name for the enum value @return string
[ "Gets", "the", "name", "for", "the", "enum", "value" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Enum/Enum.php#L142-L146
23,514
wenbinye/PhalconX
src/Enum/Enum.php
Enum.valueOf
public static function valueOf($name) { $names = static::getNames(); return isset($names[$name]) ? $names[$name] : null; }
php
public static function valueOf($name) { $names = static::getNames(); return isset($names[$name]) ? $names[$name] : null; }
[ "public", "static", "function", "valueOf", "(", "$", "name", ")", "{", "$", "names", "=", "static", "::", "getNames", "(", ")", ";", "return", "isset", "(", "$", "names", "[", "$", "name", "]", ")", "?", "$", "names", "[", "$", "name", "]", ":", "null", ";", "}" ]
Gets the enum value for the name @return mixed value of
[ "Gets", "the", "enum", "value", "for", "the", "name" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Enum/Enum.php#L162-L166
23,515
wenbinye/PhalconX
src/Enum/Enum.php
Enum.fromName
public static function fromName($name) { $names = static::getNames(); if (array_key_exists($name, $names)) { return new static($name, $names[$name]); } throw new \InvalidArgumentException("No enum constant '$name' in class " . get_called_class()); }
php
public static function fromName($name) { $names = static::getNames(); if (array_key_exists($name, $names)) { return new static($name, $names[$name]); } throw new \InvalidArgumentException("No enum constant '$name' in class " . get_called_class()); }
[ "public", "static", "function", "fromName", "(", "$", "name", ")", "{", "$", "names", "=", "static", "::", "getNames", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "names", ")", ")", "{", "return", "new", "static", "(", "$", "name", ",", "$", "names", "[", "$", "name", "]", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "\"No enum constant '$name' in class \"", ".", "get_called_class", "(", ")", ")", ";", "}" ]
Gets the enum instance for the name @return Enum
[ "Gets", "the", "enum", "instance", "for", "the", "name" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Enum/Enum.php#L173-L180
23,516
wenbinye/PhalconX
src/Enum/Enum.php
Enum.fromValue
public static function fromValue($value) { $values = static::getValues(); if (array_key_exists($value, $values)) { return new static($values[$value], $value); } throw new \InvalidArgumentException("No enum constant value '$value' class " . get_called_class()); }
php
public static function fromValue($value) { $values = static::getValues(); if (array_key_exists($value, $values)) { return new static($values[$value], $value); } throw new \InvalidArgumentException("No enum constant value '$value' class " . get_called_class()); }
[ "public", "static", "function", "fromValue", "(", "$", "value", ")", "{", "$", "values", "=", "static", "::", "getValues", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "value", ",", "$", "values", ")", ")", "{", "return", "new", "static", "(", "$", "values", "[", "$", "value", "]", ",", "$", "value", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "\"No enum constant value '$value' class \"", ".", "get_called_class", "(", ")", ")", ";", "}" ]
Gets the enum instance for the value @return Enum
[ "Gets", "the", "enum", "instance", "for", "the", "value" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Enum/Enum.php#L187-L194
23,517
surebert/surebert-framework
src/sb/PDO.php
PDO.s2o
public function s2o($sql, $params=null, $class_name='') { //if it has parameters then prepare the statement and execute with the parameters //stmts that have already been prepared will reuse the prepared statement if(is_array($params) || is_object($params)){ //convert object parameters $param = is_array($params) ? $params : self::paramify($params); $stmt = $this->prepare($sql); $result = $stmt->execute($params); if(!$result){ return Array(); } //if there } else { $result = $this->query($sql); if(!is_object($result)){ return Array(); } else { $stmt = $result; } } //if the class_name is set return instances if(!preg_match("~^SELECT|EXEC|CALL~i", trim($sql))){ return $stmt; } elseif(!empty($class_name)){ if(class_exists($class_name)){ return $stmt->fetchAll(\PDO::FETCH_CLASS, $class_name); } } else { //otherwise return standard objects return $stmt->fetchAll(\PDO::FETCH_OBJ); } }
php
public function s2o($sql, $params=null, $class_name='') { //if it has parameters then prepare the statement and execute with the parameters //stmts that have already been prepared will reuse the prepared statement if(is_array($params) || is_object($params)){ //convert object parameters $param = is_array($params) ? $params : self::paramify($params); $stmt = $this->prepare($sql); $result = $stmt->execute($params); if(!$result){ return Array(); } //if there } else { $result = $this->query($sql); if(!is_object($result)){ return Array(); } else { $stmt = $result; } } //if the class_name is set return instances if(!preg_match("~^SELECT|EXEC|CALL~i", trim($sql))){ return $stmt; } elseif(!empty($class_name)){ if(class_exists($class_name)){ return $stmt->fetchAll(\PDO::FETCH_CLASS, $class_name); } } else { //otherwise return standard objects return $stmt->fetchAll(\PDO::FETCH_OBJ); } }
[ "public", "function", "s2o", "(", "$", "sql", ",", "$", "params", "=", "null", ",", "$", "class_name", "=", "''", ")", "{", "//if it has parameters then prepare the statement and execute with the parameters", "//stmts that have already been prepared will reuse the prepared statement", "if", "(", "is_array", "(", "$", "params", ")", "||", "is_object", "(", "$", "params", ")", ")", "{", "//convert object parameters", "$", "param", "=", "is_array", "(", "$", "params", ")", "?", "$", "params", ":", "self", "::", "paramify", "(", "$", "params", ")", ";", "$", "stmt", "=", "$", "this", "->", "prepare", "(", "$", "sql", ")", ";", "$", "result", "=", "$", "stmt", "->", "execute", "(", "$", "params", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "Array", "(", ")", ";", "}", "//if there", "}", "else", "{", "$", "result", "=", "$", "this", "->", "query", "(", "$", "sql", ")", ";", "if", "(", "!", "is_object", "(", "$", "result", ")", ")", "{", "return", "Array", "(", ")", ";", "}", "else", "{", "$", "stmt", "=", "$", "result", ";", "}", "}", "//if the class_name is set return instances", "if", "(", "!", "preg_match", "(", "\"~^SELECT|EXEC|CALL~i\"", ",", "trim", "(", "$", "sql", ")", ")", ")", "{", "return", "$", "stmt", ";", "}", "elseif", "(", "!", "empty", "(", "$", "class_name", ")", ")", "{", "if", "(", "class_exists", "(", "$", "class_name", ")", ")", "{", "return", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "$", "class_name", ")", ";", "}", "}", "else", "{", "//otherwise return standard objects", "return", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_OBJ", ")", ";", "}", "}" ]
Turn a sql query into an array of objects representing each row returned @param string $sql A sql string, can be used with :prop to create a prepared statement @param Array params An array hash of values to match with properties inside prepared statement @param Object params An object whose properties match with properties inside prepared statement. @param Array class_name Here you can specify a class_name, so that rows returned are instances of that class_name instead of standard objects @return array An array of objects representing rows returned <code> //without prepared statements $results = App::$db->s2o("SELECT * FROM pages WHERE pid =1"); //with prepared statement and params array $results = App::$db->s2o("SELECT * FROM pages WHERE pid =:pid", Array(":pid"=>1)); //with prepared statement and params object $params = new stdClass(); $params->pid = 1; $results = App::$db->s2o("SELECT * FROM pages WHERE pid =:pid", $params); //with prepared statement and params array plus class_name $results = App::$db->s2o("SELECT * FROM pages WHERE pid =:pid", Array(":pid" => 1), 'Page'); * //without prepared statement and plus class_name, fetches rows from the pages table into Page instances $results = App::$db->s2o("SELECT * FROM pages", null, 'Page'); </code>
[ "Turn", "a", "sql", "query", "into", "an", "array", "of", "objects", "representing", "each", "row", "returned" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO.php#L74-L116
23,518
surebert/surebert-framework
src/sb/PDO.php
PDO.paramify
public static function paramify($data, $omit=Array()) { $params = Array(); if(is_object($data)){ $data = get_object_vars($data); } if(is_array($data)){ foreach($data as $key=>$val){ if(!in_array($key, $omit)){ $params[':'.$key] = $val; } } } return $params; }
php
public static function paramify($data, $omit=Array()) { $params = Array(); if(is_object($data)){ $data = get_object_vars($data); } if(is_array($data)){ foreach($data as $key=>$val){ if(!in_array($key, $omit)){ $params[':'.$key] = $val; } } } return $params; }
[ "public", "static", "function", "paramify", "(", "$", "data", ",", "$", "omit", "=", "Array", "(", ")", ")", "{", "$", "params", "=", "Array", "(", ")", ";", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "$", "data", "=", "get_object_vars", "(", "$", "data", ")", ";", "}", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "omit", ")", ")", "{", "$", "params", "[", "':'", ".", "$", "key", "]", "=", "$", "val", ";", "}", "}", "}", "return", "$", "params", ";", "}" ]
Converts an array into a bound params hash @param array/object $data The object/hash to convert to a bindParams compatible hash with the colon in front of each key so that it can be used as a bid param array @param array $omit An simple array of key names to omit from the array @return array The input data as an array designed for passing to pdo's execute or bindParams @author paul.visco@roswellpark.org @version 1.0 <code> $question = new Question(); $question->qid = 1; $question->answer = 'grape'; $params = \sb\PDO::paramify($question); //returns $params as Array ( [:qid] => 1 [:answer] => 'grape' ) $params = \sb\PDO::paramify(Array('qid' => 1, 'answer' => 'grape')); //returns $params as Array ( [:qid] => 1 [:answer] => 'grape' ) </code>
[ "Converts", "an", "array", "into", "a", "bound", "params", "hash" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO.php#L139-L157
23,519
surebert/surebert-framework
src/sb/PDO.php
PDO.prepare
public function prepare($sql, $driver_options=array()) { $md5 = md5($sql); if(isset($this->prepared_sql[$md5])){ return $this->prepared_sql[$md5]; } $stmt = parent::prepare($sql, $driver_options); $this->prepared_sql[$md5] = $stmt; return $stmt; }
php
public function prepare($sql, $driver_options=array()) { $md5 = md5($sql); if(isset($this->prepared_sql[$md5])){ return $this->prepared_sql[$md5]; } $stmt = parent::prepare($sql, $driver_options); $this->prepared_sql[$md5] = $stmt; return $stmt; }
[ "public", "function", "prepare", "(", "$", "sql", ",", "$", "driver_options", "=", "array", "(", ")", ")", "{", "$", "md5", "=", "md5", "(", "$", "sql", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", ")", ")", "{", "return", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", ";", "}", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "sql", ",", "$", "driver_options", ")", ";", "$", "this", "->", "prepared_sql", "[", "$", "md5", "]", "=", "$", "stmt", ";", "return", "$", "stmt", ";", "}" ]
Used to prepare and store sql statements for value binding @param string $sql @return PDOStatement A PDO_statment instance
[ "Used", "to", "prepare", "and", "store", "sql", "statements", "for", "value", "binding" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO.php#L165-L177
23,520
mothership-ec/composer
src/Composer/Command/ShowCommand.php
ShowCommand.printLicenses
protected function printLicenses(CompletePackageInterface $package) { $spdxLicense = new SpdxLicense; $licenses = $package->getLicense(); foreach ($licenses as $licenseId) { $license = $spdxLicense->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url if (!$license) { $out = $licenseId; } else { // is license OSI approved? if ($license[1] === true) { $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]); } else { $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]); } } $this->getIO()->write('<info>license</info> : ' . $out); } }
php
protected function printLicenses(CompletePackageInterface $package) { $spdxLicense = new SpdxLicense; $licenses = $package->getLicense(); foreach ($licenses as $licenseId) { $license = $spdxLicense->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url if (!$license) { $out = $licenseId; } else { // is license OSI approved? if ($license[1] === true) { $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]); } else { $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]); } } $this->getIO()->write('<info>license</info> : ' . $out); } }
[ "protected", "function", "printLicenses", "(", "CompletePackageInterface", "$", "package", ")", "{", "$", "spdxLicense", "=", "new", "SpdxLicense", ";", "$", "licenses", "=", "$", "package", "->", "getLicense", "(", ")", ";", "foreach", "(", "$", "licenses", "as", "$", "licenseId", ")", "{", "$", "license", "=", "$", "spdxLicense", "->", "getLicenseByIdentifier", "(", "$", "licenseId", ")", ";", "// keys: 0 fullname, 1 osi, 2 url", "if", "(", "!", "$", "license", ")", "{", "$", "out", "=", "$", "licenseId", ";", "}", "else", "{", "// is license OSI approved?", "if", "(", "$", "license", "[", "1", "]", "===", "true", ")", "{", "$", "out", "=", "sprintf", "(", "'%s (%s) (OSI approved) %s'", ",", "$", "license", "[", "0", "]", ",", "$", "licenseId", ",", "$", "license", "[", "2", "]", ")", ";", "}", "else", "{", "$", "out", "=", "sprintf", "(", "'%s (%s) %s'", ",", "$", "license", "[", "0", "]", ",", "$", "licenseId", ",", "$", "license", "[", "2", "]", ")", ";", "}", "}", "$", "this", "->", "getIO", "(", ")", "->", "write", "(", "'<info>license</info> : '", ".", "$", "out", ")", ";", "}", "}" ]
Prints the licenses of a package with metadata @param CompletePackageInterface $package
[ "Prints", "the", "licenses", "of", "a", "package", "with", "metadata" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/ShowCommand.php#L391-L413
23,521
WellCommerce/AppBundle
Service/Admin/Provider/AdminMenuProvider.php
AdminMenuProvider.filterElements
protected function filterElements(Collection $collection, AdminMenu $parent = null) { $children = $collection->filter(function (AdminMenu $menuItem) use ($parent) { return $menuItem->getParent() === $parent; }); return $children; }
php
protected function filterElements(Collection $collection, AdminMenu $parent = null) { $children = $collection->filter(function (AdminMenu $menuItem) use ($parent) { return $menuItem->getParent() === $parent; }); return $children; }
[ "protected", "function", "filterElements", "(", "Collection", "$", "collection", ",", "AdminMenu", "$", "parent", "=", "null", ")", "{", "$", "children", "=", "$", "collection", "->", "filter", "(", "function", "(", "AdminMenu", "$", "menuItem", ")", "use", "(", "$", "parent", ")", "{", "return", "$", "menuItem", "->", "getParent", "(", ")", "===", "$", "parent", ";", "}", ")", ";", "return", "$", "children", ";", "}" ]
Filters the collection and returns only children elements for given parent element @param Collection $collection @param AdminMenu|null $parent @return Collection
[ "Filters", "the", "collection", "and", "returns", "only", "children", "elements", "for", "given", "parent", "element" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Service/Admin/Provider/AdminMenuProvider.php#L117-L124
23,522
SporkCode/Spork
src/View/Helper/CSS/AbstractHelper.php
AbstractHelper.getCompiler
public function getCompiler() { if (!$this->compiler instanceof AbstractCompiler) { if (null === $this->compiler) { throw new \Exception('Compiler not set'); } $compiler = $this->getView()->getHelperPluginManager()->getServiceLocator()->get($this->compiler); if (!$compiler instanceof AbstractCompiler) { throw new \Exception(sprintf( 'Invalid compiler type: %s not instance of Spork\CSS\AbstractCompiler', is_object($compiler) ? get_class($compiler) : gettype($compiler))); } $this->compiler = $compiler; } return $this->compiler; }
php
public function getCompiler() { if (!$this->compiler instanceof AbstractCompiler) { if (null === $this->compiler) { throw new \Exception('Compiler not set'); } $compiler = $this->getView()->getHelperPluginManager()->getServiceLocator()->get($this->compiler); if (!$compiler instanceof AbstractCompiler) { throw new \Exception(sprintf( 'Invalid compiler type: %s not instance of Spork\CSS\AbstractCompiler', is_object($compiler) ? get_class($compiler) : gettype($compiler))); } $this->compiler = $compiler; } return $this->compiler; }
[ "public", "function", "getCompiler", "(", ")", "{", "if", "(", "!", "$", "this", "->", "compiler", "instanceof", "AbstractCompiler", ")", "{", "if", "(", "null", "===", "$", "this", "->", "compiler", ")", "{", "throw", "new", "\\", "Exception", "(", "'Compiler not set'", ")", ";", "}", "$", "compiler", "=", "$", "this", "->", "getView", "(", ")", "->", "getHelperPluginManager", "(", ")", "->", "getServiceLocator", "(", ")", "->", "get", "(", "$", "this", "->", "compiler", ")", ";", "if", "(", "!", "$", "compiler", "instanceof", "AbstractCompiler", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Invalid compiler type: %s not instance of Spork\\CSS\\AbstractCompiler'", ",", "is_object", "(", "$", "compiler", ")", "?", "get_class", "(", "$", "compiler", ")", ":", "gettype", "(", "$", "compiler", ")", ")", ")", ";", "}", "$", "this", "->", "compiler", "=", "$", "compiler", ";", "}", "return", "$", "this", "->", "compiler", ";", "}" ]
Get compiler instance @throws \Exception On compiler not set or invalid compiler type found @return \Spork\CSS\AbstractCompiler
[ "Get", "compiler", "instance" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/CSS/AbstractHelper.php#L70-L86
23,523
SporkCode/Spork
src/View/Helper/CSS/AbstractHelper.php
AbstractHelper.initializeResolver
protected function initializeResolver() { $extensions = $this->getCompiler()->getExtensions(); $resolver = $this->resolver = new AggregateResolver(); $stack = array($this->getView()->resolver()); while ($source = array_shift($stack)) { if ($source instanceof AggregateResolver) { foreach ($source as $child) { array_push($stack, $child); } } elseif ($source instanceof TemplatePathStack) { foreach ($extensions as $extension) { $child = clone $source; $child->setDefaultSuffix($extension); $resolver->attach($child); } } else { $resolver->attach($source); } } }
php
protected function initializeResolver() { $extensions = $this->getCompiler()->getExtensions(); $resolver = $this->resolver = new AggregateResolver(); $stack = array($this->getView()->resolver()); while ($source = array_shift($stack)) { if ($source instanceof AggregateResolver) { foreach ($source as $child) { array_push($stack, $child); } } elseif ($source instanceof TemplatePathStack) { foreach ($extensions as $extension) { $child = clone $source; $child->setDefaultSuffix($extension); $resolver->attach($child); } } else { $resolver->attach($source); } } }
[ "protected", "function", "initializeResolver", "(", ")", "{", "$", "extensions", "=", "$", "this", "->", "getCompiler", "(", ")", "->", "getExtensions", "(", ")", ";", "$", "resolver", "=", "$", "this", "->", "resolver", "=", "new", "AggregateResolver", "(", ")", ";", "$", "stack", "=", "array", "(", "$", "this", "->", "getView", "(", ")", "->", "resolver", "(", ")", ")", ";", "while", "(", "$", "source", "=", "array_shift", "(", "$", "stack", ")", ")", "{", "if", "(", "$", "source", "instanceof", "AggregateResolver", ")", "{", "foreach", "(", "$", "source", "as", "$", "child", ")", "{", "array_push", "(", "$", "stack", ",", "$", "child", ")", ";", "}", "}", "elseif", "(", "$", "source", "instanceof", "TemplatePathStack", ")", "{", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "child", "=", "clone", "$", "source", ";", "$", "child", "->", "setDefaultSuffix", "(", "$", "extension", ")", ";", "$", "resolver", "->", "attach", "(", "$", "child", ")", ";", "}", "}", "else", "{", "$", "resolver", "->", "attach", "(", "$", "source", ")", ";", "}", "}", "}" ]
Initializes Resolver to find files by mimicking the default template resolver and using compiler extensions.
[ "Initializes", "Resolver", "to", "find", "files", "by", "mimicking", "the", "default", "template", "resolver", "and", "using", "compiler", "extensions", "." ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/CSS/AbstractHelper.php#L130-L151
23,524
dotkernel/dot-rbac-guard
src/Provider/ArrayGuardsProvider.php
ArrayGuardsProvider.getGuards
public function getGuards(): array { if ($this->guards) { return $this->guards; } if (empty($this->guardsConfig)) { return []; } $this->guards = []; foreach ($this->guardsConfig as $guardConfig) { $this->guards[] = $this->getGuardFactory()->create($guardConfig); } $this->sortGuardsByPriority(); return $this->guards; }
php
public function getGuards(): array { if ($this->guards) { return $this->guards; } if (empty($this->guardsConfig)) { return []; } $this->guards = []; foreach ($this->guardsConfig as $guardConfig) { $this->guards[] = $this->getGuardFactory()->create($guardConfig); } $this->sortGuardsByPriority(); return $this->guards; }
[ "public", "function", "getGuards", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "guards", ")", "{", "return", "$", "this", "->", "guards", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "guardsConfig", ")", ")", "{", "return", "[", "]", ";", "}", "$", "this", "->", "guards", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "guardsConfig", "as", "$", "guardConfig", ")", "{", "$", "this", "->", "guards", "[", "]", "=", "$", "this", "->", "getGuardFactory", "(", ")", "->", "create", "(", "$", "guardConfig", ")", ";", "}", "$", "this", "->", "sortGuardsByPriority", "(", ")", ";", "return", "$", "this", "->", "guards", ";", "}" ]
Gets the cached guard list or creates it from the config @return GuardInterface[]
[ "Gets", "the", "cached", "guard", "list", "or", "creates", "it", "from", "the", "config" ]
4ecaafe2bfcf1d2a66ae582d6d7af4830ec51653
https://github.com/dotkernel/dot-rbac-guard/blob/4ecaafe2bfcf1d2a66ae582d6d7af4830ec51653/src/Provider/ArrayGuardsProvider.php#L44-L61
23,525
dotkernel/dot-rbac-guard
src/Provider/ArrayGuardsProvider.php
ArrayGuardsProvider.sortGuardsByPriority
protected function sortGuardsByPriority() { usort($this->guards, function (GuardInterface $a, GuardInterface $b) { return $b->getPriority() - $a->getPriority(); }); }
php
protected function sortGuardsByPriority() { usort($this->guards, function (GuardInterface $a, GuardInterface $b) { return $b->getPriority() - $a->getPriority(); }); }
[ "protected", "function", "sortGuardsByPriority", "(", ")", "{", "usort", "(", "$", "this", "->", "guards", ",", "function", "(", "GuardInterface", "$", "a", ",", "GuardInterface", "$", "b", ")", "{", "return", "$", "b", "->", "getPriority", "(", ")", "-", "$", "a", "->", "getPriority", "(", ")", ";", "}", ")", ";", "}" ]
Sort the guards list internally @return void
[ "Sort", "the", "guards", "list", "internally" ]
4ecaafe2bfcf1d2a66ae582d6d7af4830ec51653
https://github.com/dotkernel/dot-rbac-guard/blob/4ecaafe2bfcf1d2a66ae582d6d7af4830ec51653/src/Provider/ArrayGuardsProvider.php#L68-L73
23,526
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Twig/Extension.php
Extension.getFilters
public function getFilters() { $parser = \Parsedown::instance(); $translator = $this->translator; $routeRenderer = $this->routeRenderer; return array( 'markdown' => new \Twig_SimpleFilter( 'markdown', function ($value) use ($parser) { return $parser->text($value); } ), 'trans' => new \Twig_SimpleFilter( 'trans', function ($value, $context) use ($translator) { if (!$context) { $context = array(); } return vsprintf($translator->translate($value), $context); } ), 'route' => new \Twig_SimpleFilter( 'route', function ($value, $presentation = 'normal') use ($routeRenderer) { return $routeRenderer->render($value, $presentation); } ), 'sort' => new \Twig_SimpleFilter( 'sort_*', function ($direction, $collection) { if (!$collection instanceof Collection) { return $collection; } $iterator = $collection->getIterator(); $iterator->uasort( function ($a, $b) use ($direction) { $aElem = strtolower($a->getName()); $bElem = strtolower($b->getName()); if ($aElem === $bElem) { return 0; } if ($direction === 'asc' && $aElem > $bElem || $direction === 'desc' && $aElem < $bElem) { return 1; } return -1; } ); return $iterator; } ), ); }
php
public function getFilters() { $parser = \Parsedown::instance(); $translator = $this->translator; $routeRenderer = $this->routeRenderer; return array( 'markdown' => new \Twig_SimpleFilter( 'markdown', function ($value) use ($parser) { return $parser->text($value); } ), 'trans' => new \Twig_SimpleFilter( 'trans', function ($value, $context) use ($translator) { if (!$context) { $context = array(); } return vsprintf($translator->translate($value), $context); } ), 'route' => new \Twig_SimpleFilter( 'route', function ($value, $presentation = 'normal') use ($routeRenderer) { return $routeRenderer->render($value, $presentation); } ), 'sort' => new \Twig_SimpleFilter( 'sort_*', function ($direction, $collection) { if (!$collection instanceof Collection) { return $collection; } $iterator = $collection->getIterator(); $iterator->uasort( function ($a, $b) use ($direction) { $aElem = strtolower($a->getName()); $bElem = strtolower($b->getName()); if ($aElem === $bElem) { return 0; } if ($direction === 'asc' && $aElem > $bElem || $direction === 'desc' && $aElem < $bElem) { return 1; } return -1; } ); return $iterator; } ), ); }
[ "public", "function", "getFilters", "(", ")", "{", "$", "parser", "=", "\\", "Parsedown", "::", "instance", "(", ")", ";", "$", "translator", "=", "$", "this", "->", "translator", ";", "$", "routeRenderer", "=", "$", "this", "->", "routeRenderer", ";", "return", "array", "(", "'markdown'", "=>", "new", "\\", "Twig_SimpleFilter", "(", "'markdown'", ",", "function", "(", "$", "value", ")", "use", "(", "$", "parser", ")", "{", "return", "$", "parser", "->", "text", "(", "$", "value", ")", ";", "}", ")", ",", "'trans'", "=>", "new", "\\", "Twig_SimpleFilter", "(", "'trans'", ",", "function", "(", "$", "value", ",", "$", "context", ")", "use", "(", "$", "translator", ")", "{", "if", "(", "!", "$", "context", ")", "{", "$", "context", "=", "array", "(", ")", ";", "}", "return", "vsprintf", "(", "$", "translator", "->", "translate", "(", "$", "value", ")", ",", "$", "context", ")", ";", "}", ")", ",", "'route'", "=>", "new", "\\", "Twig_SimpleFilter", "(", "'route'", ",", "function", "(", "$", "value", ",", "$", "presentation", "=", "'normal'", ")", "use", "(", "$", "routeRenderer", ")", "{", "return", "$", "routeRenderer", "->", "render", "(", "$", "value", ",", "$", "presentation", ")", ";", "}", ")", ",", "'sort'", "=>", "new", "\\", "Twig_SimpleFilter", "(", "'sort_*'", ",", "function", "(", "$", "direction", ",", "$", "collection", ")", "{", "if", "(", "!", "$", "collection", "instanceof", "Collection", ")", "{", "return", "$", "collection", ";", "}", "$", "iterator", "=", "$", "collection", "->", "getIterator", "(", ")", ";", "$", "iterator", "->", "uasort", "(", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "direction", ")", "{", "$", "aElem", "=", "strtolower", "(", "$", "a", "->", "getName", "(", ")", ")", ";", "$", "bElem", "=", "strtolower", "(", "$", "b", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "aElem", "===", "$", "bElem", ")", "{", "return", "0", ";", "}", "if", "(", "$", "direction", "===", "'asc'", "&&", "$", "aElem", ">", "$", "bElem", "||", "$", "direction", "===", "'desc'", "&&", "$", "aElem", "<", "$", "bElem", ")", "{", "return", "1", ";", "}", "return", "-", "1", ";", "}", ")", ";", "return", "$", "iterator", ";", "}", ")", ",", ")", ";", "}" ]
Returns a list of all filters that are exposed by this extension. @return \Twig_SimpleFilter[]
[ "Returns", "a", "list", "of", "all", "filters", "that", "are", "exposed", "by", "this", "extension", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Twig/Extension.php#L166-L222
23,527
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.virtualToScalable
public function virtualToScalable($event) { if (($this->scalableAttributeName() !== null) && ($this->virtualAttributesNames() !== null)) { $data = []; foreach ($this->virtualAttributesNames() as $name) { if (!empty($this->owner->{$name})) { $data[$name] = $this->owner->{$name}; } } $this->owner->{$this->scalableAttributeName()} = $this->convert($data); } }
php
public function virtualToScalable($event) { if (($this->scalableAttributeName() !== null) && ($this->virtualAttributesNames() !== null)) { $data = []; foreach ($this->virtualAttributesNames() as $name) { if (!empty($this->owner->{$name})) { $data[$name] = $this->owner->{$name}; } } $this->owner->{$this->scalableAttributeName()} = $this->convert($data); } }
[ "public", "function", "virtualToScalable", "(", "$", "event", ")", "{", "if", "(", "(", "$", "this", "->", "scalableAttributeName", "(", ")", "!==", "null", ")", "&&", "(", "$", "this", "->", "virtualAttributesNames", "(", ")", "!==", "null", ")", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "virtualAttributesNames", "(", ")", "as", "$", "name", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "owner", "->", "{", "$", "name", "}", ")", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "this", "->", "owner", "->", "{", "$", "name", "}", ";", "}", "}", "$", "this", "->", "owner", "->", "{", "$", "this", "->", "scalableAttributeName", "(", ")", "}", "=", "$", "this", "->", "convert", "(", "$", "data", ")", ";", "}", "}" ]
Converts configured attributes before saving them to database @param mixed $event
[ "Converts", "configured", "attributes", "before", "saving", "them", "to", "database" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L68-L82
23,528
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.scalableToVirtual
public function scalableToVirtual($event = null) { if (($this->scalableAttributeName() !== null) && ($this->virtualAttributesNames() !== null)) { $virtualAttributesConf = []; foreach ($this->virtualAttributesNames() as $name) { $virtualAttributesConf[$name] = ''; } $virtualAttributesNames = ArrayHelper::merge( $virtualAttributesConf, (($a = $this->unConvert($this->owner->{$this->scalableAttributeName()})) !== null) ? $a : [] ); foreach ($virtualAttributesNames as $name => $value) { if (in_array($name, $this->virtualAttributesNames())) { $this->owner->{$name} = $value; } } } }
php
public function scalableToVirtual($event = null) { if (($this->scalableAttributeName() !== null) && ($this->virtualAttributesNames() !== null)) { $virtualAttributesConf = []; foreach ($this->virtualAttributesNames() as $name) { $virtualAttributesConf[$name] = ''; } $virtualAttributesNames = ArrayHelper::merge( $virtualAttributesConf, (($a = $this->unConvert($this->owner->{$this->scalableAttributeName()})) !== null) ? $a : [] ); foreach ($virtualAttributesNames as $name => $value) { if (in_array($name, $this->virtualAttributesNames())) { $this->owner->{$name} = $value; } } } }
[ "public", "function", "scalableToVirtual", "(", "$", "event", "=", "null", ")", "{", "if", "(", "(", "$", "this", "->", "scalableAttributeName", "(", ")", "!==", "null", ")", "&&", "(", "$", "this", "->", "virtualAttributesNames", "(", ")", "!==", "null", ")", ")", "{", "$", "virtualAttributesConf", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "virtualAttributesNames", "(", ")", "as", "$", "name", ")", "{", "$", "virtualAttributesConf", "[", "$", "name", "]", "=", "''", ";", "}", "$", "virtualAttributesNames", "=", "ArrayHelper", "::", "merge", "(", "$", "virtualAttributesConf", ",", "(", "(", "$", "a", "=", "$", "this", "->", "unConvert", "(", "$", "this", "->", "owner", "->", "{", "$", "this", "->", "scalableAttributeName", "(", ")", "}", ")", ")", "!==", "null", ")", "?", "$", "a", ":", "[", "]", ")", ";", "foreach", "(", "$", "virtualAttributesNames", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "this", "->", "virtualAttributesNames", "(", ")", ")", ")", "{", "$", "this", "->", "owner", "->", "{", "$", "name", "}", "=", "$", "value", ";", "}", "}", "}", "}" ]
Checks if the defined attributes are unserializeable and unserializes their values @param mixed $event
[ "Checks", "if", "the", "defined", "attributes", "are", "unserializeable", "and", "unserializes", "their", "values" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L90-L111
23,529
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.convert
public function convert($data) { if (empty($data) || ($out = @serialize($data)) === false) return null; return $out; }
php
public function convert($data) { if (empty($data) || ($out = @serialize($data)) === false) return null; return $out; }
[ "public", "function", "convert", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "||", "(", "$", "out", "=", "@", "serialize", "(", "$", "data", ")", ")", "===", "false", ")", "return", "null", ";", "return", "$", "out", ";", "}" ]
Converts some input to a serialized string @param mixed $data Input as an array, String, Object, and so on @return null|string null at fault, string on success
[ "Converts", "some", "input", "to", "a", "serialized", "string" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L119-L125
23,530
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.unConvert
public function unConvert($data) { if (empty($data) || !is_string($data) || ($out = @unserialize($data)) === false) return null; if (!is_array($out) || empty($out)) return null; return $out; }
php
public function unConvert($data) { if (empty($data) || !is_string($data) || ($out = @unserialize($data)) === false) return null; if (!is_array($out) || empty($out)) return null; return $out; }
[ "public", "function", "unConvert", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "||", "!", "is_string", "(", "$", "data", ")", "||", "(", "$", "out", "=", "@", "unserialize", "(", "$", "data", ")", ")", "===", "false", ")", "return", "null", ";", "if", "(", "!", "is_array", "(", "$", "out", ")", "||", "empty", "(", "$", "out", ")", ")", "return", "null", ";", "return", "$", "out", ";", "}" ]
Unconverts a serialized string into an array @param string $data Serialized string to convert @return null|array null at fault, array on success
[ "Unconverts", "a", "serialized", "string", "into", "an", "array" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L133-L142
23,531
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.scalableAttributeName
public function scalableAttributeName() { if ($this->_scalableAttribute !== null) return $this->_scalableAttribute; if (in_array((string)$this->scalableAttribute, $this->objAttributesNames())) return $this->_scalableAttribute = $this->scalableAttribute; return null; }
php
public function scalableAttributeName() { if ($this->_scalableAttribute !== null) return $this->_scalableAttribute; if (in_array((string)$this->scalableAttribute, $this->objAttributesNames())) return $this->_scalableAttribute = $this->scalableAttribute; return null; }
[ "public", "function", "scalableAttributeName", "(", ")", "{", "if", "(", "$", "this", "->", "_scalableAttribute", "!==", "null", ")", "return", "$", "this", "->", "_scalableAttribute", ";", "if", "(", "in_array", "(", "(", "string", ")", "$", "this", "->", "scalableAttribute", ",", "$", "this", "->", "objAttributesNames", "(", ")", ")", ")", "return", "$", "this", "->", "_scalableAttribute", "=", "$", "this", "->", "scalableAttribute", ";", "return", "null", ";", "}" ]
Verifies the configured scalable attribute @return null|string
[ "Verifies", "the", "configured", "scalable", "attribute" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L153-L162
23,532
cakebake/yii2-scalable-behavior
ScalableBehavior.php
ScalableBehavior.virtualAttributesNames
public function virtualAttributesNames() { if (!empty($this->_virtualAttributes)) return $this->_virtualAttributes; if (!is_array($this->virtualAttributes) || empty($this->virtualAttributes)) return null; $attributes = []; foreach ($this->virtualAttributes as $a) { if (!in_array($a, $this->objAttributesNames()) && !in_array($a, $attributes)) { $attributes[] = $a; } } return !empty($attributes) ? $this->_virtualAttributes = $attributes : null; }
php
public function virtualAttributesNames() { if (!empty($this->_virtualAttributes)) return $this->_virtualAttributes; if (!is_array($this->virtualAttributes) || empty($this->virtualAttributes)) return null; $attributes = []; foreach ($this->virtualAttributes as $a) { if (!in_array($a, $this->objAttributesNames()) && !in_array($a, $attributes)) { $attributes[] = $a; } } return !empty($attributes) ? $this->_virtualAttributes = $attributes : null; }
[ "public", "function", "virtualAttributesNames", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_virtualAttributes", ")", ")", "return", "$", "this", "->", "_virtualAttributes", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "virtualAttributes", ")", "||", "empty", "(", "$", "this", "->", "virtualAttributes", ")", ")", "return", "null", ";", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "virtualAttributes", "as", "$", "a", ")", "{", "if", "(", "!", "in_array", "(", "$", "a", ",", "$", "this", "->", "objAttributesNames", "(", ")", ")", "&&", "!", "in_array", "(", "$", "a", ",", "$", "attributes", ")", ")", "{", "$", "attributes", "[", "]", "=", "$", "a", ";", "}", "}", "return", "!", "empty", "(", "$", "attributes", ")", "?", "$", "this", "->", "_virtualAttributes", "=", "$", "attributes", ":", "null", ";", "}" ]
Verifies the configured virtual attributes @return mixed
[ "Verifies", "the", "configured", "virtual", "attributes" ]
4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb
https://github.com/cakebake/yii2-scalable-behavior/blob/4cc7fa9766e9d58dbf6842b7f298063eac0ab9fb/ScalableBehavior.php#L173-L189
23,533
rhosocial/yii2-user
forms/LoginForm.php
LoginForm.validateId
public function validateId($attribute, $params) { foreach (Yii::$app->user->getLoginPriority() as $item) { if ($item::validate($this->$attribute)) { return; } } $this->addError($attribute, Yii::t('user', 'Incorrect ID.')); }
php
public function validateId($attribute, $params) { foreach (Yii::$app->user->getLoginPriority() as $item) { if ($item::validate($this->$attribute)) { return; } } $this->addError($attribute, Yii::t('user', 'Incorrect ID.')); }
[ "public", "function", "validateId", "(", "$", "attribute", ",", "$", "params", ")", "{", "foreach", "(", "Yii", "::", "$", "app", "->", "user", "->", "getLoginPriority", "(", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "::", "validate", "(", "$", "this", "->", "$", "attribute", ")", ")", "{", "return", ";", "}", "}", "$", "this", "->", "addError", "(", "$", "attribute", ",", "Yii", "::", "t", "(", "'user'", ",", "'Incorrect ID.'", ")", ")", ";", "}" ]
Validates the ID. @param $attribute @param $params
[ "Validates", "the", "ID", "." ]
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/forms/LoginForm.php#L82-L90
23,534
flextype-components/text
Text.php
Text.increment
public static function increment(string $str, int $first = 1, string $separator = '_') : string { preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; }
php
public static function increment(string $str, int $first = 1, string $separator = '_') : string { preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; }
[ "public", "static", "function", "increment", "(", "string", "$", "str", ",", "int", "$", "first", "=", "1", ",", "string", "$", "separator", "=", "'_'", ")", ":", "string", "{", "preg_match", "(", "'/(.+)'", ".", "$", "separator", ".", "'([0-9]+)$/'", ",", "$", "str", ",", "$", "match", ")", ";", "return", "isset", "(", "$", "match", "[", "2", "]", ")", "?", "$", "match", "[", "1", "]", ".", "$", "separator", ".", "(", "$", "match", "[", "2", "]", "+", "1", ")", ":", "$", "str", ".", "$", "separator", ".", "$", "first", ";", "}" ]
Add's _1 to a string or increment the ending number to allow _2, _3, etc $str = Text::increment($str); @param string $str String to increment @param int $first Start with @param string $separator Separator @return string
[ "Add", "s", "_1", "to", "a", "string", "or", "increment", "the", "ending", "number", "to", "allow", "_2", "_3", "etc" ]
8d707eec2dd9025cb17ae3b0c3e995e67580ece3
https://github.com/flextype-components/text/blob/8d707eec2dd9025cb17ae3b0c3e995e67580ece3/Text.php#L239-L244
23,535
flextype-components/text
Text.php
Text.safeString
public static function safeString(string $str, string $delimiter = '-', bool $lowercase = false) : string { // Remove tags $str = filter_var($str, FILTER_SANITIZE_STRING); // Decode all entities to their simpler forms $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); // Reserved characters (RFC 3986) $reserved_characters = array( '/', '?', ':', '@', '#', '[', ']', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' ); // Remove reserved characters $str = str_replace($reserved_characters, ' ', $str); // Set locale to en_US.UTF8 setlocale(LC_ALL, 'en_US.UTF8'); // Translit ua,ru => latin $str = Text::translitIt($str); // Convert string $str = iconv('UTF-8', 'ASCII//TRANSLIT', $str); // Remove characters $str = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str); if ($delimiter != null) { $str = preg_replace("/[\/_|+ -]+/", $delimiter, $str); $str = trim($str, $delimiter); } // Lowercase if ($lowercase === true) { $str = Text::lowercase($str); } // Return safe name return $str; }
php
public static function safeString(string $str, string $delimiter = '-', bool $lowercase = false) : string { // Remove tags $str = filter_var($str, FILTER_SANITIZE_STRING); // Decode all entities to their simpler forms $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); // Reserved characters (RFC 3986) $reserved_characters = array( '/', '?', ':', '@', '#', '[', ']', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' ); // Remove reserved characters $str = str_replace($reserved_characters, ' ', $str); // Set locale to en_US.UTF8 setlocale(LC_ALL, 'en_US.UTF8'); // Translit ua,ru => latin $str = Text::translitIt($str); // Convert string $str = iconv('UTF-8', 'ASCII//TRANSLIT', $str); // Remove characters $str = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str); if ($delimiter != null) { $str = preg_replace("/[\/_|+ -]+/", $delimiter, $str); $str = trim($str, $delimiter); } // Lowercase if ($lowercase === true) { $str = Text::lowercase($str); } // Return safe name return $str; }
[ "public", "static", "function", "safeString", "(", "string", "$", "str", ",", "string", "$", "delimiter", "=", "'-'", ",", "bool", "$", "lowercase", "=", "false", ")", ":", "string", "{", "// Remove tags", "$", "str", "=", "filter_var", "(", "$", "str", ",", "FILTER_SANITIZE_STRING", ")", ";", "// Decode all entities to their simpler forms", "$", "str", "=", "html_entity_decode", "(", "$", "str", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "// Reserved characters (RFC 3986)", "$", "reserved_characters", "=", "array", "(", "'/'", ",", "'?'", ",", "':'", ",", "'@'", ",", "'#'", ",", "'['", ",", "']'", ",", "'!'", ",", "'$'", ",", "'&'", ",", "'\\''", ",", "'('", ",", "')'", ",", "'*'", ",", "'+'", ",", "','", ",", "';'", ",", "'='", ")", ";", "// Remove reserved characters", "$", "str", "=", "str_replace", "(", "$", "reserved_characters", ",", "' '", ",", "$", "str", ")", ";", "// Set locale to en_US.UTF8", "setlocale", "(", "LC_ALL", ",", "'en_US.UTF8'", ")", ";", "// Translit ua,ru => latin", "$", "str", "=", "Text", "::", "translitIt", "(", "$", "str", ")", ";", "// Convert string", "$", "str", "=", "iconv", "(", "'UTF-8'", ",", "'ASCII//TRANSLIT'", ",", "$", "str", ")", ";", "// Remove characters", "$", "str", "=", "preg_replace", "(", "\"/[^a-zA-Z0-9\\/_|+ -]/\"", ",", "''", ",", "$", "str", ")", ";", "if", "(", "$", "delimiter", "!=", "null", ")", "{", "$", "str", "=", "preg_replace", "(", "\"/[\\/_|+ -]+/\"", ",", "$", "delimiter", ",", "$", "str", ")", ";", "$", "str", "=", "trim", "(", "$", "str", ",", "$", "delimiter", ")", ";", "}", "// Lowercase", "if", "(", "$", "lowercase", "===", "true", ")", "{", "$", "str", "=", "Text", "::", "lowercase", "(", "$", "str", ")", ";", "}", "// Return safe name", "return", "$", "str", ";", "}" ]
Create safe string. Use to create safe usernames or filenames. $safe_string = Text::safeString('hello world'); @param string $str String @param string $delimiter String delimiter @param boolean $lowercase String Lowercase @return string
[ "Create", "safe", "string", ".", "Use", "to", "create", "safe", "usernames", "or", "filenames", "." ]
8d707eec2dd9025cb17ae3b0c3e995e67580ece3
https://github.com/flextype-components/text/blob/8d707eec2dd9025cb17ae3b0c3e995e67580ece3/Text.php#L418-L459
23,536
philiplb/Valdi
src/Valdi/Validator/Contains.php
Contains.adjustCaseInsensitive
protected function adjustCaseInsensitive(&$value, &$parameters) { $parameterAmount = count($parameters); if ($parameterAmount == 1 || $parameterAmount > 1 && $parameters[1]) { $parameters[0] = strtolower($parameters[0]); $value = strtolower($value); } }
php
protected function adjustCaseInsensitive(&$value, &$parameters) { $parameterAmount = count($parameters); if ($parameterAmount == 1 || $parameterAmount > 1 && $parameters[1]) { $parameters[0] = strtolower($parameters[0]); $value = strtolower($value); } }
[ "protected", "function", "adjustCaseInsensitive", "(", "&", "$", "value", ",", "&", "$", "parameters", ")", "{", "$", "parameterAmount", "=", "count", "(", "$", "parameters", ")", ";", "if", "(", "$", "parameterAmount", "==", "1", "||", "$", "parameterAmount", ">", "1", "&&", "$", "parameters", "[", "1", "]", ")", "{", "$", "parameters", "[", "0", "]", "=", "strtolower", "(", "$", "parameters", "[", "0", "]", ")", ";", "$", "value", "=", "strtolower", "(", "$", "value", ")", ";", "}", "}" ]
Adjusts value and parameters to be case insensitive if the second parameter says so or is not given. @param mixed $value the value to validate @param array $parameters the other parameters the validator need
[ "Adjusts", "value", "and", "parameters", "to", "be", "case", "insensitive", "if", "the", "second", "parameter", "says", "so", "or", "is", "not", "given", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/Contains.php#L47-L53
23,537
david-mk/mail-map
src/MailMap/Query.php
Query.get
public function get(ConnectionContract $connection, MailFactoryContract $factory) { $uids = $connection->search($this->parseSearch()); $stream = $connection->getStream(); $max = $this->limit > 0 ? $this->limit : self::$max; $uids = array_slice($uids, 0, $max); return array_map(function ($uid) use ($factory, $stream) { return $factory->create($uid, $stream); }, $uids); }
php
public function get(ConnectionContract $connection, MailFactoryContract $factory) { $uids = $connection->search($this->parseSearch()); $stream = $connection->getStream(); $max = $this->limit > 0 ? $this->limit : self::$max; $uids = array_slice($uids, 0, $max); return array_map(function ($uid) use ($factory, $stream) { return $factory->create($uid, $stream); }, $uids); }
[ "public", "function", "get", "(", "ConnectionContract", "$", "connection", ",", "MailFactoryContract", "$", "factory", ")", "{", "$", "uids", "=", "$", "connection", "->", "search", "(", "$", "this", "->", "parseSearch", "(", ")", ")", ";", "$", "stream", "=", "$", "connection", "->", "getStream", "(", ")", ";", "$", "max", "=", "$", "this", "->", "limit", ">", "0", "?", "$", "this", "->", "limit", ":", "self", "::", "$", "max", ";", "$", "uids", "=", "array_slice", "(", "$", "uids", ",", "0", ",", "$", "max", ")", ";", "return", "array_map", "(", "function", "(", "$", "uid", ")", "use", "(", "$", "factory", ",", "$", "stream", ")", "{", "return", "$", "factory", "->", "create", "(", "$", "uid", ",", "$", "stream", ")", ";", "}", ",", "$", "uids", ")", ";", "}" ]
Execute search query on connection and put results into Mail wrappers using factory @param \MailMap\Contracts\Connection $connection @param \MailMap\Contracts\MailFactory $factory @return array List of Mail wrappers
[ "Execute", "search", "query", "on", "connection", "and", "put", "results", "into", "Mail", "wrappers", "using", "factory" ]
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Query.php#L108-L119
23,538
david-mk/mail-map
src/MailMap/Query.php
Query.where
public function where($flag, $value = null) { if (!in_array(strtolower($flag), static::$searchCriteria)) { throw new InvalidArgumentException("Invalid where criteria '{$flag}'"); } $this->where[$flag] = $value; return $this; }
php
public function where($flag, $value = null) { if (!in_array(strtolower($flag), static::$searchCriteria)) { throw new InvalidArgumentException("Invalid where criteria '{$flag}'"); } $this->where[$flag] = $value; return $this; }
[ "public", "function", "where", "(", "$", "flag", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "flag", ")", ",", "static", "::", "$", "searchCriteria", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Invalid where criteria '{$flag}'\"", ")", ";", "}", "$", "this", "->", "where", "[", "$", "flag", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set where condition. @param string $flag @param string $value @return $this
[ "Set", "where", "condition", "." ]
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Query.php#L140-L148
23,539
david-mk/mail-map
src/MailMap/Query.php
Query.order
public function order($orderFlag, $dir = 'desc') { if (!in_array($orderFlag, static::$orderCriteria)) { throw new InvalidArgumentException("Invalid order criteria '{$orderFlag}'"); } $this->order = $orderFlag; $this->orderDir = strtolower($dir) === 'asc' ? 0 : 1; return $this; }
php
public function order($orderFlag, $dir = 'desc') { if (!in_array($orderFlag, static::$orderCriteria)) { throw new InvalidArgumentException("Invalid order criteria '{$orderFlag}'"); } $this->order = $orderFlag; $this->orderDir = strtolower($dir) === 'asc' ? 0 : 1; return $this; }
[ "public", "function", "order", "(", "$", "orderFlag", ",", "$", "dir", "=", "'desc'", ")", "{", "if", "(", "!", "in_array", "(", "$", "orderFlag", ",", "static", "::", "$", "orderCriteria", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Invalid order criteria '{$orderFlag}'\"", ")", ";", "}", "$", "this", "->", "order", "=", "$", "orderFlag", ";", "$", "this", "->", "orderDir", "=", "strtolower", "(", "$", "dir", ")", "===", "'asc'", "?", "0", ":", "1", ";", "return", "$", "this", ";", "}" ]
Set sorting order. imap_sort only allows one sort condition http://php.net/manual/en/function.imap-sort.php Calling again will overwrite previous @param int $orderFlag @param string $dir @return $this
[ "Set", "sorting", "order", "." ]
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Query.php#L160-L170
23,540
david-mk/mail-map
src/MailMap/Query.php
Query.parseSearch
protected function parseSearch() { return implode(' ', array_map(function ($key, $val) { if (is_null($val)) { return strtoupper($key); } return sprintf('%s %s', strtoupper($key), $val); }, array_keys($this->where), array_values($this->where))); }
php
protected function parseSearch() { return implode(' ', array_map(function ($key, $val) { if (is_null($val)) { return strtoupper($key); } return sprintf('%s %s', strtoupper($key), $val); }, array_keys($this->where), array_values($this->where))); }
[ "protected", "function", "parseSearch", "(", ")", "{", "return", "implode", "(", "' '", ",", "array_map", "(", "function", "(", "$", "key", ",", "$", "val", ")", "{", "if", "(", "is_null", "(", "$", "val", ")", ")", "{", "return", "strtoupper", "(", "$", "key", ")", ";", "}", "return", "sprintf", "(", "'%s %s'", ",", "strtoupper", "(", "$", "key", ")", ",", "$", "val", ")", ";", "}", ",", "array_keys", "(", "$", "this", "->", "where", ")", ",", "array_values", "(", "$", "this", "->", "where", ")", ")", ")", ";", "}" ]
Parse the 'where' conditions for imap_search @return string
[ "Parse", "the", "where", "conditions", "for", "imap_search" ]
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Query.php#L177-L185
23,541
bpolaszek/simple-dbal
src/Model/Adapter/Mysqli/Statement.php
Statement.toScalar
protected function toScalar($value) { if (is_scalar($value)) { return $value; } elseif (null === $value) { return 'NULL'; } else { if (is_object($value)) { if (is_callable([$value, '__toString'])) { return (string) $value; } elseif ($value instanceof \DateTimeInterface) { return $value->format('Y-m-d H:i:s'); } else { throw new \InvalidArgumentException(sprintf("Cast of class %s is impossible", get_class($value))); } } else { throw new \InvalidArgumentException(sprintf("Cast of type %s is impossible", gettype($value))); } } }
php
protected function toScalar($value) { if (is_scalar($value)) { return $value; } elseif (null === $value) { return 'NULL'; } else { if (is_object($value)) { if (is_callable([$value, '__toString'])) { return (string) $value; } elseif ($value instanceof \DateTimeInterface) { return $value->format('Y-m-d H:i:s'); } else { throw new \InvalidArgumentException(sprintf("Cast of class %s is impossible", get_class($value))); } } else { throw new \InvalidArgumentException(sprintf("Cast of type %s is impossible", gettype($value))); } } }
[ "protected", "function", "toScalar", "(", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "elseif", "(", "null", "===", "$", "value", ")", "{", "return", "'NULL'", ";", "}", "else", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "is_callable", "(", "[", "$", "value", ",", "'__toString'", "]", ")", ")", "{", "return", "(", "string", ")", "$", "value", ";", "}", "elseif", "(", "$", "value", "instanceof", "\\", "DateTimeInterface", ")", "{", "return", "$", "value", "->", "format", "(", "'Y-m-d H:i:s'", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Cast of class %s is impossible\"", ",", "get_class", "(", "$", "value", ")", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Cast of type %s is impossible\"", ",", "gettype", "(", "$", "value", ")", ")", ")", ";", "}", "}", "}" ]
Attempt to convert non-scalar values. @param $value @return string
[ "Attempt", "to", "convert", "non", "-", "scalar", "values", "." ]
52cb50d326ba5854191814b470f5e84950ebb6e6
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/Statement.php#L136-L155
23,542
blast-project/BaseEntitiesBundle
src/EventListener/SortableListener.php
SortableListener.prePersist
public function prePersist(EventArgs $args) { $em = $args->getEntityManager(); $object = $args->getObject(); $class = get_class($object); $meta = $em->getClassMetadata($class); $reflectionClass = $meta->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait if ($object->getSortRank()) { return; } $maxPos = $this->getMaxPosition($em, $meta); $maxPos = $maxPos ? $maxPos + 1000 : 65536; $object->setSortRank($maxPos); $this->maxPositions[$class] = $maxPos; }
php
public function prePersist(EventArgs $args) { $em = $args->getEntityManager(); $object = $args->getObject(); $class = get_class($object); $meta = $em->getClassMetadata($class); $reflectionClass = $meta->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Sortable')) { return; } // return if current entity doesn't use Sortable trait if ($object->getSortRank()) { return; } $maxPos = $this->getMaxPosition($em, $meta); $maxPos = $maxPos ? $maxPos + 1000 : 65536; $object->setSortRank($maxPos); $this->maxPositions[$class] = $maxPos; }
[ "public", "function", "prePersist", "(", "EventArgs", "$", "args", ")", "{", "$", "em", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "$", "object", "=", "$", "args", "->", "getObject", "(", ")", ";", "$", "class", "=", "get_class", "(", "$", "object", ")", ";", "$", "meta", "=", "$", "em", "->", "getClassMetadata", "(", "$", "class", ")", ";", "$", "reflectionClass", "=", "$", "meta", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "$", "reflectionClass", "||", "!", "$", "this", "->", "hasTrait", "(", "$", "reflectionClass", ",", "'Blast\\BaseEntitiesBundle\\Entity\\Traits\\Sortable'", ")", ")", "{", "return", ";", "}", "// return if current entity doesn't use Sortable trait", "if", "(", "$", "object", "->", "getSortRank", "(", ")", ")", "{", "return", ";", "}", "$", "maxPos", "=", "$", "this", "->", "getMaxPosition", "(", "$", "em", ",", "$", "meta", ")", ";", "$", "maxPos", "=", "$", "maxPos", "?", "$", "maxPos", "+", "1000", ":", "65536", ";", "$", "object", "->", "setSortRank", "(", "$", "maxPos", ")", ";", "$", "this", "->", "maxPositions", "[", "$", "class", "]", "=", "$", "maxPos", ";", "}" ]
Compute sortRank for entities that are created. @param EventArgs $args
[ "Compute", "sortRank", "for", "entities", "that", "are", "created", "." ]
abd06891fc38922225ab7e4fcb437a286ba2c0c4
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/EventListener/SortableListener.php#L85-L107
23,543
odiaseo/pagebuilder
src/PageBuilder/Model/ResourceModel.php
ResourceModel.getGenericResources
public function getGenericResources($limit = 10, $mode = AbstractQuery::HYDRATE_OBJECT) { $builder = $this->getEntityManager()->createQueryBuilder(); $builder->select('e') ->from($this->getEntity(), 'e') ->where('e.isGeneric = 1') ->setMaxResults($limit); $query = LocaleAwareTrait::addHints($builder->getQuery()); return $query->execute($mode); }
php
public function getGenericResources($limit = 10, $mode = AbstractQuery::HYDRATE_OBJECT) { $builder = $this->getEntityManager()->createQueryBuilder(); $builder->select('e') ->from($this->getEntity(), 'e') ->where('e.isGeneric = 1') ->setMaxResults($limit); $query = LocaleAwareTrait::addHints($builder->getQuery()); return $query->execute($mode); }
[ "public", "function", "getGenericResources", "(", "$", "limit", "=", "10", ",", "$", "mode", "=", "AbstractQuery", "::", "HYDRATE_OBJECT", ")", "{", "$", "builder", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQueryBuilder", "(", ")", ";", "$", "builder", "->", "select", "(", "'e'", ")", "->", "from", "(", "$", "this", "->", "getEntity", "(", ")", ",", "'e'", ")", "->", "where", "(", "'e.isGeneric = 1'", ")", "->", "setMaxResults", "(", "$", "limit", ")", ";", "$", "query", "=", "LocaleAwareTrait", "::", "addHints", "(", "$", "builder", "->", "getQuery", "(", ")", ")", ";", "return", "$", "query", "->", "execute", "(", "$", "mode", ")", ";", "}" ]
List Generic Resources @param int $limit @param int $mode @return mixed
[ "List", "Generic", "Resources" ]
88ef7cccf305368561307efe4ca07fac8e5774f3
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/ResourceModel.php#L26-L38
23,544
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php
ExceptionRouter.handleException
private function handleException(\Throwable $t, Request $request) { if ($this->log !== null) { $this->log->error('Exception thrown inside a controller.', array( 'exception' => $t, )); } else { // If no logger is set, let's log in PHP error_log error_log($t->getMessage().' - '.$t->getTraceAsString()); } $response = SplashUtils::buildControllerResponse( function () use ($t, $request) { return $this->errorController->serverError($t, $request); } ); return $response; }
php
private function handleException(\Throwable $t, Request $request) { if ($this->log !== null) { $this->log->error('Exception thrown inside a controller.', array( 'exception' => $t, )); } else { // If no logger is set, let's log in PHP error_log error_log($t->getMessage().' - '.$t->getTraceAsString()); } $response = SplashUtils::buildControllerResponse( function () use ($t, $request) { return $this->errorController->serverError($t, $request); } ); return $response; }
[ "private", "function", "handleException", "(", "\\", "Throwable", "$", "t", ",", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "log", "!==", "null", ")", "{", "$", "this", "->", "log", "->", "error", "(", "'Exception thrown inside a controller.'", ",", "array", "(", "'exception'", "=>", "$", "t", ",", ")", ")", ";", "}", "else", "{", "// If no logger is set, let's log in PHP error_log", "error_log", "(", "$", "t", "->", "getMessage", "(", ")", ".", "' - '", ".", "$", "t", "->", "getTraceAsString", "(", ")", ")", ";", "}", "$", "response", "=", "SplashUtils", "::", "buildControllerResponse", "(", "function", "(", ")", "use", "(", "$", "t", ",", "$", "request", ")", "{", "return", "$", "this", "->", "errorController", "->", "serverError", "(", "$", "t", ",", "$", "request", ")", ";", "}", ")", ";", "return", "$", "response", ";", "}" ]
Actually handle the exception. @param \Throwable $t @param Request $request @return ResponseInterface
[ "Actually", "handle", "the", "exception", "." ]
eed0269ceda4d7d090a330a220490906a7aa60bd
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/ExceptionRouter.php#L55-L73
23,545
alevilar/ristorantino-vendor
Mesa/Controller/MesasController.php
MesasController.cerrarMesa
public function cerrarMesa ( $mesa_id, $imprimir_ticket = true) { $this->Mesa->id = $mesa_id; if( !$this->Mesa->cerrar_mesa() ) { if( !$this->request->is('ajax') ){ $this->setFlash('Error al cerrar la mesa', 'flash_error'); } } if( !$this->request->is('ajax') ){ $this->redirect( $this->referer() ); } }
php
public function cerrarMesa ( $mesa_id, $imprimir_ticket = true) { $this->Mesa->id = $mesa_id; if( !$this->Mesa->cerrar_mesa() ) { if( !$this->request->is('ajax') ){ $this->setFlash('Error al cerrar la mesa', 'flash_error'); } } if( !$this->request->is('ajax') ){ $this->redirect( $this->referer() ); } }
[ "public", "function", "cerrarMesa", "(", "$", "mesa_id", ",", "$", "imprimir_ticket", "=", "true", ")", "{", "$", "this", "->", "Mesa", "->", "id", "=", "$", "mesa_id", ";", "if", "(", "!", "$", "this", "->", "Mesa", "->", "cerrar_mesa", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "$", "this", "->", "setFlash", "(", "'Error al cerrar la mesa'", ",", "'flash_error'", ")", ";", "}", "}", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "$", "this", "->", "redirect", "(", "$", "this", "->", "referer", "(", ")", ")", ";", "}", "}" ]
Cierra la mesa, calculando el total y, si se lo indica, imprime el ticket fiscal. @param type $mesa_id @param type $imprimir_ticket @return type
[ "Cierra", "la", "mesa", "calculando", "el", "total", "y", "si", "se", "lo", "indica", "imprime", "el", "ticket", "fiscal", "." ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MesasController.php#L128-L140
23,546
webandco/neos-wireframe
Classes/ViewHelpers/RenderBoxViewHelper.php
RenderBoxViewHelper.render
public function render($mode, $node) { return ($mode > 0 || $node->hasProperty('renderBox') == false || $node->getProperty('renderBox') === null || $node->getProperty('renderBox') === true) ? true : false; }
php
public function render($mode, $node) { return ($mode > 0 || $node->hasProperty('renderBox') == false || $node->getProperty('renderBox') === null || $node->getProperty('renderBox') === true) ? true : false; }
[ "public", "function", "render", "(", "$", "mode", ",", "$", "node", ")", "{", "return", "(", "$", "mode", ">", "0", "||", "$", "node", "->", "hasProperty", "(", "'renderBox'", ")", "==", "false", "||", "$", "node", "->", "getProperty", "(", "'renderBox'", ")", "===", "null", "||", "$", "node", "->", "getProperty", "(", "'renderBox'", ")", "===", "true", ")", "?", "true", ":", "false", ";", "}" ]
Decide if box should be rendered or not based on renderMode and node properties @param integer $mode Value to check @param NodeInterface $node @return boolean
[ "Decide", "if", "box", "should", "be", "rendered", "or", "not", "based", "on", "renderMode", "and", "node", "properties" ]
b1dfd9bedee80001a9a0cf0f483d0261633d12cb
https://github.com/webandco/neos-wireframe/blob/b1dfd9bedee80001a9a0cf0f483d0261633d12cb/Classes/ViewHelpers/RenderBoxViewHelper.php#L19-L21
23,547
GrupaZero/api
src/Gzero/Api/Transformer/RoleTransformer.php
RoleTransformer.transform
public function transform($role) { $role = $this->entityToArray(Role::class, $role); return [ 'id' => (int) $role['id'], 'name' => $role['name'], 'createdAt' => $role['created_at'], 'updatedAt' => $role['updated_at'] ]; }
php
public function transform($role) { $role = $this->entityToArray(Role::class, $role); return [ 'id' => (int) $role['id'], 'name' => $role['name'], 'createdAt' => $role['created_at'], 'updatedAt' => $role['updated_at'] ]; }
[ "public", "function", "transform", "(", "$", "role", ")", "{", "$", "role", "=", "$", "this", "->", "entityToArray", "(", "Role", "::", "class", ",", "$", "role", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "role", "[", "'id'", "]", ",", "'name'", "=>", "$", "role", "[", "'name'", "]", ",", "'createdAt'", "=>", "$", "role", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "role", "[", "'updated_at'", "]", "]", ";", "}" ]
Transforms role entity @param Role|array $role Role entity @return array
[ "Transforms", "role", "entity" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/RoleTransformer.php#L26-L35
23,548
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.offsetSet
public function offsetSet($offset, $value) { if (is_null($offset)) { $this->_args[count($this->_args)] = $value; } else { if (is_int($offset)) { $this->_args[$offset] = $value; } else { throw new \Exception('Cannot set offset \''.$offset.'\' of IndexedArray.'); } } }
php
public function offsetSet($offset, $value) { if (is_null($offset)) { $this->_args[count($this->_args)] = $value; } else { if (is_int($offset)) { $this->_args[$offset] = $value; } else { throw new \Exception('Cannot set offset \''.$offset.'\' of IndexedArray.'); } } }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "_args", "[", "count", "(", "$", "this", "->", "_args", ")", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "is_int", "(", "$", "offset", ")", ")", "{", "$", "this", "->", "_args", "[", "$", "offset", "]", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Cannot set offset \\''", ".", "$", "offset", ".", "'\\' of IndexedArray.'", ")", ";", "}", "}", "}" ]
Override the offsetSet function to enforce integral keys only. @param mixed $offset @param mixed $value @throws \Exception
[ "Override", "the", "offsetSet", "function", "to", "enforce", "integral", "keys", "only", "." ]
a641856115131f76417521d3e4aa2d951158050a
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L40-L51
23,549
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.offsetGet
public function offsetGet($offset) { if (isset($this->_args[$offset])) { if (is_array($this->_args[$offset])) { return new AssociativeArray($this->_args[$offset]); } else { return $this->_args[$offset]; } } else { throw new \Exception('Undefined offset \''.$offset.'\'.'); } }
php
public function offsetGet($offset) { if (isset($this->_args[$offset])) { if (is_array($this->_args[$offset])) { return new AssociativeArray($this->_args[$offset]); } else { return $this->_args[$offset]; } } else { throw new \Exception('Undefined offset \''.$offset.'\'.'); } }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ")", "{", "return", "new", "AssociativeArray", "(", "$", "this", "->", "_args", "[", "$", "offset", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_args", "[", "$", "offset", "]", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Undefined offset \\''", ".", "$", "offset", ".", "'\\'.'", ")", ";", "}", "}" ]
Override the offsetGet function to throw an undefined offset error when a key is not found. @param mixed $offset @return mixed @throws \Exception
[ "Override", "the", "offsetGet", "function", "to", "throw", "an", "undefined", "offset", "error", "when", "a", "key", "is", "not", "found", "." ]
a641856115131f76417521d3e4aa2d951158050a
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L63-L74
23,550
nathan-fiscaletti/extended-arrays
src/ExtendedArrays/IndexedArray.php
IndexedArray.isPrefixedKey
private function isPrefixedKey($key) { if (strlen($key) > 1) { if (substr($key, 0, 1) == '_') { try { intval(substr($key, 1, strlen($key) - 1)); return true; } catch (\Exception $e) { return false; } } } }
php
private function isPrefixedKey($key) { if (strlen($key) > 1) { if (substr($key, 0, 1) == '_') { try { intval(substr($key, 1, strlen($key) - 1)); return true; } catch (\Exception $e) { return false; } } } }
[ "private", "function", "isPrefixedKey", "(", "$", "key", ")", "{", "if", "(", "strlen", "(", "$", "key", ")", ">", "1", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "==", "'_'", ")", "{", "try", "{", "intval", "(", "substr", "(", "$", "key", ",", "1", ",", "strlen", "(", "$", "key", ")", "-", "1", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}", "}", "}" ]
Check if a string is in the proper format to be a prefixed integral array key. @param string $key @return bool
[ "Check", "if", "a", "string", "is", "in", "the", "proper", "format", "to", "be", "a", "prefixed", "integral", "array", "key", "." ]
a641856115131f76417521d3e4aa2d951158050a
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/IndexedArray.php#L183-L196
23,551
mothership-ec/composer
src/Composer/Package/Locker.php
Locker.getPlatformRequirements
public function getPlatformRequirements($withDevReqs = false) { $lockData = $this->getLockData(); $versionParser = new VersionParser(); $requirements = array(); if (!empty($lockData['platform'])) { $requirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform']) ? $lockData['platform'] : array() ); } if ($withDevReqs && !empty($lockData['platform-dev'])) { $devRequirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array() ); $requirements = array_merge($requirements, $devRequirements); } return $requirements; }
php
public function getPlatformRequirements($withDevReqs = false) { $lockData = $this->getLockData(); $versionParser = new VersionParser(); $requirements = array(); if (!empty($lockData['platform'])) { $requirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform']) ? $lockData['platform'] : array() ); } if ($withDevReqs && !empty($lockData['platform-dev'])) { $devRequirements = $versionParser->parseLinks( '__ROOT__', '1.0.0', 'requires', isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array() ); $requirements = array_merge($requirements, $devRequirements); } return $requirements; }
[ "public", "function", "getPlatformRequirements", "(", "$", "withDevReqs", "=", "false", ")", "{", "$", "lockData", "=", "$", "this", "->", "getLockData", "(", ")", ";", "$", "versionParser", "=", "new", "VersionParser", "(", ")", ";", "$", "requirements", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "lockData", "[", "'platform'", "]", ")", ")", "{", "$", "requirements", "=", "$", "versionParser", "->", "parseLinks", "(", "'__ROOT__'", ",", "'1.0.0'", ",", "'requires'", ",", "isset", "(", "$", "lockData", "[", "'platform'", "]", ")", "?", "$", "lockData", "[", "'platform'", "]", ":", "array", "(", ")", ")", ";", "}", "if", "(", "$", "withDevReqs", "&&", "!", "empty", "(", "$", "lockData", "[", "'platform-dev'", "]", ")", ")", "{", "$", "devRequirements", "=", "$", "versionParser", "->", "parseLinks", "(", "'__ROOT__'", ",", "'1.0.0'", ",", "'requires'", ",", "isset", "(", "$", "lockData", "[", "'platform-dev'", "]", ")", "?", "$", "lockData", "[", "'platform-dev'", "]", ":", "array", "(", ")", ")", ";", "$", "requirements", "=", "array_merge", "(", "$", "requirements", ",", "$", "devRequirements", ")", ";", "}", "return", "$", "requirements", ";", "}" ]
Returns the platform requirements stored in the lock file @param bool $withDevReqs if true, the platform requirements from the require-dev block are also returned @return \Composer\Package\Link[]
[ "Returns", "the", "platform", "requirements", "stored", "in", "the", "lock", "file" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Locker.php#L133-L160
23,552
mothership-ec/composer
src/Composer/Package/Locker.php
Locker.setLockData
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides) { $lock = array( '_readme' => array('This file locks the dependencies of your project to a known state', 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', 'This file is @gener'.'ated automatically'), 'hash' => $this->hash, 'packages' => null, 'packages-dev' => null, 'aliases' => array(), 'minimum-stability' => $minimumStability, 'stability-flags' => $stabilityFlags, 'prefer-stable' => $preferStable, 'prefer-lowest' => $preferLowest, ); foreach ($aliases as $package => $versions) { foreach ($versions as $version => $alias) { $lock['aliases'][] = array( 'alias' => $alias['alias'], 'alias_normalized' => $alias['alias_normalized'], 'version' => $version, 'package' => $package, ); } } $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages); } $lock['platform'] = $platformReqs; $lock['platform-dev'] = $platformDevReqs; if ($platformOverrides) { $lock['platform-overrides'] = $platformOverrides; } if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) { if ($this->lockFile->exists()) { unlink($this->lockFile->getPath()); } return false; } if (!$this->isLocked() || $lock !== $this->getLockData()) { $this->lockFile->write($lock); $this->lockDataCache = null; return true; } return false; }
php
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides) { $lock = array( '_readme' => array('This file locks the dependencies of your project to a known state', 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', 'This file is @gener'.'ated automatically'), 'hash' => $this->hash, 'packages' => null, 'packages-dev' => null, 'aliases' => array(), 'minimum-stability' => $minimumStability, 'stability-flags' => $stabilityFlags, 'prefer-stable' => $preferStable, 'prefer-lowest' => $preferLowest, ); foreach ($aliases as $package => $versions) { foreach ($versions as $version => $alias) { $lock['aliases'][] = array( 'alias' => $alias['alias'], 'alias_normalized' => $alias['alias_normalized'], 'version' => $version, 'package' => $package, ); } } $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages); } $lock['platform'] = $platformReqs; $lock['platform-dev'] = $platformDevReqs; if ($platformOverrides) { $lock['platform-overrides'] = $platformOverrides; } if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) { if ($this->lockFile->exists()) { unlink($this->lockFile->getPath()); } return false; } if (!$this->isLocked() || $lock !== $this->getLockData()) { $this->lockFile->write($lock); $this->lockDataCache = null; return true; } return false; }
[ "public", "function", "setLockData", "(", "array", "$", "packages", ",", "$", "devPackages", ",", "array", "$", "platformReqs", ",", "$", "platformDevReqs", ",", "array", "$", "aliases", ",", "$", "minimumStability", ",", "array", "$", "stabilityFlags", ",", "$", "preferStable", ",", "$", "preferLowest", ",", "array", "$", "platformOverrides", ")", "{", "$", "lock", "=", "array", "(", "'_readme'", "=>", "array", "(", "'This file locks the dependencies of your project to a known state'", ",", "'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file'", ",", "'This file is @gener'", ".", "'ated automatically'", ")", ",", "'hash'", "=>", "$", "this", "->", "hash", ",", "'packages'", "=>", "null", ",", "'packages-dev'", "=>", "null", ",", "'aliases'", "=>", "array", "(", ")", ",", "'minimum-stability'", "=>", "$", "minimumStability", ",", "'stability-flags'", "=>", "$", "stabilityFlags", ",", "'prefer-stable'", "=>", "$", "preferStable", ",", "'prefer-lowest'", "=>", "$", "preferLowest", ",", ")", ";", "foreach", "(", "$", "aliases", "as", "$", "package", "=>", "$", "versions", ")", "{", "foreach", "(", "$", "versions", "as", "$", "version", "=>", "$", "alias", ")", "{", "$", "lock", "[", "'aliases'", "]", "[", "]", "=", "array", "(", "'alias'", "=>", "$", "alias", "[", "'alias'", "]", ",", "'alias_normalized'", "=>", "$", "alias", "[", "'alias_normalized'", "]", ",", "'version'", "=>", "$", "version", ",", "'package'", "=>", "$", "package", ",", ")", ";", "}", "}", "$", "lock", "[", "'packages'", "]", "=", "$", "this", "->", "lockPackages", "(", "$", "packages", ")", ";", "if", "(", "null", "!==", "$", "devPackages", ")", "{", "$", "lock", "[", "'packages-dev'", "]", "=", "$", "this", "->", "lockPackages", "(", "$", "devPackages", ")", ";", "}", "$", "lock", "[", "'platform'", "]", "=", "$", "platformReqs", ";", "$", "lock", "[", "'platform-dev'", "]", "=", "$", "platformDevReqs", ";", "if", "(", "$", "platformOverrides", ")", "{", "$", "lock", "[", "'platform-overrides'", "]", "=", "$", "platformOverrides", ";", "}", "if", "(", "empty", "(", "$", "lock", "[", "'packages'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'packages-dev'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'platform'", "]", ")", "&&", "empty", "(", "$", "lock", "[", "'platform-dev'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "lockFile", "->", "exists", "(", ")", ")", "{", "unlink", "(", "$", "this", "->", "lockFile", "->", "getPath", "(", ")", ")", ";", "}", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "isLocked", "(", ")", "||", "$", "lock", "!==", "$", "this", "->", "getLockData", "(", ")", ")", "{", "$", "this", "->", "lockFile", "->", "write", "(", "$", "lock", ")", ";", "$", "this", "->", "lockDataCache", "=", "null", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Locks provided data into lockfile. @param array $packages array of packages @param mixed $devPackages array of dev packages or null if installed without --dev @param array $platformReqs array of package name => constraint for required platform packages @param mixed $platformDevReqs array of package name => constraint for dev-required platform packages @param array $aliases array of aliases @param string $minimumStability @param array $stabilityFlags @param bool $preferStable @param bool $preferLowest @param array $platformOverrides @return bool
[ "Locks", "provided", "data", "into", "lockfile", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Locker.php#L237-L291
23,553
crysalead/storage-stream
src/Stream.php
Stream._initResource
protected function _initResource($config) { if (!empty($config['data']) && !empty($config['filename'])) { throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined."); } if ($config['filename']) { $this->_filename = $config['filename']; if ($this->_filename === 'php://input') { $this->_mode = 'r'; } $this->_resource = fopen($this->_filename, $this->_mode); return; } if (is_resource($config['data'])) { $this->_resource = $config['data']; return; } elseif (is_scalar($config['data'])) { $this->_resource = fopen('php://temp', 'r+'); fwrite($this->_resource, (string) $config['data']); rewind($this->_resource); } }
php
protected function _initResource($config) { if (!empty($config['data']) && !empty($config['filename'])) { throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined."); } if ($config['filename']) { $this->_filename = $config['filename']; if ($this->_filename === 'php://input') { $this->_mode = 'r'; } $this->_resource = fopen($this->_filename, $this->_mode); return; } if (is_resource($config['data'])) { $this->_resource = $config['data']; return; } elseif (is_scalar($config['data'])) { $this->_resource = fopen('php://temp', 'r+'); fwrite($this->_resource, (string) $config['data']); rewind($this->_resource); } }
[ "protected", "function", "_initResource", "(", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'data'", "]", ")", "&&", "!", "empty", "(", "$", "config", "[", "'filename'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"The `'data'` or `'filename'` option must be defined.\"", ")", ";", "}", "if", "(", "$", "config", "[", "'filename'", "]", ")", "{", "$", "this", "->", "_filename", "=", "$", "config", "[", "'filename'", "]", ";", "if", "(", "$", "this", "->", "_filename", "===", "'php://input'", ")", "{", "$", "this", "->", "_mode", "=", "'r'", ";", "}", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "return", ";", "}", "if", "(", "is_resource", "(", "$", "config", "[", "'data'", "]", ")", ")", "{", "$", "this", "->", "_resource", "=", "$", "config", "[", "'data'", "]", ";", "return", ";", "}", "elseif", "(", "is_scalar", "(", "$", "config", "[", "'data'", "]", ")", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "'php://temp'", ",", "'r+'", ")", ";", "fwrite", "(", "$", "this", "->", "_resource", ",", "(", "string", ")", "$", "config", "[", "'data'", "]", ")", ";", "rewind", "(", "$", "this", "->", "_resource", ")", ";", "}", "}" ]
Init the stream resource. @param array $config The constructor configuration array.
[ "Init", "the", "stream", "resource", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L140-L161
23,554
crysalead/storage-stream
src/Stream.php
Stream.length
public function length() { if ($this->_limit !== null) { return $this->_limit; } if ($this->_length !== null) { return $this->_length; } if ($this->isSeekable()) { $old = $this->tell(); $begin = $this->rewind(); $end = $this->end(); $this->seek($old); return $end - $begin; } }
php
public function length() { if ($this->_limit !== null) { return $this->_limit; } if ($this->_length !== null) { return $this->_length; } if ($this->isSeekable()) { $old = $this->tell(); $begin = $this->rewind(); $end = $this->end(); $this->seek($old); return $end - $begin; } }
[ "public", "function", "length", "(", ")", "{", "if", "(", "$", "this", "->", "_limit", "!==", "null", ")", "{", "return", "$", "this", "->", "_limit", ";", "}", "if", "(", "$", "this", "->", "_length", "!==", "null", ")", "{", "return", "$", "this", "->", "_length", ";", "}", "if", "(", "$", "this", "->", "isSeekable", "(", ")", ")", "{", "$", "old", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "begin", "=", "$", "this", "->", "rewind", "(", ")", ";", "$", "end", "=", "$", "this", "->", "end", "(", ")", ";", "$", "this", "->", "seek", "(", "$", "old", ")", ";", "return", "$", "end", "-", "$", "begin", ";", "}", "}" ]
Get the stream range length.
[ "Get", "the", "stream", "range", "length", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L213-L230
23,555
crysalead/storage-stream
src/Stream.php
Stream.meta
public function meta($key = null) { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } if (!$this->valid()) { throw new RuntimeException('Invalid resource.'); } $meta = stream_get_meta_data($this->_resource); if ($key) { return isset($meta[$key]) ? $meta[$key] : null; } return $meta; }
php
public function meta($key = null) { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } if (!$this->valid()) { throw new RuntimeException('Invalid resource.'); } $meta = stream_get_meta_data($this->_resource); if ($key) { return isset($meta[$key]) ? $meta[$key] : null; } return $meta; }
[ "public", "function", "meta", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "this", "->", "_resource", "===", "null", "&&", "$", "this", "->", "_filename", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "}", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Invalid resource.'", ")", ";", "}", "$", "meta", "=", "stream_get_meta_data", "(", "$", "this", "->", "_resource", ")", ";", "if", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "meta", "[", "$", "key", "]", ")", "?", "$", "meta", "[", "$", "key", "]", ":", "null", ";", "}", "return", "$", "meta", ";", "}" ]
Get stream meta data. @param string $key A specific meta data or `null` to get all meta data. Possibles values are: `'uri'` _string_ : the URI/filename associated with this stream. `'mode'` _string_ : the type of access required for this stream. `'wrapper_type'` _string_ : the protocol wrapper implementation layered over the stream. `'stream_type'` _string_ : the underlying implementation of the stream. `'unread_bytes'` _integer_: the number of bytes contained in the PHP's own internal buffer. `'seekable'` _boolean_: `true` means the current stream can be seeked. `'eof'` _boolean_: `true` means the stream has reached end-of-file. `'blocked'` _boolean_: `true` means the stream is in blocking IO mode. `'timed_out'` _boolean_: `true` means stream timed out on the last read call. @return mixed
[ "Get", "stream", "meta", "data", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L309-L323
23,556
crysalead/storage-stream
src/Stream.php
Stream._ensureReadable
protected function _ensureReadable($bytePerByte = true) { if (!$this->valid()) { throw new RuntimeException('Cannot read from a closed stream.'); } if (!$this->isReadable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot read on a non-readable stream (mode is `'{$mode}'`)."); } }
php
protected function _ensureReadable($bytePerByte = true) { if (!$this->valid()) { throw new RuntimeException('Cannot read from a closed stream.'); } if (!$this->isReadable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot read on a non-readable stream (mode is `'{$mode}'`)."); } }
[ "protected", "function", "_ensureReadable", "(", "$", "bytePerByte", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Cannot read from a closed stream.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isReadable", "(", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "meta", "(", "'mode'", ")", ";", "throw", "new", "RuntimeException", "(", "\"Cannot read on a non-readable stream (mode is `'{$mode}'`).\"", ")", ";", "}", "}" ]
Throw an exception if a stream is not readable. @param boolean $bytePerByte Check if the stream is readable byte per byte.
[ "Throw", "an", "exception", "if", "a", "stream", "is", "not", "readable", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L351-L360
23,557
crysalead/storage-stream
src/Stream.php
Stream._ensureWritable
protected function _ensureWritable() { if (!$this->valid()) { throw new RuntimeException('Cannot write on a closed stream.'); } if (!$this->isWritable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot write on a non-writable stream (mode is `'{$mode}'`)."); } }
php
protected function _ensureWritable() { if (!$this->valid()) { throw new RuntimeException('Cannot write on a closed stream.'); } if (!$this->isWritable()) { $mode = $this->meta('mode'); throw new RuntimeException("Cannot write on a non-writable stream (mode is `'{$mode}'`)."); } }
[ "protected", "function", "_ensureWritable", "(", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Cannot write on a closed stream.'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isWritable", "(", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "meta", "(", "'mode'", ")", ";", "throw", "new", "RuntimeException", "(", "\"Cannot write on a non-writable stream (mode is `'{$mode}'`).\"", ")", ";", "}", "}" ]
Throw an exception if a stream is not writable.
[ "Throw", "an", "exception", "if", "a", "stream", "is", "not", "writable", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L376-L385
23,558
crysalead/storage-stream
src/Stream.php
Stream._bufferSize
protected function _bufferSize($length) { if ($this->_limit !== null) { $position = $this->tell(); $max = $this->_start + $this->_limit; $length = $max - $position; } if ($length === null) { $length = $this->_bufferSize; } return $length; }
php
protected function _bufferSize($length) { if ($this->_limit !== null) { $position = $this->tell(); $max = $this->_start + $this->_limit; $length = $max - $position; } if ($length === null) { $length = $this->_bufferSize; } return $length; }
[ "protected", "function", "_bufferSize", "(", "$", "length", ")", "{", "if", "(", "$", "this", "->", "_limit", "!==", "null", ")", "{", "$", "position", "=", "$", "this", "->", "tell", "(", ")", ";", "$", "max", "=", "$", "this", "->", "_start", "+", "$", "this", "->", "_limit", ";", "$", "length", "=", "$", "max", "-", "$", "position", ";", "}", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "$", "this", "->", "_bufferSize", ";", "}", "return", "$", "length", ";", "}" ]
Determine the buffer size to read. @param integer $length Maximum number of bytes to read (default to buffer size). @return integer The allowed size.
[ "Determine", "the", "buffer", "size", "to", "read", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L448-L459
23,559
crysalead/storage-stream
src/Stream.php
Stream.pipe
public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }
php
public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }
[ "public", "function", "pipe", "(", "$", "stream", ")", "{", "$", "offset", "=", "$", "stream", "->", "tell", "(", ")", ";", "$", "result", "=", "stream_copy_to_stream", "(", "$", "this", "->", "resource", "(", ")", ",", "$", "stream", "->", "resource", "(", ")", ")", ";", "if", "(", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "$", "stream", "->", "seek", "(", "$", "offset", ")", ";", "}", "return", "$", "result", ";", "}" ]
Read the content of this stream and write it to another stream. @param instance $stream The destination stream to write to @return integer The number of copied bytes
[ "Read", "the", "content", "of", "this", "stream", "and", "write", "it", "to", "another", "stream", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L539-L547
23,560
crysalead/storage-stream
src/Stream.php
Stream.seek
public function seek($offset, $whence = SEEK_SET) { if ($this->_filename === 'php://input' && $this->eof() && !$offset && $whence === SEEK_SET) { $this->close(); $this->_resource = fopen($this->_filename, 'r'); } $this->_ensureSeekable(); fseek($this->_resource, $offset, $whence); return ftell($this->_resource); }
php
public function seek($offset, $whence = SEEK_SET) { if ($this->_filename === 'php://input' && $this->eof() && !$offset && $whence === SEEK_SET) { $this->close(); $this->_resource = fopen($this->_filename, 'r'); } $this->_ensureSeekable(); fseek($this->_resource, $offset, $whence); return ftell($this->_resource); }
[ "public", "function", "seek", "(", "$", "offset", ",", "$", "whence", "=", "SEEK_SET", ")", "{", "if", "(", "$", "this", "->", "_filename", "===", "'php://input'", "&&", "$", "this", "->", "eof", "(", ")", "&&", "!", "$", "offset", "&&", "$", "whence", "===", "SEEK_SET", ")", "{", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "'r'", ")", ";", "}", "$", "this", "->", "_ensureSeekable", "(", ")", ";", "fseek", "(", "$", "this", "->", "_resource", ",", "$", "offset", ",", "$", "whence", ")", ";", "return", "ftell", "(", "$", "this", "->", "_resource", ")", ";", "}" ]
Seek on the stream. @param integer $offset The offset. @param integer $whence Accepted values are: - SEEK_SET - Set position equal to $offset bytes. - SEEK_CUR - Set position to current location plus $offset. - SEEK_END - Set position to end-of-file plus $offset.
[ "Seek", "on", "the", "stream", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L598-L607
23,561
crysalead/storage-stream
src/Stream.php
Stream.valid
public function valid() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return !!$this->_resource && is_resource($this->_resource); }
php
public function valid() { if ($this->_resource === null && $this->_filename) { $this->_resource = fopen($this->_filename, $this->_mode); } return !!$this->_resource && is_resource($this->_resource); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "$", "this", "->", "_resource", "===", "null", "&&", "$", "this", "->", "_filename", ")", "{", "$", "this", "->", "_resource", "=", "fopen", "(", "$", "this", "->", "_filename", ",", "$", "this", "->", "_mode", ")", ";", "}", "return", "!", "!", "$", "this", "->", "_resource", "&&", "is_resource", "(", "$", "this", "->", "_resource", ")", ";", "}" ]
Check if the stream is valid. @return Boolean
[ "Check", "if", "the", "stream", "is", "valid", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L648-L654
23,562
crysalead/storage-stream
src/Stream.php
Stream.getMime
public static function getMime($stream, $mime) { if (is_string($mime)) { return $mime; } if (!$mime || !$stream->isSeekable() || !$stream->isReadable()) { return; } $finfo = finfo_open(FILEINFO_MIME_TYPE); $old = $stream->tell(); $stream->rewind(); $end = $stream->end(); $size = min($end - 0, 4); if ($size === 0) { return; } $stream->seek($size, SEEK_SET); $signature = $stream->read($size, false); $size = min($end - 0, 1024); $stream->rewind(); $signature = $stream->read($size, false) . $signature; $stream->seek($old, SEEK_SET); return finfo_buffer($finfo, $signature); }
php
public static function getMime($stream, $mime) { if (is_string($mime)) { return $mime; } if (!$mime || !$stream->isSeekable() || !$stream->isReadable()) { return; } $finfo = finfo_open(FILEINFO_MIME_TYPE); $old = $stream->tell(); $stream->rewind(); $end = $stream->end(); $size = min($end - 0, 4); if ($size === 0) { return; } $stream->seek($size, SEEK_SET); $signature = $stream->read($size, false); $size = min($end - 0, 1024); $stream->rewind(); $signature = $stream->read($size, false) . $signature; $stream->seek($old, SEEK_SET); return finfo_buffer($finfo, $signature); }
[ "public", "static", "function", "getMime", "(", "$", "stream", ",", "$", "mime", ")", "{", "if", "(", "is_string", "(", "$", "mime", ")", ")", "{", "return", "$", "mime", ";", "}", "if", "(", "!", "$", "mime", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", "||", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "return", ";", "}", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "old", "=", "$", "stream", "->", "tell", "(", ")", ";", "$", "stream", "->", "rewind", "(", ")", ";", "$", "end", "=", "$", "stream", "->", "end", "(", ")", ";", "$", "size", "=", "min", "(", "$", "end", "-", "0", ",", "4", ")", ";", "if", "(", "$", "size", "===", "0", ")", "{", "return", ";", "}", "$", "stream", "->", "seek", "(", "$", "size", ",", "SEEK_SET", ")", ";", "$", "signature", "=", "$", "stream", "->", "read", "(", "$", "size", ",", "false", ")", ";", "$", "size", "=", "min", "(", "$", "end", "-", "0", ",", "1024", ")", ";", "$", "stream", "->", "rewind", "(", ")", ";", "$", "signature", "=", "$", "stream", "->", "read", "(", "$", "size", ",", "false", ")", ".", "$", "signature", ";", "$", "stream", "->", "seek", "(", "$", "old", ",", "SEEK_SET", ")", ";", "return", "finfo_buffer", "(", "$", "finfo", ",", "$", "signature", ")", ";", "}" ]
Mime detector. Concat the first 1024 bytes + the last 4 bytes of readable & seekable streams to detext the mime info. @param string $stream The stream to extract mime value from. @param string $mime The mime type detection. Possible values are: -`true` : auto detect the mime. - a string : don't detect the mime and use the passed string instead. -`false` : don't detect the mime. @return string The detected mime.
[ "Mime", "detector", ".", "Concat", "the", "first", "1024", "bytes", "+", "the", "last", "4", "bytes", "of", "readable", "&", "seekable", "streams", "to", "detext", "the", "mime", "info", "." ]
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/Stream.php#L750-L778
23,563
silvercommerce/geozones
src/Model/Zone.php
Zone.getCountriesArray
public function getCountriesArray() { $return = json_decode($this->Country); if (empty($return) && isset($this->Country)) { $return = [$this->Country]; } return $return; }
php
public function getCountriesArray() { $return = json_decode($this->Country); if (empty($return) && isset($this->Country)) { $return = [$this->Country]; } return $return; }
[ "public", "function", "getCountriesArray", "(", ")", "{", "$", "return", "=", "json_decode", "(", "$", "this", "->", "Country", ")", ";", "if", "(", "empty", "(", "$", "return", ")", "&&", "isset", "(", "$", "this", "->", "Country", ")", ")", "{", "$", "return", "=", "[", "$", "this", "->", "Country", "]", ";", "}", "return", "$", "return", ";", "}" ]
Return an array of all associated countries @return array
[ "Return", "an", "array", "of", "all", "associated", "countries" ]
85af587805ae5cc6dce6a890ca04b338cf5552cb
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Model/Zone.php#L71-L80
23,564
ekuiter/feature-php
FeaturePhp/Generator/ChunkGenerator.php
ChunkGenerator.getSpecification
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\ChunkSpecification::fromArrayAndSettings($file, $settings); }
php
protected function getSpecification($file, $settings, $artifact) { return fphp\Specification\ChunkSpecification::fromArrayAndSettings($file, $settings); }
[ "protected", "function", "getSpecification", "(", "$", "file", ",", "$", "settings", ",", "$", "artifact", ")", "{", "return", "fphp", "\\", "Specification", "\\", "ChunkSpecification", "::", "fromArrayAndSettings", "(", "$", "file", ",", "$", "settings", ")", ";", "}" ]
Returns a chunk specification from a plain settings array. @param array $file a plain settings array @param Settings $settings the generator's settings @param \FeaturePhp\Artifact\Artifact $artifact the currently processed artifact @return \FeaturePhp\Specification\ChunkSpecification
[ "Returns", "a", "chunk", "specification", "from", "a", "plain", "settings", "array", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/ChunkGenerator.php#L33-L35
23,565
zhouyl/mellivora
Mellivora/Database/Query/Grammars/MySqlGrammar.php
MySqlGrammar.compileJsonUpdateColumn
protected function compileJsonUpdateColumn($key, JsonExpression $value) { $path = explode('->', $key); $field = $this->wrapValue(array_shift($path)); $accessor = '"$.' . implode('.', $path) . '"'; return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})"; }
php
protected function compileJsonUpdateColumn($key, JsonExpression $value) { $path = explode('->', $key); $field = $this->wrapValue(array_shift($path)); $accessor = '"$.' . implode('.', $path) . '"'; return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})"; }
[ "protected", "function", "compileJsonUpdateColumn", "(", "$", "key", ",", "JsonExpression", "$", "value", ")", "{", "$", "path", "=", "explode", "(", "'->'", ",", "$", "key", ")", ";", "$", "field", "=", "$", "this", "->", "wrapValue", "(", "array_shift", "(", "$", "path", ")", ")", ";", "$", "accessor", "=", "'\"$.'", ".", "implode", "(", "'.'", ",", "$", "path", ")", ".", "'\"'", ";", "return", "\"{$field} = json_set({$field}, {$accessor}, {$value->getValue()})\"", ";", "}" ]
Prepares a JSON column being updated using the JSON_SET function. @param string $key @param \Mellivora\Database\Query\JsonExpression $value @return string
[ "Prepares", "a", "JSON", "column", "being", "updated", "using", "the", "JSON_SET", "function", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/MySqlGrammar.php#L167-L176
23,566
mothership-ec/composer
src/Composer/Package/Archiver/GitExcludeFilter.php
GitExcludeFilter.parseGitAttributesLine
public function parseGitAttributesLine($line) { $parts = preg_split('#\s+#', $line); if (count($parts) != 2) { return null; } if ($parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } }
php
public function parseGitAttributesLine($line) { $parts = preg_split('#\s+#', $line); if (count($parts) != 2) { return null; } if ($parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } }
[ "public", "function", "parseGitAttributesLine", "(", "$", "line", ")", "{", "$", "parts", "=", "preg_split", "(", "'#\\s+#'", ",", "$", "line", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "!=", "2", ")", "{", "return", "null", ";", "}", "if", "(", "$", "parts", "[", "1", "]", "===", "'export-ignore'", ")", "{", "return", "$", "this", "->", "generatePattern", "(", "$", "parts", "[", "0", "]", ")", ";", "}", "}" ]
Callback parser which finds export-ignore rules in git attribute lines @param string $line A line from .gitattributes @return array An exclude pattern for filter()
[ "Callback", "parser", "which", "finds", "export", "-", "ignore", "rules", "in", "git", "attribute", "lines" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Archiver/GitExcludeFilter.php#L68-L79
23,567
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php
ezcMailFileSet.hasData
public function hasData() { if ( count( $this->files ) >= 1 ) { if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 ) { return true; } } return false; }
php
public function hasData() { if ( count( $this->files ) >= 1 ) { if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 ) { return true; } } return false; }
[ "public", "function", "hasData", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "files", ")", ">=", "1", ")", "{", "if", "(", "$", "this", "->", "files", "[", "0", "]", "===", "'php://stdin'", "||", "filesize", "(", "$", "this", "->", "files", "[", "0", "]", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether the file set contains files @return bool
[ "Returns", "whether", "the", "file", "set", "contains", "files" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L90-L100
23,568
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php
ezcMailFileSet.openFile
private function openFile( $isFirst = false ) { // cleanup file pointer if needed if ( $this->fp != null ) { fclose( $this->fp ); $this->fp = null; } // open the new file $file = $isFirst ? current( $this->files ) : next( $this->files ); // loop until we can open a file. while ( $this->fp == null && $file !== false ) { if ( $file === 'php://stdin' || file_exists( $file ) ) { $fp = fopen( $file, 'r' ); if ( $fp !== false ) { $this->fp = $fp; return true; } } $file = next( $this->files ); } return false; }
php
private function openFile( $isFirst = false ) { // cleanup file pointer if needed if ( $this->fp != null ) { fclose( $this->fp ); $this->fp = null; } // open the new file $file = $isFirst ? current( $this->files ) : next( $this->files ); // loop until we can open a file. while ( $this->fp == null && $file !== false ) { if ( $file === 'php://stdin' || file_exists( $file ) ) { $fp = fopen( $file, 'r' ); if ( $fp !== false ) { $this->fp = $fp; return true; } } $file = next( $this->files ); } return false; }
[ "private", "function", "openFile", "(", "$", "isFirst", "=", "false", ")", "{", "// cleanup file pointer if needed", "if", "(", "$", "this", "->", "fp", "!=", "null", ")", "{", "fclose", "(", "$", "this", "->", "fp", ")", ";", "$", "this", "->", "fp", "=", "null", ";", "}", "// open the new file", "$", "file", "=", "$", "isFirst", "?", "current", "(", "$", "this", "->", "files", ")", ":", "next", "(", "$", "this", "->", "files", ")", ";", "// loop until we can open a file.", "while", "(", "$", "this", "->", "fp", "==", "null", "&&", "$", "file", "!==", "false", ")", "{", "if", "(", "$", "file", "===", "'php://stdin'", "||", "file_exists", "(", "$", "file", ")", ")", "{", "$", "fp", "=", "fopen", "(", "$", "file", ",", "'r'", ")", ";", "if", "(", "$", "fp", "!==", "false", ")", "{", "$", "this", "->", "fp", "=", "$", "fp", ";", "return", "true", ";", "}", "}", "$", "file", "=", "next", "(", "$", "this", "->", "files", ")", ";", "}", "return", "false", ";", "}" ]
Opens the next file in the set and returns true on success. @param bool $isFirst @return bool
[ "Opens", "the", "next", "file", "in", "the", "set", "and", "returns", "true", "on", "success", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L159-L186
23,569
joni-jones/yii2-heroku-logger
HerokuTarget.php
HerokuTarget.export
public function export() { $messages = implode("\n", array_map([$this, 'formatMessage'], $this->messages))."\n"; $stdout = fopen('php://stdout', 'w'); if ($stdout === false) { throw new InvalidConfigException('Unable to open stdout stream'); } fwrite($stdout, $messages); fclose($stdout); }
php
public function export() { $messages = implode("\n", array_map([$this, 'formatMessage'], $this->messages))."\n"; $stdout = fopen('php://stdout', 'w'); if ($stdout === false) { throw new InvalidConfigException('Unable to open stdout stream'); } fwrite($stdout, $messages); fclose($stdout); }
[ "public", "function", "export", "(", ")", "{", "$", "messages", "=", "implode", "(", "\"\\n\"", ",", "array_map", "(", "[", "$", "this", ",", "'formatMessage'", "]", ",", "$", "this", "->", "messages", ")", ")", ".", "\"\\n\"", ";", "$", "stdout", "=", "fopen", "(", "'php://stdout'", ",", "'w'", ")", ";", "if", "(", "$", "stdout", "===", "false", ")", "{", "throw", "new", "InvalidConfigException", "(", "'Unable to open stdout stream'", ")", ";", "}", "fwrite", "(", "$", "stdout", ",", "$", "messages", ")", ";", "fclose", "(", "$", "stdout", ")", ";", "}" ]
Write yii logs to stdout @access public @return void
[ "Write", "yii", "logs", "to", "stdout" ]
0a648cdd52941caae49c0e54ae65b8a7fc6b2db9
https://github.com/joni-jones/yii2-heroku-logger/blob/0a648cdd52941caae49c0e54ae65b8a7fc6b2db9/HerokuTarget.php#L15-L24
23,570
zicht/z
src/Zicht/Tool/Debug.php
Debug.enterScope
public static function enterScope($scope) { if (!is_scalar($scope)) { throw new \InvalidArgumentException("Only scalars allowed as scope identifiers"); } array_push(self::$scope, $scope); list($call) = debug_backtrace(0); array_push(self::$scopeChange, $call); }
php
public static function enterScope($scope) { if (!is_scalar($scope)) { throw new \InvalidArgumentException("Only scalars allowed as scope identifiers"); } array_push(self::$scope, $scope); list($call) = debug_backtrace(0); array_push(self::$scopeChange, $call); }
[ "public", "static", "function", "enterScope", "(", "$", "scope", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "scope", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Only scalars allowed as scope identifiers\"", ")", ";", "}", "array_push", "(", "self", "::", "$", "scope", ",", "$", "scope", ")", ";", "list", "(", "$", "call", ")", "=", "debug_backtrace", "(", "0", ")", ";", "array_push", "(", "self", "::", "$", "scopeChange", ",", "$", "call", ")", ";", "}" ]
Keeps track of scope @param string $scope @return void
[ "Keeps", "track", "of", "scope" ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Debug.php#L31-L39
23,571
fdisotto/cac-api
src/fdisotto/CACApi.php
CACApi._make_power_operation
private function _make_power_operation($sid, $action) { $data = $this->_data; $data['sid'] = $sid; $data['action'] = $action; try { return $this->_make_request(self::POWER_OP_URL, $data, 'POST'); } catch (\Exception $e) { throw new \Exception('Something gone wrong', 0, $e); } return true; }
php
private function _make_power_operation($sid, $action) { $data = $this->_data; $data['sid'] = $sid; $data['action'] = $action; try { return $this->_make_request(self::POWER_OP_URL, $data, 'POST'); } catch (\Exception $e) { throw new \Exception('Something gone wrong', 0, $e); } return true; }
[ "private", "function", "_make_power_operation", "(", "$", "sid", ",", "$", "action", ")", "{", "$", "data", "=", "$", "this", "->", "_data", ";", "$", "data", "[", "'sid'", "]", "=", "$", "sid", ";", "$", "data", "[", "'action'", "]", "=", "$", "action", ";", "try", "{", "return", "$", "this", "->", "_make_request", "(", "self", "::", "POWER_OP_URL", ",", "$", "data", ",", "'POST'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "'Something gone wrong'", ",", "0", ",", "$", "e", ")", ";", "}", "return", "true", ";", "}" ]
Perform the power operation on the server @param int $sid Server ID @param string $action poweron, poweroff, reset request @return bool
[ "Perform", "the", "power", "operation", "on", "the", "server" ]
c5c7fce1a00dd35584d5ce7e78a41d54188163cc
https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L304-L317
23,572
mothership-ec/composer
src/Composer/Util/StreamContextFactory.php
StreamContextFactory.fixHttpHeaderField
private static function fixHttpHeaderField($header) { if (!is_array($header)) { $header = explode("\r\n", $header); } uasort($header, function ($el) { return preg_match('{^content-type}i', $el) ? 1 : -1; }); return $header; }
php
private static function fixHttpHeaderField($header) { if (!is_array($header)) { $header = explode("\r\n", $header); } uasort($header, function ($el) { return preg_match('{^content-type}i', $el) ? 1 : -1; }); return $header; }
[ "private", "static", "function", "fixHttpHeaderField", "(", "$", "header", ")", "{", "if", "(", "!", "is_array", "(", "$", "header", ")", ")", "{", "$", "header", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "header", ")", ";", "}", "uasort", "(", "$", "header", ",", "function", "(", "$", "el", ")", "{", "return", "preg_match", "(", "'{^content-type}i'", ",", "$", "el", ")", "?", "1", ":", "-", "1", ";", "}", ")", ";", "return", "$", "header", ";", "}" ]
A bug in PHP prevents the headers from correctly being sent when a content-type header is present and NOT at the end of the array This method fixes the array by moving the content-type header to the end @link https://bugs.php.net/bug.php?id=61548 @param $header @return array
[ "A", "bug", "in", "PHP", "prevents", "the", "headers", "from", "correctly", "being", "sent", "when", "a", "content", "-", "type", "header", "is", "present", "and", "NOT", "at", "the", "end", "of", "the", "array" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Util/StreamContextFactory.php#L143-L153
23,573
nabab/bbn
src/bbn/appui/tasks.php
tasks.stop_track
public function stop_track($id_task, $message = false, $id_user = false){ $ok = false; $now = time(); if ( ($active_track = $this->get_active_track($id_user)) && ($active_track['id_task'] === $id_task) ){ $ok = true; if ( !empty($message) && !($id_note = $this->comment($id_task, [ 'title' => _('Report tracker').' '.date('d M Y H:i', strtotime($active_track['start'])).' - '.date('d M Y H:i', $now), 'text' => $message ])) ){ $ok = false; } if ( $ok ){ $ok = $this->db->update('bbn_tasks_sessions', [ 'length' => $now - strtotime($active_track['start']), 'id_note' => $id_note ?: NULL ], [ 'id' => $active_track['id'] ]); } } return (bool)$ok; }
php
public function stop_track($id_task, $message = false, $id_user = false){ $ok = false; $now = time(); if ( ($active_track = $this->get_active_track($id_user)) && ($active_track['id_task'] === $id_task) ){ $ok = true; if ( !empty($message) && !($id_note = $this->comment($id_task, [ 'title' => _('Report tracker').' '.date('d M Y H:i', strtotime($active_track['start'])).' - '.date('d M Y H:i', $now), 'text' => $message ])) ){ $ok = false; } if ( $ok ){ $ok = $this->db->update('bbn_tasks_sessions', [ 'length' => $now - strtotime($active_track['start']), 'id_note' => $id_note ?: NULL ], [ 'id' => $active_track['id'] ]); } } return (bool)$ok; }
[ "public", "function", "stop_track", "(", "$", "id_task", ",", "$", "message", "=", "false", ",", "$", "id_user", "=", "false", ")", "{", "$", "ok", "=", "false", ";", "$", "now", "=", "time", "(", ")", ";", "if", "(", "(", "$", "active_track", "=", "$", "this", "->", "get_active_track", "(", "$", "id_user", ")", ")", "&&", "(", "$", "active_track", "[", "'id_task'", "]", "===", "$", "id_task", ")", ")", "{", "$", "ok", "=", "true", ";", "if", "(", "!", "empty", "(", "$", "message", ")", "&&", "!", "(", "$", "id_note", "=", "$", "this", "->", "comment", "(", "$", "id_task", ",", "[", "'title'", "=>", "_", "(", "'Report tracker'", ")", ".", "' '", ".", "date", "(", "'d M Y H:i'", ",", "strtotime", "(", "$", "active_track", "[", "'start'", "]", ")", ")", ".", "' - '", ".", "date", "(", "'d M Y H:i'", ",", "$", "now", ")", ",", "'text'", "=>", "$", "message", "]", ")", ")", ")", "{", "$", "ok", "=", "false", ";", "}", "if", "(", "$", "ok", ")", "{", "$", "ok", "=", "$", "this", "->", "db", "->", "update", "(", "'bbn_tasks_sessions'", ",", "[", "'length'", "=>", "$", "now", "-", "strtotime", "(", "$", "active_track", "[", "'start'", "]", ")", ",", "'id_note'", "=>", "$", "id_note", "?", ":", "NULL", "]", ",", "[", "'id'", "=>", "$", "active_track", "[", "'id'", "]", "]", ")", ";", "}", "}", "return", "(", "bool", ")", "$", "ok", ";", "}" ]
Stops a track. @param string $id_task The task's ID @param boolean|string $message The message to attach to track (optional) @param boolean|string $id_user The track's user. If you give 'false', it will use the current user @return boolean
[ "Stops", "a", "track", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/tasks.php#L1113-L1140
23,574
oroinc/OroLayoutComponent
HierarchyCollection.php
HierarchyCollection.getRootId
public function getRootId() { if (empty($this->hierarchy)) { throw new Exception\LogicException('The root item does not exist.'); } reset($this->hierarchy); $id = key($this->hierarchy); return $id; }
php
public function getRootId() { if (empty($this->hierarchy)) { throw new Exception\LogicException('The root item does not exist.'); } reset($this->hierarchy); $id = key($this->hierarchy); return $id; }
[ "public", "function", "getRootId", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "hierarchy", ")", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'The root item does not exist.'", ")", ";", "}", "reset", "(", "$", "this", "->", "hierarchy", ")", ";", "$", "id", "=", "key", "(", "$", "this", "->", "hierarchy", ")", ";", "return", "$", "id", ";", "}" ]
Returns the identifier of the root item @return string @throws Exception\LogicException if the root item does not exist
[ "Returns", "the", "identifier", "of", "the", "root", "item" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L41-L51
23,575
oroinc/OroLayoutComponent
HierarchyCollection.php
HierarchyCollection.get
public function get(array $path) { $current = &$this->hierarchy; foreach ($path as $childId) { if (!isset($current[$childId])) { return []; } $current = &$current[$childId]; } return $current; }
php
public function get(array $path) { $current = &$this->hierarchy; foreach ($path as $childId) { if (!isset($current[$childId])) { return []; } $current = &$current[$childId]; } return $current; }
[ "public", "function", "get", "(", "array", "$", "path", ")", "{", "$", "current", "=", "&", "$", "this", "->", "hierarchy", ";", "foreach", "(", "$", "path", "as", "$", "childId", ")", "{", "if", "(", "!", "isset", "(", "$", "current", "[", "$", "childId", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "current", "=", "&", "$", "current", "[", "$", "childId", "]", ";", "}", "return", "$", "current", ";", "}" ]
Gets hierarchy by the path @param string[] $path @return array
[ "Gets", "hierarchy", "by", "the", "path" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L60-L71
23,576
oroinc/OroLayoutComponent
HierarchyCollection.php
HierarchyCollection.remove
public function remove(array $path) { $current = &$this->hierarchy; $pathLength = count($path); for ($i = 0; $i < $pathLength; $i++) { if (!isset($current[$path[$i]])) { break; } if ($i === $pathLength - 1) { unset($current[$path[$i]]); break; } $current = &$current[$path[$i]]; } }
php
public function remove(array $path) { $current = &$this->hierarchy; $pathLength = count($path); for ($i = 0; $i < $pathLength; $i++) { if (!isset($current[$path[$i]])) { break; } if ($i === $pathLength - 1) { unset($current[$path[$i]]); break; } $current = &$current[$path[$i]]; } }
[ "public", "function", "remove", "(", "array", "$", "path", ")", "{", "$", "current", "=", "&", "$", "this", "->", "hierarchy", ";", "$", "pathLength", "=", "count", "(", "$", "path", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "pathLength", ";", "$", "i", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "current", "[", "$", "path", "[", "$", "i", "]", "]", ")", ")", "{", "break", ";", "}", "if", "(", "$", "i", "===", "$", "pathLength", "-", "1", ")", "{", "unset", "(", "$", "current", "[", "$", "path", "[", "$", "i", "]", "]", ")", ";", "break", ";", "}", "$", "current", "=", "&", "$", "current", "[", "$", "path", "[", "$", "i", "]", "]", ";", "}", "}" ]
Removes the item from the hierarchy @param string[] $path
[ "Removes", "the", "item", "from", "the", "hierarchy" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L180-L194
23,577
SporkCode/Spork
src/View/Helper/Dojo.php
Dojo.createService
public function createService(ServiceLocatorInterface $viewHelperManager) { $serviceLocator = $viewHelperManager->getServiceLocator(); $config = $serviceLocator->has('config') ? $serviceLocator->get('config') : array(); if (isset($config['dojo'])) { $this->config($config['dojo']); } $application = $serviceLocator->get('application'); $debug = $application->getRequest()->getQuery('debug'); if ($debug !== null) { $this->setDebug($debug == 'true'); } return $this; }
php
public function createService(ServiceLocatorInterface $viewHelperManager) { $serviceLocator = $viewHelperManager->getServiceLocator(); $config = $serviceLocator->has('config') ? $serviceLocator->get('config') : array(); if (isset($config['dojo'])) { $this->config($config['dojo']); } $application = $serviceLocator->get('application'); $debug = $application->getRequest()->getQuery('debug'); if ($debug !== null) { $this->setDebug($debug == 'true'); } return $this; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "viewHelperManager", ")", "{", "$", "serviceLocator", "=", "$", "viewHelperManager", "->", "getServiceLocator", "(", ")", ";", "$", "config", "=", "$", "serviceLocator", "->", "has", "(", "'config'", ")", "?", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ":", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'dojo'", "]", ")", ")", "{", "$", "this", "->", "config", "(", "$", "config", "[", "'dojo'", "]", ")", ";", "}", "$", "application", "=", "$", "serviceLocator", "->", "get", "(", "'application'", ")", ";", "$", "debug", "=", "$", "application", "->", "getRequest", "(", ")", "->", "getQuery", "(", "'debug'", ")", ";", "if", "(", "$", "debug", "!==", "null", ")", "{", "$", "this", "->", "setDebug", "(", "$", "debug", "==", "'true'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Create and configure service @see \Zend\ServiceManager\FactoryInterface::createService() @param ServiceLocatorInterface $viewHelperManager @return \Spork\View\Helper\Dojo
[ "Create", "and", "configure", "service" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L118-L133
23,578
SporkCode/Spork
src/View/Helper/Dojo.php
Dojo.setDebug
public function setDebug($flag = true) { $this->debug = $this->getSession()->debug = (bool) $flag; if (true == $this->debug) { if (isset($this->options['debugOptions']) && is_array($this->options['debugOptions'])) { $this->initializeOptions($this->options['debugOptions']); } } else { $this->initializeOptions($this->options); } }
php
public function setDebug($flag = true) { $this->debug = $this->getSession()->debug = (bool) $flag; if (true == $this->debug) { if (isset($this->options['debugOptions']) && is_array($this->options['debugOptions'])) { $this->initializeOptions($this->options['debugOptions']); } } else { $this->initializeOptions($this->options); } }
[ "public", "function", "setDebug", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "debug", "=", "$", "this", "->", "getSession", "(", ")", "->", "debug", "=", "(", "bool", ")", "$", "flag", ";", "if", "(", "true", "==", "$", "this", "->", "debug", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'debugOptions'", "]", ")", "&&", "is_array", "(", "$", "this", "->", "options", "[", "'debugOptions'", "]", ")", ")", "{", "$", "this", "->", "initializeOptions", "(", "$", "this", "->", "options", "[", "'debugOptions'", "]", ")", ";", "}", "}", "else", "{", "$", "this", "->", "initializeOptions", "(", "$", "this", "->", "options", ")", ";", "}", "}" ]
Set debug flag @param string $flag
[ "Set", "debug", "flag" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L170-L181
23,579
SporkCode/Spork
src/View/Helper/Dojo.php
Dojo.initialize
public function initialize() { if (true == $this->initialized) { return; } $this->initialized = true; if ($this->isEnabled()) { $headScript = $this->getView()->plugin('headScript'); $headScript->prependFile($this->src); $options = array(); foreach (array('async', 'parseOnLoad') as $property) { if (null !== $this->$property) { $options[$property] = $this->$property; } } if (!empty($this->packages)) { $options['packages'] = array_values($this->packages); } if (!empty($options)) { $headScript->prependScript("dojoConfig=" . json_encode($options) . ";"); } if (!empty($this->modules)) { $require = 'require(["' . implode('", "', $this->modules) . '"]);'; $headScript->appendScript($require); } } }
php
public function initialize() { if (true == $this->initialized) { return; } $this->initialized = true; if ($this->isEnabled()) { $headScript = $this->getView()->plugin('headScript'); $headScript->prependFile($this->src); $options = array(); foreach (array('async', 'parseOnLoad') as $property) { if (null !== $this->$property) { $options[$property] = $this->$property; } } if (!empty($this->packages)) { $options['packages'] = array_values($this->packages); } if (!empty($options)) { $headScript->prependScript("dojoConfig=" . json_encode($options) . ";"); } if (!empty($this->modules)) { $require = 'require(["' . implode('", "', $this->modules) . '"]);'; $headScript->appendScript($require); } } }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "true", "==", "$", "this", "->", "initialized", ")", "{", "return", ";", "}", "$", "this", "->", "initialized", "=", "true", ";", "if", "(", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "$", "headScript", "=", "$", "this", "->", "getView", "(", ")", "->", "plugin", "(", "'headScript'", ")", ";", "$", "headScript", "->", "prependFile", "(", "$", "this", "->", "src", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "'async'", ",", "'parseOnLoad'", ")", "as", "$", "property", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "$", "property", ")", "{", "$", "options", "[", "$", "property", "]", "=", "$", "this", "->", "$", "property", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "packages", ")", ")", "{", "$", "options", "[", "'packages'", "]", "=", "array_values", "(", "$", "this", "->", "packages", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "$", "headScript", "->", "prependScript", "(", "\"dojoConfig=\"", ".", "json_encode", "(", "$", "options", ")", ".", "\";\"", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "modules", ")", ")", "{", "$", "require", "=", "'require([\"'", ".", "implode", "(", "'\", \"'", ",", "$", "this", "->", "modules", ")", ".", "'\"]);'", ";", "$", "headScript", "->", "appendScript", "(", "$", "require", ")", ";", "}", "}", "}" ]
Add Dojo configuration to HeadScript. Should only be called once.
[ "Add", "Dojo", "configuration", "to", "HeadScript", ".", "Should", "only", "be", "called", "once", "." ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L330-L360
23,580
mothership-ec/composer
src/Composer/Downloader/ArchiveDownloader.php
ArchiveDownloader.getFolderContent
private function getFolderContent($dir) { $finder = Finder::create() ->ignoreVCS(false) ->ignoreDotFiles(false) ->depth(0) ->in($dir); return iterator_to_array($finder); }
php
private function getFolderContent($dir) { $finder = Finder::create() ->ignoreVCS(false) ->ignoreDotFiles(false) ->depth(0) ->in($dir); return iterator_to_array($finder); }
[ "private", "function", "getFolderContent", "(", "$", "dir", ")", "{", "$", "finder", "=", "Finder", "::", "create", "(", ")", "->", "ignoreVCS", "(", "false", ")", "->", "ignoreDotFiles", "(", "false", ")", "->", "depth", "(", "0", ")", "->", "in", "(", "$", "dir", ")", ";", "return", "iterator_to_array", "(", "$", "finder", ")", ";", "}" ]
Returns the folder content, excluding dotfiles @param string $dir Directory @return \SplFileInfo[]
[ "Returns", "the", "folder", "content", "excluding", "dotfiles" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/ArchiveDownloader.php#L143-L152
23,581
c5labs/block-boilerplate
controller.php
Controller.import
public function import($page, $areaHandle, SimpleXMLElement $blockNode) { parent::import($page, $areaHandle, $blockNode); }
php
public function import($page, $areaHandle, SimpleXMLElement $blockNode) { parent::import($page, $areaHandle, $blockNode); }
[ "public", "function", "import", "(", "$", "page", ",", "$", "areaHandle", ",", "SimpleXMLElement", "$", "blockNode", ")", "{", "parent", "::", "import", "(", "$", "page", ",", "$", "areaHandle", ",", "$", "blockNode", ")", ";", "}" ]
Runs when a block is being imported. @param Page $page @param string $areaHandle @param SimpleXMLElement $blockNode @return void
[ "Runs", "when", "a", "block", "is", "being", "imported", "." ]
ed011364db67d8e219fdb3e18ff3d3e87027b565
https://github.com/c5labs/block-boilerplate/blob/ed011364db67d8e219fdb3e18ff3d3e87027b565/controller.php#L371-L374
23,582
phootwork/lang
src/ArrayObject.php
ArrayObject.add
public function add($element, $index = null) { if ($index === null) { $this->array[$this->count()] = $element; } else { array_splice($this->array, $index, 0, $element); } return $this; }
php
public function add($element, $index = null) { if ($index === null) { $this->array[$this->count()] = $element; } else { array_splice($this->array, $index, 0, $element); } return $this; }
[ "public", "function", "add", "(", "$", "element", ",", "$", "index", "=", "null", ")", "{", "if", "(", "$", "index", "===", "null", ")", "{", "$", "this", "->", "array", "[", "$", "this", "->", "count", "(", ")", "]", "=", "$", "element", ";", "}", "else", "{", "array_splice", "(", "$", "this", "->", "array", ",", "$", "index", ",", "0", ",", "$", "element", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds an element to that array @param mixed $element @param int $index @return $this
[ "Adds", "an", "element", "to", "that", "array" ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L100-L108
23,583
phootwork/lang
src/ArrayObject.php
ArrayObject.doSort
protected function doSort(&$array, $cmp, callable $usort, callable $sort) { if (is_callable($cmp)) { $usort($array, $cmp); } else if ($cmp instanceof Comparator) { $usort($array, function ($a, $b) use ($cmp) { return $cmp->compare($a, $b); }); } else { $sort($array); } }
php
protected function doSort(&$array, $cmp, callable $usort, callable $sort) { if (is_callable($cmp)) { $usort($array, $cmp); } else if ($cmp instanceof Comparator) { $usort($array, function ($a, $b) use ($cmp) { return $cmp->compare($a, $b); }); } else { $sort($array); } }
[ "protected", "function", "doSort", "(", "&", "$", "array", ",", "$", "cmp", ",", "callable", "$", "usort", ",", "callable", "$", "sort", ")", "{", "if", "(", "is_callable", "(", "$", "cmp", ")", ")", "{", "$", "usort", "(", "$", "array", ",", "$", "cmp", ")", ";", "}", "else", "if", "(", "$", "cmp", "instanceof", "Comparator", ")", "{", "$", "usort", "(", "$", "array", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "cmp", ")", "{", "return", "$", "cmp", "->", "compare", "(", "$", "a", ",", "$", "b", ")", ";", "}", ")", ";", "}", "else", "{", "$", "sort", "(", "$", "array", ")", ";", "}", "}" ]
Internal sort function @param array $array the array on which is operated on @param Comparator|callable $cmp the compare function @param callable $usort the sort function for user passed $cmd @param callable $sort the default sort function
[ "Internal", "sort", "function" ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L264-L274
23,584
phootwork/lang
src/ArrayObject.php
ArrayObject.find
public function find() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } foreach ($this->array as $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { return $element; } } return null; }
php
public function find() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } foreach ($this->array as $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { return $element; } } return null; }
[ "public", "function", "find", "(", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "1", ")", "{", "$", "callback", "=", "func_get_arg", "(", "0", ")", ";", "}", "else", "{", "$", "query", "=", "func_get_arg", "(", "0", ")", ";", "$", "callback", "=", "func_get_arg", "(", "1", ")", ";", "}", "foreach", "(", "$", "this", "->", "array", "as", "$", "element", ")", "{", "$", "return", "=", "func_num_args", "(", ")", "==", "1", "?", "$", "callback", "(", "$", "element", ")", ":", "$", "callback", "(", "$", "element", ",", "$", "query", ")", ";", "if", "(", "$", "return", ")", "{", "return", "$", "element", ";", "}", "}", "return", "null", ";", "}" ]
Searches the array with a given callback and returns the first element if found. The callback function takes one or two parameters: function ($element [, $query]) {} The callback must return a boolean @param mixed $query OPTIONAL the provided query @param callable $callback the callback function @return mixed|null the found element or null if it hasn't been found
[ "Searches", "the", "array", "with", "a", "given", "callback", "and", "returns", "the", "first", "element", "if", "found", "." ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L382-L399
23,585
phootwork/lang
src/ArrayObject.php
ArrayObject.findLast
public function findLast() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } $reverse = array_reverse($this->array, true); foreach ($reverse as $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { return $element; } } return null; }
php
public function findLast() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } $reverse = array_reverse($this->array, true); foreach ($reverse as $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { return $element; } } return null; }
[ "public", "function", "findLast", "(", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "1", ")", "{", "$", "callback", "=", "func_get_arg", "(", "0", ")", ";", "}", "else", "{", "$", "query", "=", "func_get_arg", "(", "0", ")", ";", "$", "callback", "=", "func_get_arg", "(", "1", ")", ";", "}", "$", "reverse", "=", "array_reverse", "(", "$", "this", "->", "array", ",", "true", ")", ";", "foreach", "(", "$", "reverse", "as", "$", "element", ")", "{", "$", "return", "=", "func_num_args", "(", ")", "==", "1", "?", "$", "callback", "(", "$", "element", ")", ":", "$", "callback", "(", "$", "element", ",", "$", "query", ")", ";", "if", "(", "$", "return", ")", "{", "return", "$", "element", ";", "}", "}", "return", "null", ";", "}" ]
Searches the array with a given callback and returns the last element if found. The callback function takes one or two parameters: function ($element [, $query]) {} The callback must return a boolean @param mixed $query OPTIONAL the provided query @param callable $callback the callback function @return mixed|null the found element or null if it hasn't been found
[ "Searches", "the", "array", "with", "a", "given", "callback", "and", "returns", "the", "last", "element", "if", "found", "." ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L414-L432
23,586
phootwork/lang
src/ArrayObject.php
ArrayObject.findAll
public function findAll() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } $array = []; foreach ($this->array as $k => $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { $array[$k] = $element; } } return new static($array); }
php
public function findAll() { if (func_num_args() == 1) { $callback = func_get_arg(0); } else { $query = func_get_arg(0); $callback = func_get_arg(1); } $array = []; foreach ($this->array as $k => $element) { $return = func_num_args() == 1 ? $callback($element) : $callback($element, $query); if ($return) { $array[$k] = $element; } } return new static($array); }
[ "public", "function", "findAll", "(", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "1", ")", "{", "$", "callback", "=", "func_get_arg", "(", "0", ")", ";", "}", "else", "{", "$", "query", "=", "func_get_arg", "(", "0", ")", ";", "$", "callback", "=", "func_get_arg", "(", "1", ")", ";", "}", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "array", "as", "$", "k", "=>", "$", "element", ")", "{", "$", "return", "=", "func_num_args", "(", ")", "==", "1", "?", "$", "callback", "(", "$", "element", ")", ":", "$", "callback", "(", "$", "element", ",", "$", "query", ")", ";", "if", "(", "$", "return", ")", "{", "$", "array", "[", "$", "k", "]", "=", "$", "element", ";", "}", "}", "return", "new", "static", "(", "$", "array", ")", ";", "}" ]
Searches the array with a given callback and returns all matching elements. The callback function takes one or two parameters: function ($element [, $query]) {} The callback must return a boolean @param mixed $query OPTIONAL the provided query @param callable $callback the callback function @return mixed|null the found element or null if it hasn't been found
[ "Searches", "the", "array", "with", "a", "given", "callback", "and", "returns", "all", "matching", "elements", "." ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L447-L465
23,587
nonzod/yii2-foundation
Widget.php
Widget.registerPlugin
protected function registerPlugin($name = '') { $view = $this->getView(); //$id = $this->options['id']; if ($this->clientOptions !== false) { $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $js = "$(document).foundation({ '$name' : { $options } });"; $view->registerJs($js); } if (!empty($this->clientFireMethods)) { $js = []; foreach ($this->clientFireMethods as $method) { $js[] = "$(document).foundation('$name', '$method');"; } $view->registerJs(implode("\n", $js)); } }
php
protected function registerPlugin($name = '') { $view = $this->getView(); //$id = $this->options['id']; if ($this->clientOptions !== false) { $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $js = "$(document).foundation({ '$name' : { $options } });"; $view->registerJs($js); } if (!empty($this->clientFireMethods)) { $js = []; foreach ($this->clientFireMethods as $method) { $js[] = "$(document).foundation('$name', '$method');"; } $view->registerJs(implode("\n", $js)); } }
[ "protected", "function", "registerPlugin", "(", "$", "name", "=", "''", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "//$id = $this->options['id'];", "if", "(", "$", "this", "->", "clientOptions", "!==", "false", ")", "{", "$", "options", "=", "empty", "(", "$", "this", "->", "clientOptions", ")", "?", "''", ":", "Json", "::", "encode", "(", "$", "this", "->", "clientOptions", ")", ";", "$", "js", "=", "\"$(document).foundation({ '$name' : { $options } });\"", ";", "$", "view", "->", "registerJs", "(", "$", "js", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "clientFireMethods", ")", ")", "{", "$", "js", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "clientFireMethods", "as", "$", "method", ")", "{", "$", "js", "[", "]", "=", "\"$(document).foundation('$name', '$method');\"", ";", "}", "$", "view", "->", "registerJs", "(", "implode", "(", "\"\\n\"", ",", "$", "js", ")", ")", ";", "}", "}" ]
Registers a specific Foundation plugin and call related methods @param string $name the name of the Foundation plugin @todo far caricare solo i js dei plugin in uso
[ "Registers", "a", "specific", "Foundation", "plugin", "and", "call", "related", "methods" ]
5df93b8a39a73a7fade2f3189693fdb6625205d2
https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/Widget.php#L51-L69
23,588
oroinc/OroLayoutComponent
BlockOptionsResolver.php
BlockOptionsResolver.resolveOptions
public function resolveOptions($blockType, array $options = []) { $resolver = $this->getOptionResolver($blockType); return $resolver->resolve($options); }
php
public function resolveOptions($blockType, array $options = []) { $resolver = $this->getOptionResolver($blockType); return $resolver->resolve($options); }
[ "public", "function", "resolveOptions", "(", "$", "blockType", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "getOptionResolver", "(", "$", "blockType", ")", ";", "return", "$", "resolver", "->", "resolve", "(", "$", "options", ")", ";", "}" ]
Returns the combination of the default options for the given block type and the passed options @param string|BlockTypeInterface $blockType The block type name or instance of BlockTypeInterface @param array $options The options @return array A list of options and their values @throws InvalidOptionsException if any given option is not applicable to the given block type
[ "Returns", "the", "combination", "of", "the", "default", "options", "for", "the", "given", "block", "type", "and", "the", "passed", "options" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockOptionsResolver.php#L34-L39
23,589
mothership-ec/composer
src/Composer/Repository/FilesystemRepository.php
FilesystemRepository.write
public function write() { $data = array(); $dumper = new ArrayDumper(); foreach ($this->getCanonicalPackages() as $package) { $data[] = $dumper->dump($package); } $this->file->write($data); }
php
public function write() { $data = array(); $dumper = new ArrayDumper(); foreach ($this->getCanonicalPackages() as $package) { $data[] = $dumper->dump($package); } $this->file->write($data); }
[ "public", "function", "write", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "dumper", "=", "new", "ArrayDumper", "(", ")", ";", "foreach", "(", "$", "this", "->", "getCanonicalPackages", "(", ")", "as", "$", "package", ")", "{", "$", "data", "[", "]", "=", "$", "dumper", "->", "dump", "(", "$", "package", ")", ";", "}", "$", "this", "->", "file", "->", "write", "(", "$", "data", ")", ";", "}" ]
Writes writable repository.
[ "Writes", "writable", "repository", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/FilesystemRepository.php#L76-L86
23,590
leprephp/http-server
src/Server.php
Server.append
public function append($middleware, $priority = 0): Server { return $this->appendOnCondition( $middleware, $this->buildAlwaysTrue(), $priority ); }
php
public function append($middleware, $priority = 0): Server { return $this->appendOnCondition( $middleware, $this->buildAlwaysTrue(), $priority ); }
[ "public", "function", "append", "(", "$", "middleware", ",", "$", "priority", "=", "0", ")", ":", "Server", "{", "return", "$", "this", "->", "appendOnCondition", "(", "$", "middleware", ",", "$", "this", "->", "buildAlwaysTrue", "(", ")", ",", "$", "priority", ")", ";", "}" ]
Always adds a middleware to the stack. The middleware will run in any case. @param MiddlewareInterface|callable|array $middleware @param int $priority @return Server
[ "Always", "adds", "a", "middleware", "to", "the", "stack", "." ]
2e307c80986456f7c53248b792771cb13bb4234d
https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L63-L70
23,591
leprephp/http-server
src/Server.php
Server.appendOnPath
public function appendOnPath($middleware, string $path, $priority = 0): Server { return $this->appendOnCondition( $middleware, $this->buildPathCondition($path), $priority ); }
php
public function appendOnPath($middleware, string $path, $priority = 0): Server { return $this->appendOnCondition( $middleware, $this->buildPathCondition($path), $priority ); }
[ "public", "function", "appendOnPath", "(", "$", "middleware", ",", "string", "$", "path", ",", "$", "priority", "=", "0", ")", ":", "Server", "{", "return", "$", "this", "->", "appendOnCondition", "(", "$", "middleware", ",", "$", "this", "->", "buildPathCondition", "(", "$", "path", ")", ",", "$", "priority", ")", ";", "}" ]
Adds a middleware to the stack only if the request path matches. The path must match exactly. If the "*" character is present, a comparison will be made via regex. For example: the path '/api' matches only with request path '/api'. But the path '/api/*' matches with all request paths that start with '/api/'. The only position supported for the "*" character is at the end of the path. Other positions may work today, but may no longer work in the future. The path '*' (or '/*') matches with all request path. For performance reasons, in this case you can consider using the `append()` method instead. @param MiddlewareInterface|callable|array $middleware @param string $path @param int $priority @return Server
[ "Adds", "a", "middleware", "to", "the", "stack", "only", "if", "the", "request", "path", "matches", "." ]
2e307c80986456f7c53248b792771cb13bb4234d
https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L90-L97
23,592
leprephp/http-server
src/Server.php
Server.appendOnCondition
public function appendOnCondition($middleware, callable $condition, $priority = 0): Server { if (!is_array($middleware)) { $middleware = [$middleware]; } foreach ($middleware as $mw) { $this->stack[$priority][] = [$condition, $mw]; } return $this; }
php
public function appendOnCondition($middleware, callable $condition, $priority = 0): Server { if (!is_array($middleware)) { $middleware = [$middleware]; } foreach ($middleware as $mw) { $this->stack[$priority][] = [$condition, $mw]; } return $this; }
[ "public", "function", "appendOnCondition", "(", "$", "middleware", ",", "callable", "$", "condition", ",", "$", "priority", "=", "0", ")", ":", "Server", "{", "if", "(", "!", "is_array", "(", "$", "middleware", ")", ")", "{", "$", "middleware", "=", "[", "$", "middleware", "]", ";", "}", "foreach", "(", "$", "middleware", "as", "$", "mw", ")", "{", "$", "this", "->", "stack", "[", "$", "priority", "]", "[", "]", "=", "[", "$", "condition", ",", "$", "mw", "]", ";", "}", "return", "$", "this", ";", "}" ]
Adds a middleware to the stack only if the condition returns true. The `$condition` parameter must be a callable and it will be called with the `ServerRequestInterface` object as argument. @param MiddlewareInterface|callable|array $middleware @param callable $condition @param int $priority @return $this
[ "Adds", "a", "middleware", "to", "the", "stack", "only", "if", "the", "condition", "returns", "true", "." ]
2e307c80986456f7c53248b792771cb13bb4234d
https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L110-L121
23,593
ComposePress/core
src/Traits/Component.php
Component.setup_components
protected function setup_components() { $this->load_components(); $components = $this->get_components(); $this->set_component_parents( $components ); /** @var \ComposePress\Core\Abstracts\Component[] $components */ foreach ( $components as $component ) { if ( method_exists( $component, 'init' ) ) { $component->init(); } } }
php
protected function setup_components() { $this->load_components(); $components = $this->get_components(); $this->set_component_parents( $components ); /** @var \ComposePress\Core\Abstracts\Component[] $components */ foreach ( $components as $component ) { if ( method_exists( $component, 'init' ) ) { $component->init(); } } }
[ "protected", "function", "setup_components", "(", ")", "{", "$", "this", "->", "load_components", "(", ")", ";", "$", "components", "=", "$", "this", "->", "get_components", "(", ")", ";", "$", "this", "->", "set_component_parents", "(", "$", "components", ")", ";", "/** @var \\ComposePress\\Core\\Abstracts\\Component[] $components */", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "if", "(", "method_exists", "(", "$", "component", ",", "'init'", ")", ")", "{", "$", "component", "->", "init", "(", ")", ";", "}", "}", "}" ]
Setup components and run init
[ "Setup", "components", "and", "run", "init" ]
f403f81d06a1e43017cb23c19c980fe3ef3bb6f7
https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L86-L97
23,594
ComposePress/core
src/Traits/Component.php
Component.get_components
protected function get_components() { $components = ( new \ReflectionClass( $this ) )->getProperties(); $components = array_map( /** * @param \ReflectionProperty $property * * @return string */ function ( $property ) { return $property->name; }, $components ); $components = array_filter( $components, [ $this, 'is_component' ] ); $components = array_map( /** * @param \ReflectionProperty $component * * @return Component */ function ( $component ) { $getter = "get_{$component}"; return $this->$getter(); }, $components ); return $components; }
php
protected function get_components() { $components = ( new \ReflectionClass( $this ) )->getProperties(); $components = array_map( /** * @param \ReflectionProperty $property * * @return string */ function ( $property ) { return $property->name; }, $components ); $components = array_filter( $components, [ $this, 'is_component' ] ); $components = array_map( /** * @param \ReflectionProperty $component * * @return Component */ function ( $component ) { $getter = "get_{$component}"; return $this->$getter(); }, $components ); return $components; }
[ "protected", "function", "get_components", "(", ")", "{", "$", "components", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ")", "->", "getProperties", "(", ")", ";", "$", "components", "=", "array_map", "(", "/**\n\t\t * @param \\ReflectionProperty $property\n\t\t *\n\t\t * @return string\n\t\t */", "function", "(", "$", "property", ")", "{", "return", "$", "property", "->", "name", ";", "}", ",", "$", "components", ")", ";", "$", "components", "=", "array_filter", "(", "$", "components", ",", "[", "$", "this", ",", "'is_component'", "]", ")", ";", "$", "components", "=", "array_map", "(", "/**\n\t\t * @param \\ReflectionProperty $component\n\t\t *\n\t\t * @return Component\n\t\t */", "function", "(", "$", "component", ")", "{", "$", "getter", "=", "\"get_{$component}\"", ";", "return", "$", "this", "->", "$", "getter", "(", ")", ";", "}", ",", "$", "components", ")", ";", "return", "$", "components", ";", "}" ]
Get all components with a getter and that uses the Component trait @return array|\ReflectionProperty[]
[ "Get", "all", "components", "with", "a", "getter", "and", "that", "uses", "the", "Component", "trait" ]
f403f81d06a1e43017cb23c19c980fe3ef3bb6f7
https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L104-L129
23,595
ComposePress/core
src/Traits/Component.php
Component.load
protected function load( $component, $args = [] ) { $args = (array) $args; if ( ! property_exists( $this, $component ) ) { return false; } $class = $this->$component; if ( ! is_string( $class ) ) { return false; } if ( ! class_exists( $class ) ) { throw new \Exception( sprintf( 'Can not find class "%s" for Component "%s" in parent Component "%s"', $class, $component, __CLASS__ ) ); } $this->$component = $this->container->create( $class, $args ); return true; }
php
protected function load( $component, $args = [] ) { $args = (array) $args; if ( ! property_exists( $this, $component ) ) { return false; } $class = $this->$component; if ( ! is_string( $class ) ) { return false; } if ( ! class_exists( $class ) ) { throw new \Exception( sprintf( 'Can not find class "%s" for Component "%s" in parent Component "%s"', $class, $component, __CLASS__ ) ); } $this->$component = $this->container->create( $class, $args ); return true; }
[ "protected", "function", "load", "(", "$", "component", ",", "$", "args", "=", "[", "]", ")", "{", "$", "args", "=", "(", "array", ")", "$", "args", ";", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "component", ")", ")", "{", "return", "false", ";", "}", "$", "class", "=", "$", "this", "->", "$", "component", ";", "if", "(", "!", "is_string", "(", "$", "class", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Can not find class \"%s\" for Component \"%s\" in parent Component \"%s\"'", ",", "$", "class", ",", "$", "component", ",", "__CLASS__", ")", ")", ";", "}", "$", "this", "->", "$", "component", "=", "$", "this", "->", "container", "->", "create", "(", "$", "class", ",", "$", "args", ")", ";", "return", "true", ";", "}" ]
Load any property on the current component based on its string value as the class via the container @param $component @return bool @throws \Exception
[ "Load", "any", "property", "on", "the", "current", "component", "based", "on", "its", "string", "value", "as", "the", "class", "via", "the", "container" ]
f403f81d06a1e43017cb23c19c980fe3ef3bb6f7
https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L139-L157
23,596
zhouyl/mellivora
Mellivora/Database/Schema/Blueprint.php
Blueprint.toSql
public function toSql(Connection $connection, Grammar $grammar) { $this->addImpliedCommands(); $statements = []; // Each type of command has a corresponding compiler function on the schema // grammar which is used to build the necessary SQL statements to build // the blueprint element, so we'll just call that compilers function. foreach ($this->commands as $command) { $method = 'compile' . ucfirst($command->name); if (method_exists($grammar, $method)) { if (!is_null($sql = $grammar->{$method}($this, $command, $connection))) { $statements = array_merge($statements, (array) $sql); } } } return $statements; }
php
public function toSql(Connection $connection, Grammar $grammar) { $this->addImpliedCommands(); $statements = []; // Each type of command has a corresponding compiler function on the schema // grammar which is used to build the necessary SQL statements to build // the blueprint element, so we'll just call that compilers function. foreach ($this->commands as $command) { $method = 'compile' . ucfirst($command->name); if (method_exists($grammar, $method)) { if (!is_null($sql = $grammar->{$method}($this, $command, $connection))) { $statements = array_merge($statements, (array) $sql); } } } return $statements; }
[ "public", "function", "toSql", "(", "Connection", "$", "connection", ",", "Grammar", "$", "grammar", ")", "{", "$", "this", "->", "addImpliedCommands", "(", ")", ";", "$", "statements", "=", "[", "]", ";", "// Each type of command has a corresponding compiler function on the schema", "// grammar which is used to build the necessary SQL statements to build", "// the blueprint element, so we'll just call that compilers function.", "foreach", "(", "$", "this", "->", "commands", "as", "$", "command", ")", "{", "$", "method", "=", "'compile'", ".", "ucfirst", "(", "$", "command", "->", "name", ")", ";", "if", "(", "method_exists", "(", "$", "grammar", ",", "$", "method", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "sql", "=", "$", "grammar", "->", "{", "$", "method", "}", "(", "$", "this", ",", "$", "command", ",", "$", "connection", ")", ")", ")", "{", "$", "statements", "=", "array_merge", "(", "$", "statements", ",", "(", "array", ")", "$", "sql", ")", ";", "}", "}", "}", "return", "$", "statements", ";", "}" ]
Get the raw SQL statements for the blueprint. @param \Mellivora\Database\Connection $connection @param \Mellivora\Database\Schema\Grammars\Grammar $grammar @return array
[ "Get", "the", "raw", "SQL", "statements", "for", "the", "blueprint", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Schema/Blueprint.php#L98-L118
23,597
ShaoZeMing/laravel-merchant
src/Layout/Content.php
Content.render
public function render() { $items = [ 'header' => $this->header, 'description' => $this->description, 'breadcrumb' => $this->breadcrumb, 'content' => $this->build(), ]; return view('merchant::content', $items)->render(); }
php
public function render() { $items = [ 'header' => $this->header, 'description' => $this->description, 'breadcrumb' => $this->breadcrumb, 'content' => $this->build(), ]; return view('merchant::content', $items)->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "items", "=", "[", "'header'", "=>", "$", "this", "->", "header", ",", "'description'", "=>", "$", "this", "->", "description", ",", "'breadcrumb'", "=>", "$", "this", "->", "breadcrumb", ",", "'content'", "=>", "$", "this", "->", "build", "(", ")", ",", "]", ";", "return", "view", "(", "'merchant::content'", ",", "$", "items", ")", "->", "render", "(", ")", ";", "}" ]
Render this content. @return string
[ "Render", "this", "content", "." ]
20801b1735e7832a6e58b37c2c391328f8d626fa
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Layout/Content.php#L197-L207
23,598
simbiosis-group/yii2-helper
models/ExcelImportForm.php
ExcelImportForm.getToolTipTemplate
public function getToolTipTemplate($field) { if (array_key_exists($field, $this->toolTips())) { $toolTip = Html::tag('span', "{label}", [ 'data-content'=> $this->toolTips()[$field], 'data-toggle'=>'popover', 'data-trigger'=>'hover', 'style'=>'cursor:help; border-bottom: 1px dashed #888' ]); return "$toolTip \n{input}\n{hint}\n{error}"; } return "{label}\n{input}\n{hint}\n{error}"; }
php
public function getToolTipTemplate($field) { if (array_key_exists($field, $this->toolTips())) { $toolTip = Html::tag('span', "{label}", [ 'data-content'=> $this->toolTips()[$field], 'data-toggle'=>'popover', 'data-trigger'=>'hover', 'style'=>'cursor:help; border-bottom: 1px dashed #888' ]); return "$toolTip \n{input}\n{hint}\n{error}"; } return "{label}\n{input}\n{hint}\n{error}"; }
[ "public", "function", "getToolTipTemplate", "(", "$", "field", ")", "{", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "toolTips", "(", ")", ")", ")", "{", "$", "toolTip", "=", "Html", "::", "tag", "(", "'span'", ",", "\"{label}\"", ",", "[", "'data-content'", "=>", "$", "this", "->", "toolTips", "(", ")", "[", "$", "field", "]", ",", "'data-toggle'", "=>", "'popover'", ",", "'data-trigger'", "=>", "'hover'", ",", "'style'", "=>", "'cursor:help; border-bottom: 1px dashed #888'", "]", ")", ";", "return", "\"$toolTip \\n{input}\\n{hint}\\n{error}\"", ";", "}", "return", "\"{label}\\n{input}\\n{hint}\\n{error}\"", ";", "}" ]
Generate the tool tip template to use in form. @param string $field The table field name. @return string Return the tool tip template.
[ "Generate", "the", "tool", "tip", "template", "to", "use", "in", "form", "." ]
c85c4204dd06b16e54210e75fe6deb51869d1dd9
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/models/ExcelImportForm.php#L86-L100
23,599
simbiosis-group/yii2-helper
models/ExcelImportForm.php
ExcelImportForm.import
public function import($modelName, $defaultValues = [], $updateMultipleModel = false, $queryConfigs = []) { $isSuccessful = true; $sheetData = $this->arrayFromExcel; $this->header = array_shift($sheetData); foreach ($sheetData as $record) { if ($updateMultipleModel) { $parentId = $this->getParentId($queryConfigs['parentModel'], $queryConfigs['parentKey'], $record, $modelName, $defaultValues); $childModel = new $queryConfigs['childModel']; foreach ($queryConfigs['childModelArray'] as $key=>$value) { if (!is_array($value)) { $childModel->$value = $this->getCellValue($value, $childModel, $record, $key, false); } else { $childModel->$value['attribute'] = $this->getCellValue($value, $childModel, $record, $key, false); } } $childModel->$queryConfigs['childForeignKey'] = $parentId; $childModel->save(); } else { $isSuccessful = $this->createModel($modelName, $defaultValues, $record); } } return $isSuccessful; }
php
public function import($modelName, $defaultValues = [], $updateMultipleModel = false, $queryConfigs = []) { $isSuccessful = true; $sheetData = $this->arrayFromExcel; $this->header = array_shift($sheetData); foreach ($sheetData as $record) { if ($updateMultipleModel) { $parentId = $this->getParentId($queryConfigs['parentModel'], $queryConfigs['parentKey'], $record, $modelName, $defaultValues); $childModel = new $queryConfigs['childModel']; foreach ($queryConfigs['childModelArray'] as $key=>$value) { if (!is_array($value)) { $childModel->$value = $this->getCellValue($value, $childModel, $record, $key, false); } else { $childModel->$value['attribute'] = $this->getCellValue($value, $childModel, $record, $key, false); } } $childModel->$queryConfigs['childForeignKey'] = $parentId; $childModel->save(); } else { $isSuccessful = $this->createModel($modelName, $defaultValues, $record); } } return $isSuccessful; }
[ "public", "function", "import", "(", "$", "modelName", ",", "$", "defaultValues", "=", "[", "]", ",", "$", "updateMultipleModel", "=", "false", ",", "$", "queryConfigs", "=", "[", "]", ")", "{", "$", "isSuccessful", "=", "true", ";", "$", "sheetData", "=", "$", "this", "->", "arrayFromExcel", ";", "$", "this", "->", "header", "=", "array_shift", "(", "$", "sheetData", ")", ";", "foreach", "(", "$", "sheetData", "as", "$", "record", ")", "{", "if", "(", "$", "updateMultipleModel", ")", "{", "$", "parentId", "=", "$", "this", "->", "getParentId", "(", "$", "queryConfigs", "[", "'parentModel'", "]", ",", "$", "queryConfigs", "[", "'parentKey'", "]", ",", "$", "record", ",", "$", "modelName", ",", "$", "defaultValues", ")", ";", "$", "childModel", "=", "new", "$", "queryConfigs", "[", "'childModel'", "]", ";", "foreach", "(", "$", "queryConfigs", "[", "'childModelArray'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "childModel", "->", "$", "value", "=", "$", "this", "->", "getCellValue", "(", "$", "value", ",", "$", "childModel", ",", "$", "record", ",", "$", "key", ",", "false", ")", ";", "}", "else", "{", "$", "childModel", "->", "$", "value", "[", "'attribute'", "]", "=", "$", "this", "->", "getCellValue", "(", "$", "value", ",", "$", "childModel", ",", "$", "record", ",", "$", "key", ",", "false", ")", ";", "}", "}", "$", "childModel", "->", "$", "queryConfigs", "[", "'childForeignKey'", "]", "=", "$", "parentId", ";", "$", "childModel", "->", "save", "(", ")", ";", "}", "else", "{", "$", "isSuccessful", "=", "$", "this", "->", "createModel", "(", "$", "modelName", ",", "$", "defaultValues", ",", "$", "record", ")", ";", "}", "}", "return", "$", "isSuccessful", ";", "}" ]
Import the excel to the model using active record @param string $model The model name to save the excel rows into @param array $defaultValues The default values to be assigned @return Return true if all records is saved
[ "Import", "the", "excel", "to", "the", "model", "using", "active", "record" ]
c85c4204dd06b16e54210e75fe6deb51869d1dd9
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/models/ExcelImportForm.php#L108-L139