repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
romainbessugesmeusy/php-datagrid
library/RBM/Datagrid/Data/Processor/ResultRow.php
ResultRow.getCellDataForColumnName
public function getCellDataForColumnName($columnName) { return Extractor::extract( $this->_data, $this->_dataGrid->getColumn($columnName)->getCellAccessor() ); }
php
public function getCellDataForColumnName($columnName) { return Extractor::extract( $this->_data, $this->_dataGrid->getColumn($columnName)->getCellAccessor() ); }
[ "public", "function", "getCellDataForColumnName", "(", "$", "columnName", ")", "{", "return", "Extractor", "::", "extract", "(", "$", "this", "->", "_data", ",", "$", "this", "->", "_dataGrid", "->", "getColumn", "(", "$", "columnName", ")", "->", "getCellAccessor", "(", ")", ")", ";", "}" ]
Get the cell accessor from the DataGridColumn and extract the data from the row @param $columnName @return mixed
[ "Get", "the", "cell", "accessor", "from", "the", "DataGridColumn", "and", "extract", "the", "data", "from", "the", "row" ]
train
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ResultRow.php#L71-L77
highday/glitter
src/Services/Office/Circle/SearchService.php
SearchService.search
public function search(FinderItem $finder = null): LengthAwarePaginator { if ($finder) { $this->query = $finder($this->query); } return $this->query->paginate(); }
php
public function search(FinderItem $finder = null): LengthAwarePaginator { if ($finder) { $this->query = $finder($this->query); } return $this->query->paginate(); }
[ "public", "function", "search", "(", "FinderItem", "$", "finder", "=", "null", ")", ":", "LengthAwarePaginator", "{", "if", "(", "$", "finder", ")", "{", "$", "this", "->", "query", "=", "$", "finder", "(", "$", "this", "->", "query", ")", ";", "}", "return", "$", "this", "->", "query", "->", "paginate", "(", ")", ";", "}" ]
@param FinderItem|null $finder @throws \Exception @return LengthAwarePaginator
[ "@param", "FinderItem|null", "$finder" ]
train
https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Services/Office/Circle/SearchService.php#L54-L61
dotkernel/dot-rbac
src/Role/RoleService.php
RoleService.matchIdentityRoles
public function matchIdentityRoles(array $roles): bool { $identityRoles = $this->getIdentityRoles(); // Too easy... if (empty($identityRoles)) { return false; } $roleNames = []; foreach ($roles as $role) { $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role; } $identityRoleNames = []; foreach ($this->flattenRoles($identityRoles) as $role) { $identityRoleNames[] = $role->getName(); } return count(array_intersect($roleNames, $identityRoleNames)) > 0; }
php
public function matchIdentityRoles(array $roles): bool { $identityRoles = $this->getIdentityRoles(); // Too easy... if (empty($identityRoles)) { return false; } $roleNames = []; foreach ($roles as $role) { $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role; } $identityRoleNames = []; foreach ($this->flattenRoles($identityRoles) as $role) { $identityRoleNames[] = $role->getName(); } return count(array_intersect($roleNames, $identityRoleNames)) > 0; }
[ "public", "function", "matchIdentityRoles", "(", "array", "$", "roles", ")", ":", "bool", "{", "$", "identityRoles", "=", "$", "this", "->", "getIdentityRoles", "(", ")", ";", "// Too easy...", "if", "(", "empty", "(", "$", "identityRoles", ")", ")", "{", "return", "false", ";", "}", "$", "roleNames", "=", "[", "]", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "roleNames", "[", "]", "=", "$", "role", "instanceof", "RoleInterface", "?", "$", "role", "->", "getName", "(", ")", ":", "(", "string", ")", "$", "role", ";", "}", "$", "identityRoleNames", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "flattenRoles", "(", "$", "identityRoles", ")", "as", "$", "role", ")", "{", "$", "identityRoleNames", "[", "]", "=", "$", "role", "->", "getName", "(", ")", ";", "}", "return", "count", "(", "array_intersect", "(", "$", "roleNames", ",", "$", "identityRoleNames", ")", ")", ">", "0", ";", "}" ]
Check if the given roles match one of the identity roles This method is smart enough to automatically recursively extracts roles for hierarchical roles @param string[]|RoleInterface[] $roles @return bool
[ "Check", "if", "the", "given", "roles", "match", "one", "of", "the", "identity", "roles" ]
train
https://github.com/dotkernel/dot-rbac/blob/747ffadf3cf28750bb7cf81be60eb4c93b830446/src/Role/RoleService.php#L92-L110
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/variable/var_set.php
ezcMailVariableSet.getNextLine
public function getNextLine() { $line = current( $this->mail ); next( $this->mail ); if ( $line === false ) { return null; } return $line . "\n"; }
php
public function getNextLine() { $line = current( $this->mail ); next( $this->mail ); if ( $line === false ) { return null; } return $line . "\n"; }
[ "public", "function", "getNextLine", "(", ")", "{", "$", "line", "=", "current", "(", "$", "this", "->", "mail", ")", ";", "next", "(", "$", "this", "->", "mail", ")", ";", "if", "(", "$", "line", "===", "false", ")", "{", "return", "null", ";", "}", "return", "$", "line", ".", "\"\\n\"", ";", "}" ]
Returns one line of data from the current mail in the set. Null is returned if there is no current mail in the set or the end of the mail is reached. @return string
[ "Returns", "one", "line", "of", "data", "from", "the", "current", "mail", "in", "the", "set", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/variable/var_set.php#L59-L70
skeeks-cms/cms-log-db-target
src/console/controllers/FlushController.php
FlushController.actionLogs
public function actionLogs($countDay = 5) { if ($count = LogDbTargetModel::find()->where(['<=', 'log_time', time() - 3600*24*$countDay])->count()) { $this->stdout("Total logs found: {$count}\n", Console::BOLD); $totalDeleted = LogDbTargetModel::deleteAll(['<=', 'log_time', time() - 3600*24*$countDay]); $this->stdout("Total deleted: {$totalDeleted}\n"); } else { $this->stdout("Нечего удалять\n", Console::BOLD); } }
php
public function actionLogs($countDay = 5) { if ($count = LogDbTargetModel::find()->where(['<=', 'log_time', time() - 3600*24*$countDay])->count()) { $this->stdout("Total logs found: {$count}\n", Console::BOLD); $totalDeleted = LogDbTargetModel::deleteAll(['<=', 'log_time', time() - 3600*24*$countDay]); $this->stdout("Total deleted: {$totalDeleted}\n"); } else { $this->stdout("Нечего удалять\n", Console::BOLD); } }
[ "public", "function", "actionLogs", "(", "$", "countDay", "=", "5", ")", "{", "if", "(", "$", "count", "=", "LogDbTargetModel", "::", "find", "(", ")", "->", "where", "(", "[", "'<='", ",", "'log_time'", ",", "time", "(", ")", "-", "3600", "*", "24", "*", "$", "countDay", "]", ")", "->", "count", "(", ")", ")", "{", "$", "this", "->", "stdout", "(", "\"Total logs found: {$count}\\n\"", ",", "Console", "::", "BOLD", ")", ";", "$", "totalDeleted", "=", "LogDbTargetModel", "::", "deleteAll", "(", "[", "'<='", ",", "'log_time'", ",", "time", "(", ")", "-", "3600", "*", "24", "*", "$", "countDay", "]", ")", ";", "$", "this", "->", "stdout", "(", "\"Total deleted: {$totalDeleted}\\n\"", ")", ";", "}", "else", "{", "$", "this", "->", "stdout", "(", "\"Нечего удалять\\n\", Console::BO", "L", ");", "", "", "", "", "}", "}" ]
Чистка логов старше чем (указать количество дней) @param int $countDay количество дней
[ "Чистка", "логов", "старше", "чем", "(", "указать", "количество", "дней", ")" ]
train
https://github.com/skeeks-cms/cms-log-db-target/blob/cb660a50d0d4d734096230e525f66855a7373d14/src/console/controllers/FlushController.php#L24-L35
nabab/bbn
src/bbn/appui/project.php
project.get_root_path
public function get_root_path($repository){ if ( \is_string($repository) ){ $repository = $this->repository($repository); } if ( !empty($repository) && !empty($repository['bbn_path']) ){ $repository_path = !empty($repository['path']) ? '/' . $repository['path'] : ''; $path = self::decipher_path($repository['bbn_path'] . $repository_path) . '/'; return \bbn\str::parse_path($path); } return false; }
php
public function get_root_path($repository){ if ( \is_string($repository) ){ $repository = $this->repository($repository); } if ( !empty($repository) && !empty($repository['bbn_path']) ){ $repository_path = !empty($repository['path']) ? '/' . $repository['path'] : ''; $path = self::decipher_path($repository['bbn_path'] . $repository_path) . '/'; return \bbn\str::parse_path($path); } return false; }
[ "public", "function", "get_root_path", "(", "$", "repository", ")", "{", "if", "(", "\\", "is_string", "(", "$", "repository", ")", ")", "{", "$", "repository", "=", "$", "this", "->", "repository", "(", "$", "repository", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "repository", ")", "&&", "!", "empty", "(", "$", "repository", "[", "'bbn_path'", "]", ")", ")", "{", "$", "repository_path", "=", "!", "empty", "(", "$", "repository", "[", "'path'", "]", ")", "?", "'/'", ".", "$", "repository", "[", "'path'", "]", ":", "''", ";", "$", "path", "=", "self", "::", "decipher_path", "(", "$", "repository", "[", "'bbn_path'", "]", ".", "$", "repository_path", ")", ".", "'/'", ";", "return", "\\", "bbn", "\\", "str", "::", "parse_path", "(", "$", "path", ")", ";", "}", "return", "false", ";", "}" ]
Gets the real root path from a repository's id as recorded in the options. @param string|array $repository The repository's name (code) or the repository's configuration @return bool|string
[ "Gets", "the", "real", "root", "path", "from", "a", "repository", "s", "id", "as", "recorded", "in", "the", "options", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L226-L236
nabab/bbn
src/bbn/appui/project.php
project.repositories
public function repositories(string $code=''){ $all = $this->options->full_soptions($this->options->from_code('PATHS', 'ide', 'appui')); $cats = []; $r = []; foreach ( $all as $a ){ if ( \defined($a['bbn_path']) ){ $k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']); if ( !isset($cats[$a['id_alias']]) ){ unset($a['alias']['cfg']); $cats[$a['id_alias']] = $a['alias']; } unset($a['cfg']); unset($a['alias']); $r[$k] = $a; $r[$k]['title'] = $r[$k]['text']; $r[$k]['alias_code'] = $cats[$a['id_alias']]['code']; if ( !empty($cats[$a['id_alias']]['tabs']) ){ $r[$k]['tabs'] = $cats[$a['id_alias']]['tabs']; } else if( !empty($cats[$a['id_alias']]['extensions']) ){ $r[$k]['extensions'] = $cats[$a['id_alias']]['extensions']; } unset($r[$k]['alias']); } } if ( $code ){ return isset($r[$code]) ? $r[$code] : false; } return $r; }
php
public function repositories(string $code=''){ $all = $this->options->full_soptions($this->options->from_code('PATHS', 'ide', 'appui')); $cats = []; $r = []; foreach ( $all as $a ){ if ( \defined($a['bbn_path']) ){ $k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']); if ( !isset($cats[$a['id_alias']]) ){ unset($a['alias']['cfg']); $cats[$a['id_alias']] = $a['alias']; } unset($a['cfg']); unset($a['alias']); $r[$k] = $a; $r[$k]['title'] = $r[$k]['text']; $r[$k]['alias_code'] = $cats[$a['id_alias']]['code']; if ( !empty($cats[$a['id_alias']]['tabs']) ){ $r[$k]['tabs'] = $cats[$a['id_alias']]['tabs']; } else if( !empty($cats[$a['id_alias']]['extensions']) ){ $r[$k]['extensions'] = $cats[$a['id_alias']]['extensions']; } unset($r[$k]['alias']); } } if ( $code ){ return isset($r[$code]) ? $r[$code] : false; } return $r; }
[ "public", "function", "repositories", "(", "string", "$", "code", "=", "''", ")", "{", "$", "all", "=", "$", "this", "->", "options", "->", "full_soptions", "(", "$", "this", "->", "options", "->", "from_code", "(", "'PATHS'", ",", "'ide'", ",", "'appui'", ")", ")", ";", "$", "cats", "=", "[", "]", ";", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "all", "as", "$", "a", ")", "{", "if", "(", "\\", "defined", "(", "$", "a", "[", "'bbn_path'", "]", ")", ")", "{", "$", "k", "=", "$", "a", "[", "'bbn_path'", "]", ".", "'/'", ".", "(", "$", "a", "[", "'code'", "]", "===", "'/'", "?", "''", ":", "$", "a", "[", "'code'", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", ")", ")", "{", "unset", "(", "$", "a", "[", "'alias'", "]", "[", "'cfg'", "]", ")", ";", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "=", "$", "a", "[", "'alias'", "]", ";", "}", "unset", "(", "$", "a", "[", "'cfg'", "]", ")", ";", "unset", "(", "$", "a", "[", "'alias'", "]", ")", ";", "$", "r", "[", "$", "k", "]", "=", "$", "a", ";", "$", "r", "[", "$", "k", "]", "[", "'title'", "]", "=", "$", "r", "[", "$", "k", "]", "[", "'text'", "]", ";", "$", "r", "[", "$", "k", "]", "[", "'alias_code'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'code'", "]", ";", "if", "(", "!", "empty", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'tabs'", "]", ")", ")", "{", "$", "r", "[", "$", "k", "]", "[", "'tabs'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'tabs'", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'extensions'", "]", ")", ")", "{", "$", "r", "[", "$", "k", "]", "[", "'extensions'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'extensions'", "]", ";", "}", "unset", "(", "$", "r", "[", "$", "k", "]", "[", "'alias'", "]", ")", ";", "}", "}", "if", "(", "$", "code", ")", "{", "return", "isset", "(", "$", "r", "[", "$", "code", "]", ")", "?", "$", "r", "[", "$", "code", "]", ":", "false", ";", "}", "return", "$", "r", ";", "}" ]
Makes the repositories' configurations. @param string $code The repository's name (code) @return array|bool
[ "Makes", "the", "repositories", "configurations", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L254-L283
nabab/bbn
src/bbn/appui/project.php
project.repository_from_url
public function repository_from_url(string $url, bool $obj = false){ $repository = ''; $repositories = $this->repositories(); foreach ( $repositories as $i => $d ){ if ( (strpos($url, $i) === 0) && (\strlen($i) > \strlen($repository) ) ){ $repository = $i; } } if ( !empty($repository) ){ return empty($obj) ? $repository : $repositories[$repository]; } return false; }
php
public function repository_from_url(string $url, bool $obj = false){ $repository = ''; $repositories = $this->repositories(); foreach ( $repositories as $i => $d ){ if ( (strpos($url, $i) === 0) && (\strlen($i) > \strlen($repository) ) ){ $repository = $i; } } if ( !empty($repository) ){ return empty($obj) ? $repository : $repositories[$repository]; } return false; }
[ "public", "function", "repository_from_url", "(", "string", "$", "url", ",", "bool", "$", "obj", "=", "false", ")", "{", "$", "repository", "=", "''", ";", "$", "repositories", "=", "$", "this", "->", "repositories", "(", ")", ";", "foreach", "(", "$", "repositories", "as", "$", "i", "=>", "$", "d", ")", "{", "if", "(", "(", "strpos", "(", "$", "url", ",", "$", "i", ")", "===", "0", ")", "&&", "(", "\\", "strlen", "(", "$", "i", ")", ">", "\\", "strlen", "(", "$", "repository", ")", ")", ")", "{", "$", "repository", "=", "$", "i", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "repository", ")", ")", "{", "return", "empty", "(", "$", "obj", ")", "?", "$", "repository", ":", "$", "repositories", "[", "$", "repository", "]", ";", "}", "return", "false", ";", "}" ]
Returns the repository's name or object from an URL. @param string $url @param bool $obj @return bool|int|string
[ "Returns", "the", "repository", "s", "name", "or", "object", "from", "an", "URL", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L292-L307
nabab/bbn
src/bbn/appui/project.php
project.real_to_url
public function real_to_url(string $file){ foreach ( $this->repositories() as $i => $d ){ if ( // Repository's root path ($root = $this->get_root_path($d)) && (strpos($file, $root) === 0) ){ $res = $i; $bits = explode('/', substr($file, \strlen($root))); // MVC if ( !empty($d['tabs']) ){ $tab_path = array_shift($bits); $fn = array_pop($bits); $ext = \bbn\str::file_ext($fn); $fn = \bbn\str::file_ext($fn, 1)[0]; $res .= implode('/', $bits); foreach ( $d['tabs'] as $k => $t ){ if ( empty($t['fixed']) && ($t['path'] === $tab_path . '/') ){ $res .= "/$fn/$t[url]"; break; } } } // Normal file else { $res .= implode('/', $bits); } return \bbn\str::parse_path($res); } } return false; }
php
public function real_to_url(string $file){ foreach ( $this->repositories() as $i => $d ){ if ( // Repository's root path ($root = $this->get_root_path($d)) && (strpos($file, $root) === 0) ){ $res = $i; $bits = explode('/', substr($file, \strlen($root))); // MVC if ( !empty($d['tabs']) ){ $tab_path = array_shift($bits); $fn = array_pop($bits); $ext = \bbn\str::file_ext($fn); $fn = \bbn\str::file_ext($fn, 1)[0]; $res .= implode('/', $bits); foreach ( $d['tabs'] as $k => $t ){ if ( empty($t['fixed']) && ($t['path'] === $tab_path . '/') ){ $res .= "/$fn/$t[url]"; break; } } } // Normal file else { $res .= implode('/', $bits); } return \bbn\str::parse_path($res); } } return false; }
[ "public", "function", "real_to_url", "(", "string", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "repositories", "(", ")", "as", "$", "i", "=>", "$", "d", ")", "{", "if", "(", "// Repository's root path", "(", "$", "root", "=", "$", "this", "->", "get_root_path", "(", "$", "d", ")", ")", "&&", "(", "strpos", "(", "$", "file", ",", "$", "root", ")", "===", "0", ")", ")", "{", "$", "res", "=", "$", "i", ";", "$", "bits", "=", "explode", "(", "'/'", ",", "substr", "(", "$", "file", ",", "\\", "strlen", "(", "$", "root", ")", ")", ")", ";", "// MVC", "if", "(", "!", "empty", "(", "$", "d", "[", "'tabs'", "]", ")", ")", "{", "$", "tab_path", "=", "array_shift", "(", "$", "bits", ")", ";", "$", "fn", "=", "array_pop", "(", "$", "bits", ")", ";", "$", "ext", "=", "\\", "bbn", "\\", "str", "::", "file_ext", "(", "$", "fn", ")", ";", "$", "fn", "=", "\\", "bbn", "\\", "str", "::", "file_ext", "(", "$", "fn", ",", "1", ")", "[", "0", "]", ";", "$", "res", ".=", "implode", "(", "'/'", ",", "$", "bits", ")", ";", "foreach", "(", "$", "d", "[", "'tabs'", "]", "as", "$", "k", "=>", "$", "t", ")", "{", "if", "(", "empty", "(", "$", "t", "[", "'fixed'", "]", ")", "&&", "(", "$", "t", "[", "'path'", "]", "===", "$", "tab_path", ".", "'/'", ")", ")", "{", "$", "res", ".=", "\"/$fn/$t[url]\"", ";", "break", ";", "}", "}", "}", "// Normal file", "else", "{", "$", "res", ".=", "implode", "(", "'/'", ",", "$", "bits", ")", ";", "}", "return", "\\", "bbn", "\\", "str", "::", "parse_path", "(", "$", "res", ")", ";", "}", "}", "return", "false", ";", "}" ]
Returns the file's URL from the real file's path. @param string $file The real file's path @return bool|string
[ "Returns", "the", "file", "s", "URL", "from", "the", "real", "file", "s", "path", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L315-L352
qlake/framework
src/Qlake/Database/Query.php
Query.all
public function all() { $callback = $this->connection->executeSelect($this->toSql(), ['12']); $start = time() + microtime(true); $statement = $callback(); $delay = time() + microtime(true) - $start; $items = $statement->fetchAll(PDO::FETCH_OBJ); $collection = new Collection($items, (count($items) > 0 ? array_keys((array)$items[0]) : []), $delay); return $collection; }
php
public function all() { $callback = $this->connection->executeSelect($this->toSql(), ['12']); $start = time() + microtime(true); $statement = $callback(); $delay = time() + microtime(true) - $start; $items = $statement->fetchAll(PDO::FETCH_OBJ); $collection = new Collection($items, (count($items) > 0 ? array_keys((array)$items[0]) : []), $delay); return $collection; }
[ "public", "function", "all", "(", ")", "{", "$", "callback", "=", "$", "this", "->", "connection", "->", "executeSelect", "(", "$", "this", "->", "toSql", "(", ")", ",", "[", "'12'", "]", ")", ";", "$", "start", "=", "time", "(", ")", "+", "microtime", "(", "true", ")", ";", "$", "statement", "=", "$", "callback", "(", ")", ";", "$", "delay", "=", "time", "(", ")", "+", "microtime", "(", "true", ")", "-", "$", "start", ";", "$", "items", "=", "$", "statement", "->", "fetchAll", "(", "PDO", "::", "FETCH_OBJ", ")", ";", "$", "collection", "=", "new", "Collection", "(", "$", "items", ",", "(", "count", "(", "$", "items", ")", ">", "0", "?", "array_keys", "(", "(", "array", ")", "$", "items", "[", "0", "]", ")", ":", "[", "]", ")", ",", "$", "delay", ")", ";", "return", "$", "collection", ";", "}" ]
/*public static function table($table) { $query = new static; return $query->from($table); }
[ "/", "*", "public", "static", "function", "table", "(", "$table", ")", "{", "$query", "=", "new", "static", ";" ]
train
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Database/Query.php#L289-L304
qlake/framework
src/Qlake/Database/Query.php
Query.connection
public function connection($connection) { $connections = Config::get('database.connections'); $default = Config::get('database.default'); $connection = $connections[$default]; $connectionString = "{$connection['driver']}:host={$connection['host']};dbname={$connection['database']}"; try { $pdo = new PDO($connectionString, $connection['username'], $connection['password']); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } $db = new Qlake\Database\Query(new Qlake\Database\Connection($pdo), new Qlake\Database\Grammar); return $db; }
php
public function connection($connection) { $connections = Config::get('database.connections'); $default = Config::get('database.default'); $connection = $connections[$default]; $connectionString = "{$connection['driver']}:host={$connection['host']};dbname={$connection['database']}"; try { $pdo = new PDO($connectionString, $connection['username'], $connection['password']); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } $db = new Qlake\Database\Query(new Qlake\Database\Connection($pdo), new Qlake\Database\Grammar); return $db; }
[ "public", "function", "connection", "(", "$", "connection", ")", "{", "$", "connections", "=", "Config", "::", "get", "(", "'database.connections'", ")", ";", "$", "default", "=", "Config", "::", "get", "(", "'database.default'", ")", ";", "$", "connection", "=", "$", "connections", "[", "$", "default", "]", ";", "$", "connectionString", "=", "\"{$connection['driver']}:host={$connection['host']};dbname={$connection['database']}\"", ";", "try", "{", "$", "pdo", "=", "new", "PDO", "(", "$", "connectionString", ",", "$", "connection", "[", "'username'", "]", ",", "$", "connection", "[", "'password'", "]", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "print", "\"Error!: \"", ".", "$", "e", "->", "getMessage", "(", ")", ".", "\"<br/>\"", ";", "die", "(", ")", ";", "}", "$", "db", "=", "new", "Qlake", "\\", "Database", "\\", "Query", "(", "new", "Qlake", "\\", "Database", "\\", "Connection", "(", "$", "pdo", ")", ",", "new", "Qlake", "\\", "Database", "\\", "Grammar", ")", ";", "return", "$", "db", ";", "}" ]
/*public function on($connection) { }
[ "/", "*", "public", "function", "on", "(", "$connection", ")", "{" ]
train
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Database/Query.php#L392-L415
bfitech/zapstore
src/RedisConn.php
RedisConn.connection__predis
private function connection__predis() { $args = []; foreach (array_keys($this->verified_params) as $key) { if ($key == 'redistype' || !$this->$key) continue; $args[substr($key, 5)] = $this->$key; } try { $this->connection = new \Predis\Client($args); $this->connection->ping(); return $this->connection_open_ok(); } catch(\Predis\Connection\ConnectionException $e) { return $this->connection_open_fail($e->getMessage()); } }
php
private function connection__predis() { $args = []; foreach (array_keys($this->verified_params) as $key) { if ($key == 'redistype' || !$this->$key) continue; $args[substr($key, 5)] = $this->$key; } try { $this->connection = new \Predis\Client($args); $this->connection->ping(); return $this->connection_open_ok(); } catch(\Predis\Connection\ConnectionException $e) { return $this->connection_open_fail($e->getMessage()); } }
[ "private", "function", "connection__predis", "(", ")", "{", "$", "args", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "verified_params", ")", "as", "$", "key", ")", "{", "if", "(", "$", "key", "==", "'redistype'", "||", "!", "$", "this", "->", "$", "key", ")", "continue", ";", "$", "args", "[", "substr", "(", "$", "key", ",", "5", ")", "]", "=", "$", "this", "->", "$", "key", ";", "}", "try", "{", "$", "this", "->", "connection", "=", "new", "\\", "Predis", "\\", "Client", "(", "$", "args", ")", ";", "$", "this", "->", "connection", "->", "ping", "(", ")", ";", "return", "$", "this", "->", "connection_open_ok", "(", ")", ";", "}", "catch", "(", "\\", "Predis", "\\", "Connection", "\\", "ConnectionException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Open connection with predis.
[ "Open", "connection", "with", "predis", "." ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L111-L125
bfitech/zapstore
src/RedisConn.php
RedisConn.connection__redis
private function connection__redis() { $this->connection = new \Redis(); # @note: This emits warning on failure instead of throwing # exception, hence the @ sign. if (!@$this->connection->connect( $this->redishost, $this->redisport, $this->redistimeout )) // @codeCoverageIgnoreStart return $this->connection_open_fail(); // @codeCoverageIgnoreEnd if ($this->redispassword || $this->redisdatabase) { try { if ($this->redispassword) $this->connection->auth($this->redispassword); if ($this->redisdatabase) $this->connection->select($this->redisdatabase); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } } try { $this->connection->ping(); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } return $this->connection_open_ok(); }
php
private function connection__redis() { $this->connection = new \Redis(); # @note: This emits warning on failure instead of throwing # exception, hence the @ sign. if (!@$this->connection->connect( $this->redishost, $this->redisport, $this->redistimeout )) // @codeCoverageIgnoreStart return $this->connection_open_fail(); // @codeCoverageIgnoreEnd if ($this->redispassword || $this->redisdatabase) { try { if ($this->redispassword) $this->connection->auth($this->redispassword); if ($this->redisdatabase) $this->connection->select($this->redisdatabase); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } } try { $this->connection->ping(); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } return $this->connection_open_ok(); }
[ "private", "function", "connection__redis", "(", ")", "{", "$", "this", "->", "connection", "=", "new", "\\", "Redis", "(", ")", ";", "# @note: This emits warning on failure instead of throwing", "# exception, hence the @ sign.", "if", "(", "!", "@", "$", "this", "->", "connection", "->", "connect", "(", "$", "this", "->", "redishost", ",", "$", "this", "->", "redisport", ",", "$", "this", "->", "redistimeout", ")", ")", "// @codeCoverageIgnoreStart", "return", "$", "this", "->", "connection_open_fail", "(", ")", ";", "// @codeCoverageIgnoreEnd", "if", "(", "$", "this", "->", "redispassword", "||", "$", "this", "->", "redisdatabase", ")", "{", "try", "{", "if", "(", "$", "this", "->", "redispassword", ")", "$", "this", "->", "connection", "->", "auth", "(", "$", "this", "->", "redispassword", ")", ";", "if", "(", "$", "this", "->", "redisdatabase", ")", "$", "this", "->", "connection", "->", "select", "(", "$", "this", "->", "redisdatabase", ")", ";", "}", "catch", "(", "\\", "RedisException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "try", "{", "$", "this", "->", "connection", "->", "ping", "(", ")", ";", "}", "catch", "(", "\\", "RedisException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", "->", "connection_open_ok", "(", ")", ";", "}" ]
Open connection with ext-redis.
[ "Open", "connection", "with", "ext", "-", "redis", "." ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L130-L157
bfitech/zapstore
src/RedisConn.php
RedisConn.connection_open_fail
private function connection_open_fail($msg='') { $logline = sprintf('Redis: %s connection failed', $this->redistype); if ($msg) $logline .= ': ' . $msg; $logline .= ' <- ' . json_encode($this->verified_params); self::$logger->error($logline); throw new RedisError(RedisError::CONNECTION_ERROR, $logline); }
php
private function connection_open_fail($msg='') { $logline = sprintf('Redis: %s connection failed', $this->redistype); if ($msg) $logline .= ': ' . $msg; $logline .= ' <- ' . json_encode($this->verified_params); self::$logger->error($logline); throw new RedisError(RedisError::CONNECTION_ERROR, $logline); }
[ "private", "function", "connection_open_fail", "(", "$", "msg", "=", "''", ")", "{", "$", "logline", "=", "sprintf", "(", "'Redis: %s connection failed'", ",", "$", "this", "->", "redistype", ")", ";", "if", "(", "$", "msg", ")", "$", "logline", ".=", "': '", ".", "$", "msg", ";", "$", "logline", ".=", "' <- '", ".", "json_encode", "(", "$", "this", "->", "verified_params", ")", ";", "self", "::", "$", "logger", "->", "error", "(", "$", "logline", ")", ";", "throw", "new", "RedisError", "(", "RedisError", "::", "CONNECTION_ERROR", ",", "$", "logline", ")", ";", "}" ]
Throw exception on failing connection.
[ "Throw", "exception", "on", "failing", "connection", "." ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L162-L171
bfitech/zapstore
src/RedisConn.php
RedisConn.set
final public function set($key, $value, $options=null) { $res = $this->redistype == 'redis' ? $this->connection->set($key, $value, $options) : $this->connection->set($key, $value); $res_log = $res ? 'ok': 'fail'; self::$logger->info(sprintf( "Redis: set %s: %s -> '%s'.", $res_log, $key, $value)); return $res; }
php
final public function set($key, $value, $options=null) { $res = $this->redistype == 'redis' ? $this->connection->set($key, $value, $options) : $this->connection->set($key, $value); $res_log = $res ? 'ok': 'fail'; self::$logger->info(sprintf( "Redis: set %s: %s -> '%s'.", $res_log, $key, $value)); return $res; }
[ "final", "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "options", "=", "null", ")", "{", "$", "res", "=", "$", "this", "->", "redistype", "==", "'redis'", "?", "$", "this", "->", "connection", "->", "set", "(", "$", "key", ",", "$", "value", ",", "$", "options", ")", ":", "$", "this", "->", "connection", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "$", "res_log", "=", "$", "res", "?", "'ok'", ":", "'fail'", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: set %s: %s -> '%s'.\"", ",", "$", "res_log", ",", "$", "key", ",", "$", "value", ")", ")", ";", "return", "$", "res", ";", "}" ]
set Set the string value in argument as value of the key. If you're using Redis >= 2.6.12, you can pass extended options as explained below. @param string $key Key. @param string $value Value. @param mixed $options Expiration or phpredis options array. If you pass an integer, phpredis will redirect to SETEX and set the expiration. If you pass an array, it will try to use Redis >= 2.6.12 extended options if value is valid. This is ignored if you're using Predis. @see https://git.io/vHJhl. @return bool True if the command is successful.
[ "set" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L199-L208
bfitech/zapstore
src/RedisConn.php
RedisConn.hset
final public function hset($key, $hkey, $value) { $res = $this->connection->hset($key, $hkey, $value); $res_log = $res === false ? 'fail' : 'ok'; self::$logger->info(sprintf( "Redis: hset %s: %s.%s -> '%s'.", $res_log, $key, $hkey, $value)); return $res; }
php
final public function hset($key, $hkey, $value) { $res = $this->connection->hset($key, $hkey, $value); $res_log = $res === false ? 'fail' : 'ok'; self::$logger->info(sprintf( "Redis: hset %s: %s.%s -> '%s'.", $res_log, $key, $hkey, $value)); return $res; }
[ "final", "public", "function", "hset", "(", "$", "key", ",", "$", "hkey", ",", "$", "value", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "hset", "(", "$", "key", ",", "$", "hkey", ",", "$", "value", ")", ";", "$", "res_log", "=", "$", "res", "===", "false", "?", "'fail'", ":", "'ok'", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: hset %s: %s.%s -> '%s'.\"", ",", "$", "res_log", ",", "$", "key", ",", "$", "hkey", ",", "$", "value", ")", ")", ";", "return", "$", "res", ";", "}" ]
hset Add a value to the hash stored at a key. @param string $key Key. @param string $hkey Hash key. @param string $value Value. @return long 1 if old value doesn't exist and new value is added successfully, 0 if the value is already present and replaced, false on error.
[ "hset" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L222-L230
bfitech/zapstore
src/RedisConn.php
RedisConn.del
final public function del($keys) { $res = $this->connection->del($keys); $res_log = $res ? 'ok' : 'fail'; $res_keys = $keys; if (!is_array($keys)) $keys = func_get_args(); $res_keys = json_encode($keys); self::$logger->info(sprintf( "Redis: delete %s: '%s'.", $res_log, $res_keys)); return $res; }
php
final public function del($keys) { $res = $this->connection->del($keys); $res_log = $res ? 'ok' : 'fail'; $res_keys = $keys; if (!is_array($keys)) $keys = func_get_args(); $res_keys = json_encode($keys); self::$logger->info(sprintf( "Redis: delete %s: '%s'.", $res_log, $res_keys)); return $res; }
[ "final", "public", "function", "del", "(", "$", "keys", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "del", "(", "$", "keys", ")", ";", "$", "res_log", "=", "$", "res", "?", "'ok'", ":", "'fail'", ";", "$", "res_keys", "=", "$", "keys", ";", "if", "(", "!", "is_array", "(", "$", "keys", ")", ")", "$", "keys", "=", "func_get_args", "(", ")", ";", "$", "res_keys", "=", "json_encode", "(", "$", "keys", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: delete %s: '%s'.\"", ",", "$", "res_log", ",", "$", "res_keys", ")", ")", ";", "return", "$", "res", ";", "}" ]
del Remove specified keys. @param array $keys An array of keys, or variadic parameters, each corresponding to a Redis key. @return long Number of keys deleted.
[ "del" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L241-L252
bfitech/zapstore
src/RedisConn.php
RedisConn.expire
final public function expire($key, $ttl) { $method = 'setTimeout'; if ($this->redistype == 'predis') $method = 'expire'; $res = $this->connection->$method($key, $ttl); self::$logger->info(sprintf( "Redis: expire %s: %s.", $key, $ttl)); return $res; }
php
final public function expire($key, $ttl) { $method = 'setTimeout'; if ($this->redistype == 'predis') $method = 'expire'; $res = $this->connection->$method($key, $ttl); self::$logger->info(sprintf( "Redis: expire %s: %s.", $key, $ttl)); return $res; }
[ "final", "public", "function", "expire", "(", "$", "key", ",", "$", "ttl", ")", "{", "$", "method", "=", "'setTimeout'", ";", "if", "(", "$", "this", "->", "redistype", "==", "'predis'", ")", "$", "method", "=", "'expire'", ";", "$", "res", "=", "$", "this", "->", "connection", "->", "$", "method", "(", "$", "key", ",", "$", "ttl", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: expire %s: %s.\"", ",", "$", "key", ",", "$", "ttl", ")", ")", ";", "return", "$", "res", ";", "}" ]
expire Sets an expiration date (a timeout) on an item. @param string $key The key that will disappear. @param integer $ttl The key's remaining ttl, in seconds. @return bool True on success, false otherwise.
[ "expire" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L263-L271
bfitech/zapstore
src/RedisConn.php
RedisConn.expireat
final public function expireat($key, $ttl) { $res = $this->connection->expireat($key, $ttl); self::$logger->info(sprintf( "Redis: expireat %s: %s.", $key, $ttl)); return $res; }
php
final public function expireat($key, $ttl) { $res = $this->connection->expireat($key, $ttl); self::$logger->info(sprintf( "Redis: expireat %s: %s.", $key, $ttl)); return $res; }
[ "final", "public", "function", "expireat", "(", "$", "key", ",", "$", "ttl", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "expireat", "(", "$", "key", ",", "$", "ttl", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: expireat %s: %s.\"", ",", "$", "key", ",", "$", "ttl", ")", ")", ";", "return", "$", "res", ";", "}" ]
expireat Sets an expiration timestamp of an item. @param string $key The key that will disappear. @param integer $ttl Unix timestamp. The key's date of death, in seconds after Unix epoch. @return bool True on suceess, false otherwise.
[ "expireat" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L283-L288
bfitech/zapstore
src/RedisConn.php
RedisConn.get
final public function get($key) { $res = $this->connection->get($key); self::$logger->info(sprintf( "Redis: get %s: '%s'.", $key, $res)); if ($this->redistype == 'predis' && $res == null) $res = false; return $res; }
php
final public function get($key) { $res = $this->connection->get($key); self::$logger->info(sprintf( "Redis: get %s: '%s'.", $key, $res)); if ($this->redistype == 'predis' && $res == null) $res = false; return $res; }
[ "final", "public", "function", "get", "(", "$", "key", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "get", "(", "$", "key", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: get %s: '%s'.\"", ",", "$", "key", ",", "$", "res", ")", ")", ";", "if", "(", "$", "this", "->", "redistype", "==", "'predis'", "&&", "$", "res", "==", "null", ")", "$", "res", "=", "false", ";", "return", "$", "res", ";", "}" ]
get Get the value related to the specified key. @param string $key Key. @return string|bool If key doesn't exist, false is returned. Otherwise, the value related to this key is returned.
[ "get" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L299-L306
bfitech/zapstore
src/RedisConn.php
RedisConn.hget
final public function hget($key, $hkey=null) { $res = $this->connection->hget($key, $hkey); self::$logger->info(sprintf( "Redis: hget %s.%s: '%s'.", $key, $hkey, $res)); return $res; }
php
final public function hget($key, $hkey=null) { $res = $this->connection->hget($key, $hkey); self::$logger->info(sprintf( "Redis: hget %s.%s: '%s'.", $key, $hkey, $res)); return $res; }
[ "final", "public", "function", "hget", "(", "$", "key", ",", "$", "hkey", "=", "null", ")", "{", "$", "res", "=", "$", "this", "->", "connection", "->", "hget", "(", "$", "key", ",", "$", "hkey", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "sprintf", "(", "\"Redis: hget %s.%s: '%s'.\"", ",", "$", "key", ",", "$", "hkey", ",", "$", "res", ")", ")", ";", "return", "$", "res", ";", "}" ]
hget Get a value from the hash stored at key. If the hash table or the key doesn't exist, false is returned. @param string $key Key. @param string $hkey Hash key. @return string The value, if the command executed successfully. False otherwise.
[ "hget" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L319-L324
bfitech/zapstore
src/RedisConn.php
RedisConn.time
final public function time($with_mcs=false) { $time = $this->connection->time(); if (!$with_mcs) return $time[0]; return $time[0] + ($time[1] / 1e6); }
php
final public function time($with_mcs=false) { $time = $this->connection->time(); if (!$with_mcs) return $time[0]; return $time[0] + ($time[1] / 1e6); }
[ "final", "public", "function", "time", "(", "$", "with_mcs", "=", "false", ")", "{", "$", "time", "=", "$", "this", "->", "connection", "->", "time", "(", ")", ";", "if", "(", "!", "$", "with_mcs", ")", "return", "$", "time", "[", "0", "]", ";", "return", "$", "time", "[", "0", "]", "+", "(", "$", "time", "[", "1", "]", "/", "1e6", ")", ";", "}" ]
time Get Redis server time. Always use server time as a reference to do RedisConn::expireat in case of PHP interpreter's or Redis server's clock not being properly synched. @param bool $with_mcs If true, returned time includes microsecond fraction. @return int|float Redis server time in Unix epoch.
[ "time" ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L353-L358
bfitech/zapstore
src/RedisConn.php
RedisConn.close
public function close() { if ($this->redistype == 'redis') $this->connection->close(); $this->connection = null; $this->verified_params = null; }
php
public function close() { if ($this->redistype == 'redis') $this->connection->close(); $this->connection = null; $this->verified_params = null; }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "redistype", "==", "'redis'", ")", "$", "this", "->", "connection", "->", "close", "(", ")", ";", "$", "this", "->", "connection", "=", "null", ";", "$", "this", "->", "verified_params", "=", "null", ";", "}" ]
Close connection.
[ "Close", "connection", "." ]
train
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L363-L368
ronaldborla/chikka
src/Borla/Chikka/Models/Request.php
Request.toArray
public function toArray() { // Get array $array = parent::toArray(); // Insert config $array['shortcode'] = $this->config->shortcode; $array['client_id'] = $this->config->client_id; $array['secret_key'] = $this->config->secret_key; // Return return $array; }
php
public function toArray() { // Get array $array = parent::toArray(); // Insert config $array['shortcode'] = $this->config->shortcode; $array['client_id'] = $this->config->client_id; $array['secret_key'] = $this->config->secret_key; // Return return $array; }
[ "public", "function", "toArray", "(", ")", "{", "// Get array", "$", "array", "=", "parent", "::", "toArray", "(", ")", ";", "// Insert config", "$", "array", "[", "'shortcode'", "]", "=", "$", "this", "->", "config", "->", "shortcode", ";", "$", "array", "[", "'client_id'", "]", "=", "$", "this", "->", "config", "->", "client_id", ";", "$", "array", "[", "'secret_key'", "]", "=", "$", "this", "->", "config", "->", "secret_key", ";", "// Return", "return", "$", "array", ";", "}" ]
To array
[ "To", "array" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Request.php#L35-L44
heidelpay/PhpDoc
src/Cilex/Provider/JmsSerializerServiceProvider.php
JmsSerializerServiceProvider.register
public function register(Application $app) { $vendorPath = isset($app['composer.vendor_path']) ? $app['composer.vendor_path'] : __DIR__ . '/../../../vendor'; $serializerPath = $vendorPath . '/jms/serializer/src'; if (!file_exists($serializerPath)) { $serializerPath = __DIR__ . '/../../../../../jms/serializer/src'; } $app['serializer.annotations'] = array( array('namespace' => 'JMS\Serializer\Annotation', 'path' => $serializerPath) ); $app['serializer'] = $app->share( function ($container) { if (!isset($container['serializer.annotations']) || !is_array($container['serializer.annotations'])) { throw new \RuntimeException( 'Expected the container to have an array called "serializer.annotations" that describes which ' . 'annotations are supported by the Serializer and where it can find them' ); } foreach ($container['serializer.annotations'] as $annotationsDefinition) { if (!isset($annotationsDefinition['namespace'])) { throw new \UnexpectedValueException( 'The annotation definition for the Serializer should have a key "namespace" that tells the ' . 'serializer what the namespace for the provided annotations are.' ); } if (!isset($annotationsDefinition['path'])) { throw new \UnexpectedValueException( 'The annotation definition for the Serializer should have a key "path" that tells the ' . 'serializer where it can find the provided annotations.' ); } AnnotationRegistry::registerAutoloadNamespace( $annotationsDefinition['namespace'], $annotationsDefinition['path'] ); } return SerializerBuilder::create()->build(); } ); }
php
public function register(Application $app) { $vendorPath = isset($app['composer.vendor_path']) ? $app['composer.vendor_path'] : __DIR__ . '/../../../vendor'; $serializerPath = $vendorPath . '/jms/serializer/src'; if (!file_exists($serializerPath)) { $serializerPath = __DIR__ . '/../../../../../jms/serializer/src'; } $app['serializer.annotations'] = array( array('namespace' => 'JMS\Serializer\Annotation', 'path' => $serializerPath) ); $app['serializer'] = $app->share( function ($container) { if (!isset($container['serializer.annotations']) || !is_array($container['serializer.annotations'])) { throw new \RuntimeException( 'Expected the container to have an array called "serializer.annotations" that describes which ' . 'annotations are supported by the Serializer and where it can find them' ); } foreach ($container['serializer.annotations'] as $annotationsDefinition) { if (!isset($annotationsDefinition['namespace'])) { throw new \UnexpectedValueException( 'The annotation definition for the Serializer should have a key "namespace" that tells the ' . 'serializer what the namespace for the provided annotations are.' ); } if (!isset($annotationsDefinition['path'])) { throw new \UnexpectedValueException( 'The annotation definition for the Serializer should have a key "path" that tells the ' . 'serializer where it can find the provided annotations.' ); } AnnotationRegistry::registerAutoloadNamespace( $annotationsDefinition['namespace'], $annotationsDefinition['path'] ); } return SerializerBuilder::create()->build(); } ); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "vendorPath", "=", "isset", "(", "$", "app", "[", "'composer.vendor_path'", "]", ")", "?", "$", "app", "[", "'composer.vendor_path'", "]", ":", "__DIR__", ".", "'/../../../vendor'", ";", "$", "serializerPath", "=", "$", "vendorPath", ".", "'/jms/serializer/src'", ";", "if", "(", "!", "file_exists", "(", "$", "serializerPath", ")", ")", "{", "$", "serializerPath", "=", "__DIR__", ".", "'/../../../../../jms/serializer/src'", ";", "}", "$", "app", "[", "'serializer.annotations'", "]", "=", "array", "(", "array", "(", "'namespace'", "=>", "'JMS\\Serializer\\Annotation'", ",", "'path'", "=>", "$", "serializerPath", ")", ")", ";", "$", "app", "[", "'serializer'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "container", ")", "{", "if", "(", "!", "isset", "(", "$", "container", "[", "'serializer.annotations'", "]", ")", "||", "!", "is_array", "(", "$", "container", "[", "'serializer.annotations'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Expected the container to have an array called \"serializer.annotations\" that describes which '", ".", "'annotations are supported by the Serializer and where it can find them'", ")", ";", "}", "foreach", "(", "$", "container", "[", "'serializer.annotations'", "]", "as", "$", "annotationsDefinition", ")", "{", "if", "(", "!", "isset", "(", "$", "annotationsDefinition", "[", "'namespace'", "]", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'The annotation definition for the Serializer should have a key \"namespace\" that tells the '", ".", "'serializer what the namespace for the provided annotations are.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "annotationsDefinition", "[", "'path'", "]", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'The annotation definition for the Serializer should have a key \"path\" that tells the '", ".", "'serializer where it can find the provided annotations.'", ")", ";", "}", "AnnotationRegistry", "::", "registerAutoloadNamespace", "(", "$", "annotationsDefinition", "[", "'namespace'", "]", ",", "$", "annotationsDefinition", "[", "'path'", "]", ")", ";", "}", "return", "SerializerBuilder", "::", "create", "(", ")", "->", "build", "(", ")", ";", "}", ")", ";", "}" ]
Registers services on the given app. @param Application $app An Application instance
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/Cilex/Provider/JmsSerializerServiceProvider.php#L29-L76
ekuiter/feature-php
FeaturePhp/Helper/PhpParser.php
PhpParser.parseString
public function parseString($str) { $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7); $this->ast = $parser->parse($str); return $this; }
php
public function parseString($str) { $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7); $this->ast = $parser->parse($str); return $this; }
[ "public", "function", "parseString", "(", "$", "str", ")", "{", "$", "parser", "=", "(", "new", "\\", "PhpParser", "\\", "ParserFactory", "(", ")", ")", "->", "create", "(", "\\", "PhpParser", "\\", "ParserFactory", "::", "PREFER_PHP7", ")", ";", "$", "this", "->", "ast", "=", "$", "parser", "->", "parse", "(", "$", "str", ")", ";", "return", "$", "this", ";", "}" ]
Parses a PHP string. @param string $str @return PhpParser
[ "Parses", "a", "PHP", "string", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/PhpParser.php#L29-L33
ekuiter/feature-php
FeaturePhp/Helper/PhpParser.php
PhpParser.getExactlyOneClass
public function getExactlyOneClass($fileSource) { if (count($this->ast) !== 1 || $this->ast[0]->getType() !== "Stmt_Class") throw new PhpParserException("\"$fileSource\" does not define exactly one class"); return $this->ast[0]; }
php
public function getExactlyOneClass($fileSource) { if (count($this->ast) !== 1 || $this->ast[0]->getType() !== "Stmt_Class") throw new PhpParserException("\"$fileSource\" does not define exactly one class"); return $this->ast[0]; }
[ "public", "function", "getExactlyOneClass", "(", "$", "fileSource", ")", "{", "if", "(", "count", "(", "$", "this", "->", "ast", ")", "!==", "1", "||", "$", "this", "->", "ast", "[", "0", "]", "->", "getType", "(", ")", "!==", "\"Stmt_Class\"", ")", "throw", "new", "PhpParserException", "(", "\"\\\"$fileSource\\\" does not define exactly one class\"", ")", ";", "return", "$", "this", "->", "ast", "[", "0", "]", ";", "}" ]
Asserts that the code defines one class and returns it. @param string $fileSource @return \PhpParser\Node\Stmt\Class_
[ "Asserts", "that", "the", "code", "defines", "one", "class", "and", "returns", "it", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/PhpParser.php#L60-L64
clickalicious/caching-middleware
src/Cache.php
Cache.getCachedResponseHtml
protected function getCachedResponseHtml(RequestInterface $request) { return $this ->getCacheItemPool() ->getItem($this->createKeyFromRequest($request)) ->get(); }
php
protected function getCachedResponseHtml(RequestInterface $request) { return $this ->getCacheItemPool() ->getItem($this->createKeyFromRequest($request)) ->get(); }
[ "protected", "function", "getCachedResponseHtml", "(", "RequestInterface", "$", "request", ")", "{", "return", "$", "this", "->", "getCacheItemPool", "(", ")", "->", "getItem", "(", "$", "this", "->", "createKeyFromRequest", "(", "$", "request", ")", ")", "->", "get", "(", ")", ";", "}" ]
Returns a cached Response by Request(Interface). @param RequestInterface $request the request to return cached response for @author Benjamin Carl <[email protected]> @return string|null The HTML for response as string if found, otherwise NULL @throws \Psr\Cache\InvalidArgumentException
[ "Returns", "a", "cached", "Response", "by", "Request", "(", "Interface", ")", "." ]
train
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L225-L231
clickalicious/caching-middleware
src/Cache.php
Cache.handle
protected function handle(ServerRequestInterface $request, ResponseInterface $response, callable $next) { // @codeCoverageIgnoreStart if ($html = $this->getCachedResponseHtml($request)) { return $this->buildResponse($html, $response); } // @codeCoverageIgnoreEnd /** @var ResponseInterface $response */ $response = $next($request, $response); if (Http::OK === $response->getStatusCode()) { $this->cacheResponse($request, $response); } return $response; }
php
protected function handle(ServerRequestInterface $request, ResponseInterface $response, callable $next) { // @codeCoverageIgnoreStart if ($html = $this->getCachedResponseHtml($request)) { return $this->buildResponse($html, $response); } // @codeCoverageIgnoreEnd /** @var ResponseInterface $response */ $response = $next($request, $response); if (Http::OK === $response->getStatusCode()) { $this->cacheResponse($request, $response); } return $response; }
[ "protected", "function", "handle", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "callable", "$", "next", ")", "{", "// @codeCoverageIgnoreStart", "if", "(", "$", "html", "=", "$", "this", "->", "getCachedResponseHtml", "(", "$", "request", ")", ")", "{", "return", "$", "this", "->", "buildResponse", "(", "$", "html", ",", "$", "response", ")", ";", "}", "// @codeCoverageIgnoreEnd", "/** @var ResponseInterface $response */", "$", "response", "=", "$", "next", "(", "$", "request", ",", "$", "response", ")", ";", "if", "(", "Http", "::", "OK", "===", "$", "response", "->", "getStatusCode", "(", ")", ")", "{", "$", "this", "->", "cacheResponse", "(", "$", "request", ",", "$", "response", ")", ";", "}", "return", "$", "response", ";", "}" ]
@param \Psr\Http\Message\ServerRequestInterface $request @param \Psr\Http\Message\ResponseInterface $response @param callable $next @return \Psr\Http\Message\ResponseInterface @throws \InvalidArgumentException @throws \Psr\Cache\InvalidArgumentException @throws \RuntimeException
[ "@param", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$request", "@param", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ResponseInterface", "$response", "@param", "callable", "$next" ]
train
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L248-L264
clickalicious/caching-middleware
src/Cache.php
Cache.buildResponse
protected function buildResponse($html, ResponseInterface $response) { // @codeCoverageIgnoreStart $body = new Stream('php://memory', 'w'); $body->write($html); $response = $response->withBody($body); return $response; // @codeCoverageIgnoreEnd }
php
protected function buildResponse($html, ResponseInterface $response) { // @codeCoverageIgnoreStart $body = new Stream('php://memory', 'w'); $body->write($html); $response = $response->withBody($body); return $response; // @codeCoverageIgnoreEnd }
[ "protected", "function", "buildResponse", "(", "$", "html", ",", "ResponseInterface", "$", "response", ")", "{", "// @codeCoverageIgnoreStart", "$", "body", "=", "new", "Stream", "(", "'php://memory'", ",", "'w'", ")", ";", "$", "body", "->", "write", "(", "$", "html", ")", ";", "$", "response", "=", "$", "response", "->", "withBody", "(", "$", "body", ")", ";", "return", "$", "response", ";", "// @codeCoverageIgnoreEnd", "}" ]
Builds response instance with HTML body from HTML passed in. @param string $html HTML used for response body @param \Psr\Http\Message\ResponseInterface $response Response used as base for response @author Benjamin Carl <[email protected]> @return \Psr\Http\Message\ResponseInterface @throws \InvalidArgumentException @throws \RuntimeException
[ "Builds", "response", "instance", "with", "HTML", "body", "from", "HTML", "passed", "in", "." ]
train
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L279-L288
clickalicious/caching-middleware
src/Cache.php
Cache.cacheResponse
protected function cacheResponse(RequestInterface $request, ResponseInterface $response) { $cacheItem = $this->createCacheItem($this->createKeyFromRequest($request)); $value = $response->getBody()->__toString(); $cacheItem->set($value); $this ->getCacheItemPool() ->save($cacheItem); }
php
protected function cacheResponse(RequestInterface $request, ResponseInterface $response) { $cacheItem = $this->createCacheItem($this->createKeyFromRequest($request)); $value = $response->getBody()->__toString(); $cacheItem->set($value); $this ->getCacheItemPool() ->save($cacheItem); }
[ "protected", "function", "cacheResponse", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "cacheItem", "=", "$", "this", "->", "createCacheItem", "(", "$", "this", "->", "createKeyFromRequest", "(", "$", "request", ")", ")", ";", "$", "value", "=", "$", "response", "->", "getBody", "(", ")", "->", "__toString", "(", ")", ";", "$", "cacheItem", "->", "set", "(", "$", "value", ")", ";", "$", "this", "->", "getCacheItemPool", "(", ")", "->", "save", "(", "$", "cacheItem", ")", ";", "}" ]
Caches a response by Request & Response. @param RequestInterface $request Request as identifier @param ResponseInterface $response Response to cache @author Benjamin Carl <[email protected]>
[ "Caches", "a", "response", "by", "Request", "&", "Response", "." ]
train
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L330-L339
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.addElement
public function addElement($elementName, $content, $attributes = null) { $this->elements[$elementName]['name'] = $elementName; $this->elements[$elementName]['content'] = $content; $this->elements[$elementName]['attributes'] = $attributes; }
php
public function addElement($elementName, $content, $attributes = null) { $this->elements[$elementName]['name'] = $elementName; $this->elements[$elementName]['content'] = $content; $this->elements[$elementName]['attributes'] = $attributes; }
[ "public", "function", "addElement", "(", "$", "elementName", ",", "$", "content", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "elements", "[", "$", "elementName", "]", "[", "'name'", "]", "=", "$", "elementName", ";", "$", "this", "->", "elements", "[", "$", "elementName", "]", "[", "'content'", "]", "=", "$", "content", ";", "$", "this", "->", "elements", "[", "$", "elementName", "]", "[", "'attributes'", "]", "=", "$", "attributes", ";", "}" ]
Add an element to elements array @param string $elementName The tag name of an element @param string $content The content of tag @param array $attributes Attributes(if any) in 'attrName' => 'attrValue' format @return void
[ "Add", "an", "element", "to", "elements", "array" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L65-L70
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.addElementArray
public function addElementArray($elementArray) { if (!is_array($elementArray)) { return; } foreach ($elementArray as $elementName => $content) { $this->addElement($elementName, $content); } }
php
public function addElementArray($elementArray) { if (!is_array($elementArray)) { return; } foreach ($elementArray as $elementName => $content) { $this->addElement($elementName, $content); } }
[ "public", "function", "addElementArray", "(", "$", "elementArray", ")", "{", "if", "(", "!", "is_array", "(", "$", "elementArray", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "elementArray", "as", "$", "elementName", "=>", "$", "content", ")", "{", "$", "this", "->", "addElement", "(", "$", "elementName", ",", "$", "content", ")", ";", "}", "}" ]
Set multiple feed elements from an array. Elements which have attributes cannot be added by this method @param array array of elements in 'tagName' => 'tagContent' format. @return void
[ "Set", "multiple", "feed", "elements", "from", "an", "array", ".", "Elements", "which", "have", "attributes", "cannot", "be", "added", "by", "this", "method" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L79-L89
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setDescription
public function setDescription($description) { $tag = ($this->version == Eresus_Feed_Writer::ATOM) ? 'summary' : 'description'; $this->addElement($tag, $description); }
php
public function setDescription($description) { $tag = ($this->version == Eresus_Feed_Writer::ATOM) ? 'summary' : 'description'; $this->addElement($tag, $description); }
[ "public", "function", "setDescription", "(", "$", "description", ")", "{", "$", "tag", "=", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "ATOM", ")", "?", "'summary'", ":", "'description'", ";", "$", "this", "->", "addElement", "(", "$", "tag", ",", "$", "description", ")", ";", "}" ]
Set the 'description' element of feed item @param string $description The content of 'description' element @return void
[ "Set", "the", "description", "element", "of", "feed", "item" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L107-L111
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setDate
public function setDate($date) { if (!is_numeric($date)) { $date = strtotime($date); } if ($this->version == Eresus_Feed_Writer::ATOM) { $tag = 'updated'; $value = date(DATE_ATOM, $date); } elseif ($this->version == Eresus_Feed_Writer::RSS2) { $tag = 'pubDate'; $value = date(DATE_RSS, $date); } else { $tag = 'dc:date'; $value = date("Y-m-d", $date); } $this->addElement($tag, $value); }
php
public function setDate($date) { if (!is_numeric($date)) { $date = strtotime($date); } if ($this->version == Eresus_Feed_Writer::ATOM) { $tag = 'updated'; $value = date(DATE_ATOM, $date); } elseif ($this->version == Eresus_Feed_Writer::RSS2) { $tag = 'pubDate'; $value = date(DATE_RSS, $date); } else { $tag = 'dc:date'; $value = date("Y-m-d", $date); } $this->addElement($tag, $value); }
[ "public", "function", "setDate", "(", "$", "date", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "date", ")", ")", "{", "$", "date", "=", "strtotime", "(", "$", "date", ")", ";", "}", "if", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "ATOM", ")", "{", "$", "tag", "=", "'updated'", ";", "$", "value", "=", "date", "(", "DATE_ATOM", ",", "$", "date", ")", ";", "}", "elseif", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "RSS2", ")", "{", "$", "tag", "=", "'pubDate'", ";", "$", "value", "=", "date", "(", "DATE_RSS", ",", "$", "date", ")", ";", "}", "else", "{", "$", "tag", "=", "'dc:date'", ";", "$", "value", "=", "date", "(", "\"Y-m-d\"", ",", "$", "date", ")", ";", "}", "$", "this", "->", "addElement", "(", "$", "tag", ",", "$", "value", ")", ";", "}" ]
Set the 'date' element of feed item @param string $date The content of 'date' element @return void
[ "Set", "the", "date", "element", "of", "feed", "item" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L130-L154
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setLink
public function setLink($link) { if ($this->version == Eresus_Feed_Writer::RSS2 || $this->version == Eresus_Feed_Writer::RSS1) { $this->addElement('link', $link); } else { $this->addElement('link', '', array('href' => $link)); $this->addElement('id', Eresus_Feed_Writer::uuid($link, 'urn:uuid:')); } }
php
public function setLink($link) { if ($this->version == Eresus_Feed_Writer::RSS2 || $this->version == Eresus_Feed_Writer::RSS1) { $this->addElement('link', $link); } else { $this->addElement('link', '', array('href' => $link)); $this->addElement('id', Eresus_Feed_Writer::uuid($link, 'urn:uuid:')); } }
[ "public", "function", "setLink", "(", "$", "link", ")", "{", "if", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "RSS2", "||", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "RSS1", ")", "{", "$", "this", "->", "addElement", "(", "'link'", ",", "$", "link", ")", ";", "}", "else", "{", "$", "this", "->", "addElement", "(", "'link'", ",", "''", ",", "array", "(", "'href'", "=>", "$", "link", ")", ")", ";", "$", "this", "->", "addElement", "(", "'id'", ",", "Eresus_Feed_Writer", "::", "uuid", "(", "$", "link", ",", "'urn:uuid:'", ")", ")", ";", "}", "}" ]
Set the 'link' element of feed item @param string $link The content of 'link' element @return void
[ "Set", "the", "link", "element", "of", "feed", "item" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L162-L174
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setEncloser
public function setEncloser($url, $length, $type) { $attributes = array('url' => $url, 'length' => $length, 'type' => $type); $this->addElement('enclosure', '', $attributes); }
php
public function setEncloser($url, $length, $type) { $attributes = array('url' => $url, 'length' => $length, 'type' => $type); $this->addElement('enclosure', '', $attributes); }
[ "public", "function", "setEncloser", "(", "$", "url", ",", "$", "length", ",", "$", "type", ")", "{", "$", "attributes", "=", "array", "(", "'url'", "=>", "$", "url", ",", "'length'", "=>", "$", "length", ",", "'type'", "=>", "$", "type", ")", ";", "$", "this", "->", "addElement", "(", "'enclosure'", ",", "''", ",", "$", "attributes", ")", ";", "}" ]
Set the 'encloser' element of feed item For RSS 2.0 only @param string $url The url attribute of encloser tag @param string $length The length attribute of encloser tag @param string $type The type attribute of encloser tag @return void
[ "Set", "the", "encloser", "element", "of", "feed", "item", "For", "RSS", "2", ".", "0", "only" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L185-L189
ezsystems/ezcomments-ls-extension
classes/ezcomnotification.php
ezcomNotification.fetchNotificationList
static function fetchNotificationList( $status = 1, $length = null, $offset = 0, $sorts = null ) { $cond = array(); if ( is_null( $status ) ) { $cond = null; } else { $cond['status'] = $status; } $limit = array(); if ( is_null( $length ) ) { $limit = null; } else { $limit['offset'] = $offset; $limit['length'] = $length; } return eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); }
php
static function fetchNotificationList( $status = 1, $length = null, $offset = 0, $sorts = null ) { $cond = array(); if ( is_null( $status ) ) { $cond = null; } else { $cond['status'] = $status; } $limit = array(); if ( is_null( $length ) ) { $limit = null; } else { $limit['offset'] = $offset; $limit['length'] = $length; } return eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); }
[ "static", "function", "fetchNotificationList", "(", "$", "status", "=", "1", ",", "$", "length", "=", "null", ",", "$", "offset", "=", "0", ",", "$", "sorts", "=", "null", ")", "{", "$", "cond", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "status", ")", ")", "{", "$", "cond", "=", "null", ";", "}", "else", "{", "$", "cond", "[", "'status'", "]", "=", "$", "status", ";", "}", "$", "limit", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "length", ")", ")", "{", "$", "limit", "=", "null", ";", "}", "else", "{", "$", "limit", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "limit", "[", "'length'", "]", "=", "$", "length", ";", "}", "return", "eZPersistentObject", "::", "fetchObjectList", "(", "self", "::", "definition", "(", ")", ",", "null", ",", "$", "cond", ",", "$", "sorts", ",", "$", "limit", ")", ";", "}" ]
Fetch the list of notification @param $length: count of the notification to be fetched @param $status: the status of the notification @param $offset: offset @return notification list
[ "Fetch", "the", "list", "of", "notification" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotification.php#L98-L120
neilime/zf2-tree-layout-stack
src/TreeLayoutStack/TemplatingService.php
TemplatingService.factory
public static function factory($aOptions){ if($aOptions instanceof \Traversable)$aOptions = \Zend\Stdlib\ArrayUtils::iteratorToArray($aOptions); elseif(!is_array($aOptions))throw new \InvalidArgumentException(__METHOD__.' expects an array or Traversable object; received "'.(is_object($aOptions)?get_class($aOptions):gettype($aOptions)).'"'); return new static(new \TreeLayoutStack\TemplatingConfiguration($aOptions)); }
php
public static function factory($aOptions){ if($aOptions instanceof \Traversable)$aOptions = \Zend\Stdlib\ArrayUtils::iteratorToArray($aOptions); elseif(!is_array($aOptions))throw new \InvalidArgumentException(__METHOD__.' expects an array or Traversable object; received "'.(is_object($aOptions)?get_class($aOptions):gettype($aOptions)).'"'); return new static(new \TreeLayoutStack\TemplatingConfiguration($aOptions)); }
[ "public", "static", "function", "factory", "(", "$", "aOptions", ")", "{", "if", "(", "$", "aOptions", "instanceof", "\\", "Traversable", ")", "$", "aOptions", "=", "\\", "Zend", "\\", "Stdlib", "\\", "ArrayUtils", "::", "iteratorToArray", "(", "$", "aOptions", ")", ";", "elseif", "(", "!", "is_array", "(", "$", "aOptions", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "' expects an array or Traversable object; received \"'", ".", "(", "is_object", "(", "$", "aOptions", ")", "?", "get_class", "(", "$", "aOptions", ")", ":", "gettype", "(", "$", "aOptions", ")", ")", ".", "'\"'", ")", ";", "return", "new", "static", "(", "new", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "(", "$", "aOptions", ")", ")", ";", "}" ]
Instantiate a Templating service @param array|Traversable $aOptions @throws \InvalidArgumentException @return \TreeLayoutStack\TemplatingService
[ "Instantiate", "a", "Templating", "service" ]
train
https://github.com/neilime/zf2-tree-layout-stack/blob/0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a/src/TreeLayoutStack/TemplatingService.php#L28-L32
neilime/zf2-tree-layout-stack
src/TreeLayoutStack/TemplatingService.php
TemplatingService.buildLayoutTemplate
public function buildLayoutTemplate(\Zend\Mvc\MvcEvent $oEvent){ $oRequest = $oEvent->getRequest(); if(!($oRequest instanceof \Zend\Http\Request) || $oRequest->isXmlHttpRequest() || ( ($oView = $oEvent->getResult()) instanceof \Zend\View\Model\ModelInterface && $oView->terminate() ))return $this; //Define current event $this->setCurrentEvent($oEvent); //Define module Name if(($oRouter = $this->getCurrentEvent()->getRouteMatch()) instanceof \Zend\Mvc\Router\RouteMatch)$sModule = current(explode('\\',$oRouter->getParam('controller'))); if(empty($sModule))$sModule = \TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE; try{ //Retrieve template for module $oTemplate = $this->getConfiguration()->hasLayoutTreeForModule($sModule) ?$this->getConfiguration()->getLayoutTreeForModule($sModule) :$this->getConfiguration()->getLayoutTreeForModule(\TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE); //Set layout template and add its children $sTemplate = $oTemplate->getConfiguration()->getTemplate(); if(is_callable($sTemplate))$sTemplate = $sTemplate($this->getCurrentEvent()); $oEvent->setViewModel($this->setChildrenToView( $oEvent->getViewModel()->setTemplate($sTemplate), $oTemplate->getChildren() )); } catch(\Exception $oException){ throw new \RuntimeException('Error occured during building layout template process : '.$oException->getMessage(),$oException->getCode(),$oException); } //Reset current event return $this->unsetCurrentEvent(); }
php
public function buildLayoutTemplate(\Zend\Mvc\MvcEvent $oEvent){ $oRequest = $oEvent->getRequest(); if(!($oRequest instanceof \Zend\Http\Request) || $oRequest->isXmlHttpRequest() || ( ($oView = $oEvent->getResult()) instanceof \Zend\View\Model\ModelInterface && $oView->terminate() ))return $this; //Define current event $this->setCurrentEvent($oEvent); //Define module Name if(($oRouter = $this->getCurrentEvent()->getRouteMatch()) instanceof \Zend\Mvc\Router\RouteMatch)$sModule = current(explode('\\',$oRouter->getParam('controller'))); if(empty($sModule))$sModule = \TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE; try{ //Retrieve template for module $oTemplate = $this->getConfiguration()->hasLayoutTreeForModule($sModule) ?$this->getConfiguration()->getLayoutTreeForModule($sModule) :$this->getConfiguration()->getLayoutTreeForModule(\TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE); //Set layout template and add its children $sTemplate = $oTemplate->getConfiguration()->getTemplate(); if(is_callable($sTemplate))$sTemplate = $sTemplate($this->getCurrentEvent()); $oEvent->setViewModel($this->setChildrenToView( $oEvent->getViewModel()->setTemplate($sTemplate), $oTemplate->getChildren() )); } catch(\Exception $oException){ throw new \RuntimeException('Error occured during building layout template process : '.$oException->getMessage(),$oException->getCode(),$oException); } //Reset current event return $this->unsetCurrentEvent(); }
[ "public", "function", "buildLayoutTemplate", "(", "\\", "Zend", "\\", "Mvc", "\\", "MvcEvent", "$", "oEvent", ")", "{", "$", "oRequest", "=", "$", "oEvent", "->", "getRequest", "(", ")", ";", "if", "(", "!", "(", "$", "oRequest", "instanceof", "\\", "Zend", "\\", "Http", "\\", "Request", ")", "||", "$", "oRequest", "->", "isXmlHttpRequest", "(", ")", "||", "(", "(", "$", "oView", "=", "$", "oEvent", "->", "getResult", "(", ")", ")", "instanceof", "\\", "Zend", "\\", "View", "\\", "Model", "\\", "ModelInterface", "&&", "$", "oView", "->", "terminate", "(", ")", ")", ")", "return", "$", "this", ";", "//Define current event", "$", "this", "->", "setCurrentEvent", "(", "$", "oEvent", ")", ";", "//Define module Name", "if", "(", "(", "$", "oRouter", "=", "$", "this", "->", "getCurrentEvent", "(", ")", "->", "getRouteMatch", "(", ")", ")", "instanceof", "\\", "Zend", "\\", "Mvc", "\\", "Router", "\\", "RouteMatch", ")", "$", "sModule", "=", "current", "(", "explode", "(", "'\\\\'", ",", "$", "oRouter", "->", "getParam", "(", "'controller'", ")", ")", ")", ";", "if", "(", "empty", "(", "$", "sModule", ")", ")", "$", "sModule", "=", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "::", "DEFAULT_LAYOUT_TREE", ";", "try", "{", "//Retrieve template for module", "$", "oTemplate", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasLayoutTreeForModule", "(", "$", "sModule", ")", "?", "$", "this", "->", "getConfiguration", "(", ")", "->", "getLayoutTreeForModule", "(", "$", "sModule", ")", ":", "$", "this", "->", "getConfiguration", "(", ")", "->", "getLayoutTreeForModule", "(", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "::", "DEFAULT_LAYOUT_TREE", ")", ";", "//Set layout template and add its children", "$", "sTemplate", "=", "$", "oTemplate", "->", "getConfiguration", "(", ")", "->", "getTemplate", "(", ")", ";", "if", "(", "is_callable", "(", "$", "sTemplate", ")", ")", "$", "sTemplate", "=", "$", "sTemplate", "(", "$", "this", "->", "getCurrentEvent", "(", ")", ")", ";", "$", "oEvent", "->", "setViewModel", "(", "$", "this", "->", "setChildrenToView", "(", "$", "oEvent", "->", "getViewModel", "(", ")", "->", "setTemplate", "(", "$", "sTemplate", ")", ",", "$", "oTemplate", "->", "getChildren", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "oException", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error occured during building layout template process : '", ".", "$", "oException", "->", "getMessage", "(", ")", ",", "$", "oException", "->", "getCode", "(", ")", ",", "$", "oException", ")", ";", "}", "//Reset current event", "return", "$", "this", "->", "unsetCurrentEvent", "(", ")", ";", "}" ]
Define layout template @param \Zend\Mvc\MvcEvent $oEvent @throws \RuntimeException @return \TreeLayoutStack\TemplatingService
[ "Define", "layout", "template" ]
train
https://github.com/neilime/zf2-tree-layout-stack/blob/0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a/src/TreeLayoutStack/TemplatingService.php#L84-L118
expectation-php/expect
src/MatcherPackage.php
MatcherPackage.registerTo
public function registerTo(MatcherRegistry $registry) { $provideMatchers = $this->getProvideMatchers(); foreach ($provideMatchers as $provideMatcher) { $registry->register($provideMatcher); } }
php
public function registerTo(MatcherRegistry $registry) { $provideMatchers = $this->getProvideMatchers(); foreach ($provideMatchers as $provideMatcher) { $registry->register($provideMatcher); } }
[ "public", "function", "registerTo", "(", "MatcherRegistry", "$", "registry", ")", "{", "$", "provideMatchers", "=", "$", "this", "->", "getProvideMatchers", "(", ")", ";", "foreach", "(", "$", "provideMatchers", "as", "$", "provideMatcher", ")", "{", "$", "registry", "->", "register", "(", "$", "provideMatcher", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherPackage.php#L54-L61
expectation-php/expect
src/MatcherPackage.php
MatcherPackage.fromPackageFile
public static function fromPackageFile($composerJson) { if (file_exists($composerJson) === false) { throw new ComposerJsonNotFoundException("File {$composerJson} not found."); } $config = Config::load($composerJson); $autoload = $config->get('autoload.psr-4'); $composerJsonDirectory = dirname($composerJson); $keys = array_keys($autoload); $namespace = array_shift($keys); $values = array_values($autoload); $namespaceDirectory = array_shift($values); $namespaceDirectory = realpath($composerJsonDirectory . '/' . $namespaceDirectory); return new self($namespace, $namespaceDirectory); }
php
public static function fromPackageFile($composerJson) { if (file_exists($composerJson) === false) { throw new ComposerJsonNotFoundException("File {$composerJson} not found."); } $config = Config::load($composerJson); $autoload = $config->get('autoload.psr-4'); $composerJsonDirectory = dirname($composerJson); $keys = array_keys($autoload); $namespace = array_shift($keys); $values = array_values($autoload); $namespaceDirectory = array_shift($values); $namespaceDirectory = realpath($composerJsonDirectory . '/' . $namespaceDirectory); return new self($namespace, $namespaceDirectory); }
[ "public", "static", "function", "fromPackageFile", "(", "$", "composerJson", ")", "{", "if", "(", "file_exists", "(", "$", "composerJson", ")", "===", "false", ")", "{", "throw", "new", "ComposerJsonNotFoundException", "(", "\"File {$composerJson} not found.\"", ")", ";", "}", "$", "config", "=", "Config", "::", "load", "(", "$", "composerJson", ")", ";", "$", "autoload", "=", "$", "config", "->", "get", "(", "'autoload.psr-4'", ")", ";", "$", "composerJsonDirectory", "=", "dirname", "(", "$", "composerJson", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "autoload", ")", ";", "$", "namespace", "=", "array_shift", "(", "$", "keys", ")", ";", "$", "values", "=", "array_values", "(", "$", "autoload", ")", ";", "$", "namespaceDirectory", "=", "array_shift", "(", "$", "values", ")", ";", "$", "namespaceDirectory", "=", "realpath", "(", "$", "composerJsonDirectory", ".", "'/'", ".", "$", "namespaceDirectory", ")", ";", "return", "new", "self", "(", "$", "namespace", ",", "$", "namespaceDirectory", ")", ";", "}" ]
Create a new matcher package from composer.json @param string $composerJson composer.json path @throws \expect\package\ComposerJsonNotFoundException
[ "Create", "a", "new", "matcher", "package", "from", "composer", ".", "json" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherPackage.php#L107-L126
gpupo/common-schema
src/ORM/Entity/Application/API/OAuth/Client/AccessToken.php
AccessToken.setClient
public function setClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client = null) { $this->client = $client; return $this; }
php
public function setClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client = null) { $this->client = $client; return $this; }
[ "public", "function", "setClient", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Application", "\\", "API", "\\", "OAuth", "\\", "Client", "\\", "Client", "$", "client", "=", "null", ")", "{", "$", "this", "->", "client", "=", "$", "client", ";", "return", "$", "this", ";", "}" ]
Set client. @param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client @return AccessToken
[ "Set", "client", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/AccessToken.php#L274-L279
ShaoZeMing/laravel-merchant
src/Grid/Tools/BatchActions.php
BatchActions.render
public function render() { if (!$this->enableDelete) { $this->actions->shift(); } if ($this->actions->isEmpty()) { return ''; } $this->setUpScripts(); return view('merchant::grid.batch-actions', ['actions' => $this->actions])->render(); }
php
public function render() { if (!$this->enableDelete) { $this->actions->shift(); } if ($this->actions->isEmpty()) { return ''; } $this->setUpScripts(); return view('merchant::grid.batch-actions', ['actions' => $this->actions])->render(); }
[ "public", "function", "render", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enableDelete", ")", "{", "$", "this", "->", "actions", "->", "shift", "(", ")", ";", "}", "if", "(", "$", "this", "->", "actions", "->", "isEmpty", "(", ")", ")", "{", "return", "''", ";", "}", "$", "this", "->", "setUpScripts", "(", ")", ";", "return", "view", "(", "'merchant::grid.batch-actions'", ",", "[", "'actions'", "=>", "$", "this", "->", "actions", "]", ")", "->", "render", "(", ")", ";", "}" ]
Render BatchActions button groups. @return string
[ "Render", "BatchActions", "button", "groups", "." ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Grid/Tools/BatchActions.php#L124-L137
php-lug/lug
src/Component/Grid/Sort/Sorter.php
Sorter.sort
public function sort(DataSourceBuilderInterface $builder, GridInterface $grid, array $sorting) { foreach ($sorting as $name => $order) { if (!$grid->hasSort($name) || !in_array($order, [self::ASC, self::DESC], true)) { continue; } $sort = $grid->getSort($name); $types = $this->resolveTypes($sort->getType()); $resolver = new OptionsResolver(); foreach ($types as $type) { $type->configureOptions($resolver); } reset($types)->sort($order, $resolver->resolve(array_merge( ['builder' => $builder, 'grid' => $grid, 'sort' => $sort], $sort->getOptions() ))); } }
php
public function sort(DataSourceBuilderInterface $builder, GridInterface $grid, array $sorting) { foreach ($sorting as $name => $order) { if (!$grid->hasSort($name) || !in_array($order, [self::ASC, self::DESC], true)) { continue; } $sort = $grid->getSort($name); $types = $this->resolveTypes($sort->getType()); $resolver = new OptionsResolver(); foreach ($types as $type) { $type->configureOptions($resolver); } reset($types)->sort($order, $resolver->resolve(array_merge( ['builder' => $builder, 'grid' => $grid, 'sort' => $sort], $sort->getOptions() ))); } }
[ "public", "function", "sort", "(", "DataSourceBuilderInterface", "$", "builder", ",", "GridInterface", "$", "grid", ",", "array", "$", "sorting", ")", "{", "foreach", "(", "$", "sorting", "as", "$", "name", "=>", "$", "order", ")", "{", "if", "(", "!", "$", "grid", "->", "hasSort", "(", "$", "name", ")", "||", "!", "in_array", "(", "$", "order", ",", "[", "self", "::", "ASC", ",", "self", "::", "DESC", "]", ",", "true", ")", ")", "{", "continue", ";", "}", "$", "sort", "=", "$", "grid", "->", "getSort", "(", "$", "name", ")", ";", "$", "types", "=", "$", "this", "->", "resolveTypes", "(", "$", "sort", "->", "getType", "(", ")", ")", ";", "$", "resolver", "=", "new", "OptionsResolver", "(", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type", "->", "configureOptions", "(", "$", "resolver", ")", ";", "}", "reset", "(", "$", "types", ")", "->", "sort", "(", "$", "order", ",", "$", "resolver", "->", "resolve", "(", "array_merge", "(", "[", "'builder'", "=>", "$", "builder", ",", "'grid'", "=>", "$", "grid", ",", "'sort'", "=>", "$", "sort", "]", ",", "$", "sort", "->", "getOptions", "(", ")", ")", ")", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Sort/Sorter.php#L41-L61
php-lug/lug
src/Component/Grid/Sort/Sorter.php
Sorter.resolveTypes
private function resolveTypes($type) { $sortTypes = []; do { $sortTypes[] = $sortType = $this->sortRegistry[$type]; } while (($type = $sortType->getParent()) !== null); return $sortTypes; }
php
private function resolveTypes($type) { $sortTypes = []; do { $sortTypes[] = $sortType = $this->sortRegistry[$type]; } while (($type = $sortType->getParent()) !== null); return $sortTypes; }
[ "private", "function", "resolveTypes", "(", "$", "type", ")", "{", "$", "sortTypes", "=", "[", "]", ";", "do", "{", "$", "sortTypes", "[", "]", "=", "$", "sortType", "=", "$", "this", "->", "sortRegistry", "[", "$", "type", "]", ";", "}", "while", "(", "(", "$", "type", "=", "$", "sortType", "->", "getParent", "(", ")", ")", "!==", "null", ")", ";", "return", "$", "sortTypes", ";", "}" ]
@param string $type @return TypeInterface[]
[ "@param", "string", "$type" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Sort/Sorter.php#L68-L77
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.check_controller_hash_tmp_file
private function check_controller_hash_tmp_file() { if(is_writable(dirname($this->controllers_hash_file))) { App :: uses('File', 'Utility'); $file = new File($this->controllers_hash_file, true); return $file->exists(); } else { $this->Session->setFlash(sprintf(__d('acl', 'the %s directory is not writable'), dirname($this->controllers_hash_file)), 'Risto.flash_error', null, 'plugin_acl'); return false; } }
php
private function check_controller_hash_tmp_file() { if(is_writable(dirname($this->controllers_hash_file))) { App :: uses('File', 'Utility'); $file = new File($this->controllers_hash_file, true); return $file->exists(); } else { $this->Session->setFlash(sprintf(__d('acl', 'the %s directory is not writable'), dirname($this->controllers_hash_file)), 'Risto.flash_error', null, 'plugin_acl'); return false; } }
[ "private", "function", "check_controller_hash_tmp_file", "(", ")", "{", "if", "(", "is_writable", "(", "dirname", "(", "$", "this", "->", "controllers_hash_file", ")", ")", ")", "{", "App", "::", "uses", "(", "'File'", ",", "'Utility'", ")", ";", "$", "file", "=", "new", "File", "(", "$", "this", "->", "controllers_hash_file", ",", "true", ")", ";", "return", "$", "file", "->", "exists", "(", ")", ";", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "sprintf", "(", "__d", "(", "'acl'", ",", "'the %s directory is not writable'", ")", ",", "dirname", "(", "$", "this", "->", "controllers_hash_file", ")", ")", ",", "'Risto.flash_error'", ",", "null", ",", "'plugin_acl'", ")", ";", "return", "false", ";", "}", "}" ]
Check if the file containing the stored controllers hashes can be created, and create it if it does not exist @return boolean true if the file exists or could be created
[ "Check", "if", "the", "file", "containing", "the", "stored", "controllers", "hashes", "can", "be", "created", "and", "create", "it", "if", "it", "does", "not", "exist" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L31-L44
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.check_user_model_acts_as_acl_requester
public function check_user_model_acts_as_acl_requester($model_classname) { // if(!isset($this->controller->{$model_classname})) // { // /* // * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors // */ // $user_model = ClassRegistry :: init($model_classname); // } // else // { // $user_model = $this->controller->{$model_classname}; // } $user_model = $this->get_model_instance($model_classname); $behaviors = $user_model->actsAs; if(!empty($behaviors) && array_key_exists('Acl', $behaviors)) { $acl_behavior = $behaviors['Acl']; if($acl_behavior == 'requester') { return true; } elseif(is_array($acl_behavior) && isset($acl_behavior['type']) && $acl_behavior['type'] == 'requester') { return true; } } return false; }
php
public function check_user_model_acts_as_acl_requester($model_classname) { // if(!isset($this->controller->{$model_classname})) // { // /* // * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors // */ // $user_model = ClassRegistry :: init($model_classname); // } // else // { // $user_model = $this->controller->{$model_classname}; // } $user_model = $this->get_model_instance($model_classname); $behaviors = $user_model->actsAs; if(!empty($behaviors) && array_key_exists('Acl', $behaviors)) { $acl_behavior = $behaviors['Acl']; if($acl_behavior == 'requester') { return true; } elseif(is_array($acl_behavior) && isset($acl_behavior['type']) && $acl_behavior['type'] == 'requester') { return true; } } return false; }
[ "public", "function", "check_user_model_acts_as_acl_requester", "(", "$", "model_classname", ")", "{", "//\t\tif(!isset($this->controller->{$model_classname}))", "//\t\t{", "//\t\t\t/*", "//\t\t\t * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors", "//\t\t\t */", "//\t\t\t$user_model = ClassRegistry :: init($model_classname);", "//\t\t}", "//\t\telse", "//\t\t{", "//\t\t\t$user_model = $this->controller->{$model_classname};", "//\t\t}", "$", "user_model", "=", "$", "this", "->", "get_model_instance", "(", "$", "model_classname", ")", ";", "$", "behaviors", "=", "$", "user_model", "->", "actsAs", ";", "if", "(", "!", "empty", "(", "$", "behaviors", ")", "&&", "array_key_exists", "(", "'Acl'", ",", "$", "behaviors", ")", ")", "{", "$", "acl_behavior", "=", "$", "behaviors", "[", "'Acl'", "]", ";", "if", "(", "$", "acl_behavior", "==", "'requester'", ")", "{", "return", "true", ";", "}", "elseif", "(", "is_array", "(", "$", "acl_behavior", ")", "&&", "isset", "(", "$", "acl_behavior", "[", "'type'", "]", ")", "&&", "$", "acl_behavior", "[", "'type'", "]", "==", "'requester'", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
*************************************************************************************
[ "*************************************************************************************" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L48-L79
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.set_display_name
public function set_display_name($model_classname, $field_expression) { $model_instance = $this->get_model_instance($model_classname); $schema = $model_instance->schema(); if(array_key_exists($field_expression, $schema) || array_key_exists(str_replace($model_classname . '.', '', $field_expression), $schema) || array_key_exists($field_expression, $model_instance->virtualFields)) { /* * The field does not need to be created as it already exists in the model * as a datatable field, or a virtual field configured in the model */ /* * Eventually remove the model name */ if(strpos($field_expression, $model_classname . '.') === 0) { $field_expression = str_replace($model_classname . '.', '', $field_expression); } return $field_expression; } else { /* * The field does not exist in the model * -> create a virtual field with the given expression */ $this->controller->{$model_classname}->virtualFields['alaxos_acl_display_name'] = $field_expression; return 'alaxos_acl_display_name'; } }
php
public function set_display_name($model_classname, $field_expression) { $model_instance = $this->get_model_instance($model_classname); $schema = $model_instance->schema(); if(array_key_exists($field_expression, $schema) || array_key_exists(str_replace($model_classname . '.', '', $field_expression), $schema) || array_key_exists($field_expression, $model_instance->virtualFields)) { /* * The field does not need to be created as it already exists in the model * as a datatable field, or a virtual field configured in the model */ /* * Eventually remove the model name */ if(strpos($field_expression, $model_classname . '.') === 0) { $field_expression = str_replace($model_classname . '.', '', $field_expression); } return $field_expression; } else { /* * The field does not exist in the model * -> create a virtual field with the given expression */ $this->controller->{$model_classname}->virtualFields['alaxos_acl_display_name'] = $field_expression; return 'alaxos_acl_display_name'; } }
[ "public", "function", "set_display_name", "(", "$", "model_classname", ",", "$", "field_expression", ")", "{", "$", "model_instance", "=", "$", "this", "->", "get_model_instance", "(", "$", "model_classname", ")", ";", "$", "schema", "=", "$", "model_instance", "->", "schema", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "field_expression", ",", "$", "schema", ")", "||", "array_key_exists", "(", "str_replace", "(", "$", "model_classname", ".", "'.'", ",", "''", ",", "$", "field_expression", ")", ",", "$", "schema", ")", "||", "array_key_exists", "(", "$", "field_expression", ",", "$", "model_instance", "->", "virtualFields", ")", ")", "{", "/*\n\t * The field does not need to be created as it already exists in the model\n\t * as a datatable field, or a virtual field configured in the model\n\t */", "/*\n\t * Eventually remove the model name\n\t */", "if", "(", "strpos", "(", "$", "field_expression", ",", "$", "model_classname", ".", "'.'", ")", "===", "0", ")", "{", "$", "field_expression", "=", "str_replace", "(", "$", "model_classname", ".", "'.'", ",", "''", ",", "$", "field_expression", ")", ";", "}", "return", "$", "field_expression", ";", "}", "else", "{", "/*\n\t * The field does not exist in the model\n\t * -> create a virtual field with the given expression\n\t */", "$", "this", "->", "controller", "->", "{", "$", "model_classname", "}", "->", "virtualFields", "[", "'alaxos_acl_display_name'", "]", "=", "$", "field_expression", ";", "return", "'alaxos_acl_display_name'", ";", "}", "}" ]
Check if a given field_expression is an existing fieldname for the given model If it doesn't exist, a virtual field called 'alaxos_acl_display_name' is created with the given expression @param string $model_classname @param string $field_expression @return string The name of the field to use as display name
[ "Check", "if", "a", "given", "field_expression", "is", "an", "existing", "fieldname", "for", "the", "given", "model" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L90-L128
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.get_model_instance
private function get_model_instance($model_classname) { if(!isset($this->controller->{$model_classname})) { /* * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors */ $model_instance = ClassRegistry :: init($model_classname); } else { $model_instance = $this->controller->{$model_classname}; } return $model_instance; }
php
private function get_model_instance($model_classname) { if(!isset($this->controller->{$model_classname})) { /* * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors */ $model_instance = ClassRegistry :: init($model_classname); } else { $model_instance = $this->controller->{$model_classname}; } return $model_instance; }
[ "private", "function", "get_model_instance", "(", "$", "model_classname", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "{", "$", "model_classname", "}", ")", ")", "{", "/*\n\t\t\t * Do not use $this->controller->loadModel, as calling it from a plugin may prevent correct loading of behaviors\n\t\t\t */", "$", "model_instance", "=", "ClassRegistry", "::", "init", "(", "$", "model_classname", ")", ";", "}", "else", "{", "$", "model_instance", "=", "$", "this", "->", "controller", "->", "{", "$", "model_classname", "}", ";", "}", "return", "$", "model_instance", ";", "}" ]
Return an instance of the given model name @param string $model_classname @return Model
[ "Return", "an", "instance", "of", "the", "given", "model", "name" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L136-L151
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.get_stored_controllers_hashes
public function get_stored_controllers_hashes() { $file = new File($this->controllers_hash_file); $file_content = $file->read(); if(!empty($file_content)) { $stored_controller_hashes = unserialize($file_content); } else { $stored_controller_hashes = array(); } return $stored_controller_hashes; }
php
public function get_stored_controllers_hashes() { $file = new File($this->controllers_hash_file); $file_content = $file->read(); if(!empty($file_content)) { $stored_controller_hashes = unserialize($file_content); } else { $stored_controller_hashes = array(); } return $stored_controller_hashes; }
[ "public", "function", "get_stored_controllers_hashes", "(", ")", "{", "$", "file", "=", "new", "File", "(", "$", "this", "->", "controllers_hash_file", ")", ";", "$", "file_content", "=", "$", "file", "->", "read", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "file_content", ")", ")", "{", "$", "stored_controller_hashes", "=", "unserialize", "(", "$", "file_content", ")", ";", "}", "else", "{", "$", "stored_controller_hashes", "=", "array", "(", ")", ";", "}", "return", "$", "stored_controller_hashes", ";", "}" ]
return the stored array of controllers hashes @return array
[ "return", "the", "stored", "array", "of", "controllers", "hashes" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L158-L173
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.get_current_controllers_hashes
public function get_current_controllers_hashes() { $controllers = $this->AclReflector->get_all_controllers(); $current_controller_hashes = array(); foreach($controllers as $controller) { $ctler_file = new File($controller['file']); $current_controller_hashes[$controller['name']] = $ctler_file->md5(); } return $current_controller_hashes; }
php
public function get_current_controllers_hashes() { $controllers = $this->AclReflector->get_all_controllers(); $current_controller_hashes = array(); foreach($controllers as $controller) { $ctler_file = new File($controller['file']); $current_controller_hashes[$controller['name']] = $ctler_file->md5(); } return $current_controller_hashes; }
[ "public", "function", "get_current_controllers_hashes", "(", ")", "{", "$", "controllers", "=", "$", "this", "->", "AclReflector", "->", "get_all_controllers", "(", ")", ";", "$", "current_controller_hashes", "=", "array", "(", ")", ";", "foreach", "(", "$", "controllers", "as", "$", "controller", ")", "{", "$", "ctler_file", "=", "new", "File", "(", "$", "controller", "[", "'file'", "]", ")", ";", "$", "current_controller_hashes", "[", "$", "controller", "[", "'name'", "]", "]", "=", "$", "ctler_file", "->", "md5", "(", ")", ";", "}", "return", "$", "current_controller_hashes", ";", "}" ]
return an array of all controllers hashes @return array
[ "return", "an", "array", "of", "all", "controllers", "hashes" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L180-L193
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.get_missing_acos
public function get_missing_acos($update_hash_file = true) { if($this->check_controller_hash_tmp_file()) { $missing_aco_nodes = array(); $stored_controller_hashes = $this->get_stored_controllers_hashes(); $current_controller_hashes = $this->get_current_controllers_hashes(); /* * Store current controllers hashes on disk */ if($update_hash_file) { $file = new File($this->controllers_hash_file); $file->write(serialize($current_controller_hashes)); } /* * Check what controllers have changed */ $updated_controllers = array_keys(Set :: diff($current_controller_hashes, $stored_controller_hashes)); if(!empty($updated_controllers)) { $aco =& $this->Acl->Aco; foreach($updated_controllers as $controller_name) { if($controller_name !== 'App') { $controller_classname = $this->AclReflector->get_controller_classname($controller_name); $methods = $this->AclReflector->get_controller_actions($controller_classname); $aco =& $this->Acl->Aco; foreach($methods as $method) { $methodNode = $aco->node('controllers/' . $controller_name . '/' . $method); if(empty($methodNode)) { $missing_aco_nodes[] = $controller_name . '/' . $method; } } } } } return $missing_aco_nodes; } }
php
public function get_missing_acos($update_hash_file = true) { if($this->check_controller_hash_tmp_file()) { $missing_aco_nodes = array(); $stored_controller_hashes = $this->get_stored_controllers_hashes(); $current_controller_hashes = $this->get_current_controllers_hashes(); /* * Store current controllers hashes on disk */ if($update_hash_file) { $file = new File($this->controllers_hash_file); $file->write(serialize($current_controller_hashes)); } /* * Check what controllers have changed */ $updated_controllers = array_keys(Set :: diff($current_controller_hashes, $stored_controller_hashes)); if(!empty($updated_controllers)) { $aco =& $this->Acl->Aco; foreach($updated_controllers as $controller_name) { if($controller_name !== 'App') { $controller_classname = $this->AclReflector->get_controller_classname($controller_name); $methods = $this->AclReflector->get_controller_actions($controller_classname); $aco =& $this->Acl->Aco; foreach($methods as $method) { $methodNode = $aco->node('controllers/' . $controller_name . '/' . $method); if(empty($methodNode)) { $missing_aco_nodes[] = $controller_name . '/' . $method; } } } } } return $missing_aco_nodes; } }
[ "public", "function", "get_missing_acos", "(", "$", "update_hash_file", "=", "true", ")", "{", "if", "(", "$", "this", "->", "check_controller_hash_tmp_file", "(", ")", ")", "{", "$", "missing_aco_nodes", "=", "array", "(", ")", ";", "$", "stored_controller_hashes", "=", "$", "this", "->", "get_stored_controllers_hashes", "(", ")", ";", "$", "current_controller_hashes", "=", "$", "this", "->", "get_current_controllers_hashes", "(", ")", ";", "/*\n \t\t * Store current controllers hashes on disk\n \t\t */", "if", "(", "$", "update_hash_file", ")", "{", "$", "file", "=", "new", "File", "(", "$", "this", "->", "controllers_hash_file", ")", ";", "$", "file", "->", "write", "(", "serialize", "(", "$", "current_controller_hashes", ")", ")", ";", "}", "/*\n \t\t * Check what controllers have changed\n \t\t */", "$", "updated_controllers", "=", "array_keys", "(", "Set", "::", "diff", "(", "$", "current_controller_hashes", ",", "$", "stored_controller_hashes", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "updated_controllers", ")", ")", "{", "$", "aco", "=", "&", "$", "this", "->", "Acl", "->", "Aco", ";", "foreach", "(", "$", "updated_controllers", "as", "$", "controller_name", ")", "{", "if", "(", "$", "controller_name", "!==", "'App'", ")", "{", "$", "controller_classname", "=", "$", "this", "->", "AclReflector", "->", "get_controller_classname", "(", "$", "controller_name", ")", ";", "$", "methods", "=", "$", "this", "->", "AclReflector", "->", "get_controller_actions", "(", "$", "controller_classname", ")", ";", "$", "aco", "=", "&", "$", "this", "->", "Acl", "->", "Aco", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "methodNode", "=", "$", "aco", "->", "node", "(", "'controllers/'", ".", "$", "controller_name", ".", "'/'", ".", "$", "method", ")", ";", "if", "(", "empty", "(", "$", "methodNode", ")", ")", "{", "$", "missing_aco_nodes", "[", "]", "=", "$", "controller_name", ".", "'/'", ".", "$", "method", ";", "}", "}", "}", "}", "}", "return", "$", "missing_aco_nodes", ";", "}", "}" ]
Get a list of plugins, controllers and actions that don't have any corresponding ACO. To run faster, the method only checks controllers that have not already been checked or that have been modified. Depending on the $update_hash_file, the method may return the missing ACOs only once (in order to show the alert message only once in the view) @param boolean $update_hash_file If true, the method update the controller hash file, making the method returning missing ACOs only once @return array Array of missing ACO nodes by comparing with each existing plugin, controller and action
[ "Get", "a", "list", "of", "plugins", "controllers", "and", "actions", "that", "don", "t", "have", "any", "corresponding", "ACO", ".", "To", "run", "faster", "the", "method", "only", "checks", "controllers", "that", "have", "not", "already", "been", "checked", "or", "that", "have", "been", "modified", "." ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L205-L255
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.create_acos
public function create_acos() { $aco =& $this->Acl->Aco; $log = array(); $controllers = $this->AclReflector->get_all_controllers(); /****************************************** * Create 'controllers' node if it does not exist */ $root = $aco->node('controllers'); if (empty($root)) { /* * root node does not exist -> create it */ $aco->create(array('parent_id' => null, 'model' => null, 'alias' => 'controllers')); $root = $aco->save(); $root['Aco']['id'] = $aco->id; $log[] = __d('acl', 'Created Aco node for controllers'); } else { $root = $root[0]; } foreach($controllers as $controller) { $controller_name = $controller['name']; if($controller_name !== 'App') { $plugin_name = $this->AclReflector->getPluginName($controller_name); $pluginNode = null; if(!empty($plugin_name)) { /* * Case of plugin controller */ $controller_name = $this->AclReflector->getPluginControllerName($controller_name); /****************************************** * Check plugin node */ $pluginNode = $aco->node('controllers/' . $plugin_name); if(empty($pluginNode)) { /* * plugin node does not exist -> create it */ $aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $plugin_name)); $pluginNode = $aco->save(); $pluginNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s plugin'), $plugin_name); } } /****************************************** * Check controller node */ $controllerNode = $aco->node('controllers/' . (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name); if(empty($controllerNode)) { /* * controller node does not exist -> create it */ if(isset($pluginNode)) { /* * The controller belongs to a plugin */ $plugin_node_aco_id = isset($pluginNode[0]) ? $pluginNode[0]['Aco']['id'] : $pluginNode['Aco']['id']; $aco->create(array('parent_id' => $plugin_node_aco_id, 'model' => null, 'alias' => $controller_name)); $controllerNode = $aco->save(); $controllerNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s/%s'), $plugin_name, $controller_name); } else { /* * The controller is an app controller */ $aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $controller_name)); $controllerNode = $aco->save(); $controllerNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s'), $controller_name); } } else { $controllerNode = $controllerNode[0]; } /****************************************** * Check controller actions node */ $actions = $this->AclReflector->get_controller_actions($controller_name); foreach($actions as $action) { $actionNode = $aco->node('controllers/' . (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name . '/' . $action); if(empty($actionNode)) { /* * action node does not exist -> create it */ $aco->create(array('parent_id' => $controllerNode['Aco']['id'], 'model' => null, 'alias' => $action)); $methodNode = $aco->save(); $log[] = sprintf(__d('acl', 'Created Aco node for %s'), (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name . '/' . $action); } } } } return $log; }
php
public function create_acos() { $aco =& $this->Acl->Aco; $log = array(); $controllers = $this->AclReflector->get_all_controllers(); /****************************************** * Create 'controllers' node if it does not exist */ $root = $aco->node('controllers'); if (empty($root)) { /* * root node does not exist -> create it */ $aco->create(array('parent_id' => null, 'model' => null, 'alias' => 'controllers')); $root = $aco->save(); $root['Aco']['id'] = $aco->id; $log[] = __d('acl', 'Created Aco node for controllers'); } else { $root = $root[0]; } foreach($controllers as $controller) { $controller_name = $controller['name']; if($controller_name !== 'App') { $plugin_name = $this->AclReflector->getPluginName($controller_name); $pluginNode = null; if(!empty($plugin_name)) { /* * Case of plugin controller */ $controller_name = $this->AclReflector->getPluginControllerName($controller_name); /****************************************** * Check plugin node */ $pluginNode = $aco->node('controllers/' . $plugin_name); if(empty($pluginNode)) { /* * plugin node does not exist -> create it */ $aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $plugin_name)); $pluginNode = $aco->save(); $pluginNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s plugin'), $plugin_name); } } /****************************************** * Check controller node */ $controllerNode = $aco->node('controllers/' . (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name); if(empty($controllerNode)) { /* * controller node does not exist -> create it */ if(isset($pluginNode)) { /* * The controller belongs to a plugin */ $plugin_node_aco_id = isset($pluginNode[0]) ? $pluginNode[0]['Aco']['id'] : $pluginNode['Aco']['id']; $aco->create(array('parent_id' => $plugin_node_aco_id, 'model' => null, 'alias' => $controller_name)); $controllerNode = $aco->save(); $controllerNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s/%s'), $plugin_name, $controller_name); } else { /* * The controller is an app controller */ $aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $controller_name)); $controllerNode = $aco->save(); $controllerNode['Aco']['id'] = $aco->id; $log[] = sprintf(__d('acl', 'Created Aco node for %s'), $controller_name); } } else { $controllerNode = $controllerNode[0]; } /****************************************** * Check controller actions node */ $actions = $this->AclReflector->get_controller_actions($controller_name); foreach($actions as $action) { $actionNode = $aco->node('controllers/' . (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name . '/' . $action); if(empty($actionNode)) { /* * action node does not exist -> create it */ $aco->create(array('parent_id' => $controllerNode['Aco']['id'], 'model' => null, 'alias' => $action)); $methodNode = $aco->save(); $log[] = sprintf(__d('acl', 'Created Aco node for %s'), (!empty($plugin_name) ? $plugin_name . '/' : '') . $controller_name . '/' . $action); } } } } return $log; }
[ "public", "function", "create_acos", "(", ")", "{", "$", "aco", "=", "&", "$", "this", "->", "Acl", "->", "Aco", ";", "$", "log", "=", "array", "(", ")", ";", "$", "controllers", "=", "$", "this", "->", "AclReflector", "->", "get_all_controllers", "(", ")", ";", "/******************************************\n\t * Create 'controllers' node if it does not exist\n\t */", "$", "root", "=", "$", "aco", "->", "node", "(", "'controllers'", ")", ";", "if", "(", "empty", "(", "$", "root", ")", ")", "{", "/*\n\t\t * root node does not exist -> create it\n\t\t */", "$", "aco", "->", "create", "(", "array", "(", "'parent_id'", "=>", "null", ",", "'model'", "=>", "null", ",", "'alias'", "=>", "'controllers'", ")", ")", ";", "$", "root", "=", "$", "aco", "->", "save", "(", ")", ";", "$", "root", "[", "'Aco'", "]", "[", "'id'", "]", "=", "$", "aco", "->", "id", ";", "$", "log", "[", "]", "=", "__d", "(", "'acl'", ",", "'Created Aco node for controllers'", ")", ";", "}", "else", "{", "$", "root", "=", "$", "root", "[", "0", "]", ";", "}", "foreach", "(", "$", "controllers", "as", "$", "controller", ")", "{", "$", "controller_name", "=", "$", "controller", "[", "'name'", "]", ";", "if", "(", "$", "controller_name", "!==", "'App'", ")", "{", "$", "plugin_name", "=", "$", "this", "->", "AclReflector", "->", "getPluginName", "(", "$", "controller_name", ")", ";", "$", "pluginNode", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "plugin_name", ")", ")", "{", "/*\n \t * Case of plugin controller\n \t */", "$", "controller_name", "=", "$", "this", "->", "AclReflector", "->", "getPluginControllerName", "(", "$", "controller_name", ")", ";", "/******************************************\n \t * Check plugin node\n \t */", "$", "pluginNode", "=", "$", "aco", "->", "node", "(", "'controllers/'", ".", "$", "plugin_name", ")", ";", "if", "(", "empty", "(", "$", "pluginNode", ")", ")", "{", "/*\n \t * plugin node does not exist -> create it\n \t */", "$", "aco", "->", "create", "(", "array", "(", "'parent_id'", "=>", "$", "root", "[", "'Aco'", "]", "[", "'id'", "]", ",", "'model'", "=>", "null", ",", "'alias'", "=>", "$", "plugin_name", ")", ")", ";", "$", "pluginNode", "=", "$", "aco", "->", "save", "(", ")", ";", "$", "pluginNode", "[", "'Aco'", "]", "[", "'id'", "]", "=", "$", "aco", "->", "id", ";", "$", "log", "[", "]", "=", "sprintf", "(", "__d", "(", "'acl'", ",", "'Created Aco node for %s plugin'", ")", ",", "$", "plugin_name", ")", ";", "}", "}", "/******************************************\n \t * Check controller node\n \t */", "$", "controllerNode", "=", "$", "aco", "->", "node", "(", "'controllers/'", ".", "(", "!", "empty", "(", "$", "plugin_name", ")", "?", "$", "plugin_name", ".", "'/'", ":", "''", ")", ".", "$", "controller_name", ")", ";", "if", "(", "empty", "(", "$", "controllerNode", ")", ")", "{", "/*\n * controller node does not exist -> create it\n */", "if", "(", "isset", "(", "$", "pluginNode", ")", ")", "{", "/*\n * The controller belongs to a plugin\n */", "$", "plugin_node_aco_id", "=", "isset", "(", "$", "pluginNode", "[", "0", "]", ")", "?", "$", "pluginNode", "[", "0", "]", "[", "'Aco'", "]", "[", "'id'", "]", ":", "$", "pluginNode", "[", "'Aco'", "]", "[", "'id'", "]", ";", "$", "aco", "->", "create", "(", "array", "(", "'parent_id'", "=>", "$", "plugin_node_aco_id", ",", "'model'", "=>", "null", ",", "'alias'", "=>", "$", "controller_name", ")", ")", ";", "$", "controllerNode", "=", "$", "aco", "->", "save", "(", ")", ";", "$", "controllerNode", "[", "'Aco'", "]", "[", "'id'", "]", "=", "$", "aco", "->", "id", ";", "$", "log", "[", "]", "=", "sprintf", "(", "__d", "(", "'acl'", ",", "'Created Aco node for %s/%s'", ")", ",", "$", "plugin_name", ",", "$", "controller_name", ")", ";", "}", "else", "{", "/*\n * The controller is an app controller\n */", "$", "aco", "->", "create", "(", "array", "(", "'parent_id'", "=>", "$", "root", "[", "'Aco'", "]", "[", "'id'", "]", ",", "'model'", "=>", "null", ",", "'alias'", "=>", "$", "controller_name", ")", ")", ";", "$", "controllerNode", "=", "$", "aco", "->", "save", "(", ")", ";", "$", "controllerNode", "[", "'Aco'", "]", "[", "'id'", "]", "=", "$", "aco", "->", "id", ";", "$", "log", "[", "]", "=", "sprintf", "(", "__d", "(", "'acl'", ",", "'Created Aco node for %s'", ")", ",", "$", "controller_name", ")", ";", "}", "}", "else", "{", "$", "controllerNode", "=", "$", "controllerNode", "[", "0", "]", ";", "}", "/******************************************\n \t * Check controller actions node\n \t */", "$", "actions", "=", "$", "this", "->", "AclReflector", "->", "get_controller_actions", "(", "$", "controller_name", ")", ";", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "$", "actionNode", "=", "$", "aco", "->", "node", "(", "'controllers/'", ".", "(", "!", "empty", "(", "$", "plugin_name", ")", "?", "$", "plugin_name", ".", "'/'", ":", "''", ")", ".", "$", "controller_name", ".", "'/'", ".", "$", "action", ")", ";", "if", "(", "empty", "(", "$", "actionNode", ")", ")", "{", "/*\n \t * action node does not exist -> create it\n \t */", "$", "aco", "->", "create", "(", "array", "(", "'parent_id'", "=>", "$", "controllerNode", "[", "'Aco'", "]", "[", "'id'", "]", ",", "'model'", "=>", "null", ",", "'alias'", "=>", "$", "action", ")", ")", ";", "$", "methodNode", "=", "$", "aco", "->", "save", "(", ")", ";", "$", "log", "[", "]", "=", "sprintf", "(", "__d", "(", "'acl'", ",", "'Created Aco node for %s'", ")", ",", "(", "!", "empty", "(", "$", "plugin_name", ")", "?", "$", "plugin_name", ".", "'/'", ":", "''", ")", ".", "$", "controller_name", ".", "'/'", ".", "$", "action", ")", ";", "}", "}", "}", "}", "return", "$", "log", ";", "}" ]
Store missing ACOs for all actions in the datasource If necessary, it creates actions parent nodes (plugin and controller) as well
[ "Store", "missing", "ACOs", "for", "all", "actions", "in", "the", "datasource", "If", "necessary", "it", "creates", "actions", "parent", "nodes", "(", "plugin", "and", "controller", ")", "as", "well" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L261-L394
brick/di
src/InjectionPolicy/AnnotationPolicy.php
AnnotationPolicy.isClassInjected
public function isClassInjected(\ReflectionClass $class) : bool { foreach ($this->reader->getClassAnnotations($class) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
php
public function isClassInjected(\ReflectionClass $class) : bool { foreach ($this->reader->getClassAnnotations($class) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
[ "public", "function", "isClassInjected", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "reader", "->", "getClassAnnotations", "(", "$", "class", ")", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "instanceof", "Inject", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/InjectionPolicy/AnnotationPolicy.php#L40-L49
brick/di
src/InjectionPolicy/AnnotationPolicy.php
AnnotationPolicy.isMethodInjected
public function isMethodInjected(\ReflectionMethod $method) : bool { foreach ($this->reader->getMethodAnnotations($method) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
php
public function isMethodInjected(\ReflectionMethod $method) : bool { foreach ($this->reader->getMethodAnnotations($method) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
[ "public", "function", "isMethodInjected", "(", "\\", "ReflectionMethod", "$", "method", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "reader", "->", "getMethodAnnotations", "(", "$", "method", ")", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "instanceof", "Inject", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/InjectionPolicy/AnnotationPolicy.php#L54-L63
brick/di
src/InjectionPolicy/AnnotationPolicy.php
AnnotationPolicy.isPropertyInjected
public function isPropertyInjected(\ReflectionProperty $property) : bool { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
php
public function isPropertyInjected(\ReflectionProperty $property) : bool { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof Inject) { return true; } } return false; }
[ "public", "function", "isPropertyInjected", "(", "\\", "ReflectionProperty", "$", "property", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "reader", "->", "getPropertyAnnotations", "(", "$", "property", ")", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "instanceof", "Inject", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/InjectionPolicy/AnnotationPolicy.php#L68-L77
brick/di
src/InjectionPolicy/AnnotationPolicy.php
AnnotationPolicy.getParameterKey
public function getParameterKey(\ReflectionParameter $parameter) : ?string { $function = $parameter->getDeclaringFunction(); if ($function instanceof \ReflectionMethod) { foreach ($this->reader->getMethodAnnotations($function) as $annotation) { if ($annotation instanceof Inject) { return $annotation->getValue($parameter->getName()); } } } return null; }
php
public function getParameterKey(\ReflectionParameter $parameter) : ?string { $function = $parameter->getDeclaringFunction(); if ($function instanceof \ReflectionMethod) { foreach ($this->reader->getMethodAnnotations($function) as $annotation) { if ($annotation instanceof Inject) { return $annotation->getValue($parameter->getName()); } } } return null; }
[ "public", "function", "getParameterKey", "(", "\\", "ReflectionParameter", "$", "parameter", ")", ":", "?", "string", "{", "$", "function", "=", "$", "parameter", "->", "getDeclaringFunction", "(", ")", ";", "if", "(", "$", "function", "instanceof", "\\", "ReflectionMethod", ")", "{", "foreach", "(", "$", "this", "->", "reader", "->", "getMethodAnnotations", "(", "$", "function", ")", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "instanceof", "Inject", ")", "{", "return", "$", "annotation", "->", "getValue", "(", "$", "parameter", "->", "getName", "(", ")", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/InjectionPolicy/AnnotationPolicy.php#L82-L95
brick/di
src/InjectionPolicy/AnnotationPolicy.php
AnnotationPolicy.getPropertyKey
public function getPropertyKey(\ReflectionProperty $property) : ?string { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof Inject) { return $annotation->getSingleValue(); } } return null; }
php
public function getPropertyKey(\ReflectionProperty $property) : ?string { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof Inject) { return $annotation->getSingleValue(); } } return null; }
[ "public", "function", "getPropertyKey", "(", "\\", "ReflectionProperty", "$", "property", ")", ":", "?", "string", "{", "foreach", "(", "$", "this", "->", "reader", "->", "getPropertyAnnotations", "(", "$", "property", ")", "as", "$", "annotation", ")", "{", "if", "(", "$", "annotation", "instanceof", "Inject", ")", "{", "return", "$", "annotation", "->", "getSingleValue", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/InjectionPolicy/AnnotationPolicy.php#L100-L109
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Twig/ServiceProvider.php
ServiceProvider.register
public function register(Application $app) { /** @var Translator $translator */ $translator = $app['translator']; /** @var Collection $writerCollection */ $writerCollection = $app['transformer.writer.collection']; $writerCollection['twig'] = new Writer\Twig(); $writerCollection['twig']->setTranslator($translator); }
php
public function register(Application $app) { /** @var Translator $translator */ $translator = $app['translator']; /** @var Collection $writerCollection */ $writerCollection = $app['transformer.writer.collection']; $writerCollection['twig'] = new Writer\Twig(); $writerCollection['twig']->setTranslator($translator); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "/** @var Translator $translator */", "$", "translator", "=", "$", "app", "[", "'translator'", "]", ";", "/** @var Collection $writerCollection */", "$", "writerCollection", "=", "$", "app", "[", "'transformer.writer.collection'", "]", ";", "$", "writerCollection", "[", "'twig'", "]", "=", "new", "Writer", "\\", "Twig", "(", ")", ";", "$", "writerCollection", "[", "'twig'", "]", "->", "setTranslator", "(", "$", "translator", ")", ";", "}" ]
Registers services on the given app. @param Application $app An Application instance.
[ "Registers", "services", "on", "the", "given", "app", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Twig/ServiceProvider.php#L34-L44
gedex/php-janrain-api
lib/Janrain/Api/Engage/LegacySharing.php
LegacySharing.setStatus
public function setStatus(array $params) { if (!isset($params['identifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['status'])) { throw new MissingArgumentException('status'); } return $this->post('set_status', $params); }
php
public function setStatus(array $params) { if (!isset($params['identifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['status'])) { throw new MissingArgumentException('status'); } return $this->post('set_status', $params); }
[ "public", "function", "setStatus", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'identifier'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'status'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'status'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'set_status'", ",", "$", "params", ")", ";", "}" ]
Updates the user status using the current signed in identity provider. @param array $params @link http://developers.janrain.com/documentation/api-methods/engage/legacy/set_status/
[ "Updates", "the", "user", "status", "using", "the", "current", "signed", "in", "identity", "provider", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/LegacySharing.php#L51-L62
ajgarlag/AjglSessionConcurrency
src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
PdoSessionRegistryStorage.createTable
public function createTable() { // connect if we are not yet $this->getConnection(); switch ($this->driver) { case 'mysql': // We use varbinary for the ID column because it prevents unwanted conversions: // - character set conversions between server and client // - trailing space removal // - case-insensitivity // - language processing like é == e $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB"; break; case 'sqlite': $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'pgsql': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'oci': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'sqlsrv': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; default: throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver)); } try { $this->getConnection()->exec($sql); } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e); } }
php
public function createTable() { // connect if we are not yet $this->getConnection(); switch ($this->driver) { case 'mysql': // We use varbinary for the ID column because it prevents unwanted conversions: // - character set conversions between server and client // - trailing space removal // - case-insensitivity // - language processing like é == e $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB"; break; case 'sqlite': $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'pgsql': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'oci': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; case 'sqlsrv': $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)"; break; default: throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver)); } try { $this->getConnection()->exec($sql); } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e); } }
[ "public", "function", "createTable", "(", ")", "{", "// connect if we are not yet", "$", "this", "->", "getConnection", "(", ")", ";", "switch", "(", "$", "this", "->", "driver", ")", "{", "case", "'mysql'", ":", "// We use varbinary for the ID column because it prevents unwanted conversions:", "// - character set conversions between server and client", "// - trailing space removal", "// - case-insensitivity", "// - language processing like é == e", "$", "sql", "=", "\"CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB\"", ";", "break", ";", "case", "'sqlite'", ":", "$", "sql", "=", "\"CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"", ";", "break", ";", "case", "'pgsql'", ":", "$", "sql", "=", "\"CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"", ";", "break", ";", "case", "'oci'", ":", "$", "sql", "=", "\"CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"", ";", "break", ";", "case", "'sqlsrv'", ":", "$", "sql", "=", "\"CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)\"", ";", "break", ";", "default", ":", "throw", "new", "\\", "DomainException", "(", "sprintf", "(", "'Creating the session table is currently not implemented for PDO driver \"%s\".'", ",", "$", "this", "->", "driver", ")", ")", ";", "}", "try", "{", "$", "this", "->", "getConnection", "(", ")", "->", "exec", "(", "$", "sql", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'PDOException was thrown when trying to create sessions info table: %s'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Creates the table to store sessions which can be called once for setup. Session ID is saved in a column of maximum length 128 because that is enough even for a 512 bit configured session.hash_function like Whirlpool. Session username is saved in a varchar of maximun length 256 because any valid email should fit into it. One could also use a larger column if one was sure the data dfits into it. @throws \RuntimeException When the table cannot be created @throws \DomainException When an unsupported PDO driver is used
[ "Creates", "the", "table", "to", "store", "sessions", "which", "can", "be", "called", "once", "for", "setup", "." ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php#L134-L169
ajgarlag/AjglSessionConcurrency
src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
PdoSessionRegistryStorage.collectGarbage
public function collectGarbage($maxLifetime) { // delete the session records that have expired $sql = "DELETE FROM $this->table WHERE $this->lastUsedCol < :time"; try { $stmt = $this->getConnection()->prepare($sql); $stmt->bindValue(':time', time() - $maxLifetime, \PDO::PARAM_INT); $stmt->execute(); } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions info: %s', $e->getMessage()), 0, $e); } }
php
public function collectGarbage($maxLifetime) { // delete the session records that have expired $sql = "DELETE FROM $this->table WHERE $this->lastUsedCol < :time"; try { $stmt = $this->getConnection()->prepare($sql); $stmt->bindValue(':time', time() - $maxLifetime, \PDO::PARAM_INT); $stmt->execute(); } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions info: %s', $e->getMessage()), 0, $e); } }
[ "public", "function", "collectGarbage", "(", "$", "maxLifetime", ")", "{", "// delete the session records that have expired", "$", "sql", "=", "\"DELETE FROM $this->table WHERE $this->lastUsedCol < :time\"", ";", "try", "{", "$", "stmt", "=", "$", "this", "->", "getConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "$", "stmt", "->", "bindValue", "(", "':time'", ",", "time", "(", ")", "-", "$", "maxLifetime", ",", "\\", "PDO", "::", "PARAM_INT", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'PDOException was thrown when trying to delete expired sessions info: %s'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php#L174-L186
ajgarlag/AjglSessionConcurrency
src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
PdoSessionRegistryStorage.getSessionInformation
public function getSessionInformation($sessionId) { $sql = "SELECT $this->usernameCol, $this->lastUsedCol, $this->expiredCol FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->getConnection()->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); if ($sessionRows) { return new SessionInformation($sessionId, $sessionRows[0][0], $sessionRows[0][1], $sessionRows[0][2]); } } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session info: %s', $e->getMessage()), 0, $e); } }
php
public function getSessionInformation($sessionId) { $sql = "SELECT $this->usernameCol, $this->lastUsedCol, $this->expiredCol FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->getConnection()->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); if ($sessionRows) { return new SessionInformation($sessionId, $sessionRows[0][0], $sessionRows[0][1], $sessionRows[0][2]); } } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session info: %s', $e->getMessage()), 0, $e); } }
[ "public", "function", "getSessionInformation", "(", "$", "sessionId", ")", "{", "$", "sql", "=", "\"SELECT $this->usernameCol, $this->lastUsedCol, $this->expiredCol FROM $this->table WHERE $this->idCol = :id\"", ";", "try", "{", "$", "stmt", "=", "$", "this", "->", "getConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "$", "stmt", "->", "bindParam", "(", "':id'", ",", "$", "sessionId", ",", "\\", "PDO", "::", "PARAM_STR", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "// We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed", "$", "sessionRows", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_NUM", ")", ";", "if", "(", "$", "sessionRows", ")", "{", "return", "new", "SessionInformation", "(", "$", "sessionId", ",", "$", "sessionRows", "[", "0", "]", "[", "0", "]", ",", "$", "sessionRows", "[", "0", "]", "[", "1", "]", ",", "$", "sessionRows", "[", "0", "]", "[", "2", "]", ")", ";", "}", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'PDOException was thrown when trying to read the session info: %s'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php#L191-L209
ajgarlag/AjglSessionConcurrency
src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
PdoSessionRegistryStorage.getMergeSql
private function getMergeSql() { // connect if we are not yet $this->getConnection(); switch ($this->driver) { case 'mysql': return "INSERT INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "ON DUPLICATE KEY UPDATE $this->usernameCol = VALUES($this->usernameCol), $this->lastUsedCol = VALUES($this->lastUsedCol), $this->expiredCol = VALUES($this->expiredCol)"; case 'oci': // DUAL is Oracle specific dummy table return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired"; case 'sqlsrv' === $this->driver && version_compare($this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired;"; case 'sqlite': return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired)"; } }
php
private function getMergeSql() { // connect if we are not yet $this->getConnection(); switch ($this->driver) { case 'mysql': return "INSERT INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "ON DUPLICATE KEY UPDATE $this->usernameCol = VALUES($this->usernameCol), $this->lastUsedCol = VALUES($this->lastUsedCol), $this->expiredCol = VALUES($this->expiredCol)"; case 'oci': // DUAL is Oracle specific dummy table return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired"; case 'sqlsrv' === $this->driver && version_compare($this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) ". "WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired;"; case 'sqlite': return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired)"; } }
[ "private", "function", "getMergeSql", "(", ")", "{", "// connect if we are not yet", "$", "this", "->", "getConnection", "(", ")", ";", "switch", "(", "$", "this", "->", "driver", ")", "{", "case", "'mysql'", ":", "return", "\"INSERT INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) \"", ".", "\"ON DUPLICATE KEY UPDATE $this->usernameCol = VALUES($this->usernameCol), $this->lastUsedCol = VALUES($this->lastUsedCol), $this->expiredCol = VALUES($this->expiredCol)\"", ";", "case", "'oci'", ":", "// DUAL is Oracle specific dummy table", "return", "\"MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) \"", ".", "\"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) \"", ".", "\"WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired\"", ";", "case", "'sqlsrv'", "===", "$", "this", "->", "driver", "&&", "version_compare", "(", "$", "this", "->", "getConnection", "(", ")", "->", "getAttribute", "(", "\\", "PDO", "::", "ATTR_SERVER_VERSION", ")", ",", "'10'", ",", "'>='", ")", ":", "// MERGE is only available since SQL Server 2008 and must be terminated by semicolon", "// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx", "return", "\"MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) \"", ".", "\"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired) \"", ".", "\"WHEN MATCHED THEN UPDATE SET $this->usernameCol = :username, $this->lastUsedCol = :last_used, $this->expiredCol = :expired;\"", ";", "case", "'sqlite'", ":", "return", "\"INSERT OR REPLACE INTO $this->table ($this->idCol, $this->usernameCol, $this->lastUsedCol, $this->expiredCol) VALUES (:id, :username, :last_used, :expired)\"", ";", "}", "}" ]
Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. @return string|null The SQL string or null when not supported
[ "Returns", "a", "merge", "/", "upsert", "(", "i", ".", "e", ".", "insert", "or", "update", ")", "SQL", "query", "when", "supported", "by", "the", "database", "." ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php#L309-L332
expectation-php/expect
src/matcher/ToPrint.php
ToPrint.match
public function match($actual) { ob_start(); $actual(); $this->actual = ob_get_clean(); return $this->actual === $this->expected; }
php
public function match($actual) { ob_start(); $actual(); $this->actual = ob_get_clean(); return $this->actual === $this->expected; }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "ob_start", "(", ")", ";", "$", "actual", "(", ")", ";", "$", "this", "->", "actual", "=", "ob_get_clean", "(", ")", ";", "return", "$", "this", "->", "actual", "===", "$", "this", "->", "expected", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToPrint.php#L53-L60
expectation-php/expect
src/matcher/ToPrint.php
ToPrint.reportFailed
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->expected) ->appendText(', got ') ->appendValue($this->actual); }
php
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->expected) ->appendText(', got ') ->appendValue($this->actual); }
[ "public", "function", "reportFailed", "(", "FailedMessage", "$", "message", ")", "{", "$", "message", "->", "appendText", "(", "'Expected '", ")", "->", "appendValue", "(", "$", "this", "->", "expected", ")", "->", "appendText", "(", "', got '", ")", "->", "appendValue", "(", "$", "this", "->", "actual", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToPrint.php#L65-L71
zeropingheroes/steam-browser-protocol
src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php
SteamBrowserProtocol.connectToServer
public function connectToServer($address, $options = array()) { $parameters = NULL; if ( array_key_exists('port', $options) ) { $parameters = ':'.$options['port']; } if ( array_key_exists('password', $options) ) { $parameters .= '/'.$options['password']; } return $this->protocol.'connect/'.$address.$parameters; }
php
public function connectToServer($address, $options = array()) { $parameters = NULL; if ( array_key_exists('port', $options) ) { $parameters = ':'.$options['port']; } if ( array_key_exists('password', $options) ) { $parameters .= '/'.$options['password']; } return $this->protocol.'connect/'.$address.$parameters; }
[ "public", "function", "connectToServer", "(", "$", "address", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "parameters", "=", "NULL", ";", "if", "(", "array_key_exists", "(", "'port'", ",", "$", "options", ")", ")", "{", "$", "parameters", "=", "':'", ".", "$", "options", "[", "'port'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'password'", ",", "$", "options", ")", ")", "{", "$", "parameters", ".=", "'/'", ".", "$", "options", "[", "'password'", "]", ";", "}", "return", "$", "this", "->", "protocol", ".", "'connect/'", ".", "$", "address", ".", "$", "parameters", ";", "}" ]
Generates a link to connecto the specified server @param string $address Server IP or hostname @param array $options Server port and password @return string
[ "Generates", "a", "link", "to", "connecto", "the", "specified", "server" ]
train
https://github.com/zeropingheroes/steam-browser-protocol/blob/1fce6740f2aed27480be5231351656aadcbf1d39/src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php#L112-L125
zeropingheroes/steam-browser-protocol
src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php
SteamBrowserProtocol.openSteamPage
public function openSteamPage($page, $parameter = NULL) { if( in_array($page, $this->steamPages) ) { return $this->protocol.'url/'.$page.'/'.$parameter; } }
php
public function openSteamPage($page, $parameter = NULL) { if( in_array($page, $this->steamPages) ) { return $this->protocol.'url/'.$page.'/'.$parameter; } }
[ "public", "function", "openSteamPage", "(", "$", "page", ",", "$", "parameter", "=", "NULL", ")", "{", "if", "(", "in_array", "(", "$", "page", ",", "$", "this", "->", "steamPages", ")", ")", "{", "return", "$", "this", "->", "protocol", ".", "'url/'", ".", "$", "page", ".", "'/'", ".", "$", "parameter", ";", "}", "}" ]
Generates a link to open the specified named page @param string $page Page @param array $parameter Additional parameter @return string
[ "Generates", "a", "link", "to", "open", "the", "specified", "named", "page" ]
train
https://github.com/zeropingheroes/steam-browser-protocol/blob/1fce6740f2aed27480be5231351656aadcbf1d39/src/Zeropingheroes/SteamBrowserProtocol/SteamBrowserProtocol.php#L295-L301
garf/laravel-title
src/LaravelTitleServiceProvider.php
LaravelTitleServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__ . '/../config/laravel-title.php', 'laravel-title' ); $this->registerLaravelTitle(); $this->app->alias('Title', \Garf\LaravelTitle\Title::class); }
php
public function register() { $this->mergeConfigFrom( __DIR__ . '/../config/laravel-title.php', 'laravel-title' ); $this->registerLaravelTitle(); $this->app->alias('Title', \Garf\LaravelTitle\Title::class); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../config/laravel-title.php'", ",", "'laravel-title'", ")", ";", "$", "this", "->", "registerLaravelTitle", "(", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'Title'", ",", "\\", "Garf", "\\", "LaravelTitle", "\\", "Title", "::", "class", ")", ";", "}" ]
Register the application services. @return void
[ "Register", "the", "application", "services", "." ]
train
https://github.com/garf/laravel-title/blob/54b939b67fdd48d1579c9231d3a13a505279e1cd/src/LaravelTitleServiceProvider.php#L26-L34
songshenzong/log
src/DataCollector/QueryCollector.php
QueryCollector.setExplainSource
public function setExplainSource($enabled, $types) { $this->explainQuery = $enabled; if ($types) { $this->explainTypes = $types; } }
php
public function setExplainSource($enabled, $types) { $this->explainQuery = $enabled; if ($types) { $this->explainTypes = $types; } }
[ "public", "function", "setExplainSource", "(", "$", "enabled", ",", "$", "types", ")", "{", "$", "this", "->", "explainQuery", "=", "$", "enabled", ";", "if", "(", "$", "types", ")", "{", "$", "this", "->", "explainTypes", "=", "$", "types", ";", "}", "}" ]
Enable/disable the EXPLAIN queries @param bool $enabled @param array|null $types Array of types to explain queries (select/insert/update/delete)
[ "Enable", "/", "disable", "the", "EXPLAIN", "queries" ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/QueryCollector.php#L97-L103
songshenzong/log
src/DataCollector/QueryCollector.php
QueryCollector.findSource
protected function findSource() { $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); $sources = []; foreach ($stack as $index => $trace) { $sources[] = $this->parseTrace($index, $trace); } return array_filter($sources); }
php
protected function findSource() { $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); $sources = []; foreach ($stack as $index => $trace) { $sources[] = $this->parseTrace($index, $trace); } return array_filter($sources); }
[ "protected", "function", "findSource", "(", ")", "{", "$", "stack", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", "|", "DEBUG_BACKTRACE_PROVIDE_OBJECT", ")", ";", "$", "sources", "=", "[", "]", ";", "foreach", "(", "$", "stack", "as", "$", "index", "=>", "$", "trace", ")", "{", "$", "sources", "[", "]", "=", "$", "this", "->", "parseTrace", "(", "$", "index", ",", "$", "trace", ")", ";", "}", "return", "array_filter", "(", "$", "sources", ")", ";", "}" ]
Use a backtrace to search for the origins of the query. @return array
[ "Use", "a", "backtrace", "to", "search", "for", "the", "origins", "of", "the", "query", "." ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/QueryCollector.php#L215-L226
songshenzong/log
src/DataCollector/QueryCollector.php
QueryCollector.parseTrace
protected function parseTrace($index, array $trace) { $frame = (object) [ 'index' => $index, 'namespace' => null, 'name' => null, 'line' => isset($trace['line']) ? $trace['line'] : '?', ]; if (isset($trace['function']) && $trace['function'] == 'substituteBindings') { $frame->name = 'Route binding'; return $frame; } if (isset($trace['class']) && isset($trace['file']) && strpos( $trace['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework' ) === false && strpos( $trace['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar' ) === false ) { $file = $trace['file']; if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) { list($file, $frame->line) = $this->getTwigInfo($trace); } elseif (strpos($file, storage_path()) !== false) { $hash = pathinfo($file, PATHINFO_FILENAME); if (!$frame->name = $this->findViewFromHash($hash)) { $frame->name = $hash; } $frame->namespace = 'view'; return $frame; } elseif (strpos($file, 'Middleware') !== false) { $frame->name = $this->findMiddlewareFromFile($file); if ($frame->name) { $frame->namespace = 'middleware'; } else { $frame->name = $this->normalizeFilename($file); } return $frame; } $frame->name = $this->normalizeFilename($file); return $frame; } return false; }
php
protected function parseTrace($index, array $trace) { $frame = (object) [ 'index' => $index, 'namespace' => null, 'name' => null, 'line' => isset($trace['line']) ? $trace['line'] : '?', ]; if (isset($trace['function']) && $trace['function'] == 'substituteBindings') { $frame->name = 'Route binding'; return $frame; } if (isset($trace['class']) && isset($trace['file']) && strpos( $trace['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework' ) === false && strpos( $trace['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar' ) === false ) { $file = $trace['file']; if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) { list($file, $frame->line) = $this->getTwigInfo($trace); } elseif (strpos($file, storage_path()) !== false) { $hash = pathinfo($file, PATHINFO_FILENAME); if (!$frame->name = $this->findViewFromHash($hash)) { $frame->name = $hash; } $frame->namespace = 'view'; return $frame; } elseif (strpos($file, 'Middleware') !== false) { $frame->name = $this->findMiddlewareFromFile($file); if ($frame->name) { $frame->namespace = 'middleware'; } else { $frame->name = $this->normalizeFilename($file); } return $frame; } $frame->name = $this->normalizeFilename($file); return $frame; } return false; }
[ "protected", "function", "parseTrace", "(", "$", "index", ",", "array", "$", "trace", ")", "{", "$", "frame", "=", "(", "object", ")", "[", "'index'", "=>", "$", "index", ",", "'namespace'", "=>", "null", ",", "'name'", "=>", "null", ",", "'line'", "=>", "isset", "(", "$", "trace", "[", "'line'", "]", ")", "?", "$", "trace", "[", "'line'", "]", ":", "'?'", ",", "]", ";", "if", "(", "isset", "(", "$", "trace", "[", "'function'", "]", ")", "&&", "$", "trace", "[", "'function'", "]", "==", "'substituteBindings'", ")", "{", "$", "frame", "->", "name", "=", "'Route binding'", ";", "return", "$", "frame", ";", "}", "if", "(", "isset", "(", "$", "trace", "[", "'class'", "]", ")", "&&", "isset", "(", "$", "trace", "[", "'file'", "]", ")", "&&", "strpos", "(", "$", "trace", "[", "'file'", "]", ",", "DIRECTORY_SEPARATOR", ".", "'vendor'", ".", "DIRECTORY_SEPARATOR", ".", "'laravel'", ".", "DIRECTORY_SEPARATOR", ".", "'framework'", ")", "===", "false", "&&", "strpos", "(", "$", "trace", "[", "'file'", "]", ",", "DIRECTORY_SEPARATOR", ".", "'vendor'", ".", "DIRECTORY_SEPARATOR", ".", "'barryvdh'", ".", "DIRECTORY_SEPARATOR", ".", "'laravel-debugbar'", ")", "===", "false", ")", "{", "$", "file", "=", "$", "trace", "[", "'file'", "]", ";", "if", "(", "isset", "(", "$", "trace", "[", "'object'", "]", ")", "&&", "is_a", "(", "$", "trace", "[", "'object'", "]", ",", "'Twig_Template'", ")", ")", "{", "list", "(", "$", "file", ",", "$", "frame", "->", "line", ")", "=", "$", "this", "->", "getTwigInfo", "(", "$", "trace", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "file", ",", "storage_path", "(", ")", ")", "!==", "false", ")", "{", "$", "hash", "=", "pathinfo", "(", "$", "file", ",", "PATHINFO_FILENAME", ")", ";", "if", "(", "!", "$", "frame", "->", "name", "=", "$", "this", "->", "findViewFromHash", "(", "$", "hash", ")", ")", "{", "$", "frame", "->", "name", "=", "$", "hash", ";", "}", "$", "frame", "->", "namespace", "=", "'view'", ";", "return", "$", "frame", ";", "}", "elseif", "(", "strpos", "(", "$", "file", ",", "'Middleware'", ")", "!==", "false", ")", "{", "$", "frame", "->", "name", "=", "$", "this", "->", "findMiddlewareFromFile", "(", "$", "file", ")", ";", "if", "(", "$", "frame", "->", "name", ")", "{", "$", "frame", "->", "namespace", "=", "'middleware'", ";", "}", "else", "{", "$", "frame", "->", "name", "=", "$", "this", "->", "normalizeFilename", "(", "$", "file", ")", ";", "}", "return", "$", "frame", ";", "}", "$", "frame", "->", "name", "=", "$", "this", "->", "normalizeFilename", "(", "$", "file", ")", ";", "return", "$", "frame", ";", "}", "return", "false", ";", "}" ]
Parse a trace element from the backtrace stack. @param int $index @param array $trace @return object|bool
[ "Parse", "a", "trace", "element", "from", "the", "backtrace", "stack", "." ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/QueryCollector.php#L236-L292
php-comp/lite-database
src/Helper/DsnHelper.php
DsnHelper.getDsn
public static function getDsn(array $options = [], $driver = null): string { if (isset($options['dsn'])) { return $options['dsn']; } self::$options = $options; if (!$driver) { $driver = $options['driver'] ?? null; } if (!$driver) { throw new \InvalidArgumentException('The driver name is required.'); } if (!\is_callable([static::class, $driver])) { throw new \InvalidArgumentException('The ' . $driver . ' driver is not supported.'); } list($dsn, $replace) = static::$driver(); $dsn = \strtr($dsn, $replace); self::$options = []; return $dsn; }
php
public static function getDsn(array $options = [], $driver = null): string { if (isset($options['dsn'])) { return $options['dsn']; } self::$options = $options; if (!$driver) { $driver = $options['driver'] ?? null; } if (!$driver) { throw new \InvalidArgumentException('The driver name is required.'); } if (!\is_callable([static::class, $driver])) { throw new \InvalidArgumentException('The ' . $driver . ' driver is not supported.'); } list($dsn, $replace) = static::$driver(); $dsn = \strtr($dsn, $replace); self::$options = []; return $dsn; }
[ "public", "static", "function", "getDsn", "(", "array", "$", "options", "=", "[", "]", ",", "$", "driver", "=", "null", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "options", "[", "'dsn'", "]", ")", ")", "{", "return", "$", "options", "[", "'dsn'", "]", ";", "}", "self", "::", "$", "options", "=", "$", "options", ";", "if", "(", "!", "$", "driver", ")", "{", "$", "driver", "=", "$", "options", "[", "'driver'", "]", "??", "null", ";", "}", "if", "(", "!", "$", "driver", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The driver name is required.'", ")", ";", "}", "if", "(", "!", "\\", "is_callable", "(", "[", "static", "::", "class", ",", "$", "driver", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The '", ".", "$", "driver", ".", "' driver is not supported.'", ")", ";", "}", "list", "(", "$", "dsn", ",", "$", "replace", ")", "=", "static", "::", "$", "driver", "(", ")", ";", "$", "dsn", "=", "\\", "strtr", "(", "$", "dsn", ",", "$", "replace", ")", ";", "self", "::", "$", "options", "=", "[", "]", ";", "return", "$", "dsn", ";", "}" ]
getDsn @param string $driver @param array $options @throws \InvalidArgumentException @return string
[ "getDsn" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/Helper/DsnHelper.php#L45-L72
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.add
public function add($key, $value) { $key = $this->formatKey($key); $headers = $this->get($key); $headers[] = $value; array_set($this->headers, $key, $headers); }
php
public function add($key, $value) { $key = $this->formatKey($key); $headers = $this->get($key); $headers[] = $value; array_set($this->headers, $key, $headers); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "$", "headers", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "$", "headers", "[", "]", "=", "$", "value", ";", "array_set", "(", "$", "this", "->", "headers", ",", "$", "key", ",", "$", "headers", ")", ";", "}" ]
Add header. @param $key @param $value
[ "Add", "header", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L24-L31
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.find
public function find($key, $default = null) { $key = $this->formatKey($key); $headers = array_get($this->headers, $key, $default); if (is_array($headers)) { $headers = array_pop($headers); } return $headers; }
php
public function find($key, $default = null) { $key = $this->formatKey($key); $headers = array_get($this->headers, $key, $default); if (is_array($headers)) { $headers = array_pop($headers); } return $headers; }
[ "public", "function", "find", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "$", "headers", "=", "array_get", "(", "$", "this", "->", "headers", ",", "$", "key", ",", "$", "default", ")", ";", "if", "(", "is_array", "(", "$", "headers", ")", ")", "{", "$", "headers", "=", "array_pop", "(", "$", "headers", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Find the last added header. @param $key @param null $default @return string
[ "Find", "the", "last", "added", "header", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L56-L65
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.set
public function set($key, $value) { $key = $this->formatKey($key); array_set($this->headers, $key, [$value]); }
php
public function set($key, $value) { $key = $this->formatKey($key); array_set($this->headers, $key, [$value]); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "array_set", "(", "$", "this", "->", "headers", ",", "$", "key", ",", "[", "$", "value", "]", ")", ";", "}" ]
Replace all previous headers with this one. @param $key @param $value
[ "Replace", "all", "previous", "headers", "with", "this", "one", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L73-L76
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.get
public function get($key) { $key = $this->formatKey($key); return array_get($this->headers, $key, []); }
php
public function get($key) { $key = $this->formatKey($key); return array_get($this->headers, $key, []); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "return", "array_get", "(", "$", "this", "->", "headers", ",", "$", "key", ",", "[", "]", ")", ";", "}" ]
Get all headers by key. @param $key @return array
[ "Get", "all", "headers", "by", "key", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L85-L88
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.has
public function has($key) { $key = $this->formatKey($key); return array_has($this->headers, $key); }
php
public function has($key) { $key = $this->formatKey($key); return array_has($this->headers, $key); }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "return", "array_has", "(", "$", "this", "->", "headers", ",", "$", "key", ")", ";", "}" ]
Check if there are any headers. @param $key @return bool
[ "Check", "if", "there", "are", "any", "headers", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L97-L100
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.remove
public function remove($key) { $key = $this->formatKey($key); array_remove($this->headers, $key); }
php
public function remove($key) { $key = $this->formatKey($key); array_remove($this->headers, $key); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "formatKey", "(", "$", "key", ")", ";", "array_remove", "(", "$", "this", "->", "headers", ",", "$", "key", ")", ";", "}" ]
Remove all registered headers. @param $key
[ "Remove", "all", "registered", "headers", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L107-L110
weew/http
src/Weew/Http/HttpHeaders.php
HttpHeaders.toFlatArray
public function toFlatArray() { $array = []; foreach ($this->headers as $key => $headers) { foreach ($headers as $header) { $array[] = $this->formatHeader($key, $header); } } return $array; }
php
public function toFlatArray() { $array = []; foreach ($this->headers as $key => $headers) { foreach ($headers as $header) { $array[] = $this->formatHeader($key, $header); } } return $array; }
[ "public", "function", "toFlatArray", "(", ")", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "key", "=>", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "array", "[", "]", "=", "$", "this", "->", "formatHeader", "(", "$", "key", ",", "$", "header", ")", ";", "}", "}", "return", "$", "array", ";", "}" ]
Get a list of formatted header strings. @return array
[ "Get", "a", "list", "of", "formatted", "header", "strings", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpHeaders.php#L160-L170
yawik/composer-plugin
src/AssetsInstaller.php
AssetsInstaller.install
public function install($modules, $expectedMethod = null) { $publicDir = $this->getModuleAssetDir(); $rows = []; $exitCode = 0; $copyUsed = false; $expectedMethod = is_null($expectedMethod) ? self::METHOD_RELATIVE_SYMLINK:$expectedMethod; foreach ($modules as $name => $originDir) { $targetDir = $publicDir.DIRECTORY_SEPARATOR.$name; $message = $name; try { $this->filesystem->remove($targetDir); if (self::METHOD_RELATIVE_SYMLINK == $expectedMethod) { $method = $this->relativeSymlinkWithFallback($originDir, $targetDir); } elseif (self::METHOD_ABSOLUTE_SYMLINK == $expectedMethod) { $expectedMethod = self::METHOD_ABSOLUTE_SYMLINK; $method = $this->absoluteSymlinkWithFallback($originDir, $targetDir); } else { $expectedMethod = self::METHOD_COPY; $method = $this->hardCopy($originDir, $targetDir); } if (self::METHOD_COPY === $method) { $copyUsed = true; } if ($method === $expectedMethod) { $rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method); } else { $rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method); } } catch (\Exception $e) { $exitCode = 1; $rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()); } } // render this output only on cli environment if ($this->isCli()) { $this->renderInstallOutput($copyUsed, $rows, $exitCode); } }
php
public function install($modules, $expectedMethod = null) { $publicDir = $this->getModuleAssetDir(); $rows = []; $exitCode = 0; $copyUsed = false; $expectedMethod = is_null($expectedMethod) ? self::METHOD_RELATIVE_SYMLINK:$expectedMethod; foreach ($modules as $name => $originDir) { $targetDir = $publicDir.DIRECTORY_SEPARATOR.$name; $message = $name; try { $this->filesystem->remove($targetDir); if (self::METHOD_RELATIVE_SYMLINK == $expectedMethod) { $method = $this->relativeSymlinkWithFallback($originDir, $targetDir); } elseif (self::METHOD_ABSOLUTE_SYMLINK == $expectedMethod) { $expectedMethod = self::METHOD_ABSOLUTE_SYMLINK; $method = $this->absoluteSymlinkWithFallback($originDir, $targetDir); } else { $expectedMethod = self::METHOD_COPY; $method = $this->hardCopy($originDir, $targetDir); } if (self::METHOD_COPY === $method) { $copyUsed = true; } if ($method === $expectedMethod) { $rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method); } else { $rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method); } } catch (\Exception $e) { $exitCode = 1; $rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()); } } // render this output only on cli environment if ($this->isCli()) { $this->renderInstallOutput($copyUsed, $rows, $exitCode); } }
[ "public", "function", "install", "(", "$", "modules", ",", "$", "expectedMethod", "=", "null", ")", "{", "$", "publicDir", "=", "$", "this", "->", "getModuleAssetDir", "(", ")", ";", "$", "rows", "=", "[", "]", ";", "$", "exitCode", "=", "0", ";", "$", "copyUsed", "=", "false", ";", "$", "expectedMethod", "=", "is_null", "(", "$", "expectedMethod", ")", "?", "self", "::", "METHOD_RELATIVE_SYMLINK", ":", "$", "expectedMethod", ";", "foreach", "(", "$", "modules", "as", "$", "name", "=>", "$", "originDir", ")", "{", "$", "targetDir", "=", "$", "publicDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "$", "message", "=", "$", "name", ";", "try", "{", "$", "this", "->", "filesystem", "->", "remove", "(", "$", "targetDir", ")", ";", "if", "(", "self", "::", "METHOD_RELATIVE_SYMLINK", "==", "$", "expectedMethod", ")", "{", "$", "method", "=", "$", "this", "->", "relativeSymlinkWithFallback", "(", "$", "originDir", ",", "$", "targetDir", ")", ";", "}", "elseif", "(", "self", "::", "METHOD_ABSOLUTE_SYMLINK", "==", "$", "expectedMethod", ")", "{", "$", "expectedMethod", "=", "self", "::", "METHOD_ABSOLUTE_SYMLINK", ";", "$", "method", "=", "$", "this", "->", "absoluteSymlinkWithFallback", "(", "$", "originDir", ",", "$", "targetDir", ")", ";", "}", "else", "{", "$", "expectedMethod", "=", "self", "::", "METHOD_COPY", ";", "$", "method", "=", "$", "this", "->", "hardCopy", "(", "$", "originDir", ",", "$", "targetDir", ")", ";", "}", "if", "(", "self", "::", "METHOD_COPY", "===", "$", "method", ")", "{", "$", "copyUsed", "=", "true", ";", "}", "if", "(", "$", "method", "===", "$", "expectedMethod", ")", "{", "$", "rows", "[", "]", "=", "array", "(", "sprintf", "(", "'<fg=green;options=bold>%s</>'", ",", "'\\\\'", "===", "DIRECTORY_SEPARATOR", "?", "'OK'", ":", "\"\\xE2\\x9C\\x94\"", "/* HEAVY CHECK MARK (U+2714) */", ")", ",", "$", "message", ",", "$", "method", ")", ";", "}", "else", "{", "$", "rows", "[", "]", "=", "array", "(", "sprintf", "(", "'<fg=yellow;options=bold>%s</>'", ",", "'\\\\'", "===", "DIRECTORY_SEPARATOR", "?", "'WARNING'", ":", "'!'", ")", ",", "$", "message", ",", "$", "method", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "exitCode", "=", "1", ";", "$", "rows", "[", "]", "=", "array", "(", "sprintf", "(", "'<fg=red;options=bold>%s</>'", ",", "'\\\\'", "===", "DIRECTORY_SEPARATOR", "?", "'ERROR'", ":", "\"\\xE2\\x9C\\x98\"", "/* HEAVY BALLOT X (U+2718) */", ")", ",", "$", "message", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "// render this output only on cli environment", "if", "(", "$", "this", "->", "isCli", "(", ")", ")", "{", "$", "this", "->", "renderInstallOutput", "(", "$", "copyUsed", ",", "$", "rows", ",", "$", "exitCode", ")", ";", "}", "}" ]
Install modules assets with the given $modules. $modules should within this format: [module_name] => module_public_directory @param array $modules An array of modules @param string $expectedMethod Expected install method
[ "Install", "modules", "assets", "with", "the", "given", "$modules", ".", "$modules", "should", "within", "this", "format", ":" ]
train
https://github.com/yawik/composer-plugin/blob/d3a45d2ab342fc0eb21e1126e8637fb7752464e4/src/AssetsInstaller.php#L83-L125
yawik/composer-plugin
src/AssetsInstaller.php
AssetsInstaller.uninstall
public function uninstall($modules) { $assetDir = $this->getModuleAssetDir(); foreach ($modules as $name) { $publicPath = $assetDir.DIRECTORY_SEPARATOR.$name; if (is_dir($publicPath) || is_link($publicPath)) { $this->filesystem->remove($publicPath); $this->log("Removed module assets: <info>${name}</info>"); } } }
php
public function uninstall($modules) { $assetDir = $this->getModuleAssetDir(); foreach ($modules as $name) { $publicPath = $assetDir.DIRECTORY_SEPARATOR.$name; if (is_dir($publicPath) || is_link($publicPath)) { $this->filesystem->remove($publicPath); $this->log("Removed module assets: <info>${name}</info>"); } } }
[ "public", "function", "uninstall", "(", "$", "modules", ")", "{", "$", "assetDir", "=", "$", "this", "->", "getModuleAssetDir", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "name", ")", "{", "$", "publicPath", "=", "$", "assetDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "if", "(", "is_dir", "(", "$", "publicPath", ")", "||", "is_link", "(", "$", "publicPath", ")", ")", "{", "$", "this", "->", "filesystem", "->", "remove", "(", "$", "publicPath", ")", ";", "$", "this", "->", "log", "(", "\"Removed module assets: <info>${name}</info>\"", ")", ";", "}", "}", "}" ]
Uninstall modules @param array $modules A list of modules to uninstall
[ "Uninstall", "modules" ]
train
https://github.com/yawik/composer-plugin/blob/d3a45d2ab342fc0eb21e1126e8637fb7752464e4/src/AssetsInstaller.php#L132-L142
yawik/composer-plugin
src/AssetsInstaller.php
AssetsInstaller.symlink
public function symlink($originDir, $targetDir, $relative = false) { if ($relative) { $this->filesystem->mkdir(dirname($targetDir)); $originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir))); } $this->filesystem->symlink($originDir, $targetDir); if (!file_exists($targetDir)) { throw new \Exception( sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null ); } }
php
public function symlink($originDir, $targetDir, $relative = false) { if ($relative) { $this->filesystem->mkdir(dirname($targetDir)); $originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir))); } $this->filesystem->symlink($originDir, $targetDir); if (!file_exists($targetDir)) { throw new \Exception( sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null ); } }
[ "public", "function", "symlink", "(", "$", "originDir", ",", "$", "targetDir", ",", "$", "relative", "=", "false", ")", "{", "if", "(", "$", "relative", ")", "{", "$", "this", "->", "filesystem", "->", "mkdir", "(", "dirname", "(", "$", "targetDir", ")", ")", ";", "$", "originDir", "=", "$", "this", "->", "filesystem", "->", "makePathRelative", "(", "$", "originDir", ",", "realpath", "(", "dirname", "(", "$", "targetDir", ")", ")", ")", ";", "}", "$", "this", "->", "filesystem", "->", "symlink", "(", "$", "originDir", ",", "$", "targetDir", ")", ";", "if", "(", "!", "file_exists", "(", "$", "targetDir", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Symbolic link \"%s\" was created but appears to be broken.'", ",", "$", "targetDir", ")", ",", "0", ",", "null", ")", ";", "}", "}" ]
Creates symbolic link. @throws \Exception if link can not be created
[ "Creates", "symbolic", "link", "." ]
train
https://github.com/yawik/composer-plugin/blob/d3a45d2ab342fc0eb21e1126e8637fb7752464e4/src/AssetsInstaller.php#L222-L237
SporkCode/Spork
src/Mvc/Controller/AbstractRestfulTableController.php
AbstractRestfulTableController.toArray
protected function toArray($data) { if (is_array($data)) { return $data; } if (is_object($data)) { if (method_exists($data, 'toArray')) { return $data->toArray(); } if ($data instanceof \Traversable) { return iterator_to_array($data); } } return (array) $data; }
php
protected function toArray($data) { if (is_array($data)) { return $data; } if (is_object($data)) { if (method_exists($data, 'toArray')) { return $data->toArray(); } if ($data instanceof \Traversable) { return iterator_to_array($data); } } return (array) $data; }
[ "protected", "function", "toArray", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "if", "(", "method_exists", "(", "$", "data", ",", "'toArray'", ")", ")", "{", "return", "$", "data", "->", "toArray", "(", ")", ";", "}", "if", "(", "$", "data", "instanceof", "\\", "Traversable", ")", "{", "return", "iterator_to_array", "(", "$", "data", ")", ";", "}", "}", "return", "(", "array", ")", "$", "data", ";", "}" ]
Convert a result set to an array @param unknown $data
[ "Convert", "a", "result", "set", "to", "an", "array" ]
train
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Controller/AbstractRestfulTableController.php#L120-L136
mustardandrew/muan-laravel-acl
src/Commands/Role/RenameCommand.php
RenameCommand.handle
public function handle() { $roleName = $this->argument('role'); $newRoleName = $this->argument('newRole'); if (! $role = Role::whereName($roleName)->first()) { $this->warn("Role {$roleName} not exists."); return 1; } $role->name = $newRoleName; if ($role->save()) { echo "Rename role {$roleName} to {$newRoleName} successfully.", PHP_EOL; } else { $this->error("Rename role {$roleName} is fail!"); } return 0; }
php
public function handle() { $roleName = $this->argument('role'); $newRoleName = $this->argument('newRole'); if (! $role = Role::whereName($roleName)->first()) { $this->warn("Role {$roleName} not exists."); return 1; } $role->name = $newRoleName; if ($role->save()) { echo "Rename role {$roleName} to {$newRoleName} successfully.", PHP_EOL; } else { $this->error("Rename role {$roleName} is fail!"); } return 0; }
[ "public", "function", "handle", "(", ")", "{", "$", "roleName", "=", "$", "this", "->", "argument", "(", "'role'", ")", ";", "$", "newRoleName", "=", "$", "this", "->", "argument", "(", "'newRole'", ")", ";", "if", "(", "!", "$", "role", "=", "Role", "::", "whereName", "(", "$", "roleName", ")", "->", "first", "(", ")", ")", "{", "$", "this", "->", "warn", "(", "\"Role {$roleName} not exists.\"", ")", ";", "return", "1", ";", "}", "$", "role", "->", "name", "=", "$", "newRoleName", ";", "if", "(", "$", "role", "->", "save", "(", ")", ")", "{", "echo", "\"Rename role {$roleName} to {$newRoleName} successfully.\"", ",", "PHP_EOL", ";", "}", "else", "{", "$", "this", "->", "error", "(", "\"Rename role {$roleName} is fail!\"", ")", ";", "}", "return", "0", ";", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/Role/RenameCommand.php#L34-L53
loevgaard/altapay-php-sdk
src/Payload/PaymentRequest.php
PaymentRequest.parseCookieParts
public static function parseCookieParts(array $cookieParts) { $cookie = ''; foreach ($cookieParts as $key => $val) { $cookie .= $key.'='.rawurlencode($val).';'; } $cookie = trim($cookie, ';'); return $cookie; }
php
public static function parseCookieParts(array $cookieParts) { $cookie = ''; foreach ($cookieParts as $key => $val) { $cookie .= $key.'='.rawurlencode($val).';'; } $cookie = trim($cookie, ';'); return $cookie; }
[ "public", "static", "function", "parseCookieParts", "(", "array", "$", "cookieParts", ")", "{", "$", "cookie", "=", "''", ";", "foreach", "(", "$", "cookieParts", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "cookie", ".=", "$", "key", ".", "'='", ".", "rawurlencode", "(", "$", "val", ")", ".", "';'", ";", "}", "$", "cookie", "=", "trim", "(", "$", "cookie", ",", "';'", ")", ";", "return", "$", "cookie", ";", "}" ]
Takes an array of cookie parts and returns an urlencoded string ready to send @param array $cookieParts @return string
[ "Takes", "an", "array", "of", "cookie", "parts", "and", "returns", "an", "urlencoded", "string", "ready", "to", "send" ]
train
https://github.com/loevgaard/altapay-php-sdk/blob/476664e8725407249c04ca7ae76f92882e4f4583/src/Payload/PaymentRequest.php#L212-L221
heidelpay/PhpDoc
src/phpDocumentor/Translator/ServiceProvider.php
ServiceProvider.register
public function register(Application $app) { /** @var ApplicationConfiguration $config */ $config = $app['config']; $app['translator.locale'] = $config->getTranslator()->getLocale(); $app['translator'] = $app->share( function ($app) { $translator = new Translator(); $translator->setLocale($app['translator.locale']); return $translator; } ); }
php
public function register(Application $app) { /** @var ApplicationConfiguration $config */ $config = $app['config']; $app['translator.locale'] = $config->getTranslator()->getLocale(); $app['translator'] = $app->share( function ($app) { $translator = new Translator(); $translator->setLocale($app['translator.locale']); return $translator; } ); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "/** @var ApplicationConfiguration $config */", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "$", "app", "[", "'translator.locale'", "]", "=", "$", "config", "->", "getTranslator", "(", ")", "->", "getLocale", "(", ")", ";", "$", "app", "[", "'translator'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "$", "translator", "=", "new", "Translator", "(", ")", ";", "$", "translator", "->", "setLocale", "(", "$", "app", "[", "'translator.locale'", "]", ")", ";", "return", "$", "translator", ";", "}", ")", ";", "}" ]
Registers the translator using the currently active locale. @param Application $app
[ "Registers", "the", "translator", "using", "the", "currently", "active", "locale", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Translator/ServiceProvider.php#L36-L51
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php
ezcCacheStackBaseReplacementStrategy.store
public static function store( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemData, $itemAttributes = array() ) { if ( !$metaData->hasItem( $conf->id, $itemId ) && $metaData->reachedItemLimit( $conf->id, $conf->itemLimit ) ) { self::freeData( $conf, $metaData, // Number of items to remove, round() returns float (int) round( $conf->freeRate * $conf->itemLimit ) ); } $conf->storage->store( $itemId, $itemData, $itemAttributes ); $metaData->addItem( $conf->id, $itemId ); }
php
public static function store( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemData, $itemAttributes = array() ) { if ( !$metaData->hasItem( $conf->id, $itemId ) && $metaData->reachedItemLimit( $conf->id, $conf->itemLimit ) ) { self::freeData( $conf, $metaData, // Number of items to remove, round() returns float (int) round( $conf->freeRate * $conf->itemLimit ) ); } $conf->storage->store( $itemId, $itemData, $itemAttributes ); $metaData->addItem( $conf->id, $itemId ); }
[ "public", "static", "function", "store", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "itemId", ",", "$", "itemData", ",", "$", "itemAttributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "metaData", "->", "hasItem", "(", "$", "conf", "->", "id", ",", "$", "itemId", ")", "&&", "$", "metaData", "->", "reachedItemLimit", "(", "$", "conf", "->", "id", ",", "$", "conf", "->", "itemLimit", ")", ")", "{", "self", "::", "freeData", "(", "$", "conf", ",", "$", "metaData", ",", "// Number of items to remove, round() returns float", "(", "int", ")", "round", "(", "$", "conf", "->", "freeRate", "*", "$", "conf", "->", "itemLimit", ")", ")", ";", "}", "$", "conf", "->", "storage", "->", "store", "(", "$", "itemId", ",", "$", "itemData", ",", "$", "itemAttributes", ")", ";", "$", "metaData", "->", "addItem", "(", "$", "conf", "->", "id", ",", "$", "itemId", ")", ";", "}" ]
Stores the given $itemData in the storage given in $conf. This method stores the given $itemData assigned to $itemId and optionally $itemAttributes in the {@link ezcCacheStackableStorage} given in $conf. In case the storage has reached the $itemLimit defined in $conf, it must be freed according to $freeRate {@link ezcCacheStackStorageConfiguration}. The freeing of items from the storage must first happen via {@link ezcCacheStackableStorage::purge()}, which removes outdated items from the storage and returns the affected IDs. In case this does not last to free the desired number of items, the replacement strategy specific algorithm for freeing takes effect. After the necessary freeing process has been performed, the item is stored in the storage and the $metaData is updated accordingly. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param string $itemId @param mixed $itemData @param array(string=>string) $itemAttributes
[ "Stores", "the", "given", "$itemData", "in", "the", "storage", "given", "in", "$conf", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php#L64-L86
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php
ezcCacheStackBaseReplacementStrategy.freeData
private static function freeData( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $freeNum ) { $purgedIds = $conf->storage->purge(); // Unset purged items in meta data foreach ( $purgedIds as $purgedId ) { $metaData->removeItem( $conf->id, $purgedId ); } $freeNum = $freeNum - count( $purgedIds ); // Not enough items have been purged, remove manually if ( $freeNum > 0 ) { $purgeOrder = $metaData->getReplacementItems(); foreach ( $purgeOrder as $id => $replacementData ) { // Purge only if available in the current storage if ( $metaData->hasItem( $conf->id, $id ) ) { // Purge all items with this ID, no matter which // attributes, therefore: $search = true. $deletedIds = $conf->storage->delete( $id, null, true ); $metaData->removeItem( $conf->id, $id ); // Purged enough? if ( --$freeNum == 0 ) { break; } } } } }
php
private static function freeData( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $freeNum ) { $purgedIds = $conf->storage->purge(); // Unset purged items in meta data foreach ( $purgedIds as $purgedId ) { $metaData->removeItem( $conf->id, $purgedId ); } $freeNum = $freeNum - count( $purgedIds ); // Not enough items have been purged, remove manually if ( $freeNum > 0 ) { $purgeOrder = $metaData->getReplacementItems(); foreach ( $purgeOrder as $id => $replacementData ) { // Purge only if available in the current storage if ( $metaData->hasItem( $conf->id, $id ) ) { // Purge all items with this ID, no matter which // attributes, therefore: $search = true. $deletedIds = $conf->storage->delete( $id, null, true ); $metaData->removeItem( $conf->id, $id ); // Purged enough? if ( --$freeNum == 0 ) { break; } } } } }
[ "private", "static", "function", "freeData", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "freeNum", ")", "{", "$", "purgedIds", "=", "$", "conf", "->", "storage", "->", "purge", "(", ")", ";", "// Unset purged items in meta data", "foreach", "(", "$", "purgedIds", "as", "$", "purgedId", ")", "{", "$", "metaData", "->", "removeItem", "(", "$", "conf", "->", "id", ",", "$", "purgedId", ")", ";", "}", "$", "freeNum", "=", "$", "freeNum", "-", "count", "(", "$", "purgedIds", ")", ";", "// Not enough items have been purged, remove manually", "if", "(", "$", "freeNum", ">", "0", ")", "{", "$", "purgeOrder", "=", "$", "metaData", "->", "getReplacementItems", "(", ")", ";", "foreach", "(", "$", "purgeOrder", "as", "$", "id", "=>", "$", "replacementData", ")", "{", "// Purge only if available in the current storage", "if", "(", "$", "metaData", "->", "hasItem", "(", "$", "conf", "->", "id", ",", "$", "id", ")", ")", "{", "// Purge all items with this ID, no matter which", "// attributes, therefore: $search = true.", "$", "deletedIds", "=", "$", "conf", "->", "storage", "->", "delete", "(", "$", "id", ",", "null", ",", "true", ")", ";", "$", "metaData", "->", "removeItem", "(", "$", "conf", "->", "id", ",", "$", "id", ")", ";", "// Purged enough?", "if", "(", "--", "$", "freeNum", "==", "0", ")", "{", "break", ";", "}", "}", "}", "}", "}" ]
Frees $freeNum number of item slots in $storage. This method first purges outdated items from the storage inside $conf using {@link ezcCacheStackableStorage::purge()}. If this does not free $freeNum items, least recently used items (determined from {@link ezcCacheStackMetaData}) will be removed from the storage using {@link ezcCacheStackableStorage::delete()}. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param int $freeNum
[ "Frees", "$freeNum", "number", "of", "item", "slots", "in", "$storage", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php#L101-L137
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php
ezcCacheStackBaseReplacementStrategy.restore
public static function restore( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { $item = $conf->storage->restore( $itemId, $itemAttributes, $search ); // Update item meta data if ( $item === false ) { // Item has been purged / got outdated $metaData->removeItem( $conf->id, $itemId ); } else { // Updates the use time $metaData->addItem( $conf->id, $itemId ); } return $item; }
php
public static function restore( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { $item = $conf->storage->restore( $itemId, $itemAttributes, $search ); // Update item meta data if ( $item === false ) { // Item has been purged / got outdated $metaData->removeItem( $conf->id, $itemId ); } else { // Updates the use time $metaData->addItem( $conf->id, $itemId ); } return $item; }
[ "public", "static", "function", "restore", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "itemId", ",", "$", "itemAttributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "item", "=", "$", "conf", "->", "storage", "->", "restore", "(", "$", "itemId", ",", "$", "itemAttributes", ",", "$", "search", ")", ";", "// Update item meta data", "if", "(", "$", "item", "===", "false", ")", "{", "// Item has been purged / got outdated", "$", "metaData", "->", "removeItem", "(", "$", "conf", "->", "id", ",", "$", "itemId", ")", ";", "}", "else", "{", "// Updates the use time", "$", "metaData", "->", "addItem", "(", "$", "conf", "->", "id", ",", "$", "itemId", ")", ";", "}", "return", "$", "item", ";", "}" ]
Restores the data with the given $dataId from the storage given in $conf. This method takes care of restoring the item with ID $itemId and optionally $itemAttributes from the {@link ezcCacheStackableStorage} given in $conf. The parameters $itemId, $itemAttributes and $search are forwarded to {@link ezcCacheStackableStorage::restore()}, the returned value (item data on successful restore, otherwise false) are returned by this method. The method must take care that the restore process is reflected in $metaData according to the spcific replacement strategy implementation. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param string $itemId @param array(string=>string) $itemAttributes @param bool $search @return mixed Restored data or false. @throws ezcCacheInvalidMetaDataException if the given $metaData is not processable by this replacement strategy.
[ "Restores", "the", "data", "with", "the", "given", "$dataId", "from", "the", "storage", "given", "in", "$conf", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php#L163-L189
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php
ezcCacheStackBaseReplacementStrategy.delete
public static function delete( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { $deletedIds = $conf->storage->delete( $itemId, $itemAttributes, $search ); // Possibly deleted multiple items foreach ( $deletedIds as $id ) { $metaData->removeItem( $conf->id, $id ); } return $deletedIds; }
php
public static function delete( ezcCacheStackStorageConfiguration $conf, ezcCacheStackMetaData $metaData, $itemId, $itemAttributes = array(), $search = false ) { $deletedIds = $conf->storage->delete( $itemId, $itemAttributes, $search ); // Possibly deleted multiple items foreach ( $deletedIds as $id ) { $metaData->removeItem( $conf->id, $id ); } return $deletedIds; }
[ "public", "static", "function", "delete", "(", "ezcCacheStackStorageConfiguration", "$", "conf", ",", "ezcCacheStackMetaData", "$", "metaData", ",", "$", "itemId", ",", "$", "itemAttributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "deletedIds", "=", "$", "conf", "->", "storage", "->", "delete", "(", "$", "itemId", ",", "$", "itemAttributes", ",", "$", "search", ")", ";", "// Possibly deleted multiple items", "foreach", "(", "$", "deletedIds", "as", "$", "id", ")", "{", "$", "metaData", "->", "removeItem", "(", "$", "conf", "->", "id", ",", "$", "id", ")", ";", "}", "return", "$", "deletedIds", ";", "}" ]
Deletes the data with the given $itemId from the given $storage. This method takes care about deleting the item identified by $itemId and optionally $itemAttributes from the {@link ezcCacheStackableStorage} give in $conf. The parameters $itemId, $itemAttributes and $search are therefore forwarded to {@link ezcCacheStackableStorage::delete()}. This method returns a list of all item IDs that have been deleted by the call. The method reflects these changes in $metaData. @param ezcCacheStackStorageConfiguration $conf @param ezcCacheStackMetaData $metaData @param string $itemId @param array(string=>string) $itemAttributes @param bool $search @return array(string) Deleted item IDs. @throws ezcCacheInvalidMetaDataException if the given $metaData is not processable by this replacement strategy.
[ "Deletes", "the", "data", "with", "the", "given", "$itemId", "from", "the", "given", "$storage", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_replacement_strategy.php#L212-L232
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Channel.php
Channel.subChannelGetById
public function subChannelGetById($cid) { if(!array_key_exists((int) $cid, $this->subChannelList())) { throw new Exception("invalid channelID", 0x300); } return $this->channelList[(int) $cid]; }
php
public function subChannelGetById($cid) { if(!array_key_exists((int) $cid, $this->subChannelList())) { throw new Exception("invalid channelID", 0x300); } return $this->channelList[(int) $cid]; }
[ "public", "function", "subChannelGetById", "(", "$", "cid", ")", "{", "if", "(", "!", "array_key_exists", "(", "(", "int", ")", "$", "cid", ",", "$", "this", "->", "subChannelList", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "\"invalid channelID\"", ",", "0x300", ")", ";", "}", "return", "$", "this", "->", "channelList", "[", "(", "int", ")", "$", "cid", "]", ";", "}" ]
Returns the TeamSpeak3_Node_Channel object matching the given ID. @param integer $cid @throws Exception @return Channel
[ "Returns", "the", "TeamSpeak3_Node_Channel", "object", "matching", "the", "given", "ID", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Channel.php#L91-L99
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Channel.php
Channel.subChannelGetByName
public function subChannelGetByName($name) { foreach($this->subChannelList() as $channel) { if($channel["channel_name"] == $name) return $channel; } throw new Exception("invalid channelID", 0x300); }
php
public function subChannelGetByName($name) { foreach($this->subChannelList() as $channel) { if($channel["channel_name"] == $name) return $channel; } throw new Exception("invalid channelID", 0x300); }
[ "public", "function", "subChannelGetByName", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "subChannelList", "(", ")", "as", "$", "channel", ")", "{", "if", "(", "$", "channel", "[", "\"channel_name\"", "]", "==", "$", "name", ")", "return", "$", "channel", ";", "}", "throw", "new", "Exception", "(", "\"invalid channelID\"", ",", "0x300", ")", ";", "}" ]
Returns the TeamSpeak3_Node_Channel object matching the given name. @param integer $name @throws Exception @return Channel
[ "Returns", "the", "TeamSpeak3_Node_Channel", "object", "matching", "the", "given", "name", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Channel.php#L108-L116
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Node/Channel.php
Channel.clientGetById
public function clientGetById($clid) { if(!array_key_exists($clid, $this->clientList())) { throw new Exception("invalid clientID", 0x200); } return $this->clientList[intval($clid)]; }
php
public function clientGetById($clid) { if(!array_key_exists($clid, $this->clientList())) { throw new Exception("invalid clientID", 0x200); } return $this->clientList[intval($clid)]; }
[ "public", "function", "clientGetById", "(", "$", "clid", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "clid", ",", "$", "this", "->", "clientList", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "\"invalid clientID\"", ",", "0x200", ")", ";", "}", "return", "$", "this", "->", "clientList", "[", "intval", "(", "$", "clid", ")", "]", ";", "}" ]
Returns the Client object matching the given ID. @param integer $clid @throws Exception @return Client
[ "Returns", "the", "Client", "object", "matching", "the", "given", "ID", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Channel.php#L146-L154
xiewulong/yii2-fileupload
oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher.addListenerService
public function addListenerService($eventName, $callback, $priority = 0) { if (!is_array($callback) || 2 !== count($callback)) { throw new \InvalidArgumentException('Expected an array("service", "method") argument'); } $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); }
php
public function addListenerService($eventName, $callback, $priority = 0) { if (!is_array($callback) || 2 !== count($callback)) { throw new \InvalidArgumentException('Expected an array("service", "method") argument'); } $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); }
[ "public", "function", "addListenerService", "(", "$", "eventName", ",", "$", "callback", ",", "$", "priority", "=", "0", ")", "{", "if", "(", "!", "is_array", "(", "$", "callback", ")", "||", "2", "!==", "count", "(", "$", "callback", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expected an array(\"service\", \"method\") argument'", ")", ";", "}", "$", "this", "->", "listenerIds", "[", "$", "eventName", "]", "[", "]", "=", "array", "(", "$", "callback", "[", "0", "]", ",", "$", "callback", "[", "1", "]", ",", "$", "priority", ")", ";", "}" ]
Adds a service as event listener @param string $eventName Event for which the listener is added @param array $callback The service ID of the listener service & the method name that has to be called @param integer $priority The higher this value, the earlier an event listener will be triggered in the chain. Defaults to 0. @throws \InvalidArgumentException
[ "Adds", "a", "service", "as", "event", "listener" ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php#L66-L73
xiewulong/yii2-fileupload
oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher.dispatch
public function dispatch($eventName, Event $event = null) { $this->lazyLoad($eventName); return parent::dispatch($eventName, $event); }
php
public function dispatch($eventName, Event $event = null) { $this->lazyLoad($eventName); return parent::dispatch($eventName, $event); }
[ "public", "function", "dispatch", "(", "$", "eventName", ",", "Event", "$", "event", "=", "null", ")", "{", "$", "this", "->", "lazyLoad", "(", "$", "eventName", ")", ";", "return", "parent", "::", "dispatch", "(", "$", "eventName", ",", "$", "event", ")", ";", "}" ]
{@inheritDoc} Lazily loads listeners for this event from the dependency injection container. @throws \InvalidArgumentException if the service is not defined
[ "{", "@inheritDoc", "}" ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php#L163-L168
xiewulong/yii2-fileupload
oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher.lazyLoad
protected function lazyLoad($eventName) { if (isset($this->listenerIds[$eventName])) { foreach ($this->listenerIds[$eventName] as $args) { list($serviceId, $method, $priority) = $args; $listener = $this->container->get($serviceId); $key = $serviceId.'.'.$method; if (!isset($this->listeners[$eventName][$key])) { $this->addListener($eventName, array($listener, $method), $priority); } elseif ($listener !== $this->listeners[$eventName][$key]) { parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); $this->addListener($eventName, array($listener, $method), $priority); } $this->listeners[$eventName][$key] = $listener; } } }
php
protected function lazyLoad($eventName) { if (isset($this->listenerIds[$eventName])) { foreach ($this->listenerIds[$eventName] as $args) { list($serviceId, $method, $priority) = $args; $listener = $this->container->get($serviceId); $key = $serviceId.'.'.$method; if (!isset($this->listeners[$eventName][$key])) { $this->addListener($eventName, array($listener, $method), $priority); } elseif ($listener !== $this->listeners[$eventName][$key]) { parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); $this->addListener($eventName, array($listener, $method), $priority); } $this->listeners[$eventName][$key] = $listener; } } }
[ "protected", "function", "lazyLoad", "(", "$", "eventName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "listenerIds", "[", "$", "eventName", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "listenerIds", "[", "$", "eventName", "]", "as", "$", "args", ")", "{", "list", "(", "$", "serviceId", ",", "$", "method", ",", "$", "priority", ")", "=", "$", "args", ";", "$", "listener", "=", "$", "this", "->", "container", "->", "get", "(", "$", "serviceId", ")", ";", "$", "key", "=", "$", "serviceId", ".", "'.'", ".", "$", "method", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "addListener", "(", "$", "eventName", ",", "array", "(", "$", "listener", ",", "$", "method", ")", ",", "$", "priority", ")", ";", "}", "elseif", "(", "$", "listener", "!==", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "[", "$", "key", "]", ")", "{", "parent", "::", "removeListener", "(", "$", "eventName", ",", "array", "(", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "[", "$", "key", "]", ",", "$", "method", ")", ")", ";", "$", "this", "->", "addListener", "(", "$", "eventName", ",", "array", "(", "$", "listener", ",", "$", "method", ")", ",", "$", "priority", ")", ";", "}", "$", "this", "->", "listeners", "[", "$", "eventName", "]", "[", "$", "key", "]", "=", "$", "listener", ";", "}", "}", "}" ]
Lazily loads listeners for this event from the dependency injection container. @param string $eventName The name of the event to dispatch. The name of the event is the name of the method that is invoked on listeners.
[ "Lazily", "loads", "listeners", "for", "this", "event", "from", "the", "dependency", "injection", "container", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php#L183-L201
gdbots/iam-php
src/GrantRolesToAppHandler.php
GrantRolesToAppHandler.createAppRolesGranted
protected function createAppRolesGranted(GrantRolesToApp $command, Pbjx $pbjx): AppRolesGranted { /** @var AppRolesGranted $event */ $event = AppRolesGrantedV1Mixin::findOne()->createMessage(); return $event; }
php
protected function createAppRolesGranted(GrantRolesToApp $command, Pbjx $pbjx): AppRolesGranted { /** @var AppRolesGranted $event */ $event = AppRolesGrantedV1Mixin::findOne()->createMessage(); return $event; }
[ "protected", "function", "createAppRolesGranted", "(", "GrantRolesToApp", "$", "command", ",", "Pbjx", "$", "pbjx", ")", ":", "AppRolesGranted", "{", "/** @var AppRolesGranted $event */", "$", "event", "=", "AppRolesGrantedV1Mixin", "::", "findOne", "(", ")", "->", "createMessage", "(", ")", ";", "return", "$", "event", ";", "}" ]
@param GrantRolesToApp $command @param Pbjx $pbjx @return AppRolesGranted
[ "@param", "GrantRolesToApp", "$command", "@param", "Pbjx", "$pbjx" ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/GrantRolesToAppHandler.php#L68-L73
expectation-php/expect
src/matcher/ToContain.php
ToContain.match
public function match($actual) { $this->actual = $actual; $strategy = $this->createStrategy(); $this->matchResult = $strategy->match($this->expectValues); return $this->matchResult->isMatched(); }
php
public function match($actual) { $this->actual = $actual; $strategy = $this->createStrategy(); $this->matchResult = $strategy->match($this->expectValues); return $this->matchResult->isMatched(); }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "$", "strategy", "=", "$", "this", "->", "createStrategy", "(", ")", ";", "$", "this", "->", "matchResult", "=", "$", "strategy", "->", "match", "(", "$", "this", "->", "expectValues", ")", ";", "return", "$", "this", "->", "matchResult", "->", "isMatched", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToContain.php#L68-L76