repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
laravel/framework | src/Illuminate/Database/Eloquent/Builder.php | Builder.withoutGlobalScopes | public function withoutGlobalScopes(array $scopes = null)
{
if (! is_array($scopes)) {
$scopes = array_keys($this->scopes);
}
foreach ($scopes as $scope) {
$this->withoutGlobalScope($scope);
}
return $this;
} | php | public function withoutGlobalScopes(array $scopes = null)
{
if (! is_array($scopes)) {
$scopes = array_keys($this->scopes);
}
foreach ($scopes as $scope) {
$this->withoutGlobalScope($scope);
}
return $this;
} | [
"public",
"function",
"withoutGlobalScopes",
"(",
"array",
"$",
"scopes",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"scopes",
")",
")",
"{",
"$",
"scopes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"scopes",
")",
";",
"}",
"foreac... | Remove all or passed registered global scopes.
@param array|null $scopes
@return $this | [
"Remove",
"all",
"or",
"passed",
"registered",
"global",
"scopes",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L157-L168 | train | Remove all global scopes from the current context | [
30522,
2270,
3853,
2302,
23296,
16429,
9777,
16186,
2015,
1006,
9140,
1002,
9531,
2015,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
9531,
2015,
1007,
1007,
1063,
1002,
9531,
2015,
1027,
9140,
1035,
6309,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
barryvdh/laravel-debugbar | src/DataCollector/MultiAuthCollector.php | MultiAuthCollector.getUserInformation | protected function getUserInformation($user = null)
{
// Defaults
if (is_null($user)) {
return [
'name' => 'Guest',
'user' => ['guest' => true],
];
}
// The default auth identifer is the ID number, which isn't all that
// useful. Try username and email.
$identifier = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->id;
if (is_numeric($identifier)) {
try {
if ($user->username) {
$identifier = $user->username;
} elseif ($user->email) {
$identifier = $user->email;
}
} catch (\Throwable $e) {
}
}
return [
'name' => $identifier,
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
];
} | php | protected function getUserInformation($user = null)
{
// Defaults
if (is_null($user)) {
return [
'name' => 'Guest',
'user' => ['guest' => true],
];
}
// The default auth identifer is the ID number, which isn't all that
// useful. Try username and email.
$identifier = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->id;
if (is_numeric($identifier)) {
try {
if ($user->username) {
$identifier = $user->username;
} elseif ($user->email) {
$identifier = $user->email;
}
} catch (\Throwable $e) {
}
}
return [
'name' => $identifier,
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
];
} | [
"protected",
"function",
"getUserInformation",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"// Defaults",
"if",
"(",
"is_null",
"(",
"$",
"user",
")",
")",
"{",
"return",
"[",
"'name'",
"=>",
"'Guest'",
",",
"'user'",
"=>",
"[",
"'guest'",
"=>",
"true",
"... | Get displayed user information
@param \Illuminate\Auth\UserInterface $user
@return array | [
"Get",
"displayed",
"user",
"information"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/MultiAuthCollector.php#L103-L131 | train | Get user information | [
30522,
5123,
3853,
2131,
20330,
2378,
14192,
3370,
1006,
1002,
5310,
1027,
19701,
1007,
1063,
1013,
1013,
12398,
2015,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
5310,
1007,
1007,
1063,
2709,
1031,
1005,
2171,
1005,
1027,
1028,
1005,
4113,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2._connect | protected function _connect()
{
if (is_resource($this->_connection)) {
// connection already exists
return;
}
if (!extension_loaded('ibm_db2')) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded');
}
$this->_determineI5();
if ($this->_config['persistent']) {
// use persistent connection
$conn_func_name = 'db2_pconnect';
} else {
// use "normal" connection
$conn_func_name = 'db2_connect';
}
if (!isset($this->_config['driver_options']['autocommit'])) {
// set execution mode
$this->_config['driver_options']['autocommit'] = &$this->_execute_mode;
}
if (isset($this->_config['options'][Zend_Db::CASE_FOLDING])) {
$caseAttrMap = array(
Zend_Db::CASE_NATURAL => DB2_CASE_NATURAL,
Zend_Db::CASE_UPPER => DB2_CASE_UPPER,
Zend_Db::CASE_LOWER => DB2_CASE_LOWER
);
$this->_config['driver_options']['DB2_ATTR_CASE'] = $caseAttrMap[$this->_config['options'][Zend_Db::CASE_FOLDING]];
}
if ($this->_isI5 && isset($this->_config['driver_options']['i5_naming'])) {
if ($this->_config['driver_options']['i5_naming']) {
$this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_ON;
} else {
$this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_OFF;
}
}
if ($this->_config['host'] !== 'localhost' && !$this->_isI5) {
// if the host isn't localhost, use extended connection params
$dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .
';DATABASE=' . $this->_config['dbname'] .
';HOSTNAME=' . $this->_config['host'] .
';PORT=' . $this->_config['port'] .
';PROTOCOL=' . $this->_config['protocol'] .
';UID=' . $this->_config['username'] .
';PWD=' . $this->_config['password'] .';';
$this->_connection = $conn_func_name(
$dbname,
null,
null,
$this->_config['driver_options']
);
} else {
// host is localhost, so use standard connection params
$this->_connection = $conn_func_name(
$this->_config['dbname'],
$this->_config['username'],
$this->_config['password'],
$this->_config['driver_options']
);
}
// check the connection
if (!$this->_connection) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error());
}
} | php | protected function _connect()
{
if (is_resource($this->_connection)) {
// connection already exists
return;
}
if (!extension_loaded('ibm_db2')) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded');
}
$this->_determineI5();
if ($this->_config['persistent']) {
// use persistent connection
$conn_func_name = 'db2_pconnect';
} else {
// use "normal" connection
$conn_func_name = 'db2_connect';
}
if (!isset($this->_config['driver_options']['autocommit'])) {
// set execution mode
$this->_config['driver_options']['autocommit'] = &$this->_execute_mode;
}
if (isset($this->_config['options'][Zend_Db::CASE_FOLDING])) {
$caseAttrMap = array(
Zend_Db::CASE_NATURAL => DB2_CASE_NATURAL,
Zend_Db::CASE_UPPER => DB2_CASE_UPPER,
Zend_Db::CASE_LOWER => DB2_CASE_LOWER
);
$this->_config['driver_options']['DB2_ATTR_CASE'] = $caseAttrMap[$this->_config['options'][Zend_Db::CASE_FOLDING]];
}
if ($this->_isI5 && isset($this->_config['driver_options']['i5_naming'])) {
if ($this->_config['driver_options']['i5_naming']) {
$this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_ON;
} else {
$this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_OFF;
}
}
if ($this->_config['host'] !== 'localhost' && !$this->_isI5) {
// if the host isn't localhost, use extended connection params
$dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .
';DATABASE=' . $this->_config['dbname'] .
';HOSTNAME=' . $this->_config['host'] .
';PORT=' . $this->_config['port'] .
';PROTOCOL=' . $this->_config['protocol'] .
';UID=' . $this->_config['username'] .
';PWD=' . $this->_config['password'] .';';
$this->_connection = $conn_func_name(
$dbname,
null,
null,
$this->_config['driver_options']
);
} else {
// host is localhost, so use standard connection params
$this->_connection = $conn_func_name(
$this->_config['dbname'],
$this->_config['username'],
$this->_config['password'],
$this->_config['driver_options']
);
}
// check the connection
if (!$this->_connection) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error());
}
} | [
"protected",
"function",
"_connect",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_connection",
")",
")",
"{",
"// connection already exists",
"return",
";",
"}",
"if",
"(",
"!",
"extension_loaded",
"(",
"'ibm_db2'",
")",
")",
"{",
"/*... | Creates a connection resource.
@return void | [
"Creates",
"a",
"connection",
"resource",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L119-L198 | train | Connect to the database | [
30522,
5123,
3853,
1035,
7532,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
7692,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1007,
1063,
1013,
1013,
4434,
2525,
6526,
2709,
1025,
1065,
2065,
1006,
999,
5331,
1035,
8209,
1006,
1005,
9980... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.register | public function register()
{
parent::register('system');
$this->registerSingletons();
$this->registerPrivilegedActions();
/*
* Register all plugins
*/
PluginManager::instance()->registerAll();
$this->registerConsole();
$this->registerErrorHandler();
$this->registerLogging();
$this->registerTwigParser();
$this->registerMailer();
$this->registerMarkupTags();
$this->registerAssetBundles();
$this->registerValidator();
$this->registerGlobalViewVars();
/*
* Register other module providers
*/
foreach (Config::get('cms.loadModules', []) as $module) {
if (strtolower(trim($module)) != 'system') {
App::register('\\' . $module . '\ServiceProvider');
}
}
/*
* Backend specific
*/
if (App::runningInBackend()) {
$this->registerBackendNavigation();
$this->registerBackendReportWidgets();
$this->registerBackendPermissions();
$this->registerBackendSettings();
}
} | php | public function register()
{
parent::register('system');
$this->registerSingletons();
$this->registerPrivilegedActions();
/*
* Register all plugins
*/
PluginManager::instance()->registerAll();
$this->registerConsole();
$this->registerErrorHandler();
$this->registerLogging();
$this->registerTwigParser();
$this->registerMailer();
$this->registerMarkupTags();
$this->registerAssetBundles();
$this->registerValidator();
$this->registerGlobalViewVars();
/*
* Register other module providers
*/
foreach (Config::get('cms.loadModules', []) as $module) {
if (strtolower(trim($module)) != 'system') {
App::register('\\' . $module . '\ServiceProvider');
}
}
/*
* Backend specific
*/
if (App::runningInBackend()) {
$this->registerBackendNavigation();
$this->registerBackendReportWidgets();
$this->registerBackendPermissions();
$this->registerBackendSettings();
}
} | [
"public",
"function",
"register",
"(",
")",
"{",
"parent",
"::",
"register",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"registerSingletons",
"(",
")",
";",
"$",
"this",
"->",
"registerPrivilegedActions",
"(",
")",
";",
"/*\n * Register all plugins\n ... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L37-L77 | train | Registers all modules | [
30522,
2270,
3853,
4236,
1006,
1007,
1063,
6687,
1024,
1024,
4236,
1006,
1005,
2291,
1005,
1007,
1025,
1002,
2023,
1011,
1028,
18687,
2075,
19263,
2015,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
4236,
18098,
12848,
9463,
5999,
18908,
8496,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connectors/Connector.php | Connector.createPdoConnection | protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
return new PDOConnection($dsn, $username, $password, $options);
}
return new PDO($dsn, $username, $password, $options);
} | php | protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
return new PDOConnection($dsn, $username, $password, $options);
}
return new PDO($dsn, $username, $password, $options);
} | [
"protected",
"function",
"createPdoConnection",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
"{",
"if",
"(",
"class_exists",
"(",
"PDOConnection",
"::",
"class",
")",
"&&",
"!",
"$",
"this",
"->",
"isPersistentConn... | Create a new PDO connection instance.
@param string $dsn
@param string $username
@param string $password
@param array $options
@return \PDO | [
"Create",
"a",
"new",
"PDO",
"connection",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connectors/Connector.php#L64-L71 | train | Create a PDO connection | [
30522,
5123,
3853,
3443,
17299,
24163,
10087,
7542,
1006,
1002,
16233,
2078,
1010,
1002,
5310,
18442,
1010,
1002,
20786,
1010,
1002,
7047,
1007,
1063,
2065,
1006,
2465,
1035,
6526,
1006,
22851,
24163,
10087,
7542,
1024,
1024,
2465,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Controller.php | Controller.getLastUnitGraphAcrossPlugins | protected function getLastUnitGraphAcrossPlugins($currentModuleName, $currentControllerAction, $columnsToDisplay = false,
$selectableColumns = array(), $reportDocumentation = false,
$apiMethod = 'API.get')
{
// load translations from meta data
$idSite = Common::getRequestVar('idSite');
$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
$meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
$columns = array_merge($columnsToDisplay ? $columnsToDisplay : array(), $selectableColumns);
$translations = array_combine($columns, $columns);
foreach ($meta as $reportMeta) {
if ($reportMeta['action'] == 'get' && !isset($reportMeta['parameters'])) {
foreach ($columns as $column) {
if (isset($reportMeta['metrics'][$column])) {
$translations[$column] = $reportMeta['metrics'][$column];
}
}
}
}
// initialize the graph and load the data
$view = $this->getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod);
if ($columnsToDisplay !== false) {
$view->config->columns_to_display = $columnsToDisplay;
}
if (property_exists($view->config, 'selectable_columns')) {
$view->config->selectable_columns = array_merge($view->config->selectable_columns ? : array(), $selectableColumns);
}
$view->config->translations += $translations;
if ($reportDocumentation) {
$view->config->documentation = $reportDocumentation;
}
return $view;
} | php | protected function getLastUnitGraphAcrossPlugins($currentModuleName, $currentControllerAction, $columnsToDisplay = false,
$selectableColumns = array(), $reportDocumentation = false,
$apiMethod = 'API.get')
{
// load translations from meta data
$idSite = Common::getRequestVar('idSite');
$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
$meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
$columns = array_merge($columnsToDisplay ? $columnsToDisplay : array(), $selectableColumns);
$translations = array_combine($columns, $columns);
foreach ($meta as $reportMeta) {
if ($reportMeta['action'] == 'get' && !isset($reportMeta['parameters'])) {
foreach ($columns as $column) {
if (isset($reportMeta['metrics'][$column])) {
$translations[$column] = $reportMeta['metrics'][$column];
}
}
}
}
// initialize the graph and load the data
$view = $this->getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod);
if ($columnsToDisplay !== false) {
$view->config->columns_to_display = $columnsToDisplay;
}
if (property_exists($view->config, 'selectable_columns')) {
$view->config->selectable_columns = array_merge($view->config->selectable_columns ? : array(), $selectableColumns);
}
$view->config->translations += $translations;
if ($reportDocumentation) {
$view->config->documentation = $reportDocumentation;
}
return $view;
} | [
"protected",
"function",
"getLastUnitGraphAcrossPlugins",
"(",
"$",
"currentModuleName",
",",
"$",
"currentControllerAction",
",",
"$",
"columnsToDisplay",
"=",
"false",
",",
"$",
"selectableColumns",
"=",
"array",
"(",
")",
",",
"$",
"reportDocumentation",
"=",
"fa... | Same as {@link getLastUnitGraph()}, but will set some properties of the ViewDataTable
object based on the arguments supplied.
@param string $currentModuleName The name of the current plugin.
@param string $currentControllerAction The name of the action that renders the desired
report.
@param array $columnsToDisplay The value to use for the ViewDataTable's columns_to_display config
property.
@param array $selectableColumns The value to use for the ViewDataTable's selectable_columns config
property.
@param bool|string $reportDocumentation The value to use for the ViewDataTable's documentation config
property.
@param string $apiMethod The API method that the ViewDataTable will use to get graph data.
@return ViewDataTable
@api | [
"Same",
"as",
"{",
"@link",
"getLastUnitGraph",
"()",
"}",
"but",
"will",
"set",
"some",
"properties",
"of",
"the",
"ViewDataTable",
"object",
"based",
"on",
"the",
"arguments",
"supplied",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Controller.php#L390-L430 | train | This method is used to get the last unit graph of the API. | [
30522,
5123,
3853,
2131,
8523,
8525,
3490,
2102,
14413,
6305,
25725,
24759,
15916,
7076,
1006,
1002,
2783,
5302,
8566,
20844,
4168,
1010,
1002,
2783,
8663,
13181,
10820,
18908,
3258,
1010,
1002,
7753,
3406,
10521,
13068,
1027,
6270,
1010,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php | SwiftMailerHandler.flushMemorySpool | private function flushMemorySpool()
{
$mailerTransport = $this->mailer->getTransport();
if (!$mailerTransport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $mailerTransport->getSpool();
if (!$spool instanceof \Swift_MemorySpool) {
return;
}
if (null === $this->transport) {
throw new \Exception('No transport available to flush mail queue');
}
$spool->flushQueue($this->transport);
} | php | private function flushMemorySpool()
{
$mailerTransport = $this->mailer->getTransport();
if (!$mailerTransport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $mailerTransport->getSpool();
if (!$spool instanceof \Swift_MemorySpool) {
return;
}
if (null === $this->transport) {
throw new \Exception('No transport available to flush mail queue');
}
$spool->flushQueue($this->transport);
} | [
"private",
"function",
"flushMemorySpool",
"(",
")",
"{",
"$",
"mailerTransport",
"=",
"$",
"this",
"->",
"mailer",
"->",
"getTransport",
"(",
")",
";",
"if",
"(",
"!",
"$",
"mailerTransport",
"instanceof",
"\\",
"Swift_Transport_SpoolTransport",
")",
"{",
"re... | Flushes the mail queue if a memory spool is used. | [
"Flushes",
"the",
"mail",
"queue",
"if",
"a",
"memory",
"spool",
"is",
"used",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php#L75-L92 | train | Flushes the memory spool of the mail queue | [
30522,
2797,
3853,
13862,
4168,
5302,
24769,
16869,
1006,
1007,
1063,
1002,
5653,
8743,
5521,
20205,
1027,
1002,
2023,
1011,
1028,
5653,
2121,
1011,
1028,
2131,
6494,
3619,
6442,
1006,
1007,
1025,
2065,
1006,
999,
1002,
5653,
8743,
5521,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Console/Migrations/BaseCommand.php | BaseCommand.getMigrationPaths | protected function getMigrationPaths()
{
// Here, we will check to see if a path option has been defined. If it has we will
// use the path relative to the root of the installation folder so our database
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$path
: $path;
})->all();
}
return array_merge(
$this->migrator->paths(), [$this->getMigrationPath()]
);
} | php | protected function getMigrationPaths()
{
// Here, we will check to see if a path option has been defined. If it has we will
// use the path relative to the root of the installation folder so our database
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$path
: $path;
})->all();
}
return array_merge(
$this->migrator->paths(), [$this->getMigrationPath()]
);
} | [
"protected",
"function",
"getMigrationPaths",
"(",
")",
"{",
"// Here, we will check to see if a path option has been defined. If it has we will",
"// use the path relative to the root of the installation folder so our database",
"// migrations may be run for any customized path from within the appl... | Get all of the migration paths.
@return array | [
"Get",
"all",
"of",
"the",
"migration",
"paths",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Console/Migrations/BaseCommand.php#L14-L30 | train | Get the migration paths | [
30522,
5123,
3853,
2131,
4328,
29397,
15069,
2015,
1006,
1007,
1063,
1013,
1013,
2182,
1010,
2057,
2097,
4638,
2000,
2156,
2065,
1037,
4130,
5724,
2038,
2042,
4225,
1012,
2065,
2009,
2038,
2057,
2097,
1013,
1013,
2224,
1996,
4130,
5816,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Filesystem/Filesystem.php | Filesystem.readlink | public function readlink($path, $canonicalize = false)
{
if (!$canonicalize && !is_link($path)) {
return;
}
if ($canonicalize) {
if (!$this->exists($path)) {
return;
}
if ('\\' === \DIRECTORY_SEPARATOR) {
$path = readlink($path);
}
return realpath($path);
}
if ('\\' === \DIRECTORY_SEPARATOR) {
return realpath($path);
}
return readlink($path);
} | php | public function readlink($path, $canonicalize = false)
{
if (!$canonicalize && !is_link($path)) {
return;
}
if ($canonicalize) {
if (!$this->exists($path)) {
return;
}
if ('\\' === \DIRECTORY_SEPARATOR) {
$path = readlink($path);
}
return realpath($path);
}
if ('\\' === \DIRECTORY_SEPARATOR) {
return realpath($path);
}
return readlink($path);
} | [
"public",
"function",
"readlink",
"(",
"$",
"path",
",",
"$",
"canonicalize",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"canonicalize",
"&&",
"!",
"is_link",
"(",
"$",
"path",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"canonicalize",
")... | Resolves links in paths.
With $canonicalize = false (default)
- if $path does not exist or is not a link, returns null
- if $path is a link, returns the next direct target of the link without considering the existence of the target
With $canonicalize = true
- if $path does not exist, returns null
- if $path exists, returns its absolute fully resolved final version
@param string $path A filesystem path
@param bool $canonicalize Whether or not to return a canonicalized path
@return string|null | [
"Resolves",
"links",
"in",
"paths",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Filesystem/Filesystem.php#L414-L437 | train | Read link. | [
30522,
2270,
3853,
3191,
13767,
1006,
1002,
4130,
1010,
1002,
18562,
4697,
1027,
6270,
1007,
1063,
2065,
1006,
999,
1002,
18562,
4697,
1004,
1004,
999,
2003,
1035,
4957,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Dompdf.php | Dompdf.loadHtmlFile | public function loadHtmlFile($file)
{
$this->saveLocale();
if (!$this->protocol && !$this->baseHost && !$this->basePath) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
}
$protocol = strtolower($this->protocol);
if ( !in_array($protocol, $this->allowedProtocols) ) {
throw new Exception("Permission denied on $file. The communication protocol is not supported.");
}
if (!$this->options->isRemoteEnabled() && ($protocol != "" && $protocol !== "file://")) {
throw new Exception("Remote file requested, but remote file download is disabled.");
}
if ($protocol == "" || $protocol === "file://") {
$realfile = realpath($file);
$chroot = realpath($this->options->getChroot());
if ($chroot && strpos($realfile, $chroot) !== 0) {
throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
}
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
throw new Exception("Permission denied on $file. This file extension is forbidden");
}
if (!$realfile) {
throw new Exception("File '$file' not found.");
}
$file = $realfile;
}
list($contents, $http_response_header) = Helpers::getFileContent($file, $this->httpContext);
$encoding = 'UTF-8';
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header)) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
$encoding = strtoupper($matches[1]);
break;
}
}
}
$this->restoreLocale();
$this->loadHtml($contents, $encoding);
} | php | public function loadHtmlFile($file)
{
$this->saveLocale();
if (!$this->protocol && !$this->baseHost && !$this->basePath) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
}
$protocol = strtolower($this->protocol);
if ( !in_array($protocol, $this->allowedProtocols) ) {
throw new Exception("Permission denied on $file. The communication protocol is not supported.");
}
if (!$this->options->isRemoteEnabled() && ($protocol != "" && $protocol !== "file://")) {
throw new Exception("Remote file requested, but remote file download is disabled.");
}
if ($protocol == "" || $protocol === "file://") {
$realfile = realpath($file);
$chroot = realpath($this->options->getChroot());
if ($chroot && strpos($realfile, $chroot) !== 0) {
throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
}
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
throw new Exception("Permission denied on $file. This file extension is forbidden");
}
if (!$realfile) {
throw new Exception("File '$file' not found.");
}
$file = $realfile;
}
list($contents, $http_response_header) = Helpers::getFileContent($file, $this->httpContext);
$encoding = 'UTF-8';
// See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
if (isset($http_response_header)) {
foreach ($http_response_header as $_header) {
if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
$encoding = strtoupper($matches[1]);
break;
}
}
}
$this->restoreLocale();
$this->loadHtml($contents, $encoding);
} | [
"public",
"function",
"loadHtmlFile",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"saveLocale",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"protocol",
"&&",
"!",
"$",
"this",
"->",
"baseHost",
"&&",
"!",
"$",
"this",
"->",
"basePath",
")"... | Loads an HTML file
Parse errors are stored in the global array _dompdf_warnings.
@param string $file a filename or url to load
@throws Exception | [
"Loads",
"an",
"HTML",
"file",
"Parse",
"errors",
"are",
"stored",
"in",
"the",
"global",
"array",
"_dompdf_warnings",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L349-L402 | train | Load HTML File | [
30522,
2270,
3853,
7170,
11039,
19968,
8873,
2571,
1006,
1002,
5371,
1007,
1063,
1002,
2023,
1011,
1028,
3828,
4135,
9289,
2063,
1006,
1007,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
8778,
1004,
1004,
999,
1002,
2023,
1011,
1028,
291... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php | AbstractNormalizer.handleCircularReference | protected function handleCircularReference($object/*, string $format = null, array $context = []*/)
{
if (\func_num_args() < 2 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$format = \func_num_args() > 1 ? func_get_arg(1) : null;
$context = \func_num_args() > 2 ? func_get_arg(2) : [];
$circularReferenceHandler = $context[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->circularReferenceHandler;
if ($circularReferenceHandler) {
return $circularReferenceHandler($object, $format, $context);
}
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $this->circularReferenceLimit));
} | php | protected function handleCircularReference($object/*, string $format = null, array $context = []*/)
{
if (\func_num_args() < 2 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$format = \func_num_args() > 1 ? func_get_arg(1) : null;
$context = \func_num_args() > 2 ? func_get_arg(2) : [];
$circularReferenceHandler = $context[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->circularReferenceHandler;
if ($circularReferenceHandler) {
return $circularReferenceHandler($object, $format, $context);
}
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $this->circularReferenceLimit));
} | [
"protected",
"function",
"handleCircularReference",
"(",
"$",
"object",
"/*, string $format = null, array $context = []*/",
")",
"{",
"if",
"(",
"\\",
"func_num_args",
"(",
")",
"<",
"2",
"&&",
"__CLASS__",
"!==",
"\\",
"get_class",
"(",
"$",
"this",
")",
"&&",
... | Handles a circular reference.
If a circular reference handler is set, it will be called. Otherwise, a
{@class CircularReferenceException} will be thrown.
@final since Symfony 4.2
@param object $object
@param string|null $format
@param array $context
@return mixed
@throws CircularReferenceException | [
"Handles",
"a",
"circular",
"reference",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L319-L333 | train | Handles circular references | [
30522,
5123,
3853,
5047,
6895,
11890,
7934,
2890,
25523,
1006,
1002,
4874,
1013,
1008,
1010,
5164,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1008,
1013,
1007,
1063,
2065,
1006,
1032,
4569,
2278,
1035,
16371,
2213,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Response.php | Response.isRedirect | public function isRedirect(string $location = null): bool
{
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
} | php | public function isRedirect(string $location = null): bool
{
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
} | [
"public",
"function",
"isRedirect",
"(",
"string",
"$",
"location",
"=",
"null",
")",
":",
"bool",
"{",
"return",
"\\",
"in_array",
"(",
"$",
"this",
"->",
"statusCode",
",",
"[",
"201",
",",
"301",
",",
"302",
",",
"303",
",",
"307",
",",
"308",
"... | Is the response a redirect of some form?
@final | [
"Is",
"the",
"response",
"a",
"redirect",
"of",
"some",
"form?"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Response.php#L1189-L1192 | train | Is this response a redirect? | [
30522,
2270,
3853,
2003,
5596,
7442,
6593,
1006,
5164,
1002,
3295,
1027,
19701,
1007,
1024,
22017,
2140,
1063,
2709,
1032,
1999,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
3570,
16044,
1010,
1031,
16345,
1010,
19123,
1010,
22060,
1010,
19988... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/API.php | API.getMetadata | public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array(), $language = false,
$period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false)
{
Piwik::checkUserHasViewAccess($idSite);
if ($language) {
/** @var Translator $translator */
$translator = StaticContainer::get('Piwik\Translation\Translator');
$translator->setCurrentLanguage($language);
}
$metadata = $this->processedReport->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
} | php | public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array(), $language = false,
$period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false)
{
Piwik::checkUserHasViewAccess($idSite);
if ($language) {
/** @var Translator $translator */
$translator = StaticContainer::get('Piwik\Translation\Translator');
$translator->setCurrentLanguage($language);
}
$metadata = $this->processedReport->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"idSite",
",",
"$",
"apiModule",
",",
"$",
"apiAction",
",",
"$",
"apiParameters",
"=",
"array",
"(",
")",
",",
"$",
"language",
"=",
"false",
",",
"$",
"period",
"=",
"false",
",",
"$",
"date",
"=",
"fa... | Loads reports metadata, then return the requested one,
matching optional API parameters. | [
"Loads",
"reports",
"metadata",
"then",
"return",
"the",
"requested",
"one",
"matching",
"optional",
"API",
"parameters",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/API.php#L295-L308 | train | Returns metadata for the specified site | [
30522,
2270,
3853,
2131,
11368,
8447,
2696,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
17928,
5302,
8566,
2571,
1010,
1002,
17928,
18908,
3258,
1010,
1002,
30524,
5342,
12589,
16150,
10085,
1027,
6270,
1010,
1002,
3065,
12083,
10880,
2890,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Css/Style.php | Style.set_background_repeat | function set_background_repeat($val)
{
if (is_null($val)) {
$val = self::$_defaults["background_repeat"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_repeat"] = null;
$this->_props["background_repeat"] = $val;
} | php | function set_background_repeat($val)
{
if (is_null($val)) {
$val = self::$_defaults["background_repeat"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_repeat"] = null;
$this->_props["background_repeat"] = $val;
} | [
"function",
"set_background_repeat",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"$",
"val",
"=",
"self",
"::",
"$",
"_defaults",
"[",
"\"background_repeat\"",
"]",
";",
"}",
"//see __set and __get, on all assignments clear... | Sets the background repeat
@link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
@param string $val | [
"Sets",
"the",
"background",
"repeat"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1858-L1867 | train | set background repeat | [
30522,
3853,
2275,
1035,
4281,
1035,
9377,
1006,
1002,
11748,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
11748,
1007,
1007,
1063,
1002,
11748,
1027,
2969,
1024,
1024,
1002,
1035,
12398,
2015,
1031,
1000,
4281,
1035,
9377,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.arrayMergeRecursiveUnique | public static function arrayMergeRecursiveUnique($array1, $array2)
{
if (empty($array1)) {
// Optimize the base case
return $array2;
}
foreach ($array2 as $key => $value) {
if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) {
$value = static::arrayMergeRecursiveUnique($array1[$key], $value);
}
$array1[$key] = $value;
}
return $array1;
} | php | public static function arrayMergeRecursiveUnique($array1, $array2)
{
if (empty($array1)) {
// Optimize the base case
return $array2;
}
foreach ($array2 as $key => $value) {
if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) {
$value = static::arrayMergeRecursiveUnique($array1[$key], $value);
}
$array1[$key] = $value;
}
return $array1;
} | [
"public",
"static",
"function",
"arrayMergeRecursiveUnique",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array1",
")",
")",
"{",
"// Optimize the base case",
"return",
"$",
"array2",
";",
"}",
"foreach",
"(",
"$",
"arra... | Recursive Merge with uniqueness
@param array $array1
@param array $array2
@return array | [
"Recursive",
"Merge",
"with",
"uniqueness"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L284-L299 | train | Recursive merge array1 = > array2 | [
30522,
2270,
10763,
3853,
9140,
5017,
4590,
8586,
9236,
3512,
19496,
4226,
1006,
1002,
9140,
2487,
1010,
1002,
9140,
2475,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
9140,
2487,
1007,
1007,
1063,
1013,
1013,
23569,
27605,
4371,
1996,
2918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Mbox.php | Zend_Mail_Storage_Mbox.getMessage | public function getMessage($id)
{
// TODO that's ugly, would be better to let the message class decide
if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
// TODO top/body lines
$messagePos = $this->_getPos($id);
return new $this->_messageClass(array('file' => $this->_fh, 'startPos' => $messagePos['start'],
'endPos' => $messagePos['end']));
}
$bodyLines = 0; // TODO: need a way to change that
$message = $this->getRawHeader($id);
// file pointer is after headers now
if ($bodyLines) {
$message .= "\n";
while ($bodyLines-- && ftell($this->_fh) < $this->_positions[$id - 1]['end']) {
$message .= fgets($this->_fh);
}
}
return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $message));
} | php | public function getMessage($id)
{
// TODO that's ugly, would be better to let the message class decide
if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
// TODO top/body lines
$messagePos = $this->_getPos($id);
return new $this->_messageClass(array('file' => $this->_fh, 'startPos' => $messagePos['start'],
'endPos' => $messagePos['end']));
}
$bodyLines = 0; // TODO: need a way to change that
$message = $this->getRawHeader($id);
// file pointer is after headers now
if ($bodyLines) {
$message .= "\n";
while ($bodyLines-- && ftell($this->_fh) < $this->_positions[$id - 1]['end']) {
$message .= fgets($this->_fh);
}
}
return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $message));
} | [
"public",
"function",
"getMessage",
"(",
"$",
"id",
")",
"{",
"// TODO that's ugly, would be better to let the message class decide",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"_messageClass",
")",
"==",
"'zend_mail_message_file'",
"||",
"is_subclass_of",
"(",
"$... | Fetch a message
@param int $id number of message
@return Zend_Mail_Message_File
@throws Zend_Mail_Storage_Exception | [
"Fetch",
"a",
"message"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Mbox.php#L142-L164 | train | Returns the message object for the given message id | [
30522,
2270,
3853,
2131,
7834,
3736,
3351,
1006,
1002,
8909,
1007,
1063,
1013,
1013,
28681,
2080,
2008,
1005,
1055,
9200,
1010,
2052,
2022,
2488,
2000,
2292,
1996,
4471,
2465,
5630,
2065,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Dimension/DimensionMetadataProvider.php | DimensionMetadataProvider.getActionReferenceColumnsByTable | public function getActionReferenceColumnsByTable()
{
$result = array(
'log_link_visit_action' => array('idaction_url',
'idaction_url_ref',
'idaction_name_ref'
),
'log_conversion' => array('idaction_url'),
'log_visit' => array('visit_exit_idaction_url',
'visit_exit_idaction_name',
'visit_entry_idaction_url',
'visit_entry_idaction_name'),
'log_conversion_item' => array('idaction_sku',
'idaction_name',
'idaction_category',
'idaction_category2',
'idaction_category3',
'idaction_category4',
'idaction_category5')
);
$dimensionIdActionColumns = $this->getVisitActionTableActionReferences();
$result['log_link_visit_action'] = array_unique(
array_merge($result['log_link_visit_action'], $dimensionIdActionColumns));
foreach ($this->actionReferenceColumnsOverride as $table => $columns) {
if (empty($result[$table])) {
$result[$table] = $columns;
} else {
$result[$table] = array_unique(array_merge($result[$table], $columns));
}
}
/**
* Triggered when detecting which log_action entries to keep. Any log tables that use the log_action
* table to reference text via an ID should add their table info so no actions that are still in use
* will be accidentally deleted.
*
* **Example**
*
* Piwik::addAction('Db.getActionReferenceColumnsByTable', function(&$result) {
* $tableNameUnprefixed = 'log_example';
* $columnNameThatReferencesIdActionInLogActionTable = 'idaction_example';
* $result[$tableNameUnprefixed] = array($columnNameThatReferencesIdActionInLogActionTable);
* });
* @param array $result
*/
Piwik::postEvent('Db.getActionReferenceColumnsByTable', array(&$result));
return $result;
} | php | public function getActionReferenceColumnsByTable()
{
$result = array(
'log_link_visit_action' => array('idaction_url',
'idaction_url_ref',
'idaction_name_ref'
),
'log_conversion' => array('idaction_url'),
'log_visit' => array('visit_exit_idaction_url',
'visit_exit_idaction_name',
'visit_entry_idaction_url',
'visit_entry_idaction_name'),
'log_conversion_item' => array('idaction_sku',
'idaction_name',
'idaction_category',
'idaction_category2',
'idaction_category3',
'idaction_category4',
'idaction_category5')
);
$dimensionIdActionColumns = $this->getVisitActionTableActionReferences();
$result['log_link_visit_action'] = array_unique(
array_merge($result['log_link_visit_action'], $dimensionIdActionColumns));
foreach ($this->actionReferenceColumnsOverride as $table => $columns) {
if (empty($result[$table])) {
$result[$table] = $columns;
} else {
$result[$table] = array_unique(array_merge($result[$table], $columns));
}
}
/**
* Triggered when detecting which log_action entries to keep. Any log tables that use the log_action
* table to reference text via an ID should add their table info so no actions that are still in use
* will be accidentally deleted.
*
* **Example**
*
* Piwik::addAction('Db.getActionReferenceColumnsByTable', function(&$result) {
* $tableNameUnprefixed = 'log_example';
* $columnNameThatReferencesIdActionInLogActionTable = 'idaction_example';
* $result[$tableNameUnprefixed] = array($columnNameThatReferencesIdActionInLogActionTable);
* });
* @param array $result
*/
Piwik::postEvent('Db.getActionReferenceColumnsByTable', array(&$result));
return $result;
} | [
"public",
"function",
"getActionReferenceColumnsByTable",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'log_link_visit_action'",
"=>",
"array",
"(",
"'idaction_url'",
",",
"'idaction_url_ref'",
",",
"'idaction_name_ref'",
")",
",",
"'log_conversion'",
"=>",
"arra... | Returns a list of idaction column names organized by table name. Uses dimension metadata
to find idaction columns dynamically.
Note: It is not currently possible to use the Piwik platform to add idaction columns to tables
other than log_link_visit_action (w/o doing something unsupported), so idaction columns in
other tables are hard coded.
@return array[] | [
"Returns",
"a",
"list",
"of",
"idaction",
"column",
"names",
"organized",
"by",
"table",
"name",
".",
"Uses",
"dimension",
"metadata",
"to",
"find",
"idaction",
"columns",
"dynamically",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Dimension/DimensionMetadataProvider.php#L41-L94 | train | Returns an array of action reference columns by table name | [
30522,
2270,
3853,
2131,
18908,
3258,
2890,
25523,
25778,
2819,
3619,
3762,
10880,
1006,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1005,
8833,
1035,
4957,
1035,
3942,
1035,
2895,
1005,
1027,
1028,
9140,
1006,
1005,
16096,
7542,
1035,
24471,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Apc.php | Zend_Cache_Backend_Apc.load | public function load($id, $doNotTestCacheValidity = false)
{
$tmp = apc_fetch($id);
if (is_array($tmp)) {
return $tmp[0];
}
return false;
} | php | public function load($id, $doNotTestCacheValidity = false)
{
$tmp = apc_fetch($id);
if (is_array($tmp)) {
return $tmp[0];
}
return false;
} | [
"public",
"function",
"load",
"(",
"$",
"id",
",",
"$",
"doNotTestCacheValidity",
"=",
"false",
")",
"{",
"$",
"tmp",
"=",
"apc_fetch",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"tmp",
")",
")",
"{",
"return",
"$",
"tmp",
"[",
"0... | Test if a cache is available for the given id and (if yes) return it (false else)
WARNING $doNotTestCacheValidity=true is unsupported by the Apc backend
@param string $id cache id
@param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
@return string cached datas (or false) | [
"Test",
"if",
"a",
"cache",
"is",
"available",
"for",
"the",
"given",
"id",
"and",
"(",
"if",
"yes",
")",
"return",
"it",
"(",
"false",
"else",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Apc.php#L73-L80 | train | Load a language from the cache | [
30522,
2270,
3853,
7170,
1006,
1002,
8909,
1010,
1002,
2123,
28495,
3367,
3540,
16179,
11475,
25469,
1027,
6270,
1007,
1063,
1002,
1056,
8737,
1027,
9706,
2278,
1035,
18584,
1006,
1002,
8909,
1007,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Mapping/ClassMetadata.php | ClassMetadata.setGroupSequenceProvider | public function setGroupSequenceProvider($active)
{
if ($this->hasGroupSequence()) {
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence');
}
if (!$this->getReflectionClass()->implementsInterface('Symfony\Component\Validator\GroupSequenceProviderInterface')) {
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface', $this->name));
}
$this->groupSequenceProvider = $active;
} | php | public function setGroupSequenceProvider($active)
{
if ($this->hasGroupSequence()) {
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence');
}
if (!$this->getReflectionClass()->implementsInterface('Symfony\Component\Validator\GroupSequenceProviderInterface')) {
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface', $this->name));
}
$this->groupSequenceProvider = $active;
} | [
"public",
"function",
"setGroupSequenceProvider",
"(",
"$",
"active",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasGroupSequence",
"(",
")",
")",
"{",
"throw",
"new",
"GroupDefinitionException",
"(",
"'Defining a group sequence provider is not allowed with a static group s... | Sets whether a group sequence provider should be used.
@param bool $active
@throws GroupDefinitionException | [
"Sets",
"whether",
"a",
"group",
"sequence",
"provider",
"should",
"be",
"used",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Mapping/ClassMetadata.php#L461-L472 | train | Set the group sequence provider | [
30522,
2270,
3853,
2275,
17058,
3366,
4226,
5897,
21572,
17258,
2121,
1006,
1002,
3161,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
17058,
3366,
4226,
5897,
1006,
1007,
1007,
1063,
5466,
2047,
2177,
3207,
16294,
22753,
10288,
2442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Card/SubMerchantClient.php | SubMerchantClient.update | public function update(int $merchantId, array $info = [])
{
$params = [
'info' => array_merge(['merchant_id' => $merchantId],
Arr::only($info, [
'brand_name',
'logo_url',
'protocol',
'end_time',
'primary_category_id',
'secondary_category_id',
'agreement_media_id',
'operator_media_id',
'app_id',
])),
];
return $this->httpPostJson('card/submerchant/update', $params);
} | php | public function update(int $merchantId, array $info = [])
{
$params = [
'info' => array_merge(['merchant_id' => $merchantId],
Arr::only($info, [
'brand_name',
'logo_url',
'protocol',
'end_time',
'primary_category_id',
'secondary_category_id',
'agreement_media_id',
'operator_media_id',
'app_id',
])),
];
return $this->httpPostJson('card/submerchant/update', $params);
} | [
"public",
"function",
"update",
"(",
"int",
"$",
"merchantId",
",",
"array",
"$",
"info",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"'info'",
"=>",
"array_merge",
"(",
"[",
"'merchant_id'",
"=>",
"$",
"merchantId",
"]",
",",
"Arr",
"::",
"onl... | 更新子商户.
@param int $merchantId
@param array $info
@return mixed | [
"更新子商户",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/SubMerchantClient.php#L58-L76 | train | Update a card submerchant | [
30522,
2270,
3853,
10651,
1006,
20014,
1002,
6432,
3593,
1010,
9140,
1002,
18558,
1027,
1031,
1033,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
18558,
1005,
1027,
1028,
9140,
1035,
13590,
1006,
1031,
1005,
6432,
1035,
8909,
1005,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.menu | public function menu($var = null)
{
if ($var !== null) {
$this->menu = $var;
}
if (empty($this->menu)) {
$this->menu = $this->title();
}
return $this->menu;
} | php | public function menu($var = null)
{
if ($var !== null) {
$this->menu = $var;
}
if (empty($this->menu)) {
$this->menu = $this->title();
}
return $this->menu;
} | [
"public",
"function",
"menu",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"menu",
"=",
"$",
"var",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"menu",
")",
")",
"{",
"... | Gets and sets the menu name for this Page. This is the text that can be used specifically for navigation.
If no menu field is set, it will use the title()
@param string $var the menu field for the page
@return string the menu field for the page | [
"Gets",
"and",
"sets",
"the",
"menu",
"name",
"for",
"this",
"Page",
".",
"This",
"is",
"the",
"text",
"that",
"can",
"be",
"used",
"specifically",
"for",
"navigation",
".",
"If",
"no",
"menu",
"field",
"is",
"set",
"it",
"will",
"use",
"the",
"title",... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L1519-L1529 | train | Get menu of the page | [
30522,
2270,
3853,
12183,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
12183,
1027,
1002,
13075,
1025,
1065,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/ChoiceList/Loader/CallbackChoiceLoader.php | CallbackChoiceLoader.loadChoiceList | public function loadChoiceList($value = null)
{
if (null !== $this->choiceList) {
return $this->choiceList;
}
return $this->choiceList = new ArrayChoiceList(($this->callback)(), $value);
} | php | public function loadChoiceList($value = null)
{
if (null !== $this->choiceList) {
return $this->choiceList;
}
return $this->choiceList = new ArrayChoiceList(($this->callback)(), $value);
} | [
"public",
"function",
"loadChoiceList",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"choiceList",
")",
"{",
"return",
"$",
"this",
"->",
"choiceList",
";",
"}",
"return",
"$",
"this",
"->",
"choiceList",
"=",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/ChoiceList/Loader/CallbackChoiceLoader.php#L43-L50 | train | Load the choice list | [
30522,
2270,
3853,
7170,
9905,
6610,
9863,
1006,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
3601,
9863,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3601,
9863,
1025,
1065,
2709,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Overlay/Controller.php | Controller.showErrorWrongDomain | public function showErrorWrongDomain()
{
$this->checkSitePermission();
Piwik::checkUserHasViewAccess($this->idSite);
$url = Common::getRequestVar('url', '');
$url = Common::unsanitizeInputValue($url);
$message = Piwik::translate('Overlay_RedirectUrlError', array($url, "\n"));
$message = nl2br(htmlentities($message, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
$view = new View('@Overlay/showErrorWrongDomain');
$this->addCustomLogoInfo($view);
$view->message = $message;
if (Piwik::isUserHasWriteAccess($this->idSite)) {
// TODO use $idSite to link to the correct row. This is tricky because the #rowX ids don't match
// the site ids when sites have been deleted.
$url = 'index.php?module=SitesManager&action=index';
$troubleshoot = htmlentities(Piwik::translate('Overlay_RedirectUrlErrorAdmin'), ENT_COMPAT | ENT_HTML401, 'UTF-8');
$troubleshoot = sprintf($troubleshoot, '<a href="' . $url . '" target="_top">', '</a>');
$view->troubleshoot = $troubleshoot;
} else {
$view->troubleshoot = htmlentities(Piwik::translate('Overlay_RedirectUrlErrorUser'), ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
$this->outputCORSHeaders();
return $view->render();
} | php | public function showErrorWrongDomain()
{
$this->checkSitePermission();
Piwik::checkUserHasViewAccess($this->idSite);
$url = Common::getRequestVar('url', '');
$url = Common::unsanitizeInputValue($url);
$message = Piwik::translate('Overlay_RedirectUrlError', array($url, "\n"));
$message = nl2br(htmlentities($message, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
$view = new View('@Overlay/showErrorWrongDomain');
$this->addCustomLogoInfo($view);
$view->message = $message;
if (Piwik::isUserHasWriteAccess($this->idSite)) {
// TODO use $idSite to link to the correct row. This is tricky because the #rowX ids don't match
// the site ids when sites have been deleted.
$url = 'index.php?module=SitesManager&action=index';
$troubleshoot = htmlentities(Piwik::translate('Overlay_RedirectUrlErrorAdmin'), ENT_COMPAT | ENT_HTML401, 'UTF-8');
$troubleshoot = sprintf($troubleshoot, '<a href="' . $url . '" target="_top">', '</a>');
$view->troubleshoot = $troubleshoot;
} else {
$view->troubleshoot = htmlentities(Piwik::translate('Overlay_RedirectUrlErrorUser'), ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
$this->outputCORSHeaders();
return $view->render();
} | [
"public",
"function",
"showErrorWrongDomain",
"(",
")",
"{",
"$",
"this",
"->",
"checkSitePermission",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"this",
"->",
"idSite",
")",
";",
"$",
"url",
"=",
"Common",
"::",
"getRequestVar",
"(",
... | This method is called when the JS from startOverlaySession() detects that the target domain
is not configured for the current site. | [
"This",
"method",
"is",
"called",
"when",
"the",
"JS",
"from",
"startOverlaySession",
"()",
"detects",
"that",
"the",
"target",
"domain",
"is",
"not",
"configured",
"for",
"the",
"current",
"site",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Overlay/Controller.php#L189-L217 | train | Show the error wrong domain | [
30522,
2270,
3853,
6457,
29165,
13088,
5063,
9527,
8113,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
14148,
4221,
4842,
25481,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
8584,
6305,
9623,
2015,
1006,
1002,
2023,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/PasswordResetter.php | PasswordResetter.getPasswordToResetTo | private function getPasswordToResetTo($login)
{
$optionName = self::getPasswordResetInfoOptionName($login);
$optionValue = Option::get($optionName);
$optionValue = json_decode($optionValue, $isAssoc = true);
return $optionValue;
} | php | private function getPasswordToResetTo($login)
{
$optionName = self::getPasswordResetInfoOptionName($login);
$optionValue = Option::get($optionName);
$optionValue = json_decode($optionValue, $isAssoc = true);
return $optionValue;
} | [
"private",
"function",
"getPasswordToResetTo",
"(",
"$",
"login",
")",
"{",
"$",
"optionName",
"=",
"self",
"::",
"getPasswordResetInfoOptionName",
"(",
"$",
"login",
")",
";",
"$",
"optionValue",
"=",
"Option",
"::",
"get",
"(",
"$",
"optionName",
")",
";",... | Gets password hash stored in password reset info.
@param string $login The user login to check for.
@return string|false The hashed password or false if no reset info exists. | [
"Gets",
"password",
"hash",
"stored",
"in",
"password",
"reset",
"info",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/PasswordResetter.php#L479-L485 | train | Get password to reset to | [
30522,
2797,
3853,
2131,
15194,
18351,
19277,
21678,
2080,
1006,
1002,
8833,
2378,
1007,
1063,
1002,
5724,
18442,
1027,
2969,
1024,
1024,
2131,
15194,
18351,
6072,
20624,
2078,
14876,
7361,
3508,
18442,
1006,
1002,
8833,
2378,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Helpers.php | Helpers.record_warnings | public static function record_warnings($errno, $errstr, $errfile, $errline)
{
// Not a warning or notice
if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) {
throw new Exception($errstr . " $errno");
}
global $_dompdf_warnings;
global $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
echo $errstr . "\n";
}
$_dompdf_warnings[] = $errstr;
} | php | public static function record_warnings($errno, $errstr, $errfile, $errline)
{
// Not a warning or notice
if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) {
throw new Exception($errstr . " $errno");
}
global $_dompdf_warnings;
global $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
echo $errstr . "\n";
}
$_dompdf_warnings[] = $errstr;
} | [
"public",
"static",
"function",
"record_warnings",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"// Not a warning or notice",
"if",
"(",
"!",
"(",
"$",
"errno",
"&",
"(",
"E_WARNING",
"|",
"E_NOTICE",
"|",
"E... | Stores warnings in an array for display later
This function allows warnings generated by the DomDocument parser
and CSS loader ({@link Stylesheet}) to be captured and displayed
later. Without this function, errors are displayed immediately and
PDF streaming is impossible.
@see http://www.php.net/manual/en/function.set-error_handler.php
@param int $errno
@param string $errstr
@param string $errfile
@param string $errline
@throws Exception | [
"Stores",
"warnings",
"in",
"an",
"array",
"for",
"display",
"later",
"This",
"function",
"allows",
"warnings",
"generated",
"by",
"the",
"DomDocument",
"parser",
"and",
"CSS",
"loader",
"(",
"{",
"@link",
"Stylesheet",
"}",
")",
"to",
"be",
"captured",
"and... | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L503-L518 | train | Record dompdf warnings | [
30522,
2270,
10763,
3853,
2501,
1035,
16234,
1006,
1002,
9413,
19139,
1010,
1002,
9413,
12096,
2099,
1010,
1002,
9413,
12881,
9463,
1010,
1002,
9413,
19403,
2063,
1007,
1063,
1013,
1013,
2025,
1037,
5432,
2030,
5060,
2065,
1006,
999,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/DevicesDetection/API.php | API.getType | public function getType($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
// ensure all device types are in the list
$this->ensureDefaultRowsInTable($dataTable);
$mapping = DeviceParserAbstract::getAvailableDeviceTypeNames();
$dataTable->filter('AddSegmentByLabelMapping', array('deviceType', $mapping));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
return $dataTable;
} | php | public function getType($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
// ensure all device types are in the list
$this->ensureDefaultRowsInTable($dataTable);
$mapping = DeviceParserAbstract::getAvailableDeviceTypeNames();
$dataTable->filter('AddSegmentByLabelMapping', array('deviceType', $mapping));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
return $dataTable;
} | [
"public",
"function",
"getType",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"'DevicesDetection_types'",
",",
"$",
"idSite",
",",
... | Gets datatable displaying number of visits by device type (eg. desktop, smartphone, tablet)
@param int $idSite
@param string $period
@param string $date
@param bool|string $segment
@return DataTable | [
"Gets",
"datatable",
"displaying",
"number",
"of",
"visits",
"by",
"device",
"type",
"(",
"eg",
".",
"desktop",
"smartphone",
"tablet",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicesDetection/API.php#L50-L61 | train | Get the data table for device detection types | [
30522,
2270,
3853,
2131,
13874,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
1011,
1028,
2131,
2850,
29336,
3085,
1006,
1005,
5733,
3207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Helpers.php | Helpers.explode_url | public static function explode_url($url)
{
$protocol = "";
$host = "";
$path = "";
$file = "";
$arr = parse_url($url);
if ( isset($arr["scheme"]) ) {
$arr["scheme"] = mb_strtolower($arr["scheme"]);
}
// Exclude windows drive letters...
if (isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1) {
$protocol = $arr["scheme"] . "://";
if (isset($arr["user"])) {
$host .= $arr["user"];
if (isset($arr["pass"])) {
$host .= ":" . $arr["pass"];
}
$host .= "@";
}
if (isset($arr["host"])) {
$host .= $arr["host"];
}
if (isset($arr["port"])) {
$host .= ":" . $arr["port"];
}
if (isset($arr["path"]) && $arr["path"] !== "") {
// Do we have a trailing slash?
if ($arr["path"][mb_strlen($arr["path"]) - 1] === "/") {
$path = $arr["path"];
$file = "";
} else {
$path = rtrim(dirname($arr["path"]), '/\\') . "/";
$file = basename($arr["path"]);
}
}
if (isset($arr["query"])) {
$file .= "?" . $arr["query"];
}
if (isset($arr["fragment"])) {
$file .= "#" . $arr["fragment"];
}
} else {
$i = mb_stripos($url, "file://");
if ($i !== false) {
$url = mb_substr($url, $i + 7);
}
$protocol = ""; // "file://"; ? why doesn't this work... It's because of
// network filenames like //COMPU/SHARENAME
$host = ""; // localhost, really
$file = basename($url);
$path = dirname($url);
// Check that the path exists
if ($path !== false) {
$path .= '/';
} else {
// generate a url to access the file if no real path found.
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
$host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
if (substr($arr["path"], 0, 1) === '/') {
$path = dirname($arr["path"]);
} else {
$path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
}
}
}
$ret = array($protocol, $host, $path, $file,
"protocol" => $protocol,
"host" => $host,
"path" => $path,
"file" => $file);
return $ret;
} | php | public static function explode_url($url)
{
$protocol = "";
$host = "";
$path = "";
$file = "";
$arr = parse_url($url);
if ( isset($arr["scheme"]) ) {
$arr["scheme"] = mb_strtolower($arr["scheme"]);
}
// Exclude windows drive letters...
if (isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1) {
$protocol = $arr["scheme"] . "://";
if (isset($arr["user"])) {
$host .= $arr["user"];
if (isset($arr["pass"])) {
$host .= ":" . $arr["pass"];
}
$host .= "@";
}
if (isset($arr["host"])) {
$host .= $arr["host"];
}
if (isset($arr["port"])) {
$host .= ":" . $arr["port"];
}
if (isset($arr["path"]) && $arr["path"] !== "") {
// Do we have a trailing slash?
if ($arr["path"][mb_strlen($arr["path"]) - 1] === "/") {
$path = $arr["path"];
$file = "";
} else {
$path = rtrim(dirname($arr["path"]), '/\\') . "/";
$file = basename($arr["path"]);
}
}
if (isset($arr["query"])) {
$file .= "?" . $arr["query"];
}
if (isset($arr["fragment"])) {
$file .= "#" . $arr["fragment"];
}
} else {
$i = mb_stripos($url, "file://");
if ($i !== false) {
$url = mb_substr($url, $i + 7);
}
$protocol = ""; // "file://"; ? why doesn't this work... It's because of
// network filenames like //COMPU/SHARENAME
$host = ""; // localhost, really
$file = basename($url);
$path = dirname($url);
// Check that the path exists
if ($path !== false) {
$path .= '/';
} else {
// generate a url to access the file if no real path found.
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
$host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
if (substr($arr["path"], 0, 1) === '/') {
$path = dirname($arr["path"]);
} else {
$path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
}
}
}
$ret = array($protocol, $host, $path, $file,
"protocol" => $protocol,
"host" => $host,
"path" => $path,
"file" => $file);
return $ret;
} | [
"public",
"static",
"function",
"explode_url",
"(",
"$",
"url",
")",
"{",
"$",
"protocol",
"=",
"\"\"",
";",
"$",
"host",
"=",
"\"\"",
";",
"$",
"path",
"=",
"\"\"",
";",
"$",
"file",
"=",
"\"\"",
";",
"$",
"arr",
"=",
"parse_url",
"(",
"$",
"url... | parse a full url or pathname and return an array(protocol, host, path,
file + query + fragment)
@param string $url
@return array | [
"parse",
"a",
"full",
"url",
"or",
"pathname",
"and",
"return",
"an",
"array",
"(",
"protocol",
"host",
"path",
"file",
"+",
"query",
"+",
"fragment",
")"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Helpers.php#L377-L469 | train | Explodes a URL into its components | [
30522,
2270,
10763,
3853,
15044,
1035,
24471,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
8778,
1027,
1000,
1000,
1025,
1002,
3677,
1027,
1000,
1000,
1025,
1002,
4130,
1027,
1000,
1000,
1025,
1002,
5371,
1027,
1000,
1000,
1025,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/FolderStorage.php | FolderStorage.buildIndex | protected function buildIndex(): array
{
$path = $this->getStoragePath();
if (!file_exists($path)) {
return [];
}
if ($this->prefixed) {
$list = $this->buildPrefixedIndexFromFilesystem($path);
} else {
$list = $this->buildIndexFromFilesystem($path);
}
ksort($list, SORT_NATURAL);
return $list;
} | php | protected function buildIndex(): array
{
$path = $this->getStoragePath();
if (!file_exists($path)) {
return [];
}
if ($this->prefixed) {
$list = $this->buildPrefixedIndexFromFilesystem($path);
} else {
$list = $this->buildIndexFromFilesystem($path);
}
ksort($list, SORT_NATURAL);
return $list;
} | [
"protected",
"function",
"buildIndex",
"(",
")",
":",
"array",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getStoragePath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$"... | Returns list of all stored keys in [key => timestamp] pairs.
@return array | [
"Returns",
"list",
"of",
"all",
"stored",
"keys",
"in",
"[",
"key",
"=",
">",
"timestamp",
"]",
"pairs",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FolderStorage.php#L371-L387 | train | Build the index from the filesystem | [
30522,
5123,
3853,
3857,
22254,
10288,
1006,
1007,
1024,
9140,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
4152,
4263,
4270,
15069,
1006,
1007,
1025,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Container.php | HTML_QuickForm2_Container.getValue | public function getValue()
{
$values = array();
foreach ($this as $child) {
$value = $child->getValue();
if (null !== $value) {
if ($child instanceof HTML_QuickForm2_Container
&& !$child->prependsName()
) {
$values = self::arrayMerge($values, $value);
} else {
$name = $child->getName();
if (!strpos($name, '[')) {
$values[$name] = $value;
} else {
$tokens = explode('[', str_replace(']', '', $name));
$valueAry =& $values;
do {
$token = array_shift($tokens);
if (!isset($valueAry[$token])) {
$valueAry[$token] = array();
}
$valueAry =& $valueAry[$token];
} while (count($tokens) > 1);
$valueAry[$tokens[0]] = $value;
}
}
}
}
return empty($values)? null: $this->applyFilters($values);
} | php | public function getValue()
{
$values = array();
foreach ($this as $child) {
$value = $child->getValue();
if (null !== $value) {
if ($child instanceof HTML_QuickForm2_Container
&& !$child->prependsName()
) {
$values = self::arrayMerge($values, $value);
} else {
$name = $child->getName();
if (!strpos($name, '[')) {
$values[$name] = $value;
} else {
$tokens = explode('[', str_replace(']', '', $name));
$valueAry =& $values;
do {
$token = array_shift($tokens);
if (!isset($valueAry[$token])) {
$valueAry[$token] = array();
}
$valueAry =& $valueAry[$token];
} while (count($tokens) > 1);
$valueAry[$tokens[0]] = $value;
}
}
}
}
return empty($values)? null: $this->applyFilters($values);
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"child",
")",
"{",
"$",
"value",
"=",
"$",
"child",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"null",
"!==",
... | Returns the element's value
The default implementation for Containers is to return an array with
contained elements' values. The array is indexed the same way $_GET and
$_POST arrays would be for these elements.
@return array|null | [
"Returns",
"the",
"element",
"s",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Container.php#L115-L145 | train | Returns the value of the form element | [
30522,
2270,
3853,
2131,
10175,
5657,
1006,
1007,
1063,
1002,
5300,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
2004,
1002,
2775,
1007,
1063,
1002,
3643,
1027,
1002,
2775,
1011,
1028,
2131,
10175,
5657,
1006,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/ResolvedFormType.php | ResolvedFormType.createBuilder | public function createBuilder(FormFactoryInterface $factory, $name, array $options = [])
{
$options = $this->getOptionsResolver()->resolve($options);
// Should be decoupled from the specific option at some point
$dataClass = isset($options['data_class']) ? $options['data_class'] : null;
$builder = $this->newBuilder($name, $dataClass, $factory, $options);
$builder->setType($this);
return $builder;
} | php | public function createBuilder(FormFactoryInterface $factory, $name, array $options = [])
{
$options = $this->getOptionsResolver()->resolve($options);
// Should be decoupled from the specific option at some point
$dataClass = isset($options['data_class']) ? $options['data_class'] : null;
$builder = $this->newBuilder($name, $dataClass, $factory, $options);
$builder->setType($this);
return $builder;
} | [
"public",
"function",
"createBuilder",
"(",
"FormFactoryInterface",
"$",
"factory",
",",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptionsResolver",
"(",
")",
"->",
"resolve",
"(",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/ResolvedFormType.php#L93-L104 | train | Create a new builder for the current type | [
30522,
2270,
3853,
3443,
8569,
23891,
2099,
1006,
2433,
21450,
18447,
2121,
12172,
1002,
4713,
1010,
1002,
2171,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
7047,
1027,
1002,
2023,
1011,
1028,
2131,
7361,
9285,
6072,
4747,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemAdapter.php | FilesystemAdapter.assertMissing | public function assertMissing($path)
{
$paths = Arr::wrap($path);
foreach ($paths as $path) {
PHPUnit::assertFalse(
$this->exists($path), "Found unexpected file at path [{$path}]."
);
}
return $this;
} | php | public function assertMissing($path)
{
$paths = Arr::wrap($path);
foreach ($paths as $path) {
PHPUnit::assertFalse(
$this->exists($path), "Found unexpected file at path [{$path}]."
);
}
return $this;
} | [
"public",
"function",
"assertMissing",
"(",
"$",
"path",
")",
"{",
"$",
"paths",
"=",
"Arr",
"::",
"wrap",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"PHPUnit",
"::",
"assertFalse",
"(",
"$",
"this",
"->"... | Assert that the given file does not exist.
@param string|array $path
@return $this | [
"Assert",
"that",
"the",
"given",
"file",
"does",
"not",
"exist",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemAdapter.php#L76-L87 | train | Assert that a file does not exist at the given path | [
30522,
2270,
3853,
20865,
15630,
7741,
1006,
1002,
4130,
1007,
1063,
1002,
10425,
1027,
12098,
2099,
1024,
1024,
10236,
1006,
1002,
4130,
1007,
1025,
18921,
6776,
1006,
1002,
10425,
2004,
1002,
4130,
1007,
1063,
25718,
19496,
2102,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.whereColumn | protected function whereColumn(Builder $query, $where)
{
return $this->wrap($where['first']).' '.$where['operator'].' '.$this->wrap($where['second']);
} | php | protected function whereColumn(Builder $query, $where)
{
return $this->wrap($where['first']).' '.$where['operator'].' '.$this->wrap($where['second']);
} | [
"protected",
"function",
"whereColumn",
"(",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"return",
"$",
"this",
"->",
"wrap",
"(",
"$",
"where",
"[",
"'first'",
"]",
")",
".",
"' '",
".",
"$",
"where",
"[",
"'operator'",
"]",
".",
"' '",
... | Compile a where clause comparing two columns..
@param \Illuminate\Database\Query\Builder $query
@param array $where
@return string | [
"Compile",
"a",
"where",
"clause",
"comparing",
"two",
"columns",
".."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L466-L469 | train | Protected whereColumn - Helper function | [
30522,
5123,
3853,
2073,
25778,
2819,
2078,
1006,
12508,
1002,
23032,
1010,
1002,
2073,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
10236,
1006,
1002,
2073,
1031,
1005,
2034,
1005,
1033,
1007,
1012,
1005,
1005,
1012,
1002,
2073,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Dimension/VisitDimension.php | VisitDimension.uninstall | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
try {
if (!$this->isHandlingLogConversion()) {
return;
}
$sql = "ALTER TABLE `" . Common::prefixTable('log_conversion') . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | php | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
try {
if (!$this->isHandlingLogConversion()) {
return;
}
$sql = "ALTER TABLE `" . Common::prefixTable('log_conversion') . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | [
"public",
"function",
"uninstall",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"columnName",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"columnType",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"sql",
"=",
"\"ALTER TABLE `\"",... | Uninstalls the dimension if a {@link $columnName} and {@link columnType} is set. In case you perform any custom
actions during {@link install()} - for instance adding an index - you should make sure to undo those actions by
overwriting this method. Make sure to call this parent method to make sure the uninstallation of the column
will be done.
@throws Exception
@api | [
"Uninstalls",
"the",
"dimension",
"if",
"a",
"{"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Dimension/VisitDimension.php#L118-L145 | train | Uninstalls the column if it s not present in the database | [
30522,
2270,
3853,
4895,
7076,
9080,
2140,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
18442,
1007,
1064,
1064,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
13874,
1007,
1007,
1063,
2709,
1025,
1065,
3046,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/UsersManager.php | UsersManager.isValidPasswordString | public static function isValidPasswordString($input)
{
if (!SettingsPiwik::isUserCredentialsSanityCheckEnabled()
&& !empty($input)
) {
return true;
}
$l = strlen($input);
return $l >= self::PASSWORD_MIN_LENGTH;
} | php | public static function isValidPasswordString($input)
{
if (!SettingsPiwik::isUserCredentialsSanityCheckEnabled()
&& !empty($input)
) {
return true;
}
$l = strlen($input);
return $l >= self::PASSWORD_MIN_LENGTH;
} | [
"public",
"static",
"function",
"isValidPasswordString",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"!",
"SettingsPiwik",
"::",
"isUserCredentialsSanityCheckEnabled",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"return",
"true",
";",
"}",
... | Returns true if the password is complex enough (at least 6 characters and max 26 characters)
@param $input string
@return bool | [
"Returns",
"true",
"if",
"the",
"password",
"is",
"complex",
"enough",
"(",
"at",
"least",
"6",
"characters",
"and",
"max",
"26",
"characters",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/UsersManager.php#L157-L168 | train | Returns true if the input string is valid for the password minimum length | [
30522,
2270,
10763,
3853,
2003,
10175,
3593,
15194,
22104,
18886,
3070,
1006,
1002,
7953,
1007,
1063,
2065,
1006,
999,
10906,
8197,
9148,
2243,
1024,
1024,
2003,
20330,
16748,
16454,
26340,
8791,
3012,
5403,
19766,
3085,
2094,
1006,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Yaml/Inline.php | Inline.dumpArray | private static function dumpArray(array $value, int $flags): string
{
// array
if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
$output = [];
foreach ($value as $val) {
$output[] = self::dump($val, $flags);
}
return sprintf('[%s]', implode(', ', $output));
}
// hash
$output = [];
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
}
return sprintf('{ %s }', implode(', ', $output));
} | php | private static function dumpArray(array $value, int $flags): string
{
// array
if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
$output = [];
foreach ($value as $val) {
$output[] = self::dump($val, $flags);
}
return sprintf('[%s]', implode(', ', $output));
}
// hash
$output = [];
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
}
return sprintf('{ %s }', implode(', ', $output));
} | [
"private",
"static",
"function",
"dumpArray",
"(",
"array",
"$",
"value",
",",
"int",
"$",
"flags",
")",
":",
"string",
"{",
"// array",
"if",
"(",
"(",
"$",
"value",
"||",
"Yaml",
"::",
"DUMP_EMPTY_ARRAY_AS_SEQUENCE",
"&",
"$",
"flags",
")",
"&&",
"!",
... | Dumps a PHP array to a YAML string.
@param array $value The PHP array to dump
@param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
@return string The YAML string representing the PHP array | [
"Dumps",
"a",
"PHP",
"array",
"to",
"a",
"YAML",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Yaml/Inline.php#L238-L257 | train | Dump array value | [
30522,
2797,
10763,
3853,
15653,
2906,
9447,
1006,
9140,
1002,
3643,
1010,
20014,
1002,
9245,
1007,
1024,
5164,
1063,
1013,
1013,
9140,
2065,
1006,
1006,
1002,
3643,
1064,
1064,
8038,
19968,
1024,
1024,
15653,
1035,
4064,
1035,
9140,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php | FormDataCollector.collectDefaultData | public function collectDefaultData(FormInterface $form)
{
$hash = spl_object_hash($form);
if (!isset($this->dataByForm[$hash])) {
$this->dataByForm[$hash] = [];
}
$this->dataByForm[$hash] = array_replace(
$this->dataByForm[$hash],
$this->dataExtractor->extractDefaultData($form)
);
foreach ($form as $child) {
$this->collectDefaultData($child);
}
} | php | public function collectDefaultData(FormInterface $form)
{
$hash = spl_object_hash($form);
if (!isset($this->dataByForm[$hash])) {
$this->dataByForm[$hash] = [];
}
$this->dataByForm[$hash] = array_replace(
$this->dataByForm[$hash],
$this->dataExtractor->extractDefaultData($form)
);
foreach ($form as $child) {
$this->collectDefaultData($child);
}
} | [
"public",
"function",
"collectDefaultData",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"form",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dataByForm",
"[",
"$",
"hash",
"]",
")",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php#L129-L145 | train | Collect default data for form | [
30522,
2270,
3853,
8145,
3207,
7011,
11314,
2850,
2696,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1007,
1063,
1002,
23325,
1027,
11867,
2140,
1035,
4874,
1035,
23325,
1006,
1002,
2433,
1007,
1025,
2065,
1006,
999,
26354,
3388,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Cookie/CookieJar.php | CookieJar.getCookiePathFromRequest | private function getCookiePathFromRequest(RequestInterface $request)
{
$uriPath = $request->getUri()->getPath();
if ('' === $uriPath) {
return '/';
}
if (0 !== strpos($uriPath, '/')) {
return '/';
}
if ('/' === $uriPath) {
return '/';
}
if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
return '/';
}
return substr($uriPath, 0, $lastSlashPos);
} | php | private function getCookiePathFromRequest(RequestInterface $request)
{
$uriPath = $request->getUri()->getPath();
if ('' === $uriPath) {
return '/';
}
if (0 !== strpos($uriPath, '/')) {
return '/';
}
if ('/' === $uriPath) {
return '/';
}
if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
return '/';
}
return substr($uriPath, 0, $lastSlashPos);
} | [
"private",
"function",
"getCookiePathFromRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"uriPath",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"''",
"===",
"$",
"uriPath",
")",
"{",
"return... | Computes cookie path following RFC 6265 section 5.1.4
@link https://tools.ietf.org/html/rfc6265#section-5.1.4
@param RequestInterface $request
@return string | [
"Computes",
"cookie",
"path",
"following",
"RFC",
"6265",
"section",
"5",
".",
"1",
".",
"4"
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Cookie/CookieJar.php#L254-L271 | train | Get cookie path from request | [
30522,
2797,
3853,
2131,
3597,
23212,
13699,
8988,
19699,
5358,
2890,
15500,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1007,
1063,
1002,
24471,
11514,
8988,
1027,
1002,
5227,
1011,
1028,
2131,
9496,
1006,
1007,
1011,
1028,
2131,
15069,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Notifications/Messages/SimpleMessage.php | SimpleMessage.formatLine | protected function formatLine($line)
{
if ($line instanceof Htmlable) {
return $line;
}
if (is_array($line)) {
return implode(' ', array_map('trim', $line));
}
return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line))));
} | php | protected function formatLine($line)
{
if ($line instanceof Htmlable) {
return $line;
}
if (is_array($line)) {
return implode(' ', array_map('trim', $line));
}
return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line))));
} | [
"protected",
"function",
"formatLine",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"instanceof",
"Htmlable",
")",
"{",
"return",
"$",
"line",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"line",
")",
")",
"{",
"return",
"implode",
"(",
"' '",
... | Format the given line of text.
@param \Illuminate\Contracts\Support\Htmlable|string|array $line
@return \Illuminate\Contracts\Support\Htmlable|string | [
"Format",
"the",
"given",
"line",
"of",
"text",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Messages/SimpleMessage.php#L178-L189 | train | Format a line of code | [
30522,
5123,
3853,
4289,
4179,
1006,
1002,
2240,
1007,
1063,
2065,
1006,
1002,
2240,
6013,
11253,
16129,
3085,
1007,
1063,
2709,
1002,
2240,
1025,
1065,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2240,
1007,
1007,
1063,
2709,
17727,
4135,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Renderer/Default.php | HTML_QuickForm2_Renderer_Default.setElementTemplateForGroupClass | public function setElementTemplateForGroupClass($groupClass, $elementClass, $template)
{
$this->elementTemplatesForGroupClass[strtolower($groupClass)][strtolower($elementClass)] = $template;
return $this;
} | php | public function setElementTemplateForGroupClass($groupClass, $elementClass, $template)
{
$this->elementTemplatesForGroupClass[strtolower($groupClass)][strtolower($elementClass)] = $template;
return $this;
} | [
"public",
"function",
"setElementTemplateForGroupClass",
"(",
"$",
"groupClass",
",",
"$",
"elementClass",
",",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"elementTemplatesForGroupClass",
"[",
"strtolower",
"(",
"$",
"groupClass",
")",
"]",
"[",
"strtolower",
... | Sets grouped elements templates using group class
Templates set via {@link setTemplateForClass()} will not be used for
grouped form elements. When searching for a template to use, the renderer
will first consider template set for a specific group id, then the
group templates set by group class.
@param string Group class name
@param string Element class name
@param mixed Template
@return HTML_QuickForm2_Renderer_Default | [
"Sets",
"grouped",
"elements",
"templates",
"using",
"group",
"class"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Default.php#L227-L231 | train | Set the element template for the group class | [
30522,
2270,
3853,
2275,
12260,
3672,
18532,
15725,
29278,
17058,
26266,
1006,
1002,
2177,
26266,
1010,
1002,
5783,
26266,
1010,
1002,
23561,
1007,
1063,
1002,
2023,
1011,
1028,
5783,
18532,
15725,
22747,
21759,
22107,
26266,
1031,
2358,
5339... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/SqsQueue.php | SqsQueue.size | public function size($queue = null)
{
$response = $this->sqs->getQueueAttributes([
'QueueUrl' => $this->getQueue($queue),
'AttributeNames' => ['ApproximateNumberOfMessages'],
]);
$attributes = $response->get('Attributes');
return (int) $attributes['ApproximateNumberOfMessages'];
} | php | public function size($queue = null)
{
$response = $this->sqs->getQueueAttributes([
'QueueUrl' => $this->getQueue($queue),
'AttributeNames' => ['ApproximateNumberOfMessages'],
]);
$attributes = $response->get('Attributes');
return (int) $attributes['ApproximateNumberOfMessages'];
} | [
"public",
"function",
"size",
"(",
"$",
"queue",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sqs",
"->",
"getQueueAttributes",
"(",
"[",
"'QueueUrl'",
"=>",
"$",
"this",
"->",
"getQueue",
"(",
"$",
"queue",
")",
",",
"'AttributeNam... | Get the size of the queue.
@param string $queue
@return int | [
"Get",
"the",
"size",
"of",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/SqsQueue.php#L53-L63 | train | Get the size of all messages in the queue | [
30522,
2270,
3853,
2946,
1006,
1002,
24240,
1027,
19701,
1007,
1063,
1002,
3433,
1027,
1002,
2023,
1011,
1028,
5490,
2015,
1011,
1028,
2131,
4226,
5657,
19321,
3089,
8569,
4570,
1006,
1031,
1005,
24240,
3126,
2140,
1005,
1027,
1028,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/QuickForm2.php | QuickForm2.getSubmitValue | public function getSubmitValue($elementName)
{
$value = $this->getValue();
return isset($value[$elementName]) ? $value[$elementName] : null;
} | php | public function getSubmitValue($elementName)
{
$value = $this->getValue();
return isset($value[$elementName]) ? $value[$elementName] : null;
} | [
"public",
"function",
"getSubmitValue",
"(",
"$",
"elementName",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"value",
"[",
"$",
"elementName",
"]",
")",
"?",
"$",
"value",
"[",
"$",
"element... | Ported from HTML_QuickForm to minimize changes to Controllers
@param string $elementName
@return mixed | [
"Ported",
"from",
"HTML_QuickForm",
"to",
"minimize",
"changes",
"to",
"Controllers"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/QuickForm2.php#L104-L108 | train | Get Submit Value | [
30522,
2270,
3853,
4152,
12083,
22930,
10175,
5657,
1006,
1002,
5783,
18442,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
2131,
10175,
5657,
1006,
1007,
1025,
2709,
26354,
3388,
1006,
1002,
3643,
1031,
1002,
5783,
18442,
1033,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Connection/TcpConnection.php | TcpConnection.pauseRecv | public function pauseRecv()
{
Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
$this->_isPaused = true;
} | php | public function pauseRecv()
{
Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
$this->_isPaused = true;
} | [
"public",
"function",
"pauseRecv",
"(",
")",
"{",
"Worker",
"::",
"$",
"globalEvent",
"->",
"del",
"(",
"$",
"this",
"->",
"_socket",
",",
"EventInterface",
"::",
"EV_READ",
")",
";",
"$",
"this",
"->",
"_isPaused",
"=",
"true",
";",
"}"
] | Pauses the reading of data. That is onMessage will not be emitted. Useful to throttle back an upload.
@return void | [
"Pauses",
"the",
"reading",
"of",
"data",
".",
"That",
"is",
"onMessage",
"will",
"not",
"be",
"emitted",
".",
"Useful",
"to",
"throttle",
"back",
"an",
"upload",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L548-L552 | train | Pause the receive process. | [
30522,
2270,
3853,
8724,
2890,
2278,
2615,
1006,
1007,
1063,
7309,
1024,
1024,
1002,
3795,
18697,
3372,
1011,
1028,
3972,
1006,
1002,
2023,
1011,
1028,
1035,
22278,
1010,
2724,
18447,
2121,
12172,
1024,
1024,
23408,
1035,
3191,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Apc.php | Zend_Cache_Backend_Apc.getMetadatas | public function getMetadatas($id)
{
$tmp = apc_fetch($id);
if (is_array($tmp)) {
$data = $tmp[0];
$mtime = $tmp[1];
if (!isset($tmp[2])) {
// because this record is only with 1.7 release
// if old cache records are still there...
return false;
}
$lifetime = $tmp[2];
return array(
'expire' => $mtime + $lifetime,
'tags' => array(),
'mtime' => $mtime
);
}
return false;
} | php | public function getMetadatas($id)
{
$tmp = apc_fetch($id);
if (is_array($tmp)) {
$data = $tmp[0];
$mtime = $tmp[1];
if (!isset($tmp[2])) {
// because this record is only with 1.7 release
// if old cache records are still there...
return false;
}
$lifetime = $tmp[2];
return array(
'expire' => $mtime + $lifetime,
'tags' => array(),
'mtime' => $mtime
);
}
return false;
} | [
"public",
"function",
"getMetadatas",
"(",
"$",
"id",
")",
"{",
"$",
"tmp",
"=",
"apc_fetch",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"tmp",
")",
")",
"{",
"$",
"data",
"=",
"$",
"tmp",
"[",
"0",
"]",
";",
"$",
"mtime",
"="... | Return an array of metadatas for the given cache id
The array must include these keys :
- expire : the expire timestamp
- tags : a string array of tags
- mtime : timestamp of last modification time
@param string $id cache id
@return array array of metadatas (false if the cache id is not found) | [
"Return",
"an",
"array",
"of",
"metadatas",
"for",
"the",
"given",
"cache",
"id"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Apc.php#L279-L298 | train | Returns array of cache record information | [
30522,
2270,
3853,
2131,
11368,
8447,
10230,
1006,
1002,
8909,
1007,
1063,
1002,
1056,
8737,
1027,
9706,
2278,
1035,
18584,
1006,
1002,
8909,
1007,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
1056,
8737,
1007,
1007,
1063,
1002,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Data/Validation.php | Validation.validate | public static function validate($value, array $field)
{
if (!isset($field['type'])) {
$field['type'] = 'text';
}
$type = $validate['type'] ?? $field['type'];
$validate = (array)($field['validate'] ?? null);
$required = $validate['required'] ?? false;
// If value isn't required, we will stop validation if empty value is given.
if ($required !== true && ($value === null || $value === '' || (($field['type'] === 'checkbox' || $field['type'] === 'switch') && $value == false))
) {
return [];
}
// Get language class.
$language = Grav::instance()['language'];
$name = ucfirst($field['label'] ?? $field['name']);
$message = (string) isset($field['validate']['message'])
? $language->translate($field['validate']['message'])
: $language->translate('GRAV.FORM.INVALID_INPUT', null, true) . ' "' . $language->translate($name) . '"';
// Validate type with fallback type text.
$method = 'type' . str_replace('-', '_', $type);
// If this is a YAML field validate/filter as such
if (isset($field['yaml']) && $field['yaml'] === true) {
$method = 'typeYaml';
}
$messages = [];
$success = method_exists(__CLASS__, $method) ? self::$method($value, $validate, $field) : true;
if (!$success) {
$messages[$field['name']][] = $message;
}
// Check individual rules.
foreach ($validate as $rule => $params) {
$method = 'validate' . ucfirst(str_replace('-', '_', $rule));
if (method_exists(__CLASS__, $method)) {
$success = self::$method($value, $params);
if (!$success) {
$messages[$field['name']][] = $message;
}
}
}
return $messages;
} | php | public static function validate($value, array $field)
{
if (!isset($field['type'])) {
$field['type'] = 'text';
}
$type = $validate['type'] ?? $field['type'];
$validate = (array)($field['validate'] ?? null);
$required = $validate['required'] ?? false;
// If value isn't required, we will stop validation if empty value is given.
if ($required !== true && ($value === null || $value === '' || (($field['type'] === 'checkbox' || $field['type'] === 'switch') && $value == false))
) {
return [];
}
// Get language class.
$language = Grav::instance()['language'];
$name = ucfirst($field['label'] ?? $field['name']);
$message = (string) isset($field['validate']['message'])
? $language->translate($field['validate']['message'])
: $language->translate('GRAV.FORM.INVALID_INPUT', null, true) . ' "' . $language->translate($name) . '"';
// Validate type with fallback type text.
$method = 'type' . str_replace('-', '_', $type);
// If this is a YAML field validate/filter as such
if (isset($field['yaml']) && $field['yaml'] === true) {
$method = 'typeYaml';
}
$messages = [];
$success = method_exists(__CLASS__, $method) ? self::$method($value, $validate, $field) : true;
if (!$success) {
$messages[$field['name']][] = $message;
}
// Check individual rules.
foreach ($validate as $rule => $params) {
$method = 'validate' . ucfirst(str_replace('-', '_', $rule));
if (method_exists(__CLASS__, $method)) {
$success = self::$method($value, $params);
if (!$success) {
$messages[$field['name']][] = $message;
}
}
}
return $messages;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"value",
",",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"field",
"[",
"'type'",
"]",
"=",
"'text'",
";",
"}",
"$",
... | Validate value against a blueprint field definition.
@param mixed $value
@param array $field
@return array | [
"Validate",
"value",
"against",
"a",
"blueprint",
"field",
"definition",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L25-L78 | train | Validate a value with the type and optional validation rules. | [
30522,
2270,
10763,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
9140,
1002,
2492,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2492,
1031,
1005,
2828,
1005,
1033,
1007,
1007,
1063,
1002,
2492,
1031,
1005,
2828,
1005,
1033,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Kernel.php | Kernel.locateResource | public function locateResource($name, $dir = null, $first = true)
{
if ('@' !== $name[0]) {
throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
}
if (false !== strpos($name, '..')) {
throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
}
$bundleName = substr($name, 1);
$path = '';
if (false !== strpos($bundleName, '/')) {
list($bundleName, $path) = explode('/', $bundleName, 2);
}
$isResource = 0 === strpos($path, 'Resources') && null !== $dir;
$overridePath = substr($path, 9);
$bundle = $this->getBundle($bundleName);
$files = [];
if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
$files[] = $file;
}
if (file_exists($file = $bundle->getPath().'/'.$path)) {
if ($first && !$isResource) {
return $file;
}
$files[] = $file;
}
if (\count($files) > 0) {
return $first && $isResource ? $files[0] : $files;
}
throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
} | php | public function locateResource($name, $dir = null, $first = true)
{
if ('@' !== $name[0]) {
throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
}
if (false !== strpos($name, '..')) {
throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
}
$bundleName = substr($name, 1);
$path = '';
if (false !== strpos($bundleName, '/')) {
list($bundleName, $path) = explode('/', $bundleName, 2);
}
$isResource = 0 === strpos($path, 'Resources') && null !== $dir;
$overridePath = substr($path, 9);
$bundle = $this->getBundle($bundleName);
$files = [];
if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
$files[] = $file;
}
if (file_exists($file = $bundle->getPath().'/'.$path)) {
if ($first && !$isResource) {
return $file;
}
$files[] = $file;
}
if (\count($files) > 0) {
return $first && $isResource ? $files[0] : $files;
}
throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
} | [
"public",
"function",
"locateResource",
"(",
"$",
"name",
",",
"$",
"dir",
"=",
"null",
",",
"$",
"first",
"=",
"true",
")",
"{",
"if",
"(",
"'@'",
"!==",
"$",
"name",
"[",
"0",
"]",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
... | {@inheritdoc}
@throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Kernel.php#L242-L279 | train | Locates a resource file | [
30522,
2270,
3853,
12453,
6072,
8162,
3401,
1006,
1002,
2171,
1010,
1002,
16101,
1027,
19701,
1010,
1002,
2034,
1027,
2995,
1007,
1063,
2065,
1006,
1005,
1030,
1005,
999,
1027,
1027,
1002,
2171,
1031,
1014,
1033,
1007,
1063,
5466,
2047,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/CssSelector/Parser/Parser.php | Parser.parse | public function parse(string $source): array
{
$reader = new Reader($source);
$stream = $this->tokenizer->tokenize($reader);
return $this->parseSelectorList($stream);
} | php | public function parse(string $source): array
{
$reader = new Reader($source);
$stream = $this->tokenizer->tokenize($reader);
return $this->parseSelectorList($stream);
} | [
"public",
"function",
"parse",
"(",
"string",
"$",
"source",
")",
":",
"array",
"{",
"$",
"reader",
"=",
"new",
"Reader",
"(",
"$",
"source",
")",
";",
"$",
"stream",
"=",
"$",
"this",
"->",
"tokenizer",
"->",
"tokenize",
"(",
"$",
"reader",
")",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/CssSelector/Parser/Parser.php#L40-L46 | train | Parse a selector list | [
30522,
2270,
3853,
11968,
3366,
1006,
5164,
1002,
3120,
1007,
1024,
9140,
1063,
1002,
8068,
1027,
2047,
8068,
1006,
1002,
3120,
1007,
1025,
1002,
5460,
1027,
1002,
2023,
1011,
1028,
19204,
17629,
1011,
1028,
19204,
4697,
1006,
1002,
8068,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Element/Select.php | HTML_QuickForm2_Element_Select.getValue | public function getValue()
{
if (!empty($this->attributes['disabled']) || 0 == count($this->values)
|| ($this->data['intrinsic_validation']
&& (0 == count($this->optionContainer) || 0 == count($this->possibleValues)))
) {
return null;
}
$values = array();
foreach ($this->values as $value) {
if (!$this->data['intrinsic_validation'] || !empty($this->possibleValues[$value])) {
$values[] = $value;
}
}
if (0 == count($values)) {
return null;
} elseif (!empty($this->attributes['multiple'])) {
return $this->applyFilters($values);
} elseif (1 == count($values)) {
return $this->applyFilters($values[0]);
} else {
// The <select> is not multiple, but several options are to be
// selected. At least IE and Mozilla select the last selected
// option in this case, we should do the same
foreach ($this->optionContainer->getRecursiveIterator() as $child) {
if (is_array($child) && in_array($child['attr']['value'], $values)) {
$lastValue = $child['attr']['value'];
}
}
return $this->applyFilters($lastValue);
}
} | php | public function getValue()
{
if (!empty($this->attributes['disabled']) || 0 == count($this->values)
|| ($this->data['intrinsic_validation']
&& (0 == count($this->optionContainer) || 0 == count($this->possibleValues)))
) {
return null;
}
$values = array();
foreach ($this->values as $value) {
if (!$this->data['intrinsic_validation'] || !empty($this->possibleValues[$value])) {
$values[] = $value;
}
}
if (0 == count($values)) {
return null;
} elseif (!empty($this->attributes['multiple'])) {
return $this->applyFilters($values);
} elseif (1 == count($values)) {
return $this->applyFilters($values[0]);
} else {
// The <select> is not multiple, but several options are to be
// selected. At least IE and Mozilla select the last selected
// option in this case, we should do the same
foreach ($this->optionContainer->getRecursiveIterator() as $child) {
if (is_array($child) && in_array($child['attr']['value'], $values)) {
$lastValue = $child['attr']['value'];
}
}
return $this->applyFilters($lastValue);
}
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'disabled'",
"]",
")",
"||",
"0",
"==",
"count",
"(",
"$",
"this",
"->",
"values",
")",
"||",
"(",
"$",
"this",
"->",
"data",
"[... | Returns the value of the <select> element
Please note that the returned value may not necessarily be equal to that
passed to {@link setValue()}. It passes "intrinsic validation" confirming
that such value could possibly be submitted by this <select> element.
Specifically, this method will return null if the elements "disabled"
attribute is set, it will not return values if there are no options having
such a "value" attribute or if such options' "disabled" attribute is set.
It will also only return a scalar value for single selects, mimicking
the common browsers' behaviour.
@return mixed "value" attribute of selected option in case of single
select, array of selected options' "value" attributes in
case of multiple selects, null if no options selected | [
"Returns",
"the",
"value",
"of",
"the",
"<select",
">",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Element/Select.php#L423-L455 | train | Returns the value of the select field | [
30522,
2270,
3853,
2131,
10175,
5657,
1006,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
12332,
1031,
1005,
9776,
1005,
1033,
1007,
1064,
1064,
1014,
1027,
1027,
4175,
1006,
1002,
2023,
1011,
1028,
5300,
1007,
1064,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php | PdoSessionHandler.commit | private function commit()
{
if ($this->inTransaction) {
try {
// commit read-write transaction which also releases the lock
if ('sqlite' === $this->driver) {
$this->pdo->exec('COMMIT');
} else {
$this->pdo->commit();
}
$this->inTransaction = false;
} catch (\PDOException $e) {
$this->rollback();
throw $e;
}
}
} | php | private function commit()
{
if ($this->inTransaction) {
try {
// commit read-write transaction which also releases the lock
if ('sqlite' === $this->driver) {
$this->pdo->exec('COMMIT');
} else {
$this->pdo->commit();
}
$this->inTransaction = false;
} catch (\PDOException $e) {
$this->rollback();
throw $e;
}
}
} | [
"private",
"function",
"commit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inTransaction",
")",
"{",
"try",
"{",
"// commit read-write transaction which also releases the lock",
"if",
"(",
"'sqlite'",
"===",
"$",
"this",
"->",
"driver",
")",
"{",
"$",
"thi... | Helper method to commit a transaction. | [
"Helper",
"method",
"to",
"commit",
"a",
"transaction",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L562-L579 | train | Commits the current transaction | [
30522,
2797,
3853,
10797,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
26721,
3619,
18908,
3258,
1007,
1063,
3046,
1063,
1013,
1013,
10797,
3191,
1011,
4339,
12598,
2029,
2036,
7085,
1996,
5843,
2065,
1006,
1005,
29296,
4221,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.view | public function view($uri, $view, $data = [])
{
return $this->match(['GET', 'HEAD'], $uri, '\Illuminate\Routing\ViewController')
->defaults('view', $view)
->defaults('data', $data);
} | php | public function view($uri, $view, $data = [])
{
return $this->match(['GET', 'HEAD'], $uri, '\Illuminate\Routing\ViewController')
->defaults('view', $view)
->defaults('data', $data);
} | [
"public",
"function",
"view",
"(",
"$",
"uri",
",",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"match",
"(",
"[",
"'GET'",
",",
"'HEAD'",
"]",
",",
"$",
"uri",
",",
"'\\Illuminate\\Routing\\ViewController'",
... | Register a new route that returns a view.
@param string $uri
@param string $view
@param array $data
@return \Illuminate\Routing\Route | [
"Register",
"a",
"new",
"route",
"that",
"returns",
"a",
"view",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L269-L274 | train | View a controller | [
30522,
2270,
3853,
3193,
1006,
1002,
24471,
2072,
1010,
1002,
3193,
1010,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
30524,
12717,
12556,
1032,
16972,
1032,
3193,
8663,
13181,
10820,
1005,
1007,
1011,
1028,
1239... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/EventDispatcher/EventDispatcher.php | EventDispatcher.hasListeners | public function hasListeners($eventName = null)
{
if (null !== $eventName) {
return !empty($this->listeners[$eventName]);
}
foreach ($this->listeners as $eventListeners) {
if ($eventListeners) {
return true;
}
}
return false;
} | php | public function hasListeners($eventName = null)
{
if (null !== $eventName) {
return !empty($this->listeners[$eventName]);
}
foreach ($this->listeners as $eventListeners) {
if ($eventListeners) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasListeners",
"(",
"$",
"eventName",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"eventName",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
")",
";",
"}",
"foreach... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/EventDispatcher/EventDispatcher.php#L135-L148 | train | Has listeners? | [
30522,
2270,
3853,
2038,
9863,
24454,
2015,
1006,
1002,
2724,
18442,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2724,
18442,
1007,
1063,
2709,
999,
4064,
1006,
1002,
2023,
1011,
1028,
13810,
1031,
1002,
2724,
18442,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Console/Migrations/RefreshCommand.php | RefreshCommand.runReset | protected function runReset($database, $path)
{
$this->call('migrate:reset', array_filter([
'--database' => $database,
'--path' => $path,
'--realpath' => $this->input->getOption('realpath'),
'--force' => true,
]));
} | php | protected function runReset($database, $path)
{
$this->call('migrate:reset', array_filter([
'--database' => $database,
'--path' => $path,
'--realpath' => $this->input->getOption('realpath'),
'--force' => true,
]));
} | [
"protected",
"function",
"runReset",
"(",
"$",
"database",
",",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'migrate:reset'",
",",
"array_filter",
"(",
"[",
"'--database'",
"=>",
"$",
"database",
",",
"'--path'",
"=>",
"$",
"path",
",",
"'--r... | Run the reset command.
@param string $database
@param string $path
@return void | [
"Run",
"the",
"reset",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php#L97-L105 | train | Runs the reset command on the next reset process. | [
30522,
5123,
3853,
2448,
6072,
3388,
1006,
1002,
7809,
1010,
1002,
4130,
1007,
1063,
1002,
2023,
1011,
1028,
2655,
1006,
1005,
22806,
1024,
25141,
1005,
1010,
9140,
1035,
11307,
1006,
1031,
1005,
1011,
1011,
7809,
1005,
1027,
1028,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreAdminHome/Commands/SetConfig/ConfigSettingManipulation.php | ConfigSettingManipulation.manipulate | public function manipulate(Config $config)
{
if ($this->isArrayAppend) {
$this->appendToArraySetting($config);
} else {
$this->setSingleConfigValue($config);
}
} | php | public function manipulate(Config $config)
{
if ($this->isArrayAppend) {
$this->appendToArraySetting($config);
} else {
$this->setSingleConfigValue($config);
}
} | [
"public",
"function",
"manipulate",
"(",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isArrayAppend",
")",
"{",
"$",
"this",
"->",
"appendToArraySetting",
"(",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setSingl... | Performs the INI config manipulation.
@param Config $config
@throws \Exception if trying to append to a non-array setting value or if trying to set an
array value to a non-array setting | [
"Performs",
"the",
"INI",
"config",
"manipulation",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/Commands/SetConfig/ConfigSettingManipulation.php#L60-L67 | train | This method is called by the parent class to manipulate the config. | [
30522,
2270,
3853,
17708,
1006,
9530,
8873,
2290,
1002,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
18061,
11335,
3148,
21512,
4859,
1007,
1063,
1002,
2023,
1011,
1028,
10439,
10497,
3406,
2906,
9447,
21678,
2075,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/Concerns/InteractsWithInput.php | InteractsWithInput.input | public function input($key = null, $default = null)
{
return data_get(
$this->getInputSource()->all() + $this->query->all(), $key, $default
);
} | php | public function input($key = null, $default = null)
{
return data_get(
$this->getInputSource()->all() + $this->query->all(), $key, $default
);
} | [
"public",
"function",
"input",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"data_get",
"(",
"$",
"this",
"->",
"getInputSource",
"(",
")",
"->",
"all",
"(",
")",
"+",
"$",
"this",
"->",
"query",
"->",
"all",
... | Retrieve an input item from the request.
@param string|null $key
@param string|array|null $default
@return string|array|null | [
"Retrieve",
"an",
"input",
"item",
"from",
"the",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Concerns/InteractsWithInput.php#L206-L211 | train | Get the input from the request | [
30522,
2270,
3853,
7953,
1006,
1002,
3145,
1027,
19701,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2709,
2951,
1035,
2131,
1006,
1002,
2023,
1011,
1028,
2131,
2378,
18780,
6499,
3126,
3401,
1006,
1007,
1011,
1028,
2035,
1006,
1007,
1009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreVisualizations/JqplotDataGenerator.php | JqplotDataGenerator.factory | public static function factory($type, $properties)
{
switch ($type) {
case 'evolution':
return new JqplotDataGenerator\Evolution($properties, $type);
case 'pie':
case 'bar':
return new JqplotDataGenerator($properties, $type);
default:
throw new Exception("Unknown JqplotDataGenerator type '$type'.");
}
} | php | public static function factory($type, $properties)
{
switch ($type) {
case 'evolution':
return new JqplotDataGenerator\Evolution($properties, $type);
case 'pie':
case 'bar':
return new JqplotDataGenerator($properties, $type);
default:
throw new Exception("Unknown JqplotDataGenerator type '$type'.");
}
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"type",
",",
"$",
"properties",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'evolution'",
":",
"return",
"new",
"JqplotDataGenerator",
"\\",
"Evolution",
"(",
"$",
"properties",
",",
"$",
... | Creates a new JqplotDataGenerator instance for a graph type and view properties.
@param string $type 'pie', 'bar', or 'evolution'
@param array $properties The view properties.
@throws \Exception
@return JqplotDataGenerator | [
"Creates",
"a",
"new",
"JqplotDataGenerator",
"instance",
"for",
"a",
"graph",
"type",
"and",
"view",
"properties",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/JqplotDataGenerator.php#L45-L56 | train | Factory method for the given type and properties | [
30522,
2270,
10763,
3853,
4713,
1006,
1002,
2828,
1010,
1002,
5144,
1007,
1063,
6942,
1006,
1002,
2828,
1007,
1063,
2553,
1005,
6622,
1005,
1024,
2709,
2047,
1046,
4160,
24759,
4140,
2850,
26702,
3678,
8844,
1032,
6622,
1006,
1002,
5144,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Crawler.php | Crawler.filterXPath | public function filterXPath($xpath)
{
$xpath = $this->relativize($xpath);
// If we dropped all expressions in the XPath while preparing it, there would be no match
if ('' === $xpath) {
return $this->createSubCrawler(null);
}
return $this->filterRelativeXPath($xpath);
} | php | public function filterXPath($xpath)
{
$xpath = $this->relativize($xpath);
// If we dropped all expressions in the XPath while preparing it, there would be no match
if ('' === $xpath) {
return $this->createSubCrawler(null);
}
return $this->filterRelativeXPath($xpath);
} | [
"public",
"function",
"filterXPath",
"(",
"$",
"xpath",
")",
"{",
"$",
"xpath",
"=",
"$",
"this",
"->",
"relativize",
"(",
"$",
"xpath",
")",
";",
"// If we dropped all expressions in the XPath while preparing it, there would be no match",
"if",
"(",
"''",
"===",
"$... | Filters the list of nodes with an XPath expression.
The XPath expression is evaluated in the context of the crawler, which
is considered as a fake parent of the elements inside it.
This means that a child selector "div" or "./div" will match only
the div elements of the current crawler, not their children.
@param string $xpath An XPath expression
@return self | [
"Filters",
"the",
"list",
"of",
"nodes",
"with",
"an",
"XPath",
"expression",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L698-L708 | train | Filter the XPath to a single node | [
30522,
2270,
3853,
11307,
2595,
15069,
1006,
1002,
26726,
8988,
1007,
1063,
1002,
26726,
8988,
1027,
1002,
2023,
1011,
1028,
2128,
20051,
12848,
4697,
1006,
1002,
26726,
8988,
1007,
1025,
1013,
1013,
2065,
2057,
3333,
2035,
11423,
1999,
199... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Translation/TranslationServiceProvider.php | TranslationServiceProvider.register | public function register()
{
$this->registerLoader();
$this->app->singleton('translator', function ($app) {
$loader = $app['translation.loader'];
// When registering the translator component, we'll need to set the default
// locale as well as the fallback locale. So, we'll grab the application
// configuration so we can easily get both of these values from there.
$locale = $app['config']['app.locale'];
$trans = new Translator($loader, $locale);
$trans->setFallback($app['config']['app.fallback_locale']);
return $trans;
});
} | php | public function register()
{
$this->registerLoader();
$this->app->singleton('translator', function ($app) {
$loader = $app['translation.loader'];
// When registering the translator component, we'll need to set the default
// locale as well as the fallback locale. So, we'll grab the application
// configuration so we can easily get both of these values from there.
$locale = $app['config']['app.locale'];
$trans = new Translator($loader, $locale);
$trans->setFallback($app['config']['app.fallback_locale']);
return $trans;
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerLoader",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'translator'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"loader",
"=",
"$",
"app",
"[",
... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Translation/TranslationServiceProvider.php#L15-L33 | train | Registers the translator component | [
30522,
2270,
3853,
4236,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4236,
11066,
2121,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
10439,
1011,
1028,
28159,
1006,
1005,
11403,
1005,
1010,
3853,
1006,
1002,
10439,
1007,
1063,
1002,
7170,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Libmemcached.php | Zend_Cache_Backend_Libmemcached.clean | public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
return $this->_memcache->flush();
break;
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_Libmemcached::clean() : CLEANING_MODE_OLD is unsupported by the Libmemcached backend");
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
$this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_LIBMEMCACHED_BACKEND);
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
} | php | public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
return $this->_memcache->flush();
break;
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_Libmemcached::clean() : CLEANING_MODE_OLD is unsupported by the Libmemcached backend");
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
$this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_LIBMEMCACHED_BACKEND);
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
} | [
"public",
"function",
"clean",
"(",
"$",
"mode",
"=",
"Zend_Cache",
"::",
"CLEANING_MODE_ALL",
",",
"$",
"tags",
"=",
"array",
"(",
")",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"Zend_Cache",
"::",
"CLEANING_MODE_ALL",
":",
"return",
"$",
... | Clean some cache records
Available modes are :
'all' (default) => remove all cache entries ($tags is not used)
'old' => unsupported
'matchingTag' => unsupported
'notMatchingTag' => unsupported
'matchingAnyTag' => unsupported
@param string $mode Clean mode
@param array $tags Array of tags
@throws Zend_Cache_Exception
@return boolean True if no problem | [
"Clean",
"some",
"cache",
"records"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Libmemcached.php#L245-L263 | train | Flushes all cache | [
30522,
2270,
3853,
4550,
1006,
1002,
5549,
1027,
16729,
2094,
1035,
17053,
1024,
1024,
9344,
1035,
5549,
1035,
2035,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1007,
1063,
6942,
1006,
1002,
5549,
1007,
1063,
2553,
16729,
2094,
1035,
17053,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/File/Size.php | Zend_Validate_File_Size.getMin | public function getMin($raw = false)
{
$min = $this->_min;
if (!$raw && $this->useByteString()) {
$min = $this->_toByteString($min);
}
return $min;
} | php | public function getMin($raw = false)
{
$min = $this->_min;
if (!$raw && $this->useByteString()) {
$min = $this->_toByteString($min);
}
return $min;
} | [
"public",
"function",
"getMin",
"(",
"$",
"raw",
"=",
"false",
")",
"{",
"$",
"min",
"=",
"$",
"this",
"->",
"_min",
";",
"if",
"(",
"!",
"$",
"raw",
"&&",
"$",
"this",
"->",
"useByteString",
"(",
")",
")",
"{",
"$",
"min",
"=",
"$",
"this",
... | Returns the minimum filesize
@param bool $raw Whether or not to force return of the raw value (defaults off)
@return integer|string | [
"Returns",
"the",
"minimum",
"filesize"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/File/Size.php#L164-L172 | train | Get Minimum Value of this Field | [
30522,
2270,
3853,
2131,
10020,
1006,
1002,
6315,
1027,
6270,
1007,
1063,
1002,
8117,
1027,
1002,
2023,
1011,
1028,
1035,
8117,
1025,
2065,
1006,
999,
1002,
6315,
1004,
1004,
1002,
2023,
1011,
1028,
2224,
3762,
22199,
4892,
1006,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FactoryTrait.php | FactoryTrait.factory | final public function factory($factory)
{
if (\is_string($factory) && 1 === substr_count($factory, ':')) {
$factoryParts = explode(':', $factory);
throw new InvalidArgumentException(sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[ref(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
}
$this->definition->setFactory(static::processValue($factory, true));
return $this;
} | php | final public function factory($factory)
{
if (\is_string($factory) && 1 === substr_count($factory, ':')) {
$factoryParts = explode(':', $factory);
throw new InvalidArgumentException(sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[ref(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
}
$this->definition->setFactory(static::processValue($factory, true));
return $this;
} | [
"final",
"public",
"function",
"factory",
"(",
"$",
"factory",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"factory",
")",
"&&",
"1",
"===",
"substr_count",
"(",
"$",
"factory",
",",
"':'",
")",
")",
"{",
"$",
"factoryParts",
"=",
"explode",
"(... | Sets a factory.
@param string|array $factory A PHP callable reference
@return $this | [
"Sets",
"a",
"factory",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FactoryTrait.php#L25-L36 | train | Sets the factory for the class | [
30522,
2345,
2270,
3853,
4713,
1006,
1002,
4713,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
4713,
1007,
1004,
1004,
1015,
1027,
1027,
1027,
4942,
3367,
2099,
1035,
4175,
1006,
1002,
4713,
1010,
1005,
1024,
1005,
1007,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Manager.php | Manager.deleteAll | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | php | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | [
"public",
"function",
"deleteAll",
"(",
"$",
"deleteWhenIdTableGreaterThan",
"=",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"id",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"id",
">",
"$",
"deleteWhenIdTableGreaterThan",
")",
"{",
"$",
... | Delete all the registered DataTables from the manager | [
"Delete",
"all",
"the",
"registered",
"DataTables",
"from",
"the",
"manager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L84-L96 | train | Delete all tables from the database | [
30522,
2270,
3853,
3972,
12870,
8095,
1006,
1002,
3972,
12870,
2860,
10222,
3593,
10880,
17603,
24932,
21604,
1027,
1014,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
2004,
1002,
8909,
1027,
1028,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
890... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.setGlobalSearchParameters | public function setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters)
{
Piwik::checkUserHasSuperUserAccess();
Option::set(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL, $searchKeywordParameters);
Option::set(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL, $searchCategoryParameters);
Cache::deleteTrackerCache();
return true;
} | php | public function setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters)
{
Piwik::checkUserHasSuperUserAccess();
Option::set(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL, $searchKeywordParameters);
Option::set(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL, $searchCategoryParameters);
Cache::deleteTrackerCache();
return true;
} | [
"public",
"function",
"setGlobalSearchParameters",
"(",
"$",
"searchKeywordParameters",
",",
"$",
"searchCategoryParameters",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"Option",
"::",
"set",
"(",
"self",
"::",
"OPTION_SEARCH_KEYWORD_QUERY_PA... | Sets Site Search keyword/category parameter names, to be used on websites which have not specified these values
Expects Comma separated list of query params names
@param string
@param string
@return bool | [
"Sets",
"Site",
"Search",
"keyword",
"/",
"category",
"parameter",
"names",
"to",
"be",
"used",
"on",
"websites",
"which",
"have",
"not",
"specified",
"these",
"values",
"Expects",
"Comma",
"separated",
"list",
"of",
"query",
"params",
"names"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L985-L992 | train | This method sets the global search parameters for the current language. | [
30522,
2270,
3853,
2275,
23296,
16429,
9777,
14644,
2818,
28689,
22828,
2015,
1006,
1002,
3945,
14839,
18351,
28689,
22828,
2015,
1010,
1002,
3945,
16280,
20255,
22571,
5400,
22828,
2015,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.getFieldNameFromData | protected function getFieldNameFromData($fieldName, $data, $default = null)
{
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($fieldName);
$lastField = end($keyParts);
$result = $data;
/*
* Loop the field key parts and build a value.
* To support relations only the last field should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
}
else {
$result = $result->{$key};
}
}
elseif (is_array($result)) {
if (!array_key_exists($key, $result)) {
return $default;
}
$result = $result[$key];
}
else {
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | php | protected function getFieldNameFromData($fieldName, $data, $default = null)
{
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($fieldName);
$lastField = end($keyParts);
$result = $data;
/*
* Loop the field key parts and build a value.
* To support relations only the last field should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
}
else {
$result = $result->{$key};
}
}
elseif (is_array($result)) {
if (!array_key_exists($key, $result)) {
return $default;
}
$result = $result[$key];
}
else {
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | [
"protected",
"function",
"getFieldNameFromData",
"(",
"$",
"fieldName",
",",
"$",
"data",
",",
"$",
"default",
"=",
"null",
")",
"{",
"/*\n * Array field name, eg: field[key][key2][key3]\n */",
"$",
"keyParts",
"=",
"HtmlHelper",
"::",
"nameToArray",
"("... | Internal method to extract the value of a field name from a data set.
@param string $fieldName
@param mixed $data
@param mixed $default
@return mixed | [
"Internal",
"method",
"to",
"extract",
"the",
"value",
"of",
"a",
"field",
"name",
"from",
"a",
"data",
"set",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L676-L716 | train | Get the field name from the data | [
30522,
5123,
3853,
2131,
3790,
18442,
19699,
5358,
2850,
2696,
1006,
1002,
2492,
18442,
1010,
1002,
2951,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1013,
1008,
1008,
9140,
2492,
2171,
1010,
1041,
2290,
1024,
2492,
1031,
3145,
1033,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Proxy.php | Proxy.registerClass | public function registerClass($className)
{
if (isset($this->alreadyRegistered[$className])) {
return;
}
$this->includeApiFile($className);
$this->checkClassIsSingleton($className);
$rClass = new ReflectionClass($className);
if (!$this->shouldHideAPIMethod($rClass->getDocComment())) {
foreach ($rClass->getMethods() as $method) {
$this->loadMethodMetadata($className, $method);
}
$this->setDocumentation($rClass, $className);
$this->alreadyRegistered[$className] = true;
}
} | php | public function registerClass($className)
{
if (isset($this->alreadyRegistered[$className])) {
return;
}
$this->includeApiFile($className);
$this->checkClassIsSingleton($className);
$rClass = new ReflectionClass($className);
if (!$this->shouldHideAPIMethod($rClass->getDocComment())) {
foreach ($rClass->getMethods() as $method) {
$this->loadMethodMetadata($className, $method);
}
$this->setDocumentation($rClass, $className);
$this->alreadyRegistered[$className] = true;
}
} | [
"public",
"function",
"registerClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"alreadyRegistered",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"includeApiFile",
"(",
"$",
"clas... | Registers the API information of a given module.
The module to be registered must be
- a singleton (providing a getInstance() method)
- the API file must be located in plugins/ModuleName/API.php
for example plugins/Referrers/API.php
The method will introspect the methods, their parameters, etc.
@param string $className ModuleName eg. "API" | [
"Registers",
"the",
"API",
"information",
"of",
"a",
"given",
"module",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Proxy.php#L75-L92 | train | Registers the API method metadata for the given class. | [
30522,
2270,
3853,
4236,
26266,
1006,
1002,
2465,
18442,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2525,
2890,
24063,
6850,
1031,
1002,
2465,
18442,
1033,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpKernel.php | HttpKernel.finishRequest | private function finishRequest(Request $request, int $type)
{
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
$this->requestStack->pop();
} | php | private function finishRequest(Request $request, int $type)
{
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
$this->requestStack->pop();
} | [
"private",
"function",
"finishRequest",
"(",
"Request",
"$",
"request",
",",
"int",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"FinishRequestEvent",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"type",
")",
... | Publishes the finish request event, then pop the request from the stack.
Note that the order of the operations is important here, otherwise
operations such as {@link RequestStack::getParentRequest()} can lead to
weird results. | [
"Publishes",
"the",
"finish",
"request",
"event",
"then",
"pop",
"the",
"request",
"from",
"the",
"stack",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpKernel.php#L204-L208 | train | Finishes the current request | [
30522,
2797,
3853,
3926,
2890,
15500,
1006,
5227,
1002,
5227,
1010,
20014,
1002,
2828,
1007,
1063,
1002,
2023,
1011,
1028,
18365,
2121,
1011,
1028,
18365,
1006,
2047,
3926,
2890,
15500,
18697,
3372,
1006,
1002,
2023,
1010,
1002,
5227,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/LogTablesProvider.php | LogTablesProvider.getLogTable | public function getLogTable($tableNameWithoutPrefix)
{
foreach ($this->getAllLogTables() as $table) {
if ($table->getName() === $tableNameWithoutPrefix) {
return $table;
}
}
} | php | public function getLogTable($tableNameWithoutPrefix)
{
foreach ($this->getAllLogTables() as $table) {
if ($table->getName() === $tableNameWithoutPrefix) {
return $table;
}
}
} | [
"public",
"function",
"getLogTable",
"(",
"$",
"tableNameWithoutPrefix",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAllLogTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"->",
"getName",
"(",
")",
"===",
"$",
"tableNameWit... | Get an instance of a specific log table if such a log table exists.
@param string $tableNameWithoutPrefix eg "log_visit"
@return LogTable|null | [
"Get",
"an",
"instance",
"of",
"a",
"specific",
"log",
"table",
"if",
"such",
"a",
"log",
"table",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/LogTablesProvider.php#L38-L45 | train | Get the log table for a given name without prefix | [
30522,
2270,
3853,
2131,
21197,
10880,
1006,
1002,
2795,
18442,
24415,
5833,
28139,
8873,
2595,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
8095,
21197,
10880,
2015,
1006,
1007,
2004,
1002,
2795,
1007,
1063,
2065,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/RouteListCommand.php | RouteListCommand.handle | public function handle()
{
if (empty($this->routes)) {
return $this->error("Your application doesn't have any routes.");
}
if (empty($routes = $this->getRoutes())) {
return $this->error("Your application doesn't have any routes matching the given criteria.");
}
$this->displayRoutes($routes);
} | php | public function handle()
{
if (empty($this->routes)) {
return $this->error("Your application doesn't have any routes.");
}
if (empty($routes = $this->getRoutes())) {
return $this->error("Your application doesn't have any routes matching the given criteria.");
}
$this->displayRoutes($routes);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"routes",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"\"Your application doesn't have any routes.\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/RouteListCommand.php#L68-L79 | train | Handle the request | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
5847,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7561,
1006,
1000,
2115,
30524,
1012,
1000,
1007,
1025,
1065,
2065,
1006,
4064,
1006,
1002,
58... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Renderer/Php.php | Php.render | public function render($dataTable = null)
{
if (is_null($dataTable)) {
$dataTable = $this->table;
}
$toReturn = $this->flatRender($dataTable);
if ($this->prettyDisplay) {
if (!is_array($toReturn)) {
$toReturn = Common::safe_unserialize($toReturn);
}
$toReturn = "<pre>" . var_export($toReturn, true) . "</pre>";
}
return $toReturn;
} | php | public function render($dataTable = null)
{
if (is_null($dataTable)) {
$dataTable = $this->table;
}
$toReturn = $this->flatRender($dataTable);
if ($this->prettyDisplay) {
if (!is_array($toReturn)) {
$toReturn = Common::safe_unserialize($toReturn);
}
$toReturn = "<pre>" . var_export($toReturn, true) . "</pre>";
}
return $toReturn;
} | [
"public",
"function",
"render",
"(",
"$",
"dataTable",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"dataTable",
")",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"table",
";",
"}",
"$",
"toReturn",
"=",
"$",
"this",
"->",
"flatRen... | Computes the dataTable output and returns the string/binary
@param null|DataTable|DataTable\Map|Simple $dataTable
@return string | [
"Computes",
"the",
"dataTable",
"output",
"and",
"returns",
"the",
"string",
"/",
"binary"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Renderer/Php.php#L72-L86 | train | Render the table | [
30522,
2270,
3853,
17552,
1006,
1002,
2951,
10880,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2951,
10880,
1007,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
1011,
1028,
2795,
1025,
1065,
1002,
9538,
22299,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Simple/PhpArrayCache.php | PhpArrayCache.create | public static function create($file, Psr16CacheInterface $fallbackPool)
{
// Shared memory is available in PHP 7.0+ with OPCache enabled
if (filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
return new static($file, $fallbackPool);
}
return $fallbackPool;
} | php | public static function create($file, Psr16CacheInterface $fallbackPool)
{
// Shared memory is available in PHP 7.0+ with OPCache enabled
if (filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
return new static($file, $fallbackPool);
}
return $fallbackPool;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"file",
",",
"Psr16CacheInterface",
"$",
"fallbackPool",
")",
"{",
"// Shared memory is available in PHP 7.0+ with OPCache enabled",
"if",
"(",
"filter_var",
"(",
"ini_get",
"(",
"'opcache.enable'",
")",
",",
"FILTER_V... | This adapter takes advantage of how PHP stores arrays in its latest versions.
@param string $file The PHP file were values are cached
@return Psr16CacheInterface | [
"This",
"adapter",
"takes",
"advantage",
"of",
"how",
"PHP",
"stores",
"arrays",
"in",
"its",
"latest",
"versions",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Simple/PhpArrayCache.php#L48-L56 | train | Create a new instance of the class | [
30522,
2270,
10763,
3853,
3443,
1006,
1002,
5371,
1010,
8827,
2099,
16048,
3540,
5403,
18447,
2121,
12172,
1002,
2991,
5963,
16869,
1007,
1063,
1013,
1013,
4207,
3638,
2003,
2800,
1999,
25718,
1021,
1012,
1014,
1009,
2007,
6728,
3540,
5403,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Rule.php | HTML_QuickForm2_Rule.or_ | public function or_(HTML_QuickForm2_Rule $next)
{
if ($next instanceof HTML_QuickForm2_Rule_Required) {
throw new HTML_QuickForm2_InvalidArgumentException(
'or_(): Cannot add a "required" rule'
);
}
$this->chainedRules[] = array($next);
return $this;
} | php | public function or_(HTML_QuickForm2_Rule $next)
{
if ($next instanceof HTML_QuickForm2_Rule_Required) {
throw new HTML_QuickForm2_InvalidArgumentException(
'or_(): Cannot add a "required" rule'
);
}
$this->chainedRules[] = array($next);
return $this;
} | [
"public",
"function",
"or_",
"(",
"HTML_QuickForm2_Rule",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"next",
"instanceof",
"HTML_QuickForm2_Rule_Required",
")",
"{",
"throw",
"new",
"HTML_QuickForm2_InvalidArgumentException",
"(",
"'or_(): Cannot add a \"required\" rule'",
")... | Adds a rule to the chain with an "or" operator
Evaluation is short-circuited, next rule will not be evaluated if the
previous one returns true. The method is named this way because "or" is
a reserved word in PHP.
@param HTML_QuickForm2_Rule
@return HTML_QuickForm2_Rule first rule in the chain (i.e. $this)
@throws HTML_QuickForm2_InvalidArgumentException when trying to add
a "required" rule to the chain | [
"Adds",
"a",
"rule",
"to",
"the",
"chain",
"with",
"an",
"or",
"operator"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule.php#L225-L234 | train | Adds a rule to the chain of rules and returns the current one | [
30522,
2270,
3853,
2030,
1035,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
3627,
1002,
2279,
1007,
1063,
2065,
1006,
1002,
2279,
6013,
11253,
16129,
1035,
4248,
14192,
2475,
1035,
3627,
1035,
3223,
1007,
1063,
5466,
2047,
16129,
1035,
4248,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config.php | Zend_Config.getSectionName | public function getSectionName()
{
if(is_array($this->_loadedSection) && count($this->_loadedSection) == 1) {
$this->_loadedSection = $this->_loadedSection[0];
}
return $this->_loadedSection;
} | php | public function getSectionName()
{
if(is_array($this->_loadedSection) && count($this->_loadedSection) == 1) {
$this->_loadedSection = $this->_loadedSection[0];
}
return $this->_loadedSection;
} | [
"public",
"function",
"getSectionName",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_loadedSection",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_loadedSection",
")",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"_loadedSection",
"=",
"$... | Returns the section name(s) loaded.
@return mixed | [
"Returns",
"the",
"section",
"name",
"(",
"s",
")",
"loaded",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config.php#L314-L320 | train | Get Section Name | [
30522,
2270,
3853,
4152,
18491,
18442,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
1035,
8209,
29015,
1007,
1004,
1004,
4175,
1006,
1002,
2023,
1011,
1028,
1035,
8209,
29015,
1007,
1027,
1027,
1015,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/RequestSet.php | RequestSet.shouldPerformRedirectToUrl | public function shouldPerformRedirectToUrl()
{
if (!$this->hasRedirectUrl()) {
return false;
}
if (!$this->hasRequests()) {
return false;
}
$redirectUrl = $this->getRedirectUrl();
$host = Url::getHostFromUrl($redirectUrl);
if (empty($host)) {
return false;
}
$urls = new SiteUrls();
$siteUrls = $urls->getAllCachedSiteUrls();
$siteIds = $this->getAllSiteIdsWithinRequest();
foreach ($siteIds as $siteId) {
if (empty($siteUrls[$siteId])) {
$siteUrls[$siteId] = array();
}
if (Url::isHostInUrls($host, $siteUrls[$siteId])) {
return $redirectUrl;
}
}
return false;
} | php | public function shouldPerformRedirectToUrl()
{
if (!$this->hasRedirectUrl()) {
return false;
}
if (!$this->hasRequests()) {
return false;
}
$redirectUrl = $this->getRedirectUrl();
$host = Url::getHostFromUrl($redirectUrl);
if (empty($host)) {
return false;
}
$urls = new SiteUrls();
$siteUrls = $urls->getAllCachedSiteUrls();
$siteIds = $this->getAllSiteIdsWithinRequest();
foreach ($siteIds as $siteId) {
if (empty($siteUrls[$siteId])) {
$siteUrls[$siteId] = array();
}
if (Url::isHostInUrls($host, $siteUrls[$siteId])) {
return $redirectUrl;
}
}
return false;
} | [
"public",
"function",
"shouldPerformRedirectToUrl",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRedirectUrl",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRequests",
"(",
")",
")",
"{",
"return",
"... | TODO maybe move to response? or somewhere else? not sure where! | [
"TODO",
"maybe",
"move",
"to",
"response?",
"or",
"somewhere",
"else?",
"not",
"sure",
"where!"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/RequestSet.php#L149-L181 | train | Returns the redirect url if the request should be redirected to the same host as the redirect url if it is in the site list | [
30522,
2270,
3853,
2323,
4842,
14192,
5596,
7442,
6593,
21163,
2140,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2038,
5596,
7442,
6593,
3126,
2140,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
999,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/RowEvolution.php | RowEvolution.getSingleRowEvolution | private function getSingleRowEvolution($idSite, $dataTable, $metadata, $apiModule, $apiAction, $label, $labelUseAbsoluteUrl = true)
{
$metricNames = array_keys($metadata['metrics']);
$logo = $actualLabel = false;
$urlFound = false;
foreach ($dataTable->getDataTables() as $subTable) {
/** @var $subTable DataTable */
$subTable->applyQueuedFilters();
if ($subTable->getRowsCount() > 0) {
/** @var $row Row */
$row = $subTable->getFirstRow();
if (!$actualLabel) {
$logo = $row->getMetadata('logo');
$actualLabel = $this->getRowUrlForEvolutionLabel($row, $apiModule, $apiAction, $labelUseAbsoluteUrl);
$urlFound = $actualLabel !== false;
if (empty($actualLabel)) {
$actualLabel = $row->getColumn('label');
}
}
// remove all columns that are not in the available metrics.
// this removes the label as well (which is desired for two reasons: (1) it was passed
// in the request, (2) it would cause the evolution graph to show the label in the legend).
foreach ($row->getColumns() as $column => $value) {
if (!in_array($column, $metricNames) && $column != 'label_html') {
$row->deleteColumn($column);
}
}
$row->deleteMetadata();
}
}
$this->enhanceRowEvolutionMetaData($metadata, $dataTable);
// if we have a recursive label and no url, use the path
if (!$urlFound) {
$actualLabel = $this->formatQueryLabelForDisplay($idSite, $apiModule, $apiAction, $label);
}
$return = array(
'label' => SafeDecodeLabel::decodeLabelSafe($actualLabel),
'reportData' => $dataTable,
'metadata' => $metadata
);
if (!empty($logo)) {
$return['logo'] = $logo;
}
return $return;
} | php | private function getSingleRowEvolution($idSite, $dataTable, $metadata, $apiModule, $apiAction, $label, $labelUseAbsoluteUrl = true)
{
$metricNames = array_keys($metadata['metrics']);
$logo = $actualLabel = false;
$urlFound = false;
foreach ($dataTable->getDataTables() as $subTable) {
/** @var $subTable DataTable */
$subTable->applyQueuedFilters();
if ($subTable->getRowsCount() > 0) {
/** @var $row Row */
$row = $subTable->getFirstRow();
if (!$actualLabel) {
$logo = $row->getMetadata('logo');
$actualLabel = $this->getRowUrlForEvolutionLabel($row, $apiModule, $apiAction, $labelUseAbsoluteUrl);
$urlFound = $actualLabel !== false;
if (empty($actualLabel)) {
$actualLabel = $row->getColumn('label');
}
}
// remove all columns that are not in the available metrics.
// this removes the label as well (which is desired for two reasons: (1) it was passed
// in the request, (2) it would cause the evolution graph to show the label in the legend).
foreach ($row->getColumns() as $column => $value) {
if (!in_array($column, $metricNames) && $column != 'label_html') {
$row->deleteColumn($column);
}
}
$row->deleteMetadata();
}
}
$this->enhanceRowEvolutionMetaData($metadata, $dataTable);
// if we have a recursive label and no url, use the path
if (!$urlFound) {
$actualLabel = $this->formatQueryLabelForDisplay($idSite, $apiModule, $apiAction, $label);
}
$return = array(
'label' => SafeDecodeLabel::decodeLabelSafe($actualLabel),
'reportData' => $dataTable,
'metadata' => $metadata
);
if (!empty($logo)) {
$return['logo'] = $logo;
}
return $return;
} | [
"private",
"function",
"getSingleRowEvolution",
"(",
"$",
"idSite",
",",
"$",
"dataTable",
",",
"$",
"metadata",
",",
"$",
"apiModule",
",",
"$",
"apiAction",
",",
"$",
"label",
",",
"$",
"labelUseAbsoluteUrl",
"=",
"true",
")",
"{",
"$",
"metricNames",
"=... | Get row evolution for a single label
@param DataTable\Map $dataTable
@param array $metadata
@param string $apiModule
@param string $apiAction
@param string $label
@param bool $labelUseAbsoluteUrl
@return array containing report data, metadata, label, logo | [
"Get",
"row",
"evolution",
"for",
"a",
"single",
"label"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/RowEvolution.php#L141-L192 | train | Returns the row evolution information for a single row | [
30522,
2797,
3853,
4152,
2075,
3917,
29385,
6767,
7630,
3508,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2951,
10880,
1010,
1002,
27425,
1010,
1002,
17928,
5302,
8566,
2571,
1010,
1002,
17928,
18908,
3258,
1010,
1002,
3830,
1010,
1002,
3830... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hhxsv5/laravel-s | src/Swoole/Task/Task.php | Task.deliver | public static function deliver(Task $task, $bySendMessage = false)
{
$task->bySendMessage = $bySendMessage;
$deliver = function () use ($task, $bySendMessage) {
/**
* @var \swoole_http_server $swoole
*/
$swoole = app('swoole');
if ($bySendMessage) {
$taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0;
if ($taskWorkerNum === 0) {
throw new \InvalidArgumentException('LaravelS: Asynchronous task needs to set task_worker_num > 0');
}
$workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0;
$totalNum = $workerNum + $taskWorkerNum;
$getAvailableId = function ($startId, $endId, $excludeId) {
$ids = range($startId, $endId);
$ids = array_flip($ids);
unset($ids[$excludeId]);
return array_rand($ids);
};
$availableId = $getAvailableId($workerNum, $totalNum - 1, $swoole->worker_id);
return $swoole->sendMessage($task, $availableId);
} else {
$taskId = $swoole->task($task);
return $taskId !== false;
}
};
if ($task->delay > 0) {
swoole_timer_after($task->delay * 1000, $deliver);
return true;
} else {
return $deliver();
}
} | php | public static function deliver(Task $task, $bySendMessage = false)
{
$task->bySendMessage = $bySendMessage;
$deliver = function () use ($task, $bySendMessage) {
/**
* @var \swoole_http_server $swoole
*/
$swoole = app('swoole');
if ($bySendMessage) {
$taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0;
if ($taskWorkerNum === 0) {
throw new \InvalidArgumentException('LaravelS: Asynchronous task needs to set task_worker_num > 0');
}
$workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0;
$totalNum = $workerNum + $taskWorkerNum;
$getAvailableId = function ($startId, $endId, $excludeId) {
$ids = range($startId, $endId);
$ids = array_flip($ids);
unset($ids[$excludeId]);
return array_rand($ids);
};
$availableId = $getAvailableId($workerNum, $totalNum - 1, $swoole->worker_id);
return $swoole->sendMessage($task, $availableId);
} else {
$taskId = $swoole->task($task);
return $taskId !== false;
}
};
if ($task->delay > 0) {
swoole_timer_after($task->delay * 1000, $deliver);
return true;
} else {
return $deliver();
}
} | [
"public",
"static",
"function",
"deliver",
"(",
"Task",
"$",
"task",
",",
"$",
"bySendMessage",
"=",
"false",
")",
"{",
"$",
"task",
"->",
"bySendMessage",
"=",
"$",
"bySendMessage",
";",
"$",
"deliver",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"tas... | Deliver a task
@param Task $task The task object
@param bool $bySendMessage If set to true, the task will be delivered via the pipe message, and this task does not support the finish callback. Default false.
@return bool | [
"Deliver",
"a",
"task"
] | 247b86c9d5aee0f347f1b37fe89d739f806057bd | https://github.com/hhxsv5/laravel-s/blob/247b86c9d5aee0f347f1b37fe89d739f806057bd/src/Swoole/Task/Task.php#L54-L89 | train | Deliver a task | [
30522,
2270,
10763,
3853,
8116,
1006,
4708,
1002,
4708,
1010,
1002,
2011,
5054,
22117,
7971,
4270,
1027,
6270,
1007,
1063,
1002,
4708,
1011,
1028,
2011,
5054,
22117,
7971,
4270,
1027,
1002,
2011,
5054,
22117,
7971,
4270,
1025,
1002,
8116,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Pipeline/Hub.php | Hub.pipe | public function pipe($object, $pipeline = null)
{
$pipeline = $pipeline ?: 'default';
return call_user_func(
$this->pipelines[$pipeline], new Pipeline($this->container), $object
);
} | php | public function pipe($object, $pipeline = null)
{
$pipeline = $pipeline ?: 'default';
return call_user_func(
$this->pipelines[$pipeline], new Pipeline($this->container), $object
);
} | [
"public",
"function",
"pipe",
"(",
"$",
"object",
",",
"$",
"pipeline",
"=",
"null",
")",
"{",
"$",
"pipeline",
"=",
"$",
"pipeline",
"?",
":",
"'default'",
";",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"pipelines",
"[",
"$",
"pipeline",
"]"... | Send an object through one of the available pipelines.
@param mixed $object
@param string|null $pipeline
@return mixed | [
"Send",
"an",
"object",
"through",
"one",
"of",
"the",
"available",
"pipelines",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pipeline/Hub.php#L66-L73 | train | Pipe an object to the pipeline | [
30522,
2270,
3853,
8667,
1006,
1002,
4874,
1010,
1002,
13117,
1027,
19701,
1007,
1063,
1002,
13117,
1027,
1002,
13117,
1029,
1024,
1005,
12398,
1005,
1025,
2709,
2655,
1035,
5310,
1035,
4569,
2278,
1006,
1002,
2023,
1011,
1028,
13117,
2015,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/ValidationRuleParser.php | ValidationRuleParser.parseParameters | protected static function parseParameters($rule, $parameter)
{
$rule = strtolower($rule);
if (in_array($rule, ['regex', 'not_regex', 'notregex'], true)) {
return [$parameter];
}
return str_getcsv($parameter);
} | php | protected static function parseParameters($rule, $parameter)
{
$rule = strtolower($rule);
if (in_array($rule, ['regex', 'not_regex', 'notregex'], true)) {
return [$parameter];
}
return str_getcsv($parameter);
} | [
"protected",
"static",
"function",
"parseParameters",
"(",
"$",
"rule",
",",
"$",
"parameter",
")",
"{",
"$",
"rule",
"=",
"strtolower",
"(",
"$",
"rule",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"rule",
",",
"[",
"'regex'",
",",
"'not_regex'",
",",
... | Parse a parameter list.
@param string $rule
@param string $parameter
@return array | [
"Parse",
"a",
"parameter",
"list",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/ValidationRuleParser.php#L249-L258 | train | Parse parameters from the rule | [
30522,
5123,
10763,
3853,
11968,
3366,
28689,
22828,
2015,
1006,
1002,
3627,
1010,
1002,
16381,
1007,
1063,
1002,
3627,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
3627,
1007,
1025,
2065,
1006,
1999,
1035,
9140,
1006,
1002,
3627,
1010,
1031... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
php-ai/php-ml | src/Association/Apriori.php | Apriori.getRules | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | php | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | [
"public",
"function",
"getRules",
"(",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"large",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"large",
"=",
"$",
"this",
"->",
"apriori",
"(",
")",
";",
"}",
"if",
"(",
"count"... | Get all association rules which are generated for every k-length frequent item set.
@return mixed[][] | [
"Get",
"all",
"association",
"rules",
"which",
"are",
"generated",
"for",
"every",
"k",
"-",
"length",
"frequent",
"item",
"set",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L65-L80 | train | Get rules from all languages | [
30522,
2270,
3853,
2131,
6820,
4244,
1006,
1007,
1024,
9140,
1063,
2065,
1006,
4175,
1006,
1002,
2023,
1011,
1028,
2312,
1007,
1027,
1027,
1027,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
2312,
1027,
1002,
2023,
1011,
1028,
19804,
25346,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/PageUrl.php | PageUrl.getQueryParametersToExclude | public static function getQueryParametersToExclude($idSite)
{
$campaignTrackingParameters = Common::getCampaignParameters();
$campaignTrackingParameters = array_merge(
$campaignTrackingParameters[0], // campaign name parameters
$campaignTrackingParameters[1] // campaign keyword parameters
);
$website = Cache::getCacheWebsiteAttributes($idSite);
$excludedParameters = self::getExcludedParametersFromWebsite($website);
$parametersToExclude = array_merge($excludedParameters,
self::getUrlParameterNamesToExcludeFromUrl(),
$campaignTrackingParameters);
/**
* Triggered before setting the action url in Piwik\Tracker\Action so plugins can register
* parameters to be excluded from the tracking URL (e.g. campaign parameters).
*
* @param array &$parametersToExclude An array of parameters to exclude from the tracking url.
*/
Piwik::postEvent('Tracker.PageUrl.getQueryParametersToExclude', array(&$parametersToExclude));
if (!empty($parametersToExclude)) {
Common::printDebug('Excluding parameters "' . implode(',', $parametersToExclude) . '" from URL');
}
$parametersToExclude = array_map('strtolower', $parametersToExclude);
return $parametersToExclude;
} | php | public static function getQueryParametersToExclude($idSite)
{
$campaignTrackingParameters = Common::getCampaignParameters();
$campaignTrackingParameters = array_merge(
$campaignTrackingParameters[0], // campaign name parameters
$campaignTrackingParameters[1] // campaign keyword parameters
);
$website = Cache::getCacheWebsiteAttributes($idSite);
$excludedParameters = self::getExcludedParametersFromWebsite($website);
$parametersToExclude = array_merge($excludedParameters,
self::getUrlParameterNamesToExcludeFromUrl(),
$campaignTrackingParameters);
/**
* Triggered before setting the action url in Piwik\Tracker\Action so plugins can register
* parameters to be excluded from the tracking URL (e.g. campaign parameters).
*
* @param array &$parametersToExclude An array of parameters to exclude from the tracking url.
*/
Piwik::postEvent('Tracker.PageUrl.getQueryParametersToExclude', array(&$parametersToExclude));
if (!empty($parametersToExclude)) {
Common::printDebug('Excluding parameters "' . implode(',', $parametersToExclude) . '" from URL');
}
$parametersToExclude = array_map('strtolower', $parametersToExclude);
return $parametersToExclude;
} | [
"public",
"static",
"function",
"getQueryParametersToExclude",
"(",
"$",
"idSite",
")",
"{",
"$",
"campaignTrackingParameters",
"=",
"Common",
"::",
"getCampaignParameters",
"(",
")",
";",
"$",
"campaignTrackingParameters",
"=",
"array_merge",
"(",
"$",
"campaignTrack... | Returns the array of parameters names that must be excluded from the Query String in all tracked URLs
@static
@param $idSite
@return array | [
"Returns",
"the",
"array",
"of",
"parameters",
"names",
"that",
"must",
"be",
"excluded",
"from",
"the",
"Query",
"String",
"in",
"all",
"tracked",
"URLs"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/PageUrl.php#L73-L103 | train | Returns an array of parameters that should be excluded from the URL | [
30522,
2270,
10763,
3853,
2131,
4226,
2854,
28689,
22828,
16033,
10288,
20464,
12672,
1006,
1002,
8909,
28032,
2063,
1007,
1063,
1002,
3049,
6494,
23177,
28689,
22828,
2015,
1027,
2691,
1024,
1024,
2131,
26468,
4886,
16206,
28689,
22828,
2015... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/ServiceProvider.php | ServiceProvider.registerComponents | protected function registerComponents()
{
ComponentManager::instance()->registerComponents(function ($manager) {
$manager->registerComponent(\Cms\Components\ViewBag::class, 'viewBag');
$manager->registerComponent(\Cms\Components\Resources::class, 'resources');
});
} | php | protected function registerComponents()
{
ComponentManager::instance()->registerComponents(function ($manager) {
$manager->registerComponent(\Cms\Components\ViewBag::class, 'viewBag');
$manager->registerComponent(\Cms\Components\Resources::class, 'resources');
});
} | [
"protected",
"function",
"registerComponents",
"(",
")",
"{",
"ComponentManager",
"::",
"instance",
"(",
")",
"->",
"registerComponents",
"(",
"function",
"(",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"registerComponent",
"(",
"\\",
"Cms",
"\\",
"Compon... | Register components. | [
"Register",
"components",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/ServiceProvider.php#L61-L67 | train | Registers the view bag and resources components | [
30522,
5123,
3853,
4236,
9006,
29513,
7666,
1006,
1007,
1063,
6922,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1011,
1028,
4236,
9006,
29513,
7666,
1006,
3853,
1006,
1002,
3208,
1007,
1063,
1002,
3208,
1011,
1028,
4236,
9006,
29513,
3372,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Session/SaveHandler/DbTable.php | DbTable.write | public function write($id, $data)
{
$sql = 'INSERT INTO ' . $this->config['name']
. ' (' . $this->config['primary'] . ','
. $this->config['modifiedColumn'] . ','
. $this->config['lifetimeColumn'] . ','
. $this->config['dataColumn'] . ')'
. ' VALUES (?,?,?,?)'
. ' ON DUPLICATE KEY UPDATE '
. $this->config['modifiedColumn'] . ' = ?,'
. $this->config['lifetimeColumn'] . ' = ?,'
. $this->config['dataColumn'] . ' = ?';
$this->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data));
return true;
} | php | public function write($id, $data)
{
$sql = 'INSERT INTO ' . $this->config['name']
. ' (' . $this->config['primary'] . ','
. $this->config['modifiedColumn'] . ','
. $this->config['lifetimeColumn'] . ','
. $this->config['dataColumn'] . ')'
. ' VALUES (?,?,?,?)'
. ' ON DUPLICATE KEY UPDATE '
. $this->config['modifiedColumn'] . ' = ?,'
. $this->config['lifetimeColumn'] . ' = ?,'
. $this->config['dataColumn'] . ' = ?';
$this->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data));
return true;
} | [
"public",
"function",
"write",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"$",
"sql",
"=",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"config",
"[",
"'name'",
"]",
".",
"' ('",
".",
"$",
"this",
"->",
"config",
"[",
"'primary'",
"]",
".",
"','",
... | Write Session - commit data to resource
@param string $id
@param mixed $data
@return boolean | [
"Write",
"Session",
"-",
"commit",
"data",
"to",
"resource"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session/SaveHandler/DbTable.php#L132-L148 | train | Write a record to the database | [
30522,
2270,
3853,
4339,
1006,
1002,
8909,
1010,
1002,
2951,
1007,
1063,
1002,
29296,
1027,
1005,
19274,
2046,
1005,
1012,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1031,
1005,
2171,
1005,
1033,
1012,
1005,
1006,
1005,
1012,
1002,
2023,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/ViewCacheCommand.php | ViewCacheCommand.bladeFilesIn | protected function bladeFilesIn(array $paths)
{
return collect(
Finder::create()
->in($paths)
->exclude('vendor')
->name('*.blade.php')
->files()
);
} | php | protected function bladeFilesIn(array $paths)
{
return collect(
Finder::create()
->in($paths)
->exclude('vendor')
->name('*.blade.php')
->files()
);
} | [
"protected",
"function",
"bladeFilesIn",
"(",
"array",
"$",
"paths",
")",
"{",
"return",
"collect",
"(",
"Finder",
"::",
"create",
"(",
")",
"->",
"in",
"(",
"$",
"paths",
")",
"->",
"exclude",
"(",
"'vendor'",
")",
"->",
"name",
"(",
"'*.blade.php'",
... | Get the Blade files in the given path.
@param array $paths
@return \Illuminate\Support\Collection | [
"Get",
"the",
"Blade",
"files",
"in",
"the",
"given",
"path",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/ViewCacheCommand.php#L63-L72 | train | Returns all blade files in the given paths | [
30522,
5123,
3853,
6085,
8873,
4244,
2378,
1006,
9140,
1002,
10425,
1007,
1063,
2709,
8145,
1006,
2424,
2121,
1024,
1024,
3443,
1006,
1007,
1011,
1028,
1999,
1006,
1002,
10425,
1007,
1011,
1028,
23329,
1006,
1005,
21431,
1005,
1007,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/ViewDataTable/Manager.php | Manager.getIdsWithInheritance | public static function getIdsWithInheritance($klass)
{
$klasses = Common::getClassLineage($klass);
$result = array();
foreach ($klasses as $klass) {
try {
$result[] = $klass::getViewDataTableId();
} catch (\Exception $e) {
// in case $klass did not define an id: eg Plugin\ViewDataTable
continue;
}
}
return $result;
} | php | public static function getIdsWithInheritance($klass)
{
$klasses = Common::getClassLineage($klass);
$result = array();
foreach ($klasses as $klass) {
try {
$result[] = $klass::getViewDataTableId();
} catch (\Exception $e) {
// in case $klass did not define an id: eg Plugin\ViewDataTable
continue;
}
}
return $result;
} | [
"public",
"static",
"function",
"getIdsWithInheritance",
"(",
"$",
"klass",
")",
"{",
"$",
"klasses",
"=",
"Common",
"::",
"getClassLineage",
"(",
"$",
"klass",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"klasses",
"as",
... | Returns the viewDataTable IDs of a visualization's class lineage.
@see self::getVisualizationClassLineage
@param string $klass The visualization class.
@return array | [
"Returns",
"the",
"viewDataTable",
"IDs",
"of",
"a",
"visualization",
"s",
"class",
"lineage",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L40-L55 | train | Returns an array of all viewDataTable IDs that have a parent class | [
30522,
2270,
10763,
3853,
2131,
9821,
24415,
2378,
5886,
25451,
3401,
1006,
1002,
1047,
27102,
1007,
1063,
1002,
1047,
27102,
2229,
1027,
2691,
1024,
1024,
2131,
26266,
4179,
4270,
1006,
1002,
1047,
27102,
1007,
1025,
1002,
2765,
1027,
9140... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spatie/laravel-permission | src/PermissionServiceProvider.php | PermissionServiceProvider.getMigrationFileName | protected function getMigrationFileName(Filesystem $filesystem): string
{
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $filesystem->glob($path.'*_create_permission_tables.php');
})->push($this->app->databasePath()."/migrations/{$timestamp}_create_permission_tables.php")
->first();
} | php | protected function getMigrationFileName(Filesystem $filesystem): string
{
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $filesystem->glob($path.'*_create_permission_tables.php');
})->push($this->app->databasePath()."/migrations/{$timestamp}_create_permission_tables.php")
->first();
} | [
"protected",
"function",
"getMigrationFileName",
"(",
"Filesystem",
"$",
"filesystem",
")",
":",
"string",
"{",
"$",
"timestamp",
"=",
"date",
"(",
"'Y_m_d_His'",
")",
";",
"return",
"Collection",
"::",
"make",
"(",
"$",
"this",
"->",
"app",
"->",
"databaseP... | Returns existing migration file if found, else uses the current timestamp.
@param Filesystem $filesystem
@return string | [
"Returns",
"existing",
"migration",
"file",
"if",
"found",
"else",
"uses",
"the",
"current",
"timestamp",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/PermissionServiceProvider.php#L157-L166 | train | Get the migration file name. | [
30522,
5123,
3853,
2131,
4328,
29397,
8873,
20844,
4168,
1006,
6764,
27268,
6633,
1002,
6764,
27268,
6633,
1007,
1024,
5164,
1063,
1002,
2335,
15464,
2361,
1027,
3058,
1006,
1005,
1061,
1035,
1049,
1035,
1040,
1035,
2010,
1005,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php | LoggingMiddleware.handle | public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
$message = $envelope->getMessage();
$context = [
'message' => $message,
'class' => \get_class($envelope->getMessage()),
];
$this->logger->debug('Starting handling message "{class}"', $context);
try {
$envelope = $stack->next()->handle($envelope, $stack);
} catch (\Throwable $e) {
$context['exception'] = $e;
$this->logger->warning('An exception occurred while handling message "{class}": '.$e->getMessage(), $context);
throw $e;
}
$this->logger->debug('Finished handling message "{class}"', $context);
return $envelope;
} | php | public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
$message = $envelope->getMessage();
$context = [
'message' => $message,
'class' => \get_class($envelope->getMessage()),
];
$this->logger->debug('Starting handling message "{class}"', $context);
try {
$envelope = $stack->next()->handle($envelope, $stack);
} catch (\Throwable $e) {
$context['exception'] = $e;
$this->logger->warning('An exception occurred while handling message "{class}": '.$e->getMessage(), $context);
throw $e;
}
$this->logger->debug('Finished handling message "{class}"', $context);
return $envelope;
} | [
"public",
"function",
"handle",
"(",
"Envelope",
"$",
"envelope",
",",
"StackInterface",
"$",
"stack",
")",
":",
"Envelope",
"{",
"$",
"message",
"=",
"$",
"envelope",
"->",
"getMessage",
"(",
")",
";",
"$",
"context",
"=",
"[",
"'message'",
"=>",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php#L36-L57 | train | Handle the message | [
30522,
2270,
3853,
5047,
1006,
11255,
1002,
11255,
1010,
9991,
18447,
2121,
12172,
1002,
9991,
1007,
1024,
11255,
1063,
1002,
4471,
1027,
1002,
11255,
1011,
1028,
2131,
7834,
3736,
3351,
1006,
1007,
1025,
1002,
6123,
1027,
1031,
1005,
4471,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Folder/Mbox.php | Zend_Mail_Storage_Folder_Mbox._buildFolderTree | protected function _buildFolderTree($currentDir, $parentFolder = null, $parentGlobalName = '')
{
if (!$parentFolder) {
$this->_rootFolder = new Zend_Mail_Storage_Folder('/', '/', false);
$parentFolder = $this->_rootFolder;
}
$dh = @opendir($currentDir);
if (!$dh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("can't read dir $currentDir");
}
while (($entry = readdir($dh)) !== false) {
// ignore hidden files for mbox
if ($entry[0] == '.') {
continue;
}
$absoluteEntry = $currentDir . $entry;
$globalName = $parentGlobalName . DIRECTORY_SEPARATOR . $entry;
if (is_file($absoluteEntry) && $this->_isMboxFile($absoluteEntry)) {
$parentFolder->$entry = new Zend_Mail_Storage_Folder($entry, $globalName);
continue;
}
if (!is_dir($absoluteEntry) /* || $entry == '.' || $entry == '..' */) {
continue;
}
$folder = new Zend_Mail_Storage_Folder($entry, $globalName, false);
$parentFolder->$entry = $folder;
$this->_buildFolderTree($absoluteEntry . DIRECTORY_SEPARATOR, $folder, $globalName);
}
closedir($dh);
} | php | protected function _buildFolderTree($currentDir, $parentFolder = null, $parentGlobalName = '')
{
if (!$parentFolder) {
$this->_rootFolder = new Zend_Mail_Storage_Folder('/', '/', false);
$parentFolder = $this->_rootFolder;
}
$dh = @opendir($currentDir);
if (!$dh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("can't read dir $currentDir");
}
while (($entry = readdir($dh)) !== false) {
// ignore hidden files for mbox
if ($entry[0] == '.') {
continue;
}
$absoluteEntry = $currentDir . $entry;
$globalName = $parentGlobalName . DIRECTORY_SEPARATOR . $entry;
if (is_file($absoluteEntry) && $this->_isMboxFile($absoluteEntry)) {
$parentFolder->$entry = new Zend_Mail_Storage_Folder($entry, $globalName);
continue;
}
if (!is_dir($absoluteEntry) /* || $entry == '.' || $entry == '..' */) {
continue;
}
$folder = new Zend_Mail_Storage_Folder($entry, $globalName, false);
$parentFolder->$entry = $folder;
$this->_buildFolderTree($absoluteEntry . DIRECTORY_SEPARATOR, $folder, $globalName);
}
closedir($dh);
} | [
"protected",
"function",
"_buildFolderTree",
"(",
"$",
"currentDir",
",",
"$",
"parentFolder",
"=",
"null",
",",
"$",
"parentGlobalName",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"parentFolder",
")",
"{",
"$",
"this",
"->",
"_rootFolder",
"=",
"new",
"Z... | find all subfolders and mbox files for folder structure
Result is save in Zend_Mail_Storage_Folder instances with the root in $this->_rootFolder.
$parentFolder and $parentGlobalName are only used internally for recursion.
@param string $currentDir call with root dir, also used for recursion.
@param Zend_Mail_Storage_Folder|null $parentFolder used for recursion
@param string $parentGlobalName used for rescursion
@return null
@throws Zend_Mail_Storage_Exception | [
"find",
"all",
"subfolders",
"and",
"mbox",
"files",
"for",
"folder",
"structure"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Folder/Mbox.php#L121-L156 | train | Recursive method to build the tree structure of the folder tree | [
30522,
5123,
3853,
1035,
3857,
10371,
8743,
9910,
1006,
1002,
2783,
4305,
2099,
1010,
1002,
6687,
10371,
2121,
1027,
19701,
1010,
1002,
6687,
23296,
16429,
2389,
18442,
1027,
1005,
1005,
1007,
1063,
2065,
1006,
999,
1002,
6687,
10371,
2121,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.forgetPushed | public function forgetPushed()
{
foreach ($this->listeners as $key => $value) {
if (Str::endsWith($key, '_pushed')) {
$this->forget($key);
}
}
} | php | public function forgetPushed()
{
foreach ($this->listeners as $key => $value) {
if (Str::endsWith($key, '_pushed')) {
$this->forget($key);
}
}
} | [
"public",
"function",
"forgetPushed",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"Str",
"::",
"endsWith",
"(",
"$",
"key",
",",
"'_pushed'",
")",
")",
"{",
"$",
"this",
... | Forget all of the pushed listeners.
@return void | [
"Forget",
"all",
"of",
"the",
"pushed",
"listeners",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/Dispatcher.php#L529-L536 | train | Forget all pushed messages | [
30522,
2270,
3853,
5293,
12207,
9072,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
13810,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
4515,
24415,
1006,
1002,
3145,
1010,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/MemcachedTrait.php | MemcachedTrait.createConnection | public static function createConnection($servers, array $options = [])
{
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Memcached >= 2.2.0 is required');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::$defaultClientOptions;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];
// parse any DSN in $servers
foreach ($servers as $i => $dsn) {
if (\is_array($dsn)) {
continue;
}
if (0 !== strpos($dsn, 'memcached:')) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn));
}
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
if (!empty($m[2])) {
list($username, $password) = explode(':', $m[2], 2) + [1 => null];
}
return 'file:'.($m[1] ?? '');
}, $dsn);
if (false === $params = parse_url($params)) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
$query = $hosts = [];
if (isset($params['query'])) {
parse_str($params['query'], $query);
if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
$hosts[$host] = [$host, 11211, (int) $weight];
} else {
$hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight];
}
}
$hosts = array_values($hosts);
unset($query['host']);
}
if ($hosts && !isset($params['host']) && !isset($params['path'])) {
unset($servers[$i]);
$servers = array_merge($servers, $hosts);
continue;
}
}
if (!isset($params['host']) && !isset($params['path'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
$params['weight'] = $m[1];
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];
if ($query) {
$params += $query;
$options = $query + $options;
}
$servers[$i] = [$params['host'], $params['port'], $params['weight']];
if ($hosts) {
$servers = array_merge($servers, $hosts);
}
}
// set client's options
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
$options = array_change_key_case($options, CASE_UPPER);
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
}
foreach ($options as $name => $value) {
if (\is_int($name)) {
continue;
}
if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
$value = \constant('Memcached::'.$name.'_'.strtoupper($value));
}
$opt = \constant('Memcached::OPT_'.$name);
unset($options[$name]);
$options[$opt] = $value;
}
$client->setOptions($options);
// set client's servers, taking care of persistent connections
if (!$client->isPristine()) {
$oldServers = [];
foreach ($client->getServerList() as $server) {
$oldServers[] = [$server['host'], $server['port']];
}
$newServers = [];
foreach ($servers as $server) {
if (1 < \count($server)) {
$server = array_values($server);
unset($server[2]);
$server[1] = (int) $server[1];
}
$newServers[] = $server;
}
if ($oldServers !== $newServers) {
$client->resetServerList();
$client->addServers($servers);
}
} else {
$client->addServers($servers);
}
if (null !== $username || null !== $password) {
if (!method_exists($client, 'setSaslAuthData')) {
trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.');
}
$client->setSaslAuthData($username, $password);
}
return $client;
} finally {
restore_error_handler();
}
} | php | public static function createConnection($servers, array $options = [])
{
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Memcached >= 2.2.0 is required');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::$defaultClientOptions;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];
// parse any DSN in $servers
foreach ($servers as $i => $dsn) {
if (\is_array($dsn)) {
continue;
}
if (0 !== strpos($dsn, 'memcached:')) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn));
}
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
if (!empty($m[2])) {
list($username, $password) = explode(':', $m[2], 2) + [1 => null];
}
return 'file:'.($m[1] ?? '');
}, $dsn);
if (false === $params = parse_url($params)) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
$query = $hosts = [];
if (isset($params['query'])) {
parse_str($params['query'], $query);
if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
$hosts[$host] = [$host, 11211, (int) $weight];
} else {
$hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight];
}
}
$hosts = array_values($hosts);
unset($query['host']);
}
if ($hosts && !isset($params['host']) && !isset($params['path'])) {
unset($servers[$i]);
$servers = array_merge($servers, $hosts);
continue;
}
}
if (!isset($params['host']) && !isset($params['path'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
$params['weight'] = $m[1];
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];
if ($query) {
$params += $query;
$options = $query + $options;
}
$servers[$i] = [$params['host'], $params['port'], $params['weight']];
if ($hosts) {
$servers = array_merge($servers, $hosts);
}
}
// set client's options
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
$options = array_change_key_case($options, CASE_UPPER);
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
}
foreach ($options as $name => $value) {
if (\is_int($name)) {
continue;
}
if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
$value = \constant('Memcached::'.$name.'_'.strtoupper($value));
}
$opt = \constant('Memcached::OPT_'.$name);
unset($options[$name]);
$options[$opt] = $value;
}
$client->setOptions($options);
// set client's servers, taking care of persistent connections
if (!$client->isPristine()) {
$oldServers = [];
foreach ($client->getServerList() as $server) {
$oldServers[] = [$server['host'], $server['port']];
}
$newServers = [];
foreach ($servers as $server) {
if (1 < \count($server)) {
$server = array_values($server);
unset($server[2]);
$server[1] = (int) $server[1];
}
$newServers[] = $server;
}
if ($oldServers !== $newServers) {
$client->resetServerList();
$client->addServers($servers);
}
} else {
$client->addServers($servers);
}
if (null !== $username || null !== $password) {
if (!method_exists($client, 'setSaslAuthData')) {
trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.');
}
$client->setSaslAuthData($username, $password);
}
return $client;
} finally {
restore_error_handler();
}
} | [
"public",
"static",
"function",
"createConnection",
"(",
"$",
"servers",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"servers",
")",
")",
"{",
"$",
"servers",
"=",
"[",
"$",
"servers",
"]",
";",
"}... | Creates a Memcached instance.
By default, the binary protocol, no block, and libketama compatible options are enabled.
Examples for servers:
- 'memcached://user:pass@localhost?weight=33'
- [['localhost', 11211, 33]]
@param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs
@param array $options An array of options
@return \Memcached
@throws \ErrorException When invalid options or servers are provided | [
"Creates",
"a",
"Memcached",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/MemcachedTrait.php#L80-L222 | train | Creates a Memcached client using the memcached server and options | [
30522,
2270,
10763,
3853,
3443,
8663,
2638,
7542,
1006,
1002,
14903,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
14903,
1007,
1007,
1063,
1002,
14903,
1027,
1031,
1002,
14903,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/widgets/TemplateList.php | TemplateList.render | public function render()
{
$toolbarClass = Str::contains($this->controlClass, 'hero') ? 'separator' : null;
$this->vars['toolbarClass'] = $toolbarClass;
return $this->makePartial('body', [
'data' => $this->getData()
]);
} | php | public function render()
{
$toolbarClass = Str::contains($this->controlClass, 'hero') ? 'separator' : null;
$this->vars['toolbarClass'] = $toolbarClass;
return $this->makePartial('body', [
'data' => $this->getData()
]);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"toolbarClass",
"=",
"Str",
"::",
"contains",
"(",
"$",
"this",
"->",
"controlClass",
",",
"'hero'",
")",
"?",
"'separator'",
":",
"null",
";",
"$",
"this",
"->",
"vars",
"[",
"'toolbarClass'",
"]",
"... | Renders the widget.
@return string | [
"Renders",
"the",
"widget",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/widgets/TemplateList.php#L112-L121 | train | Render the body of the form | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
6994,
8237,
26266,
1027,
2358,
2099,
1024,
1024,
3397,
1006,
1002,
2023,
1011,
1028,
2491,
26266,
1010,
1005,
5394,
1005,
1007,
1029,
1005,
19802,
25879,
2953,
1005,
1024,
19701,
1025,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerTwigParser | protected function registerTwigParser()
{
/*
* Register system Twig environment
*/
App::singleton('twig.environment', function ($app) {
$twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
$twig->addExtension(new TwigExtension);
return $twig;
});
/*
* Register .htm extension for Twig views
*/
App::make('view')->addExtension('htm', 'twig', function () {
return new TwigEngine(App::make('twig.environment'));
});
} | php | protected function registerTwigParser()
{
/*
* Register system Twig environment
*/
App::singleton('twig.environment', function ($app) {
$twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
$twig->addExtension(new TwigExtension);
return $twig;
});
/*
* Register .htm extension for Twig views
*/
App::make('view')->addExtension('htm', 'twig', function () {
return new TwigEngine(App::make('twig.environment'));
});
} | [
"protected",
"function",
"registerTwigParser",
"(",
")",
"{",
"/*\n * Register system Twig environment\n */",
"App",
"::",
"singleton",
"(",
"'twig.environment'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"twig",
"=",
"new",
"Twig_Environment",
... | /*
Register text twig parser | [
"/",
"*",
"Register",
"text",
"twig",
"parser"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L275-L292 | train | Register Twig parser | [
30522,
5123,
3853,
4236,
2102,
16279,
19362,
8043,
1006,
1007,
1063,
1013,
1008,
1008,
4236,
2291,
1056,
16279,
4044,
1008,
1013,
10439,
1024,
1024,
28159,
1006,
1005,
1056,
16279,
1012,
4044,
1005,
1010,
3853,
1006,
1002,
10439,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.psubscribe | public function psubscribe($channels, Closure $callback)
{
$this->client->psubscribe((array) $channels, function ($redis, $pattern, $channel, $message) use ($callback) {
$callback($message, $channel);
});
} | php | public function psubscribe($channels, Closure $callback)
{
$this->client->psubscribe((array) $channels, function ($redis, $pattern, $channel, $message) use ($callback) {
$callback($message, $channel);
});
} | [
"public",
"function",
"psubscribe",
"(",
"$",
"channels",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"psubscribe",
"(",
"(",
"array",
")",
"$",
"channels",
",",
"function",
"(",
"$",
"redis",
",",
"$",
"pattern",
",",... | Subscribe to a set of given channels with wildcards.
@param array|string $channels
@param \Closure $callback
@return void | [
"Subscribe",
"to",
"a",
"set",
"of",
"given",
"channels",
"with",
"wildcards",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L371-L376 | train | Subscribes to a list of channels | [
30522,
2270,
3853,
8827,
12083,
29234,
1006,
1002,
6833,
1010,
8503,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
7396,
1011,
1028,
8827,
12083,
29234,
1006,
1006,
9140,
1007,
1002,
6833,
1010,
3853,
1006,
1002,
2417,
2483,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php | AbstractDoctrineExtension.setMappingDriverAlias | protected function setMappingDriverAlias($mappingConfig, $mappingName)
{
if (isset($mappingConfig['alias'])) {
$this->aliasMap[$mappingConfig['alias']] = $mappingConfig['prefix'];
} else {
$this->aliasMap[$mappingName] = $mappingConfig['prefix'];
}
} | php | protected function setMappingDriverAlias($mappingConfig, $mappingName)
{
if (isset($mappingConfig['alias'])) {
$this->aliasMap[$mappingConfig['alias']] = $mappingConfig['prefix'];
} else {
$this->aliasMap[$mappingName] = $mappingConfig['prefix'];
}
} | [
"protected",
"function",
"setMappingDriverAlias",
"(",
"$",
"mappingConfig",
",",
"$",
"mappingName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mappingConfig",
"[",
"'alias'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"aliasMap",
"[",
"$",
"mappingConfig",
"["... | Register the alias for this mapping driver.
Aliases can be used in the Query languages of all the Doctrine object managers to simplify writing tasks.
@param array $mappingConfig
@param string $mappingName | [
"Register",
"the",
"alias",
"for",
"this",
"mapping",
"driver",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php#L108-L115 | train | Set mapping driver alias | [
30522,
5123,
3853,
2275,
2863,
14853,
23663,
7941,
7951,
1006,
1002,
12375,
8663,
8873,
2290,
1010,
1002,
12375,
18442,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
12375,
8663,
8873,
2290,
1031,
1005,
14593,
1005,
1033,
1007,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/CombineAssets.php | CombineAssets.prepareRequest | protected function prepareRequest(array $assets, $localPath = null)
{
if (substr($localPath, -1) != '/') {
$localPath = $localPath.'/';
}
$this->localPath = $localPath;
$this->storagePath = storage_path('cms/combiner/assets');
list($assets, $extension) = $this->prepareAssets($assets);
/*
* Cache and process
*/
$cacheKey = $this->getCacheKey($assets);
$cacheInfo = $this->useCache ? $this->getCache($cacheKey) : false;
if (!$cacheInfo) {
$this->setHashOnCombinerFilters($cacheKey);
$combiner = $this->prepareCombiner($assets);
if ($this->useDeepHashing) {
$factory = new AssetFactory($this->localPath);
$lastMod = $factory->getLastModified($combiner);
}
else {
$lastMod = $combiner->getLastModified();
}
$cacheInfo = [
'version' => $cacheKey.'-'.$lastMod,
'etag' => $cacheKey,
'lastMod' => $lastMod,
'files' => $assets,
'path' => $this->localPath,
'extension' => $extension
];
$this->putCache($cacheKey, $cacheInfo);
}
return $this->getCombinedUrl($cacheInfo['version']);
} | php | protected function prepareRequest(array $assets, $localPath = null)
{
if (substr($localPath, -1) != '/') {
$localPath = $localPath.'/';
}
$this->localPath = $localPath;
$this->storagePath = storage_path('cms/combiner/assets');
list($assets, $extension) = $this->prepareAssets($assets);
/*
* Cache and process
*/
$cacheKey = $this->getCacheKey($assets);
$cacheInfo = $this->useCache ? $this->getCache($cacheKey) : false;
if (!$cacheInfo) {
$this->setHashOnCombinerFilters($cacheKey);
$combiner = $this->prepareCombiner($assets);
if ($this->useDeepHashing) {
$factory = new AssetFactory($this->localPath);
$lastMod = $factory->getLastModified($combiner);
}
else {
$lastMod = $combiner->getLastModified();
}
$cacheInfo = [
'version' => $cacheKey.'-'.$lastMod,
'etag' => $cacheKey,
'lastMod' => $lastMod,
'files' => $assets,
'path' => $this->localPath,
'extension' => $extension
];
$this->putCache($cacheKey, $cacheInfo);
}
return $this->getCombinedUrl($cacheInfo['version']);
} | [
"protected",
"function",
"prepareRequest",
"(",
"array",
"$",
"assets",
",",
"$",
"localPath",
"=",
"null",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"localPath",
",",
"-",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"localPath",
"=",
"$",
"localPath",
".",... | Combines asset file references of a single type to produce
a URL reference to the combined contents.
@param array $assets List of asset files.
@param string $localPath File extension, used for aesthetic purposes only.
@return string URL to contents. | [
"Combines",
"asset",
"file",
"references",
"of",
"a",
"single",
"type",
"to",
"produce",
"a",
"URL",
"reference",
"to",
"the",
"combined",
"contents",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L358-L401 | train | Prepare request for asset manipulation | [
30522,
5123,
3853,
7374,
2890,
15500,
1006,
9140,
1002,
7045,
1010,
1002,
2334,
15069,
1027,
19701,
1007,
1063,
2065,
1006,
4942,
3367,
2099,
1006,
1002,
2334,
15069,
1010,
1011,
1015,
1007,
999,
1027,
1005,
1013,
1005,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Sqlsrv.php | Zend_Db_Statement_Sqlsrv.getColumnMeta | public function getColumnMeta($column)
{
$fields = sqlsrv_field_metadata($this->_stmt);
if (!$fields) {
throw new Zend_Db_Statement_Sqlsrv_Exception('Column metadata can not be fetched');
}
if (!isset($fields[$column])) {
throw new Zend_Db_Statement_Sqlsrv_Exception('Column index does not exist in statement');
}
return $fields[$column];
} | php | public function getColumnMeta($column)
{
$fields = sqlsrv_field_metadata($this->_stmt);
if (!$fields) {
throw new Zend_Db_Statement_Sqlsrv_Exception('Column metadata can not be fetched');
}
if (!isset($fields[$column])) {
throw new Zend_Db_Statement_Sqlsrv_Exception('Column index does not exist in statement');
}
return $fields[$column];
} | [
"public",
"function",
"getColumnMeta",
"(",
"$",
"column",
")",
"{",
"$",
"fields",
"=",
"sqlsrv_field_metadata",
"(",
"$",
"this",
"->",
"_stmt",
")",
";",
"if",
"(",
"!",
"$",
"fields",
")",
"{",
"throw",
"new",
"Zend_Db_Statement_Sqlsrv_Exception",
"(",
... | Returns metadata for a column in a result set.
@param int $column
@return mixed
@throws Zend_Db_Statement_Sqlsrv_Exception | [
"Returns",
"metadata",
"for",
"a",
"column",
"in",
"a",
"result",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Sqlsrv.php#L350-L363 | train | Get column metadata | [
30522,
2270,
3853,
2131,
25778,
2819,
2078,
11368,
2050,
1006,
1002,
5930,
1007,
1063,
1002,
4249,
1027,
29296,
21338,
2615,
1035,
2492,
1035,
27425,
1006,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1025,
2065,
1006,
999,
1002,
4249,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract.find | public function find()
{
$this->_setupPrimaryKey();
$args = func_get_args();
$keyNames = array_values((array) $this->_primary);
if (count($args) < count($keyNames)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Too few columns for the primary key");
}
if (count($args) > count($keyNames)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Too many columns for the primary key");
}
$whereList = array();
$numberTerms = 0;
foreach ($args as $keyPosition => $keyValues) {
$keyValuesCount = count($keyValues);
// Coerce the values to an array.
// Don't simply typecast to array, because the values
// might be Zend_Db_Expr objects.
if (!is_array($keyValues)) {
$keyValues = array($keyValues);
}
if ($numberTerms == 0) {
$numberTerms = $keyValuesCount;
} else if ($keyValuesCount != $numberTerms) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
}
$keyValues = array_values($keyValues);
for ($i = 0; $i < $keyValuesCount; ++$i) {
if (!isset($whereList[$i])) {
$whereList[$i] = array();
}
$whereList[$i][$keyPosition] = $keyValues[$i];
}
}
$whereClause = null;
if (count($whereList)) {
$whereOrTerms = array();
$tableName = $this->_db->quoteTableAs($this->_name, null, true);
foreach ($whereList as $keyValueSets) {
$whereAndTerms = array();
foreach ($keyValueSets as $keyPosition => $keyValue) {
$type = $this->_metadata[$keyNames[$keyPosition]]['DATA_TYPE'];
$columnName = $this->_db->quoteIdentifier($keyNames[$keyPosition], true);
$whereAndTerms[] = $this->_db->quoteInto(
$tableName . '.' . $columnName . ' = ?',
$keyValue, $type);
}
$whereOrTerms[] = '(' . implode(' AND ', $whereAndTerms) . ')';
}
$whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
}
// issue ZF-5775 (empty where clause should return empty rowset)
if ($whereClause == null) {
$rowsetClass = $this->getRowsetClass();
if (!class_exists($rowsetClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($rowsetClass);
}
return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
}
return $this->fetchAll($whereClause);
} | php | public function find()
{
$this->_setupPrimaryKey();
$args = func_get_args();
$keyNames = array_values((array) $this->_primary);
if (count($args) < count($keyNames)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Too few columns for the primary key");
}
if (count($args) > count($keyNames)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Too many columns for the primary key");
}
$whereList = array();
$numberTerms = 0;
foreach ($args as $keyPosition => $keyValues) {
$keyValuesCount = count($keyValues);
// Coerce the values to an array.
// Don't simply typecast to array, because the values
// might be Zend_Db_Expr objects.
if (!is_array($keyValues)) {
$keyValues = array($keyValues);
}
if ($numberTerms == 0) {
$numberTerms = $keyValuesCount;
} else if ($keyValuesCount != $numberTerms) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
}
$keyValues = array_values($keyValues);
for ($i = 0; $i < $keyValuesCount; ++$i) {
if (!isset($whereList[$i])) {
$whereList[$i] = array();
}
$whereList[$i][$keyPosition] = $keyValues[$i];
}
}
$whereClause = null;
if (count($whereList)) {
$whereOrTerms = array();
$tableName = $this->_db->quoteTableAs($this->_name, null, true);
foreach ($whereList as $keyValueSets) {
$whereAndTerms = array();
foreach ($keyValueSets as $keyPosition => $keyValue) {
$type = $this->_metadata[$keyNames[$keyPosition]]['DATA_TYPE'];
$columnName = $this->_db->quoteIdentifier($keyNames[$keyPosition], true);
$whereAndTerms[] = $this->_db->quoteInto(
$tableName . '.' . $columnName . ' = ?',
$keyValue, $type);
}
$whereOrTerms[] = '(' . implode(' AND ', $whereAndTerms) . ')';
}
$whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
}
// issue ZF-5775 (empty where clause should return empty rowset)
if ($whereClause == null) {
$rowsetClass = $this->getRowsetClass();
if (!class_exists($rowsetClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($rowsetClass);
}
return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
}
return $this->fetchAll($whereClause);
} | [
"public",
"function",
"find",
"(",
")",
"{",
"$",
"this",
"->",
"_setupPrimaryKey",
"(",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"keyNames",
"=",
"array_values",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"_primary",
")",
";"... | Fetches rows by primary key. The argument specifies one or more primary
key value(s). To find multiple rows by primary key, the argument must
be an array.
This method accepts a variable number of arguments. If the table has a
multi-column primary key, the number of arguments must be the same as
the number of columns in the primary key. To find multiple rows in a
table with a multi-column primary key, each argument must be an array
with the same number of elements.
The find() method always returns a Rowset object, even if only one row
was found.
@param mixed $key The value(s) of the primary keys.
@return Zend_Db_Table_Rowset_Abstract Row(s) matching the criteria.
@throws Zend_Db_Table_Exception | [
"Fetches",
"rows",
"by",
"primary",
"key",
".",
"The",
"argument",
"specifies",
"one",
"or",
"more",
"primary",
"key",
"value",
"(",
"s",
")",
".",
"To",
"find",
"multiple",
"rows",
"by",
"primary",
"key",
"the",
"argument",
"must",
"be",
"an",
"array",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L1240-L1310 | train | Find all records matching the given conditions | [
30522,
2270,
3853,
2424,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
16437,
18098,
9581,
2854,
14839,
1006,
1007,
1025,
1002,
12098,
5620,
1027,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1025,
1002,
3145,
18442,
2015,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.defineFormFields | protected function defineFormFields()
{
if ($this->fieldsDefined) {
return;
}
/**
* @event backend.form.extendFieldsBefore
* Called before the form fields are defined
*
* Example usage:
*
* Event::listen('backend.form.extendFieldsBefore', function((\Backend\Widgets\Form) $formWidget) {
* // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) {
* return;
* }
*
* // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [
* 'label' => 'Example field',
* 'comment' => 'Your example field',
* 'type' => 'text',
* ];
* });
*
* Or
*
* $formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) {
* // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) {
* return;
* }
*
* // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [
* 'label' => 'Example field',
* 'comment' => 'Your example field',
* 'type' => 'text',
* ];
* });
*
*/
$this->fireSystemEvent('backend.form.extendFieldsBefore');
/*
* Outside fields
*/
if (!isset($this->fields) || !is_array($this->fields)) {
$this->fields = [];
}
$this->allTabs->outside = new FormTabs(FormTabs::SECTION_OUTSIDE, (array) $this->config);
$this->addFields($this->fields);
/*
* Primary Tabs + Fields
*/
if (!isset($this->tabs['fields']) || !is_array($this->tabs['fields'])) {
$this->tabs['fields'] = [];
}
$this->allTabs->primary = new FormTabs(FormTabs::SECTION_PRIMARY, $this->tabs);
$this->addFields($this->tabs['fields'], FormTabs::SECTION_PRIMARY);
/*
* Secondary Tabs + Fields
*/
if (!isset($this->secondaryTabs['fields']) || !is_array($this->secondaryTabs['fields'])) {
$this->secondaryTabs['fields'] = [];
}
$this->allTabs->secondary = new FormTabs(FormTabs::SECTION_SECONDARY, $this->secondaryTabs);
$this->addFields($this->secondaryTabs['fields'], FormTabs::SECTION_SECONDARY);
/**
* @event backend.form.extendFields
* Called after the form fields are defined
*
* Example usage:
*
* Event::listen('backend.form.extendFields', function((\Backend\Widgets\Form) $formWidget) {
* // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
* return;
* }
*
* // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) {
* return;
* }
*
* // Add an extra birthday field
* $widget->addFields([
* 'birthday' => [
* 'label' => 'Birthday',
* 'comment' => 'Select the users birthday',
* 'type' => 'datepicker'
* ]
* ]);
*
* // Remove a Surname field
* $widget->removeField('surname');
* });
*
* Or
*
* $formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) {
* // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
* return;
* }
*
* // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) {
* return;
* }
*
* // Add an extra birthday field
* $widget->addFields([
* 'birthday' => [
* 'label' => 'Birthday',
* 'comment' => 'Select the users birthday',
* 'type' => 'datepicker'
* ]
* ]);
*
* // Remove a Surname field
* $widget->removeField('surname');
* });
*
*/
$this->fireSystemEvent('backend.form.extendFields', [$this->allFields]);
/*
* Convert automatic spanned fields
*/
foreach ($this->allTabs->outside->getFields() as $fields) {
$this->processAutoSpan($fields);
}
foreach ($this->allTabs->primary->getFields() as $fields) {
$this->processAutoSpan($fields);
}
foreach ($this->allTabs->secondary->getFields() as $fields) {
$this->processAutoSpan($fields);
}
/*
* At least one tab section should stretch
*/
if (
$this->allTabs->secondary->stretch === null
&& $this->allTabs->primary->stretch === null
&& $this->allTabs->outside->stretch === null
) {
if ($this->allTabs->secondary->hasFields()) {
$this->allTabs->secondary->stretch = true;
}
elseif ($this->allTabs->primary->hasFields()) {
$this->allTabs->primary->stretch = true;
}
else {
$this->allTabs->outside->stretch = true;
}
}
/*
* Bind all form widgets to controller
*/
foreach ($this->allFields as $field) {
if ($field->type !== 'widget') {
continue;
}
$widget = $this->makeFormFieldWidget($field);
$widget->bindToController();
}
$this->fieldsDefined = true;
} | php | protected function defineFormFields()
{
if ($this->fieldsDefined) {
return;
}
/**
* @event backend.form.extendFieldsBefore
* Called before the form fields are defined
*
* Example usage:
*
* Event::listen('backend.form.extendFieldsBefore', function((\Backend\Widgets\Form) $formWidget) {
* // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) {
* return;
* }
*
* // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [
* 'label' => 'Example field',
* 'comment' => 'Your example field',
* 'type' => 'text',
* ];
* });
*
* Or
*
* $formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) {
* // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) {
* return;
* }
*
* // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [
* 'label' => 'Example field',
* 'comment' => 'Your example field',
* 'type' => 'text',
* ];
* });
*
*/
$this->fireSystemEvent('backend.form.extendFieldsBefore');
/*
* Outside fields
*/
if (!isset($this->fields) || !is_array($this->fields)) {
$this->fields = [];
}
$this->allTabs->outside = new FormTabs(FormTabs::SECTION_OUTSIDE, (array) $this->config);
$this->addFields($this->fields);
/*
* Primary Tabs + Fields
*/
if (!isset($this->tabs['fields']) || !is_array($this->tabs['fields'])) {
$this->tabs['fields'] = [];
}
$this->allTabs->primary = new FormTabs(FormTabs::SECTION_PRIMARY, $this->tabs);
$this->addFields($this->tabs['fields'], FormTabs::SECTION_PRIMARY);
/*
* Secondary Tabs + Fields
*/
if (!isset($this->secondaryTabs['fields']) || !is_array($this->secondaryTabs['fields'])) {
$this->secondaryTabs['fields'] = [];
}
$this->allTabs->secondary = new FormTabs(FormTabs::SECTION_SECONDARY, $this->secondaryTabs);
$this->addFields($this->secondaryTabs['fields'], FormTabs::SECTION_SECONDARY);
/**
* @event backend.form.extendFields
* Called after the form fields are defined
*
* Example usage:
*
* Event::listen('backend.form.extendFields', function((\Backend\Widgets\Form) $formWidget) {
* // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
* return;
* }
*
* // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) {
* return;
* }
*
* // Add an extra birthday field
* $widget->addFields([
* 'birthday' => [
* 'label' => 'Birthday',
* 'comment' => 'Select the users birthday',
* 'type' => 'datepicker'
* ]
* ]);
*
* // Remove a Surname field
* $widget->removeField('surname');
* });
*
* Or
*
* $formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) {
* // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
* return;
* }
*
* // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) {
* return;
* }
*
* // Add an extra birthday field
* $widget->addFields([
* 'birthday' => [
* 'label' => 'Birthday',
* 'comment' => 'Select the users birthday',
* 'type' => 'datepicker'
* ]
* ]);
*
* // Remove a Surname field
* $widget->removeField('surname');
* });
*
*/
$this->fireSystemEvent('backend.form.extendFields', [$this->allFields]);
/*
* Convert automatic spanned fields
*/
foreach ($this->allTabs->outside->getFields() as $fields) {
$this->processAutoSpan($fields);
}
foreach ($this->allTabs->primary->getFields() as $fields) {
$this->processAutoSpan($fields);
}
foreach ($this->allTabs->secondary->getFields() as $fields) {
$this->processAutoSpan($fields);
}
/*
* At least one tab section should stretch
*/
if (
$this->allTabs->secondary->stretch === null
&& $this->allTabs->primary->stretch === null
&& $this->allTabs->outside->stretch === null
) {
if ($this->allTabs->secondary->hasFields()) {
$this->allTabs->secondary->stretch = true;
}
elseif ($this->allTabs->primary->hasFields()) {
$this->allTabs->primary->stretch = true;
}
else {
$this->allTabs->outside->stretch = true;
}
}
/*
* Bind all form widgets to controller
*/
foreach ($this->allFields as $field) {
if ($field->type !== 'widget') {
continue;
}
$widget = $this->makeFormFieldWidget($field);
$widget->bindToController();
}
$this->fieldsDefined = true;
} | [
"protected",
"function",
"defineFormFields",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fieldsDefined",
")",
"{",
"return",
";",
"}",
"/**\n * @event backend.form.extendFieldsBefore\n * Called before the form fields are defined\n *\n * Example usa... | Creates a flat array of form fields from the configuration.
Also slots fields in to their respective tabs.
@return void | [
"Creates",
"a",
"flat",
"array",
"of",
"form",
"fields",
"from",
"the",
"configuration",
".",
"Also",
"slots",
"fields",
"in",
"to",
"their",
"respective",
"tabs",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L461-L646 | train | Define form fields | [
30522,
5123,
3853,
9375,
14192,
15155,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
4249,
3207,
23460,
2094,
1007,
1063,
2709,
1025,
1065,
1013,
1008,
1008,
1008,
1030,
2724,
2067,
10497,
1012,
2433,
1012,
7949,
15155,
4783,
29278,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.readPipes | private function readPipes(bool $blocking, bool $close)
{
$result = $this->processPipes->readAndWrite($blocking, $close);
$callback = $this->callback;
foreach ($result as $type => $data) {
if (3 !== $type) {
$callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
} elseif (!isset($this->fallbackStatus['signaled'])) {
$this->fallbackStatus['exitcode'] = (int) $data;
}
}
} | php | private function readPipes(bool $blocking, bool $close)
{
$result = $this->processPipes->readAndWrite($blocking, $close);
$callback = $this->callback;
foreach ($result as $type => $data) {
if (3 !== $type) {
$callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
} elseif (!isset($this->fallbackStatus['signaled'])) {
$this->fallbackStatus['exitcode'] = (int) $data;
}
}
} | [
"private",
"function",
"readPipes",
"(",
"bool",
"$",
"blocking",
",",
"bool",
"$",
"close",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"processPipes",
"->",
"readAndWrite",
"(",
"$",
"blocking",
",",
"$",
"close",
")",
";",
"$",
"callback",
"=",... | Reads pipes, executes callback.
@param bool $blocking Whether to use blocking calls or not
@param bool $close Whether to close file handles or not | [
"Reads",
"pipes",
"executes",
"callback",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L1421-L1433 | train | Read pipes and write to the output stream | [
30522,
2797,
3853,
3191,
24548,
2015,
1006,
22017,
2140,
1002,
10851,
1010,
22017,
2140,
1002,
2485,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
2832,
24548,
2015,
1011,
1028,
3191,
5685,
26373,
30524,
1006,
2969,
1024,
1024,
2358... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Renderer/Xml.php | Xml.renderArray | private function renderArray($array, $prefixLines)
{
$isAssociativeArray = Piwik::isAssociativeArray($array);
// check if array contains arrays, and if not wrap the result in an extra <row> element
// (only check if this is the root renderArray call)
// NOTE: this is for backwards compatibility. before, array's were added to a new DataTable.
// if the array had arrays, they were added as multiple rows, otherwise it was treated as
// one row. removing will change API output.
$wrapInRow = $prefixLines === "\t"
&& self::shouldWrapArrayBeforeRendering($array, $wrapSingleValues = false, $isAssociativeArray);
// render the array
$result = "";
if ($wrapInRow) {
$result .= "$prefixLines<row>\n";
$prefixLines .= "\t";
}
foreach ($array as $key => $value) {
// based on the type of array & the key, determine how this node will look
if ($isAssociativeArray) {
if (strpos($key, '=') !== false) {
list($keyAttributeName, $key) = explode('=', $key, 2);
$prefix = "<row $keyAttributeName=\"$key\">";
$suffix = "</row>";
$emptyNode = "<row $keyAttributeName=\"$key\">";
} elseif (!self::isValidXmlTagName($key)) {
$prefix = "<row key=\"$key\">";
$suffix = "</row>";
$emptyNode = "<row key=\"$key\"/>";
} else {
$prefix = "<$key>";
$suffix = "</$key>";
$emptyNode = "<$key />";
}
} else {
$prefix = "<row>";
$suffix = "</row>";
$emptyNode = "<row/>";
}
// render the array item
if (is_array($value) || $value instanceof \stdClass) {
$result .= $prefixLines . $prefix . "\n";
$result .= $this->renderArray((array) $value, $prefixLines . "\t");
$result .= $prefixLines . $suffix . "\n";
} elseif ($value instanceof DataTable
|| $value instanceof Map
) {
if ($value->getRowsCount() == 0) {
$result .= $prefixLines . $emptyNode . "\n";
} else {
$result .= $prefixLines . $prefix . "\n";
if ($value instanceof Map) {
$result .= $this->renderDataTableMap($value, $this->getArrayFromDataTable($value), $prefixLines);
} elseif ($value instanceof Simple) {
$result .= $this->renderDataTableSimple($this->getArrayFromDataTable($value), $prefixLines);
} else {
$result .= $this->renderDataTable($this->getArrayFromDataTable($value), $prefixLines);
}
$result .= $prefixLines . $suffix . "\n";
}
} else {
$xmlValue = self::formatValueXml($value);
if (strlen($xmlValue) != 0) {
$result .= $prefixLines . $prefix . $xmlValue . $suffix . "\n";
} else {
$result .= $prefixLines . $emptyNode . "\n";
}
}
}
if ($wrapInRow) {
$result .= substr($prefixLines, 0, strlen($prefixLines) - 1) . "</row>\n";
}
return $result;
} | php | private function renderArray($array, $prefixLines)
{
$isAssociativeArray = Piwik::isAssociativeArray($array);
// check if array contains arrays, and if not wrap the result in an extra <row> element
// (only check if this is the root renderArray call)
// NOTE: this is for backwards compatibility. before, array's were added to a new DataTable.
// if the array had arrays, they were added as multiple rows, otherwise it was treated as
// one row. removing will change API output.
$wrapInRow = $prefixLines === "\t"
&& self::shouldWrapArrayBeforeRendering($array, $wrapSingleValues = false, $isAssociativeArray);
// render the array
$result = "";
if ($wrapInRow) {
$result .= "$prefixLines<row>\n";
$prefixLines .= "\t";
}
foreach ($array as $key => $value) {
// based on the type of array & the key, determine how this node will look
if ($isAssociativeArray) {
if (strpos($key, '=') !== false) {
list($keyAttributeName, $key) = explode('=', $key, 2);
$prefix = "<row $keyAttributeName=\"$key\">";
$suffix = "</row>";
$emptyNode = "<row $keyAttributeName=\"$key\">";
} elseif (!self::isValidXmlTagName($key)) {
$prefix = "<row key=\"$key\">";
$suffix = "</row>";
$emptyNode = "<row key=\"$key\"/>";
} else {
$prefix = "<$key>";
$suffix = "</$key>";
$emptyNode = "<$key />";
}
} else {
$prefix = "<row>";
$suffix = "</row>";
$emptyNode = "<row/>";
}
// render the array item
if (is_array($value) || $value instanceof \stdClass) {
$result .= $prefixLines . $prefix . "\n";
$result .= $this->renderArray((array) $value, $prefixLines . "\t");
$result .= $prefixLines . $suffix . "\n";
} elseif ($value instanceof DataTable
|| $value instanceof Map
) {
if ($value->getRowsCount() == 0) {
$result .= $prefixLines . $emptyNode . "\n";
} else {
$result .= $prefixLines . $prefix . "\n";
if ($value instanceof Map) {
$result .= $this->renderDataTableMap($value, $this->getArrayFromDataTable($value), $prefixLines);
} elseif ($value instanceof Simple) {
$result .= $this->renderDataTableSimple($this->getArrayFromDataTable($value), $prefixLines);
} else {
$result .= $this->renderDataTable($this->getArrayFromDataTable($value), $prefixLines);
}
$result .= $prefixLines . $suffix . "\n";
}
} else {
$xmlValue = self::formatValueXml($value);
if (strlen($xmlValue) != 0) {
$result .= $prefixLines . $prefix . $xmlValue . $suffix . "\n";
} else {
$result .= $prefixLines . $emptyNode . "\n";
}
}
}
if ($wrapInRow) {
$result .= substr($prefixLines, 0, strlen($prefixLines) - 1) . "</row>\n";
}
return $result;
} | [
"private",
"function",
"renderArray",
"(",
"$",
"array",
",",
"$",
"prefixLines",
")",
"{",
"$",
"isAssociativeArray",
"=",
"Piwik",
"::",
"isAssociativeArray",
"(",
"$",
"array",
")",
";",
"// check if array contains arrays, and if not wrap the result in an extra <row> e... | Renders an array as XML.
@param array $array The array to render.
@param string $prefixLines The string to prefix each line in the output.
@return string | [
"Renders",
"an",
"array",
"as",
"XML",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Renderer/Xml.php#L136-L213 | train | Renders the array | [
30522,
2797,
3853,
17552,
2906,
9447,
1006,
1002,
9140,
1010,
1002,
17576,
30524,
5783,
1013,
1013,
1006,
2069,
4638,
2065,
2023,
2003,
1996,
7117,
17552,
2906,
9447,
2655,
1007,
1013,
1013,
3602,
1024,
2023,
2003,
2005,
11043,
21778,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OpenPlatform/Auth/ServiceProvider.php | ServiceProvider.register | public function register(Container $app)
{
$app['verify_ticket'] = function ($app) {
return new VerifyTicket($app);
};
$app['access_token'] = function ($app) {
return new AccessToken($app);
};
} | php | public function register(Container $app)
{
$app['verify_ticket'] = function ($app) {
return new VerifyTicket($app);
};
$app['access_token'] = function ($app) {
return new AccessToken($app);
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'verify_ticket'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"VerifyTicket",
"(",
"$",
"app",
")",
";",
"}",
";",
"$",
"app",
"[",
"'... | {@inheritdoc}. | [
"{"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenPlatform/Auth/ServiceProvider.php#L27-L36 | train | Register the verify ticket and access token | [
30522,
2270,
3853,
4236,
1006,
11661,
1002,
10439,
1007,
1063,
1002,
10439,
1031,
1005,
20410,
1035,
7281,
1005,
1033,
1027,
3853,
1006,
1002,
10439,
1007,
1063,
2709,
2047,
20410,
26348,
3388,
1006,
1002,
10439,
1007,
1025,
1065,
1025,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php | HasManyThrough.shouldSelect | protected function shouldSelect(array $columns = ['*'])
{
if ($columns == ['*']) {
$columns = [$this->related->getTable().'.*'];
}
return array_merge($columns, [$this->getQualifiedFirstKeyName().' as laravel_through_key']);
} | php | protected function shouldSelect(array $columns = ['*'])
{
if ($columns == ['*']) {
$columns = [$this->related->getTable().'.*'];
}
return array_merge($columns, [$this->getQualifiedFirstKeyName().' as laravel_through_key']);
} | [
"protected",
"function",
"shouldSelect",
"(",
"array",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"if",
"(",
"$",
"columns",
"==",
"[",
"'*'",
"]",
")",
"{",
"$",
"columns",
"=",
"[",
"$",
"this",
"->",
"related",
"->",
"getTable",
"(",
")",
... | Set the select clause for the relation query.
@param array $columns
@return array | [
"Set",
"the",
"select",
"clause",
"for",
"the",
"relation",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php#L411-L418 | train | Returns the columns that should be selected. | [
30522,
5123,
3853,
2323,
11246,
22471,
1006,
9140,
1002,
7753,
1027,
1031,
1005,
1008,
1005,
1033,
1007,
1063,
2065,
1006,
1002,
7753,
1027,
1027,
1031,
1005,
1008,
1005,
1033,
1007,
1063,
1002,
7753,
1027,
1031,
1002,
2023,
1011,
1028,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db/BatchInsert.php | BatchInsert.tableInsertBatchIterate | public static function tableInsertBatchIterate($tableName, $fields, $values, $ignoreWhenDuplicate = true)
{
$fieldList = '(' . join(',', $fields) . ')';
$ignore = $ignoreWhenDuplicate ? 'IGNORE' : '';
foreach ($values as $row) {
$query = "INSERT $ignore INTO " . $tableName . "
$fieldList
VALUES (" . Common::getSqlStringFieldsArray($row) . ")";
Db::query($query, $row);
}
} | php | public static function tableInsertBatchIterate($tableName, $fields, $values, $ignoreWhenDuplicate = true)
{
$fieldList = '(' . join(',', $fields) . ')';
$ignore = $ignoreWhenDuplicate ? 'IGNORE' : '';
foreach ($values as $row) {
$query = "INSERT $ignore INTO " . $tableName . "
$fieldList
VALUES (" . Common::getSqlStringFieldsArray($row) . ")";
Db::query($query, $row);
}
} | [
"public",
"static",
"function",
"tableInsertBatchIterate",
"(",
"$",
"tableName",
",",
"$",
"fields",
",",
"$",
"values",
",",
"$",
"ignoreWhenDuplicate",
"=",
"true",
")",
"{",
"$",
"fieldList",
"=",
"'('",
".",
"join",
"(",
"','",
",",
"$",
"fields",
"... | Performs a batch insert into a specific table by iterating through the data
NOTE: you should use tableInsertBatch() which will fallback to this function if LOAD DATA INFILE not available
@param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
@param array $fields array of unquoted field names
@param array $values array of data to be inserted
@param bool $ignoreWhenDuplicate Ignore new rows that contain unique key values that duplicate old rows | [
"Performs",
"a",
"batch",
"insert",
"into",
"a",
"specific",
"table",
"by",
"iterating",
"through",
"the",
"data"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/BatchInsert.php#L31-L42 | train | Insert Batch Iterators | [
30522,
2270,
10763,
3853,
2795,
7076,
8743,
14479,
5428,
14621,
2618,
1006,
1002,
2795,
18442,
1010,
1002,
4249,
1010,
1002,
5300,
1010,
1002,
8568,
2860,
22342,
6279,
19341,
2618,
1027,
2995,
1007,
1063,
1002,
2492,
9863,
1027,
1005,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/HttpClientTrait.php | HttpClientTrait.prepareRequest | private static function prepareRequest(?string $method, ?string $url, array $options, array $defaultOptions = [], bool $allowExtraOptions = false): array
{
if (null !== $method) {
if (\strlen($method) !== strspn($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) {
throw new InvalidArgumentException(sprintf('Invalid HTTP method "%s", only uppercase letters are accepted.', $method));
}
if (!$method) {
throw new InvalidArgumentException('The HTTP method can not be empty.');
}
}
$options = self::mergeDefaultOptions($options, $defaultOptions, $allowExtraOptions);
if (isset($options['json'])) {
if (isset($options['body']) && '' !== $options['body']) {
throw new InvalidArgumentException('Define either the "json" or the "body" option, setting both is not supported.');
}
$options['body'] = self::jsonEncode($options['json']);
unset($options['json']);
$options['headers']['content-type'] = $options['headers']['content-type'] ?? ['application/json'];
}
if (isset($options['body'])) {
$options['body'] = self::normalizeBody($options['body']);
}
if (isset($options['peer_fingerprint'])) {
$options['peer_fingerprint'] = self::normalizePeerFingerprint($options['peer_fingerprint']);
}
// Compute request headers
$requestHeaders = $headers = [];
foreach ($options['headers'] as $name => $values) {
foreach ($values as $value) {
$requestHeaders[] = $name.': '.$headers[$name][] = $value = (string) $value;
if (\strlen($value) !== strcspn($value, "\r\n\0")) {
throw new InvalidArgumentException(sprintf('Invalid header value: CR/LF/NUL found in "%s".', $value));
}
}
}
// Validate on_progress
if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) {
throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, %s given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress)));
}
if (\is_array($options['auth_basic'] ?? null)) {
$count = \count($options['auth_basic']);
if ($count <= 0 || $count > 2) {
throw new InvalidArgumentException(sprintf('Option "auth_basic" must contain 1 or 2 elements, %s given.', $count));
}
$options['auth_basic'] = implode(':', $options['auth_basic']);
}
if (!\is_string($options['auth_basic'] ?? '')) {
throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, %s given.', \gettype($options['auth_basic'])));
}
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._~+/0-9a-zA-Z]++=*+$}', $options['auth_bearer']))) {
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : \gettype($options['auth_bearer'])));
}
if (isset($options['auth_basic'], $options['auth_bearer'])) {
throw new InvalidArgumentException('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.');
}
if (null !== $url) {
// Merge auth with headers
if (($options['auth_basic'] ?? false) && !($headers['authorization'] ?? false)) {
$requestHeaders[] = 'authorization: '.$headers['authorization'][] = 'Basic '.base64_encode($options['auth_basic']);
}
// Merge bearer with headers
if (($options['auth_bearer'] ?? false) && !($headers['authorization'] ?? false)) {
$requestHeaders[] = 'authorization: '.$headers['authorization'][] = 'Bearer '.$options['auth_bearer'];
}
$options['request_headers'] = $requestHeaders;
unset($options['auth_basic'], $options['auth_bearer']);
// Parse base URI
if (\is_string($options['base_uri'])) {
$options['base_uri'] = self::parseUrl($options['base_uri']);
}
// Validate and resolve URL
$url = self::parseUrl($url, $options['query']);
$url = self::resolveUrl($url, $options['base_uri'], $defaultOptions['query'] ?? []);
}
// Finalize normalization of options
$options['headers'] = $headers;
$options['http_version'] = (string) ($options['http_version'] ?? '') ?: null;
$options['timeout'] = (float) ($options['timeout'] ?? ini_get('default_socket_timeout'));
return [$url, $options];
} | php | private static function prepareRequest(?string $method, ?string $url, array $options, array $defaultOptions = [], bool $allowExtraOptions = false): array
{
if (null !== $method) {
if (\strlen($method) !== strspn($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) {
throw new InvalidArgumentException(sprintf('Invalid HTTP method "%s", only uppercase letters are accepted.', $method));
}
if (!$method) {
throw new InvalidArgumentException('The HTTP method can not be empty.');
}
}
$options = self::mergeDefaultOptions($options, $defaultOptions, $allowExtraOptions);
if (isset($options['json'])) {
if (isset($options['body']) && '' !== $options['body']) {
throw new InvalidArgumentException('Define either the "json" or the "body" option, setting both is not supported.');
}
$options['body'] = self::jsonEncode($options['json']);
unset($options['json']);
$options['headers']['content-type'] = $options['headers']['content-type'] ?? ['application/json'];
}
if (isset($options['body'])) {
$options['body'] = self::normalizeBody($options['body']);
}
if (isset($options['peer_fingerprint'])) {
$options['peer_fingerprint'] = self::normalizePeerFingerprint($options['peer_fingerprint']);
}
// Compute request headers
$requestHeaders = $headers = [];
foreach ($options['headers'] as $name => $values) {
foreach ($values as $value) {
$requestHeaders[] = $name.': '.$headers[$name][] = $value = (string) $value;
if (\strlen($value) !== strcspn($value, "\r\n\0")) {
throw new InvalidArgumentException(sprintf('Invalid header value: CR/LF/NUL found in "%s".', $value));
}
}
}
// Validate on_progress
if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) {
throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, %s given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress)));
}
if (\is_array($options['auth_basic'] ?? null)) {
$count = \count($options['auth_basic']);
if ($count <= 0 || $count > 2) {
throw new InvalidArgumentException(sprintf('Option "auth_basic" must contain 1 or 2 elements, %s given.', $count));
}
$options['auth_basic'] = implode(':', $options['auth_basic']);
}
if (!\is_string($options['auth_basic'] ?? '')) {
throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, %s given.', \gettype($options['auth_basic'])));
}
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._~+/0-9a-zA-Z]++=*+$}', $options['auth_bearer']))) {
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : \gettype($options['auth_bearer'])));
}
if (isset($options['auth_basic'], $options['auth_bearer'])) {
throw new InvalidArgumentException('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.');
}
if (null !== $url) {
// Merge auth with headers
if (($options['auth_basic'] ?? false) && !($headers['authorization'] ?? false)) {
$requestHeaders[] = 'authorization: '.$headers['authorization'][] = 'Basic '.base64_encode($options['auth_basic']);
}
// Merge bearer with headers
if (($options['auth_bearer'] ?? false) && !($headers['authorization'] ?? false)) {
$requestHeaders[] = 'authorization: '.$headers['authorization'][] = 'Bearer '.$options['auth_bearer'];
}
$options['request_headers'] = $requestHeaders;
unset($options['auth_basic'], $options['auth_bearer']);
// Parse base URI
if (\is_string($options['base_uri'])) {
$options['base_uri'] = self::parseUrl($options['base_uri']);
}
// Validate and resolve URL
$url = self::parseUrl($url, $options['query']);
$url = self::resolveUrl($url, $options['base_uri'], $defaultOptions['query'] ?? []);
}
// Finalize normalization of options
$options['headers'] = $headers;
$options['http_version'] = (string) ($options['http_version'] ?? '') ?: null;
$options['timeout'] = (float) ($options['timeout'] ?? ini_get('default_socket_timeout'));
return [$url, $options];
} | [
"private",
"static",
"function",
"prepareRequest",
"(",
"?",
"string",
"$",
"method",
",",
"?",
"string",
"$",
"url",
",",
"array",
"$",
"options",
",",
"array",
"$",
"defaultOptions",
"=",
"[",
"]",
",",
"bool",
"$",
"allowExtraOptions",
"=",
"false",
"... | Validates and normalizes method, URL and options, and merges them with defaults.
@throws InvalidArgumentException When a not-supported option is found | [
"Validates",
"and",
"normalizes",
"method",
"URL",
"and",
"options",
"and",
"merges",
"them",
"with",
"defaults",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/HttpClientTrait.php#L34-L132 | train | Prepares the request. | [
30522,
2797,
10763,
3853,
7374,
2890,
15500,
1006,
1029,
5164,
1002,
4118,
1010,
1029,
5164,
1002,
24471,
2140,
1010,
9140,
1002,
7047,
1010,
9140,
1002,
12398,
7361,
9285,
1027,
1031,
1033,
1010,
22017,
2140,
1002,
3499,
10288,
6494,
7361,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.