repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
babenkoivan/scout-elasticsearch-driver | src/Payloads/RawPayload.php | RawPayload.add | public function add($key, $value)
{
if (! is_null($key)) {
$currentValue = Arr::get($this->payload, $key, []);
if (! is_array($currentValue)) {
$currentValue = Arr::wrap($currentValue);
}
$currentValue[] = $value;
Arr::set($this->payload, $key, $currentValue);
}
return $this;
} | php | public function add($key, $value)
{
if (! is_null($key)) {
$currentValue = Arr::get($this->payload, $key, []);
if (! is_array($currentValue)) {
$currentValue = Arr::wrap($currentValue);
}
$currentValue[] = $value;
Arr::set($this->payload, $key, $currentValue);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"$",
"currentValue",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"payload",
",",
"$",
"key",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"currentValue",
")",
")",
"{",
"$",
"currentValue",
"=",
"Arr",
"::",
"wrap",
"(",
"$",
"currentValue",
")",
";",
"}",
"$",
"currentValue",
"[",
"]",
"=",
"$",
"value",
";",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"payload",
",",
"$",
"key",
",",
"$",
"currentValue",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a value.
@param string $key
@param mixed $value
@return $this | [
"Add",
"a",
"value",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Payloads/RawPayload.php#L82-L97 | train |
babenkoivan/scout-elasticsearch-driver | src/Payloads/RawPayload.php | RawPayload.addIfNotEmpty | public function addIfNotEmpty($key, $value)
{
if (empty($value)) {
return $this;
}
return $this->add($key, $value);
} | php | public function addIfNotEmpty($key, $value)
{
if (empty($value)) {
return $this;
}
return $this->add($key, $value);
} | [
"public",
"function",
"addIfNotEmpty",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Add a value if it's not empty.
@param string $key
@param mixed $value
@return $this | [
"Add",
"a",
"value",
"if",
"it",
"s",
"not",
"empty",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Payloads/RawPayload.php#L106-L113 | train |
babenkoivan/scout-elasticsearch-driver | src/IndexConfigurator.php | IndexConfigurator.getName | public function getName()
{
$name = $this->name ?? Str::snake(str_replace('IndexConfigurator', '', class_basename($this)));
return config('scout.prefix').$name;
} | php | public function getName()
{
$name = $this->name ?? Str::snake(str_replace('IndexConfigurator', '', class_basename($this)));
return config('scout.prefix').$name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
"??",
"Str",
"::",
"snake",
"(",
"str_replace",
"(",
"'IndexConfigurator'",
",",
"''",
",",
"class_basename",
"(",
"$",
"this",
")",
")",
")",
";",
"return",
"config",
"(",
"'scout.prefix'",
")",
".",
"$",
"name",
";",
"}"
]
| Get th name.
@return string | [
"Get",
"th",
"name",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/IndexConfigurator.php#L35-L40 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticIndexCreateCommand.php | ElasticIndexCreateCommand.createWriteAlias | protected function createWriteAlias()
{
$configurator = $this->getIndexConfigurator();
if (! in_array(Migratable::class, class_uses_recursive($configurator))) {
return;
}
$payload = (new IndexPayload($configurator))
->set('name', $configurator->getWriteAlias())
->get();
ElasticClient::indices()
->putAlias($payload);
$this->info(sprintf(
'The %s alias for the %s index was created!',
$configurator->getWriteAlias(),
$configurator->getName()
));
} | php | protected function createWriteAlias()
{
$configurator = $this->getIndexConfigurator();
if (! in_array(Migratable::class, class_uses_recursive($configurator))) {
return;
}
$payload = (new IndexPayload($configurator))
->set('name', $configurator->getWriteAlias())
->get();
ElasticClient::indices()
->putAlias($payload);
$this->info(sprintf(
'The %s alias for the %s index was created!',
$configurator->getWriteAlias(),
$configurator->getName()
));
} | [
"protected",
"function",
"createWriteAlias",
"(",
")",
"{",
"$",
"configurator",
"=",
"$",
"this",
"->",
"getIndexConfigurator",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"Migratable",
"::",
"class",
",",
"class_uses_recursive",
"(",
"$",
"configurator",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"payload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"configurator",
")",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"configurator",
"->",
"getWriteAlias",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"putAlias",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s alias for the %s index was created!'",
",",
"$",
"configurator",
"->",
"getWriteAlias",
"(",
")",
",",
"$",
"configurator",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
]
| Create an write alias.
@return void | [
"Create",
"an",
"write",
"alias",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticIndexCreateCommand.php#L53-L73 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.isTargetIndexExists | protected function isTargetIndexExists()
{
$targetIndex = $this->argument('target-index');
$payload = (new RawPayload())
->set('index', $targetIndex)
->get();
return ElasticClient::indices()
->exists($payload);
} | php | protected function isTargetIndexExists()
{
$targetIndex = $this->argument('target-index');
$payload = (new RawPayload())
->set('index', $targetIndex)
->get();
return ElasticClient::indices()
->exists($payload);
} | [
"protected",
"function",
"isTargetIndexExists",
"(",
")",
"{",
"$",
"targetIndex",
"=",
"$",
"this",
"->",
"argument",
"(",
"'target-index'",
")",
";",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"get",
"(",
")",
";",
"return",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"exists",
"(",
"$",
"payload",
")",
";",
"}"
]
| Checks if the target index exists.
@return bool | [
"Checks",
"if",
"the",
"target",
"index",
"exists",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L49-L59 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.createTargetIndex | protected function createTargetIndex()
{
$targetIndex = $this->argument('target-index');
$sourceIndexConfigurator = $this->getModel()
->getIndexConfigurator();
$payload = (new RawPayload())
->set('index', $targetIndex)
->setIfNotEmpty('body.settings', $sourceIndexConfigurator->getSettings())
->setIfNotEmpty('body.mappings._default_', $sourceIndexConfigurator->getDefaultMapping())
->get();
ElasticClient::indices()
->create($payload);
$this->info(sprintf(
'The %s index was created.',
$targetIndex
));
} | php | protected function createTargetIndex()
{
$targetIndex = $this->argument('target-index');
$sourceIndexConfigurator = $this->getModel()
->getIndexConfigurator();
$payload = (new RawPayload())
->set('index', $targetIndex)
->setIfNotEmpty('body.settings', $sourceIndexConfigurator->getSettings())
->setIfNotEmpty('body.mappings._default_', $sourceIndexConfigurator->getDefaultMapping())
->get();
ElasticClient::indices()
->create($payload);
$this->info(sprintf(
'The %s index was created.',
$targetIndex
));
} | [
"protected",
"function",
"createTargetIndex",
"(",
")",
"{",
"$",
"targetIndex",
"=",
"$",
"this",
"->",
"argument",
"(",
"'target-index'",
")",
";",
"$",
"sourceIndexConfigurator",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getIndexConfigurator",
"(",
")",
";",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"setIfNotEmpty",
"(",
"'body.settings'",
",",
"$",
"sourceIndexConfigurator",
"->",
"getSettings",
"(",
")",
")",
"->",
"setIfNotEmpty",
"(",
"'body.mappings._default_'",
",",
"$",
"sourceIndexConfigurator",
"->",
"getDefaultMapping",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"create",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s index was created.'",
",",
"$",
"targetIndex",
")",
")",
";",
"}"
]
| Create a target index.
@return void | [
"Create",
"a",
"target",
"index",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L66-L86 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.updateTargetIndex | protected function updateTargetIndex()
{
$targetIndex = $this->argument('target-index');
$sourceIndexConfigurator = $this->getModel()
->getIndexConfigurator();
$targetIndexPayload = (new RawPayload())
->set('index', $targetIndex)
->get();
$indices = ElasticClient::indices();
try {
$indices->close($targetIndexPayload);
if ($settings = $sourceIndexConfigurator->getSettings()) {
$targetIndexSettingsPayload = (new RawPayload())
->set('index', $targetIndex)
->set('body.settings', $settings)
->get();
$indices->putSettings($targetIndexSettingsPayload);
}
if ($defaultMapping = $sourceIndexConfigurator->getDefaultMapping()) {
$targetIndexMappingPayload = (new RawPayload())
->set('index', $targetIndex)
->set('type', '_default_')
->set('body._default_', $defaultMapping)
->get();
$indices->putMapping($targetIndexMappingPayload);
}
$indices->open($targetIndexPayload);
} catch (Exception $exception) {
$indices->open($targetIndexPayload);
throw $exception;
}
$this->info(sprintf(
'The index %s was updated.',
$targetIndex
));
} | php | protected function updateTargetIndex()
{
$targetIndex = $this->argument('target-index');
$sourceIndexConfigurator = $this->getModel()
->getIndexConfigurator();
$targetIndexPayload = (new RawPayload())
->set('index', $targetIndex)
->get();
$indices = ElasticClient::indices();
try {
$indices->close($targetIndexPayload);
if ($settings = $sourceIndexConfigurator->getSettings()) {
$targetIndexSettingsPayload = (new RawPayload())
->set('index', $targetIndex)
->set('body.settings', $settings)
->get();
$indices->putSettings($targetIndexSettingsPayload);
}
if ($defaultMapping = $sourceIndexConfigurator->getDefaultMapping()) {
$targetIndexMappingPayload = (new RawPayload())
->set('index', $targetIndex)
->set('type', '_default_')
->set('body._default_', $defaultMapping)
->get();
$indices->putMapping($targetIndexMappingPayload);
}
$indices->open($targetIndexPayload);
} catch (Exception $exception) {
$indices->open($targetIndexPayload);
throw $exception;
}
$this->info(sprintf(
'The index %s was updated.',
$targetIndex
));
} | [
"protected",
"function",
"updateTargetIndex",
"(",
")",
"{",
"$",
"targetIndex",
"=",
"$",
"this",
"->",
"argument",
"(",
"'target-index'",
")",
";",
"$",
"sourceIndexConfigurator",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getIndexConfigurator",
"(",
")",
";",
"$",
"targetIndexPayload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"=",
"ElasticClient",
"::",
"indices",
"(",
")",
";",
"try",
"{",
"$",
"indices",
"->",
"close",
"(",
"$",
"targetIndexPayload",
")",
";",
"if",
"(",
"$",
"settings",
"=",
"$",
"sourceIndexConfigurator",
"->",
"getSettings",
"(",
")",
")",
"{",
"$",
"targetIndexSettingsPayload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"set",
"(",
"'body.settings'",
",",
"$",
"settings",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"->",
"putSettings",
"(",
"$",
"targetIndexSettingsPayload",
")",
";",
"}",
"if",
"(",
"$",
"defaultMapping",
"=",
"$",
"sourceIndexConfigurator",
"->",
"getDefaultMapping",
"(",
")",
")",
"{",
"$",
"targetIndexMappingPayload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"set",
"(",
"'type'",
",",
"'_default_'",
")",
"->",
"set",
"(",
"'body._default_'",
",",
"$",
"defaultMapping",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"->",
"putMapping",
"(",
"$",
"targetIndexMappingPayload",
")",
";",
"}",
"$",
"indices",
"->",
"open",
"(",
"$",
"targetIndexPayload",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"indices",
"->",
"open",
"(",
"$",
"targetIndexPayload",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The index %s was updated.'",
",",
"$",
"targetIndex",
")",
")",
";",
"}"
]
| Update the target index.
@throws \Exception
@return void | [
"Update",
"the",
"target",
"index",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L94-L140 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.updateTargetIndexMapping | protected function updateTargetIndexMapping()
{
$sourceModel = $this->getModel();
$sourceIndexConfigurator = $sourceModel->getIndexConfigurator();
$targetIndex = $this->argument('target-index');
$targetType = $sourceModel->searchableAs();
$mapping = array_merge_recursive(
$sourceIndexConfigurator->getDefaultMapping(),
$sourceModel->getMapping()
);
if (empty($mapping)) {
$this->warn(sprintf(
'The %s mapping is empty.',
get_class($sourceModel)
));
return;
}
$payload = (new RawPayload())
->set('index', $targetIndex)
->set('type', $targetType)
->set('body.'.$targetType, $mapping)
->get();
ElasticClient::indices()
->putMapping($payload);
$this->info(sprintf(
'The %s mapping was updated.',
$targetIndex
));
} | php | protected function updateTargetIndexMapping()
{
$sourceModel = $this->getModel();
$sourceIndexConfigurator = $sourceModel->getIndexConfigurator();
$targetIndex = $this->argument('target-index');
$targetType = $sourceModel->searchableAs();
$mapping = array_merge_recursive(
$sourceIndexConfigurator->getDefaultMapping(),
$sourceModel->getMapping()
);
if (empty($mapping)) {
$this->warn(sprintf(
'The %s mapping is empty.',
get_class($sourceModel)
));
return;
}
$payload = (new RawPayload())
->set('index', $targetIndex)
->set('type', $targetType)
->set('body.'.$targetType, $mapping)
->get();
ElasticClient::indices()
->putMapping($payload);
$this->info(sprintf(
'The %s mapping was updated.',
$targetIndex
));
} | [
"protected",
"function",
"updateTargetIndexMapping",
"(",
")",
"{",
"$",
"sourceModel",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"sourceIndexConfigurator",
"=",
"$",
"sourceModel",
"->",
"getIndexConfigurator",
"(",
")",
";",
"$",
"targetIndex",
"=",
"$",
"this",
"->",
"argument",
"(",
"'target-index'",
")",
";",
"$",
"targetType",
"=",
"$",
"sourceModel",
"->",
"searchableAs",
"(",
")",
";",
"$",
"mapping",
"=",
"array_merge_recursive",
"(",
"$",
"sourceIndexConfigurator",
"->",
"getDefaultMapping",
"(",
")",
",",
"$",
"sourceModel",
"->",
"getMapping",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"mapping",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"sprintf",
"(",
"'The %s mapping is empty.'",
",",
"get_class",
"(",
"$",
"sourceModel",
")",
")",
")",
";",
"return",
";",
"}",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"set",
"(",
"'type'",
",",
"$",
"targetType",
")",
"->",
"set",
"(",
"'body.'",
".",
"$",
"targetType",
",",
"$",
"mapping",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"putMapping",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s mapping was updated.'",
",",
"$",
"targetIndex",
")",
")",
";",
"}"
]
| Update the target index mapping.
@return void | [
"Update",
"the",
"target",
"index",
"mapping",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L147-L182 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.isAliasExists | protected function isAliasExists($name)
{
$payload = (new RawPayload())
->set('name', $name)
->get();
return ElasticClient::indices()
->existsAlias($payload);
} | php | protected function isAliasExists($name)
{
$payload = (new RawPayload())
->set('name', $name)
->get();
return ElasticClient::indices()
->existsAlias($payload);
} | [
"protected",
"function",
"isAliasExists",
"(",
"$",
"name",
")",
"{",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"get",
"(",
")",
";",
"return",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"existsAlias",
"(",
"$",
"payload",
")",
";",
"}"
]
| Check if an alias exists.
@param string $name
@return bool | [
"Check",
"if",
"an",
"alias",
"exists",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L190-L198 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.deleteAlias | protected function deleteAlias($name)
{
$aliases = $this->getAlias($name);
if (empty($aliases)) {
return;
}
foreach ($aliases as $index => $alias) {
$deletePayload = (new RawPayload())
->set('index', $index)
->set('name', $name)
->get();
ElasticClient::indices()
->deleteAlias($deletePayload);
$this->info(sprintf(
'The %s alias for the %s index was deleted.',
$name,
$index
));
}
} | php | protected function deleteAlias($name)
{
$aliases = $this->getAlias($name);
if (empty($aliases)) {
return;
}
foreach ($aliases as $index => $alias) {
$deletePayload = (new RawPayload())
->set('index', $index)
->set('name', $name)
->get();
ElasticClient::indices()
->deleteAlias($deletePayload);
$this->info(sprintf(
'The %s alias for the %s index was deleted.',
$name,
$index
));
}
} | [
"protected",
"function",
"deleteAlias",
"(",
"$",
"name",
")",
"{",
"$",
"aliases",
"=",
"$",
"this",
"->",
"getAlias",
"(",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"aliases",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"aliases",
"as",
"$",
"index",
"=>",
"$",
"alias",
")",
"{",
"$",
"deletePayload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"index",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"deleteAlias",
"(",
"$",
"deletePayload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s alias for the %s index was deleted.'",
",",
"$",
"name",
",",
"$",
"index",
")",
")",
";",
"}",
"}"
]
| Delete an alias.
@param string $name
@return void | [
"Delete",
"an",
"alias",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L222-L245 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.createAliasForTargetIndex | protected function createAliasForTargetIndex($name)
{
$targetIndex = $this->argument('target-index');
if ($this->isAliasExists($name)) {
$this->deleteAlias($name);
}
$payload = (new RawPayload())
->set('index', $targetIndex)
->set('name', $name)
->get();
ElasticClient::indices()
->putAlias($payload);
$this->info(sprintf(
'The %s alias for the %s index was created.',
$name,
$targetIndex
));
} | php | protected function createAliasForTargetIndex($name)
{
$targetIndex = $this->argument('target-index');
if ($this->isAliasExists($name)) {
$this->deleteAlias($name);
}
$payload = (new RawPayload())
->set('index', $targetIndex)
->set('name', $name)
->get();
ElasticClient::indices()
->putAlias($payload);
$this->info(sprintf(
'The %s alias for the %s index was created.',
$name,
$targetIndex
));
} | [
"protected",
"function",
"createAliasForTargetIndex",
"(",
"$",
"name",
")",
"{",
"$",
"targetIndex",
"=",
"$",
"this",
"->",
"argument",
"(",
"'target-index'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isAliasExists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"deleteAlias",
"(",
"$",
"name",
")",
";",
"}",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"targetIndex",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"putAlias",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s alias for the %s index was created.'",
",",
"$",
"name",
",",
"$",
"targetIndex",
")",
")",
";",
"}"
]
| Create an alias for the target index.
@param string $name
@return void | [
"Create",
"an",
"alias",
"for",
"the",
"target",
"index",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L253-L274 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticMigrateCommand.php | ElasticMigrateCommand.deleteSourceIndex | protected function deleteSourceIndex()
{
$sourceIndexConfigurator = $this
->getModel()
->getIndexConfigurator();
if ($this->isAliasExists($sourceIndexConfigurator->getName())) {
$aliases = $this->getAlias($sourceIndexConfigurator->getName());
foreach ($aliases as $index => $alias) {
$payload = (new RawPayload())
->set('index', $index)
->get();
ElasticClient::indices()
->delete($payload);
$this->info(sprintf(
'The %s index was removed.',
$index
));
}
} else {
$payload = (new IndexPayload($sourceIndexConfigurator))
->get();
ElasticClient::indices()
->delete($payload);
$this->info(sprintf(
'The %s index was removed.',
$sourceIndexConfigurator->getName()
));
}
} | php | protected function deleteSourceIndex()
{
$sourceIndexConfigurator = $this
->getModel()
->getIndexConfigurator();
if ($this->isAliasExists($sourceIndexConfigurator->getName())) {
$aliases = $this->getAlias($sourceIndexConfigurator->getName());
foreach ($aliases as $index => $alias) {
$payload = (new RawPayload())
->set('index', $index)
->get();
ElasticClient::indices()
->delete($payload);
$this->info(sprintf(
'The %s index was removed.',
$index
));
}
} else {
$payload = (new IndexPayload($sourceIndexConfigurator))
->get();
ElasticClient::indices()
->delete($payload);
$this->info(sprintf(
'The %s index was removed.',
$sourceIndexConfigurator->getName()
));
}
} | [
"protected",
"function",
"deleteSourceIndex",
"(",
")",
"{",
"$",
"sourceIndexConfigurator",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getIndexConfigurator",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isAliasExists",
"(",
"$",
"sourceIndexConfigurator",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"aliases",
"=",
"$",
"this",
"->",
"getAlias",
"(",
"$",
"sourceIndexConfigurator",
"->",
"getName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"aliases",
"as",
"$",
"index",
"=>",
"$",
"alias",
")",
"{",
"$",
"payload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'index'",
",",
"$",
"index",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"delete",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s index was removed.'",
",",
"$",
"index",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"payload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"sourceIndexConfigurator",
")",
")",
"->",
"get",
"(",
")",
";",
"ElasticClient",
"::",
"indices",
"(",
")",
"->",
"delete",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s index was removed.'",
",",
"$",
"sourceIndexConfigurator",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"}"
]
| Delete the source index.
@return void | [
"Delete",
"the",
"source",
"index",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticMigrateCommand.php#L296-L330 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticIndexUpdateCommand.php | ElasticIndexUpdateCommand.updateIndex | protected function updateIndex()
{
$configurator = $this->getIndexConfigurator();
$indexPayload = (new IndexPayload($configurator))->get();
$indices = ElasticClient::indices();
if (! $indices->exists($indexPayload)) {
throw new LogicException(sprintf(
'Index %s doesn\'t exist',
$configurator->getName()
));
}
try {
$indices->close($indexPayload);
if ($settings = $configurator->getSettings()) {
$indexSettingsPayload = (new IndexPayload($configurator))
->set('body.settings', $settings)
->get();
$indices->putSettings($indexSettingsPayload);
}
if ($defaultMapping = $configurator->getDefaultMapping()) {
$indexMappingPayload = (new IndexPayload($configurator))
->set('type', '_default_')
->set('body._default_', $defaultMapping)
->get();
$indices->putMapping($indexMappingPayload);
}
$indices->open($indexPayload);
} catch (Exception $exception) {
$indices->open($indexPayload);
throw $exception;
}
$this->info(sprintf(
'The index %s was updated!',
$configurator->getName()
));
} | php | protected function updateIndex()
{
$configurator = $this->getIndexConfigurator();
$indexPayload = (new IndexPayload($configurator))->get();
$indices = ElasticClient::indices();
if (! $indices->exists($indexPayload)) {
throw new LogicException(sprintf(
'Index %s doesn\'t exist',
$configurator->getName()
));
}
try {
$indices->close($indexPayload);
if ($settings = $configurator->getSettings()) {
$indexSettingsPayload = (new IndexPayload($configurator))
->set('body.settings', $settings)
->get();
$indices->putSettings($indexSettingsPayload);
}
if ($defaultMapping = $configurator->getDefaultMapping()) {
$indexMappingPayload = (new IndexPayload($configurator))
->set('type', '_default_')
->set('body._default_', $defaultMapping)
->get();
$indices->putMapping($indexMappingPayload);
}
$indices->open($indexPayload);
} catch (Exception $exception) {
$indices->open($indexPayload);
throw $exception;
}
$this->info(sprintf(
'The index %s was updated!',
$configurator->getName()
));
} | [
"protected",
"function",
"updateIndex",
"(",
")",
"{",
"$",
"configurator",
"=",
"$",
"this",
"->",
"getIndexConfigurator",
"(",
")",
";",
"$",
"indexPayload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"configurator",
")",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"=",
"ElasticClient",
"::",
"indices",
"(",
")",
";",
"if",
"(",
"!",
"$",
"indices",
"->",
"exists",
"(",
"$",
"indexPayload",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Index %s doesn\\'t exist'",
",",
"$",
"configurator",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"$",
"indices",
"->",
"close",
"(",
"$",
"indexPayload",
")",
";",
"if",
"(",
"$",
"settings",
"=",
"$",
"configurator",
"->",
"getSettings",
"(",
")",
")",
"{",
"$",
"indexSettingsPayload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"configurator",
")",
")",
"->",
"set",
"(",
"'body.settings'",
",",
"$",
"settings",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"->",
"putSettings",
"(",
"$",
"indexSettingsPayload",
")",
";",
"}",
"if",
"(",
"$",
"defaultMapping",
"=",
"$",
"configurator",
"->",
"getDefaultMapping",
"(",
")",
")",
"{",
"$",
"indexMappingPayload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"configurator",
")",
")",
"->",
"set",
"(",
"'type'",
",",
"'_default_'",
")",
"->",
"set",
"(",
"'body._default_'",
",",
"$",
"defaultMapping",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"->",
"putMapping",
"(",
"$",
"indexMappingPayload",
")",
";",
"}",
"$",
"indices",
"->",
"open",
"(",
"$",
"indexPayload",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"indices",
"->",
"open",
"(",
"$",
"indexPayload",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The index %s was updated!'",
",",
"$",
"configurator",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
]
| Update the index.
@throws \Exception
@return void | [
"Update",
"the",
"index",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticIndexUpdateCommand.php#L34-L80 | train |
babenkoivan/scout-elasticsearch-driver | src/Console/ElasticIndexUpdateCommand.php | ElasticIndexUpdateCommand.createWriteAlias | protected function createWriteAlias()
{
$configurator = $this->getIndexConfigurator();
if (! in_array(Migratable::class, class_uses_recursive($configurator))) {
return;
}
$indices = ElasticClient::indices();
$existsPayload = (new RawPayload())
->set('name', $configurator->getWriteAlias())
->get();
if ($indices->existsAlias($existsPayload)) {
return;
}
$putPayload = (new IndexPayload($configurator))
->set('name', $configurator->getWriteAlias())
->get();
$indices->putAlias($putPayload);
$this->info(sprintf(
'The %s alias for the %s index was created!',
$configurator->getWriteAlias(),
$configurator->getName()
));
} | php | protected function createWriteAlias()
{
$configurator = $this->getIndexConfigurator();
if (! in_array(Migratable::class, class_uses_recursive($configurator))) {
return;
}
$indices = ElasticClient::indices();
$existsPayload = (new RawPayload())
->set('name', $configurator->getWriteAlias())
->get();
if ($indices->existsAlias($existsPayload)) {
return;
}
$putPayload = (new IndexPayload($configurator))
->set('name', $configurator->getWriteAlias())
->get();
$indices->putAlias($putPayload);
$this->info(sprintf(
'The %s alias for the %s index was created!',
$configurator->getWriteAlias(),
$configurator->getName()
));
} | [
"protected",
"function",
"createWriteAlias",
"(",
")",
"{",
"$",
"configurator",
"=",
"$",
"this",
"->",
"getIndexConfigurator",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"Migratable",
"::",
"class",
",",
"class_uses_recursive",
"(",
"$",
"configurator",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"indices",
"=",
"ElasticClient",
"::",
"indices",
"(",
")",
";",
"$",
"existsPayload",
"=",
"(",
"new",
"RawPayload",
"(",
")",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"configurator",
"->",
"getWriteAlias",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"$",
"indices",
"->",
"existsAlias",
"(",
"$",
"existsPayload",
")",
")",
"{",
"return",
";",
"}",
"$",
"putPayload",
"=",
"(",
"new",
"IndexPayload",
"(",
"$",
"configurator",
")",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"configurator",
"->",
"getWriteAlias",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"$",
"indices",
"->",
"putAlias",
"(",
"$",
"putPayload",
")",
";",
"$",
"this",
"->",
"info",
"(",
"sprintf",
"(",
"'The %s alias for the %s index was created!'",
",",
"$",
"configurator",
"->",
"getWriteAlias",
"(",
")",
",",
"$",
"configurator",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
]
| Create a write alias.
@return void | [
"Create",
"a",
"write",
"alias",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Console/ElasticIndexUpdateCommand.php#L87-L116 | train |
babenkoivan/scout-elasticsearch-driver | src/Payloads/IndexPayload.php | IndexPayload.useAlias | public function useAlias($alias)
{
$aliasGetter = 'get'.ucfirst($alias).'Alias';
if (! method_exists($this->indexConfigurator, $aliasGetter)) {
throw new Exception(sprintf(
'The index configurator %s doesn\'t have getter for the %s alias.',
get_class($this->indexConfigurator),
$alias
));
}
$this->payload['index'] = call_user_func([$this->indexConfigurator, $aliasGetter]);
return $this;
} | php | public function useAlias($alias)
{
$aliasGetter = 'get'.ucfirst($alias).'Alias';
if (! method_exists($this->indexConfigurator, $aliasGetter)) {
throw new Exception(sprintf(
'The index configurator %s doesn\'t have getter for the %s alias.',
get_class($this->indexConfigurator),
$alias
));
}
$this->payload['index'] = call_user_func([$this->indexConfigurator, $aliasGetter]);
return $this;
} | [
"public",
"function",
"useAlias",
"(",
"$",
"alias",
")",
"{",
"$",
"aliasGetter",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"alias",
")",
".",
"'Alias'",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"indexConfigurator",
",",
"$",
"aliasGetter",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The index configurator %s doesn\\'t have getter for the %s alias.'",
",",
"get_class",
"(",
"$",
"this",
"->",
"indexConfigurator",
")",
",",
"$",
"alias",
")",
")",
";",
"}",
"$",
"this",
"->",
"payload",
"[",
"'index'",
"]",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"indexConfigurator",
",",
"$",
"aliasGetter",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Use an alias.
@param string $alias
@return $this
@throws \Exception | [
"Use",
"an",
"alias",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Payloads/IndexPayload.php#L49-L64 | train |
babenkoivan/scout-elasticsearch-driver | src/Searchable.php | Searchable.getMapping | public function getMapping()
{
$mapping = $this->mapping ?? [];
if ($this::usesSoftDelete() && config('scout.soft_delete', false)) {
Arr::set($mapping, 'properties.__soft_deleted', ['type' => 'integer']);
}
return $mapping;
} | php | public function getMapping()
{
$mapping = $this->mapping ?? [];
if ($this::usesSoftDelete() && config('scout.soft_delete', false)) {
Arr::set($mapping, 'properties.__soft_deleted', ['type' => 'integer']);
}
return $mapping;
} | [
"public",
"function",
"getMapping",
"(",
")",
"{",
"$",
"mapping",
"=",
"$",
"this",
"->",
"mapping",
"??",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"::",
"usesSoftDelete",
"(",
")",
"&&",
"config",
"(",
"'scout.soft_delete'",
",",
"false",
")",
")",
"{",
"Arr",
"::",
"set",
"(",
"$",
"mapping",
",",
"'properties.__soft_deleted'",
",",
"[",
"'type'",
"=>",
"'integer'",
"]",
")",
";",
"}",
"return",
"$",
"mapping",
";",
"}"
]
| Get the mapping.
@return array | [
"Get",
"the",
"mapping",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Searchable.php#L72-L81 | train |
babenkoivan/scout-elasticsearch-driver | src/Searchable.php | Searchable.getSearchRules | public function getSearchRules()
{
return isset($this->searchRules) && count($this->searchRules) > 0 ?
$this->searchRules : [SearchRule::class];
} | php | public function getSearchRules()
{
return isset($this->searchRules) && count($this->searchRules) > 0 ?
$this->searchRules : [SearchRule::class];
} | [
"public",
"function",
"getSearchRules",
"(",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"searchRules",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"searchRules",
")",
">",
"0",
"?",
"$",
"this",
"->",
"searchRules",
":",
"[",
"SearchRule",
"::",
"class",
"]",
";",
"}"
]
| Get the search rules.
@return array | [
"Get",
"the",
"search",
"rules",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Searchable.php#L88-L92 | train |
babenkoivan/scout-elasticsearch-driver | src/Searchable.php | Searchable.search | public static function search($query, $callback = null)
{
$softDelete = static::usesSoftDelete() && config('scout.soft_delete', false);
if ($query == '*') {
return new FilterBuilder(new static, $callback, $softDelete);
} else {
return new SearchBuilder(new static, $query, $callback, $softDelete);
}
} | php | public static function search($query, $callback = null)
{
$softDelete = static::usesSoftDelete() && config('scout.soft_delete', false);
if ($query == '*') {
return new FilterBuilder(new static, $callback, $softDelete);
} else {
return new SearchBuilder(new static, $query, $callback, $softDelete);
}
} | [
"public",
"static",
"function",
"search",
"(",
"$",
"query",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"softDelete",
"=",
"static",
"::",
"usesSoftDelete",
"(",
")",
"&&",
"config",
"(",
"'scout.soft_delete'",
",",
"false",
")",
";",
"if",
"(",
"$",
"query",
"==",
"'*'",
")",
"{",
"return",
"new",
"FilterBuilder",
"(",
"new",
"static",
",",
"$",
"callback",
",",
"$",
"softDelete",
")",
";",
"}",
"else",
"{",
"return",
"new",
"SearchBuilder",
"(",
"new",
"static",
",",
"$",
"query",
",",
"$",
"callback",
",",
"$",
"softDelete",
")",
";",
"}",
"}"
]
| Execute the search.
@param string $query
@param callable|null $callback
@return \ScoutElastic\Builders\FilterBuilder|\ScoutElastic\Builders\SearchBuilder | [
"Execute",
"the",
"search",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Searchable.php#L101-L110 | train |
babenkoivan/scout-elasticsearch-driver | src/Builders/FilterBuilder.php | FilterBuilder.whereRegexp | public function whereRegexp($field, $value, $flags = 'ALL')
{
$this->wheres['must'][] = [
'regexp' => [
$field => [
'value' => $value,
'flags' => $flags,
],
],
];
return $this;
} | php | public function whereRegexp($field, $value, $flags = 'ALL')
{
$this->wheres['must'][] = [
'regexp' => [
$field => [
'value' => $value,
'flags' => $flags,
],
],
];
return $this;
} | [
"public",
"function",
"whereRegexp",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"flags",
"=",
"'ALL'",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"'must'",
"]",
"[",
"]",
"=",
"[",
"'regexp'",
"=>",
"[",
"$",
"field",
"=>",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'flags'",
"=>",
"$",
"flags",
",",
"]",
",",
"]",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a whereRegexp condition.
@see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html Regexp query
@param string $field
@param string $value
@param string $flags
@return $this | [
"Add",
"a",
"whereRegexp",
"condition",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Builders/FilterBuilder.php#L288-L300 | train |
babenkoivan/scout-elasticsearch-driver | src/Builders/FilterBuilder.php | FilterBuilder.whereGeoDistance | public function whereGeoDistance($field, $value, $distance)
{
$this->wheres['must'][] = [
'geo_distance' => [
'distance' => $distance,
$field => $value,
],
];
return $this;
} | php | public function whereGeoDistance($field, $value, $distance)
{
$this->wheres['must'][] = [
'geo_distance' => [
'distance' => $distance,
$field => $value,
],
];
return $this;
} | [
"public",
"function",
"whereGeoDistance",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"distance",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"'must'",
"]",
"[",
"]",
"=",
"[",
"'geo_distance'",
"=>",
"[",
"'distance'",
"=>",
"$",
"distance",
",",
"$",
"field",
"=>",
"$",
"value",
",",
"]",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a whereGeoDistance condition.
@see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html Geo distance query
@param string $field
@param string|array $value
@param int|string $distance
@return $this | [
"Add",
"a",
"whereGeoDistance",
"condition",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Builders/FilterBuilder.php#L312-L322 | train |
babenkoivan/scout-elasticsearch-driver | src/Builders/FilterBuilder.php | FilterBuilder.select | public function select($fields)
{
$this->select = array_merge(
$this->select,
Arr::wrap($fields)
);
return $this;
} | php | public function select($fields)
{
$this->select = array_merge(
$this->select,
Arr::wrap($fields)
);
return $this;
} | [
"public",
"function",
"select",
"(",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"select",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"select",
",",
"Arr",
"::",
"wrap",
"(",
"$",
"fields",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Select one or many fields.
@param mixed $fields
@return $this | [
"Select",
"one",
"or",
"many",
"fields",
"."
]
| f078a6f9d35b44e4ff440ea31e583973596e9726 | https://github.com/babenkoivan/scout-elasticsearch-driver/blob/f078a6f9d35b44e4ff440ea31e583973596e9726/src/Builders/FilterBuilder.php#L515-L523 | train |
filp/whoops | src/Whoops/Exception/Formatter.php | Formatter.formatExceptionAsDataArray | public static function formatExceptionAsDataArray(Inspector $inspector, $shouldAddTrace)
{
$exception = $inspector->getException();
$response = [
'type' => get_class($exception),
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
];
if ($shouldAddTrace) {
$frames = $inspector->getFrames();
$frameData = [];
foreach ($frames as $frame) {
/** @var Frame $frame */
$frameData[] = [
'file' => $frame->getFile(),
'line' => $frame->getLine(),
'function' => $frame->getFunction(),
'class' => $frame->getClass(),
'args' => $frame->getArgs(),
];
}
$response['trace'] = $frameData;
}
return $response;
} | php | public static function formatExceptionAsDataArray(Inspector $inspector, $shouldAddTrace)
{
$exception = $inspector->getException();
$response = [
'type' => get_class($exception),
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
];
if ($shouldAddTrace) {
$frames = $inspector->getFrames();
$frameData = [];
foreach ($frames as $frame) {
/** @var Frame $frame */
$frameData[] = [
'file' => $frame->getFile(),
'line' => $frame->getLine(),
'function' => $frame->getFunction(),
'class' => $frame->getClass(),
'args' => $frame->getArgs(),
];
}
$response['trace'] = $frameData;
}
return $response;
} | [
"public",
"static",
"function",
"formatExceptionAsDataArray",
"(",
"Inspector",
"$",
"inspector",
",",
"$",
"shouldAddTrace",
")",
"{",
"$",
"exception",
"=",
"$",
"inspector",
"->",
"getException",
"(",
")",
";",
"$",
"response",
"=",
"[",
"'type'",
"=>",
"get_class",
"(",
"$",
"exception",
")",
",",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"'file'",
"=>",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"exception",
"->",
"getLine",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"shouldAddTrace",
")",
"{",
"$",
"frames",
"=",
"$",
"inspector",
"->",
"getFrames",
"(",
")",
";",
"$",
"frameData",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"frames",
"as",
"$",
"frame",
")",
"{",
"/** @var Frame $frame */",
"$",
"frameData",
"[",
"]",
"=",
"[",
"'file'",
"=>",
"$",
"frame",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"frame",
"->",
"getLine",
"(",
")",
",",
"'function'",
"=>",
"$",
"frame",
"->",
"getFunction",
"(",
")",
",",
"'class'",
"=>",
"$",
"frame",
"->",
"getClass",
"(",
")",
",",
"'args'",
"=>",
"$",
"frame",
"->",
"getArgs",
"(",
")",
",",
"]",
";",
"}",
"$",
"response",
"[",
"'trace'",
"]",
"=",
"$",
"frameData",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Returns all basic information about the exception in a simple array
for further convertion to other languages
@param Inspector $inspector
@param bool $shouldAddTrace
@return array | [
"Returns",
"all",
"basic",
"information",
"about",
"the",
"exception",
"in",
"a",
"simple",
"array",
"for",
"further",
"convertion",
"to",
"other",
"languages"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Formatter.php#L18-L47 | train |
filp/whoops | src/Whoops/Util/TemplateHelper.php | TemplateHelper.breakOnDelimiter | public function breakOnDelimiter($delimiter, $s)
{
$parts = explode($delimiter, $s);
foreach ($parts as &$part) {
$part = '<div class="delimiter">' . $part . '</div>';
}
return implode($delimiter, $parts);
} | php | public function breakOnDelimiter($delimiter, $s)
{
$parts = explode($delimiter, $s);
foreach ($parts as &$part) {
$part = '<div class="delimiter">' . $part . '</div>';
}
return implode($delimiter, $parts);
} | [
"public",
"function",
"breakOnDelimiter",
"(",
"$",
"delimiter",
",",
"$",
"s",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"s",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"&",
"$",
"part",
")",
"{",
"$",
"part",
"=",
"'<div class=\"delimiter\">'",
".",
"$",
"part",
".",
"'</div>'",
";",
"}",
"return",
"implode",
"(",
"$",
"delimiter",
",",
"$",
"parts",
")",
";",
"}"
]
| Makes sure that the given string breaks on the delimiter.
@param string $delimiter
@param string $s
@return string | [
"Makes",
"sure",
"that",
"the",
"given",
"string",
"breaks",
"on",
"the",
"delimiter",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/TemplateHelper.php#L103-L111 | train |
filp/whoops | src/Whoops/Util/TemplateHelper.php | TemplateHelper.shorten | public function shorten($path)
{
if ($this->applicationRootPath != "/") {
$path = str_replace($this->applicationRootPath, '…', $path);
}
return $path;
} | php | public function shorten($path)
{
if ($this->applicationRootPath != "/") {
$path = str_replace($this->applicationRootPath, '…', $path);
}
return $path;
} | [
"public",
"function",
"shorten",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"applicationRootPath",
"!=",
"\"/\"",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"applicationRootPath",
",",
"'…'",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
]
| Replace the part of the path that all files have in common.
@param string $path
@return string | [
"Replace",
"the",
"part",
"of",
"the",
"path",
"that",
"all",
"files",
"have",
"in",
"common",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/TemplateHelper.php#L119-L126 | train |
filp/whoops | src/Whoops/Util/TemplateHelper.php | TemplateHelper.dumpArgs | public function dumpArgs(Frame $frame)
{
// we support frame args only when the optional dumper is available
if (!$this->getDumper()) {
return '';
}
$html = '';
$numFrames = count($frame->getArgs());
if ($numFrames > 0) {
$html = '<ol class="linenums">';
foreach ($frame->getArgs() as $j => $frameArg) {
$html .= '<li>'. $this->dump($frameArg) .'</li>';
}
$html .= '</ol>';
}
return $html;
} | php | public function dumpArgs(Frame $frame)
{
// we support frame args only when the optional dumper is available
if (!$this->getDumper()) {
return '';
}
$html = '';
$numFrames = count($frame->getArgs());
if ($numFrames > 0) {
$html = '<ol class="linenums">';
foreach ($frame->getArgs() as $j => $frameArg) {
$html .= '<li>'. $this->dump($frameArg) .'</li>';
}
$html .= '</ol>';
}
return $html;
} | [
"public",
"function",
"dumpArgs",
"(",
"Frame",
"$",
"frame",
")",
"{",
"// we support frame args only when the optional dumper is available",
"if",
"(",
"!",
"$",
"this",
"->",
"getDumper",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"html",
"=",
"''",
";",
"$",
"numFrames",
"=",
"count",
"(",
"$",
"frame",
"->",
"getArgs",
"(",
")",
")",
";",
"if",
"(",
"$",
"numFrames",
">",
"0",
")",
"{",
"$",
"html",
"=",
"'<ol class=\"linenums\">'",
";",
"foreach",
"(",
"$",
"frame",
"->",
"getArgs",
"(",
")",
"as",
"$",
"j",
"=>",
"$",
"frameArg",
")",
"{",
"$",
"html",
".=",
"'<li>'",
".",
"$",
"this",
"->",
"dump",
"(",
"$",
"frameArg",
")",
".",
"'</li>'",
";",
"}",
"$",
"html",
".=",
"'</ol>'",
";",
"}",
"return",
"$",
"html",
";",
"}"
]
| Format the args of the given Frame as a human readable html string
@param Frame $frame
@return string the rendered html | [
"Format",
"the",
"args",
"of",
"the",
"given",
"Frame",
"as",
"a",
"human",
"readable",
"html",
"string"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/TemplateHelper.php#L195-L214 | train |
filp/whoops | src/Whoops/Util/TemplateHelper.php | TemplateHelper.slug | public function slug($original)
{
$slug = str_replace(" ", "-", $original);
$slug = preg_replace('/[^\w\d\-\_]/i', '', $slug);
return strtolower($slug);
} | php | public function slug($original)
{
$slug = str_replace(" ", "-", $original);
$slug = preg_replace('/[^\w\d\-\_]/i', '', $slug);
return strtolower($slug);
} | [
"public",
"function",
"slug",
"(",
"$",
"original",
")",
"{",
"$",
"slug",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"-\"",
",",
"$",
"original",
")",
";",
"$",
"slug",
"=",
"preg_replace",
"(",
"'/[^\\w\\d\\-\\_]/i'",
",",
"''",
",",
"$",
"slug",
")",
";",
"return",
"strtolower",
"(",
"$",
"slug",
")",
";",
"}"
]
| Convert a string to a slug version of itself
@param string $original
@return string | [
"Convert",
"a",
"string",
"to",
"a",
"slug",
"version",
"of",
"itself"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/TemplateHelper.php#L222-L227 | train |
filp/whoops | src/Whoops/Util/TemplateHelper.php | TemplateHelper.render | public function render($template, array $additionalVariables = null)
{
$variables = $this->getVariables();
// Pass the helper to the template:
$variables["tpl"] = $this;
if ($additionalVariables !== null) {
$variables = array_replace($variables, $additionalVariables);
}
call_user_func(function () {
extract(func_get_arg(1));
require func_get_arg(0);
}, $template, $variables);
} | php | public function render($template, array $additionalVariables = null)
{
$variables = $this->getVariables();
// Pass the helper to the template:
$variables["tpl"] = $this;
if ($additionalVariables !== null) {
$variables = array_replace($variables, $additionalVariables);
}
call_user_func(function () {
extract(func_get_arg(1));
require func_get_arg(0);
}, $template, $variables);
} | [
"public",
"function",
"render",
"(",
"$",
"template",
",",
"array",
"$",
"additionalVariables",
"=",
"null",
")",
"{",
"$",
"variables",
"=",
"$",
"this",
"->",
"getVariables",
"(",
")",
";",
"// Pass the helper to the template:",
"$",
"variables",
"[",
"\"tpl\"",
"]",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"additionalVariables",
"!==",
"null",
")",
"{",
"$",
"variables",
"=",
"array_replace",
"(",
"$",
"variables",
",",
"$",
"additionalVariables",
")",
";",
"}",
"call_user_func",
"(",
"function",
"(",
")",
"{",
"extract",
"(",
"func_get_arg",
"(",
"1",
")",
")",
";",
"require",
"func_get_arg",
"(",
"0",
")",
";",
"}",
",",
"$",
"template",
",",
"$",
"variables",
")",
";",
"}"
]
| Given a template path, render it within its own scope. This
method also accepts an array of additional variables to be
passed to the template.
@param string $template
@param array $additionalVariables | [
"Given",
"a",
"template",
"path",
"render",
"it",
"within",
"its",
"own",
"scope",
".",
"This",
"method",
"also",
"accepts",
"an",
"array",
"of",
"additional",
"variables",
"to",
"be",
"passed",
"to",
"the",
"template",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/TemplateHelper.php#L237-L252 | train |
filp/whoops | src/Whoops/Run.php | Run.pushHandler | public function pushHandler($handler)
{
if (is_callable($handler)) {
$handler = new CallbackHandler($handler);
}
if (!$handler instanceof HandlerInterface) {
throw new InvalidArgumentException(
"Argument to " . __METHOD__ . " must be a callable, or instance of "
. "Whoops\\Handler\\HandlerInterface"
);
}
$this->handlerStack[] = $handler;
return $this;
} | php | public function pushHandler($handler)
{
if (is_callable($handler)) {
$handler = new CallbackHandler($handler);
}
if (!$handler instanceof HandlerInterface) {
throw new InvalidArgumentException(
"Argument to " . __METHOD__ . " must be a callable, or instance of "
. "Whoops\\Handler\\HandlerInterface"
);
}
$this->handlerStack[] = $handler;
return $this;
} | [
"public",
"function",
"pushHandler",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"handler",
")",
")",
"{",
"$",
"handler",
"=",
"new",
"CallbackHandler",
"(",
"$",
"handler",
")",
";",
"}",
"if",
"(",
"!",
"$",
"handler",
"instanceof",
"HandlerInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Argument to \"",
".",
"__METHOD__",
".",
"\" must be a callable, or instance of \"",
".",
"\"Whoops\\\\Handler\\\\HandlerInterface\"",
")",
";",
"}",
"$",
"this",
"->",
"handlerStack",
"[",
"]",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
]
| Pushes a handler to the end of the stack
@throws InvalidArgumentException If argument is not callable or instance of HandlerInterface
@param Callable|HandlerInterface $handler
@return Run | [
"Pushes",
"a",
"handler",
"to",
"the",
"end",
"of",
"the",
"stack"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Run.php#L50-L65 | train |
filp/whoops | src/Whoops/Run.php | Run.unregister | public function unregister()
{
if ($this->isRegistered) {
$this->system->restoreExceptionHandler();
$this->system->restoreErrorHandler();
$this->isRegistered = false;
}
return $this;
} | php | public function unregister()
{
if ($this->isRegistered) {
$this->system->restoreExceptionHandler();
$this->system->restoreErrorHandler();
$this->isRegistered = false;
}
return $this;
} | [
"public",
"function",
"unregister",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRegistered",
")",
"{",
"$",
"this",
"->",
"system",
"->",
"restoreExceptionHandler",
"(",
")",
";",
"$",
"this",
"->",
"system",
"->",
"restoreErrorHandler",
"(",
")",
";",
"$",
"this",
"->",
"isRegistered",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Unregisters all handlers registered by this Whoops\Run instance
@return Run | [
"Unregisters",
"all",
"handlers",
"registered",
"by",
"this",
"Whoops",
"\\",
"Run",
"instance"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Run.php#L135-L145 | train |
filp/whoops | src/Whoops/Run.php | Run.allowQuit | public function allowQuit($exit = null)
{
if (func_num_args() == 0) {
return $this->allowQuit;
}
return $this->allowQuit = (bool) $exit;
} | php | public function allowQuit($exit = null)
{
if (func_num_args() == 0) {
return $this->allowQuit;
}
return $this->allowQuit = (bool) $exit;
} | [
"public",
"function",
"allowQuit",
"(",
"$",
"exit",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"allowQuit",
";",
"}",
"return",
"$",
"this",
"->",
"allowQuit",
"=",
"(",
"bool",
")",
"$",
"exit",
";",
"}"
]
| Should Whoops allow Handlers to force the script to quit?
@param bool|int $exit
@return bool | [
"Should",
"Whoops",
"allow",
"Handlers",
"to",
"force",
"the",
"script",
"to",
"quit?"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Run.php#L152-L159 | train |
filp/whoops | src/Whoops/Run.php | Run.silenceErrorsInPaths | public function silenceErrorsInPaths($patterns, $levels = 10240)
{
$this->silencedPatterns = array_merge(
$this->silencedPatterns,
array_map(
function ($pattern) use ($levels) {
return [
"pattern" => $pattern,
"levels" => $levels,
];
},
(array) $patterns
)
);
return $this;
} | php | public function silenceErrorsInPaths($patterns, $levels = 10240)
{
$this->silencedPatterns = array_merge(
$this->silencedPatterns,
array_map(
function ($pattern) use ($levels) {
return [
"pattern" => $pattern,
"levels" => $levels,
];
},
(array) $patterns
)
);
return $this;
} | [
"public",
"function",
"silenceErrorsInPaths",
"(",
"$",
"patterns",
",",
"$",
"levels",
"=",
"10240",
")",
"{",
"$",
"this",
"->",
"silencedPatterns",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"silencedPatterns",
",",
"array_map",
"(",
"function",
"(",
"$",
"pattern",
")",
"use",
"(",
"$",
"levels",
")",
"{",
"return",
"[",
"\"pattern\"",
"=>",
"$",
"pattern",
",",
"\"levels\"",
"=>",
"$",
"levels",
",",
"]",
";",
"}",
",",
"(",
"array",
")",
"$",
"patterns",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Silence particular errors in particular files
@param array|string $patterns List or a single regex pattern to match
@param int $levels Defaults to E_STRICT | E_DEPRECATED
@return \Whoops\Run | [
"Silence",
"particular",
"errors",
"in",
"particular",
"files"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Run.php#L167-L182 | train |
filp/whoops | src/Whoops/Run.php | Run.writeToOutput | public function writeToOutput($send = null)
{
if (func_num_args() == 0) {
return $this->sendOutput;
}
return $this->sendOutput = (bool) $send;
} | php | public function writeToOutput($send = null)
{
if (func_num_args() == 0) {
return $this->sendOutput;
}
return $this->sendOutput = (bool) $send;
} | [
"public",
"function",
"writeToOutput",
"(",
"$",
"send",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"sendOutput",
";",
"}",
"return",
"$",
"this",
"->",
"sendOutput",
"=",
"(",
"bool",
")",
"$",
"send",
";",
"}"
]
| Should Whoops push output directly to the client?
If this is false, output will be returned by handleException
@param bool|int $send
@return bool | [
"Should",
"Whoops",
"push",
"output",
"directly",
"to",
"the",
"client?",
"If",
"this",
"is",
"false",
"output",
"will",
"be",
"returned",
"by",
"handleException"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Run.php#L232-L239 | train |
filp/whoops | src/Whoops/Util/Misc.php | Misc.translateErrorCode | public static function translateErrorCode($error_code)
{
$constants = get_defined_constants(true);
if (array_key_exists('Core', $constants)) {
foreach ($constants['Core'] as $constant => $value) {
if (substr($constant, 0, 2) == 'E_' && $value == $error_code) {
return $constant;
}
}
}
return "E_UNKNOWN";
} | php | public static function translateErrorCode($error_code)
{
$constants = get_defined_constants(true);
if (array_key_exists('Core', $constants)) {
foreach ($constants['Core'] as $constant => $value) {
if (substr($constant, 0, 2) == 'E_' && $value == $error_code) {
return $constant;
}
}
}
return "E_UNKNOWN";
} | [
"public",
"static",
"function",
"translateErrorCode",
"(",
"$",
"error_code",
")",
"{",
"$",
"constants",
"=",
"get_defined_constants",
"(",
"true",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'Core'",
",",
"$",
"constants",
")",
")",
"{",
"foreach",
"(",
"$",
"constants",
"[",
"'Core'",
"]",
"as",
"$",
"constant",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"constant",
",",
"0",
",",
"2",
")",
"==",
"'E_'",
"&&",
"$",
"value",
"==",
"$",
"error_code",
")",
"{",
"return",
"$",
"constant",
";",
"}",
"}",
"}",
"return",
"\"E_UNKNOWN\"",
";",
"}"
]
| Translate ErrorException code into the represented constant.
@param int $error_code
@return string | [
"Translate",
"ErrorException",
"code",
"into",
"the",
"represented",
"constant",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Util/Misc.php#L48-L59 | train |
filp/whoops | src/Whoops/Exception/Inspector.php | Inspector.getPreviousExceptionInspector | public function getPreviousExceptionInspector()
{
if ($this->previousExceptionInspector === null) {
$previousException = $this->exception->getPrevious();
if ($previousException) {
$this->previousExceptionInspector = new Inspector($previousException);
}
}
return $this->previousExceptionInspector;
} | php | public function getPreviousExceptionInspector()
{
if ($this->previousExceptionInspector === null) {
$previousException = $this->exception->getPrevious();
if ($previousException) {
$this->previousExceptionInspector = new Inspector($previousException);
}
}
return $this->previousExceptionInspector;
} | [
"public",
"function",
"getPreviousExceptionInspector",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"previousExceptionInspector",
"===",
"null",
")",
"{",
"$",
"previousException",
"=",
"$",
"this",
"->",
"exception",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"$",
"previousException",
")",
"{",
"$",
"this",
"->",
"previousExceptionInspector",
"=",
"new",
"Inspector",
"(",
"$",
"previousException",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"previousExceptionInspector",
";",
"}"
]
| Returns an Inspector for a previous Exception, if any.
@todo Clean this up a bit, cache stuff a bit better.
@return Inspector | [
"Returns",
"an",
"Inspector",
"for",
"a",
"previous",
"Exception",
"if",
"any",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Inspector.php#L134-L145 | train |
filp/whoops | src/Whoops/Exception/Inspector.php | Inspector.getPreviousExceptions | public function getPreviousExceptions()
{
if ($this->previousExceptions === null) {
$this->previousExceptions = [];
$prev = $this->exception->getPrevious();
while ($prev !== null) {
$this->previousExceptions[] = $prev;
$prev = $prev->getPrevious();
}
}
return $this->previousExceptions;
} | php | public function getPreviousExceptions()
{
if ($this->previousExceptions === null) {
$this->previousExceptions = [];
$prev = $this->exception->getPrevious();
while ($prev !== null) {
$this->previousExceptions[] = $prev;
$prev = $prev->getPrevious();
}
}
return $this->previousExceptions;
} | [
"public",
"function",
"getPreviousExceptions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"previousExceptions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"previousExceptions",
"=",
"[",
"]",
";",
"$",
"prev",
"=",
"$",
"this",
"->",
"exception",
"->",
"getPrevious",
"(",
")",
";",
"while",
"(",
"$",
"prev",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"previousExceptions",
"[",
"]",
"=",
"$",
"prev",
";",
"$",
"prev",
"=",
"$",
"prev",
"->",
"getPrevious",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"previousExceptions",
";",
"}"
]
| Returns an array of all previous exceptions for this inspector's exception
@return \Throwable[] | [
"Returns",
"an",
"array",
"of",
"all",
"previous",
"exceptions",
"for",
"this",
"inspector",
"s",
"exception"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Inspector.php#L152-L165 | train |
filp/whoops | src/Whoops/Exception/Inspector.php | Inspector.getTrace | protected function getTrace($e)
{
$traces = $e->getTrace();
// Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
if (!$e instanceof \ErrorException) {
return $traces;
}
if (!Misc::isLevelFatal($e->getSeverity())) {
return $traces;
}
if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
return [];
}
// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$traces = array_diff_key($stack, $trace);
return $traces;
} | php | protected function getTrace($e)
{
$traces = $e->getTrace();
// Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
if (!$e instanceof \ErrorException) {
return $traces;
}
if (!Misc::isLevelFatal($e->getSeverity())) {
return $traces;
}
if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
return [];
}
// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$traces = array_diff_key($stack, $trace);
return $traces;
} | [
"protected",
"function",
"getTrace",
"(",
"$",
"e",
")",
"{",
"$",
"traces",
"=",
"$",
"e",
"->",
"getTrace",
"(",
")",
";",
"// Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default",
"if",
"(",
"!",
"$",
"e",
"instanceof",
"\\",
"ErrorException",
")",
"{",
"return",
"$",
"traces",
";",
"}",
"if",
"(",
"!",
"Misc",
"::",
"isLevelFatal",
"(",
"$",
"e",
"->",
"getSeverity",
"(",
")",
")",
")",
"{",
"return",
"$",
"traces",
";",
"}",
"if",
"(",
"!",
"extension_loaded",
"(",
"'xdebug'",
")",
"||",
"!",
"xdebug_is_enabled",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// Use xdebug to get the full stack trace and remove the shutdown handler stack trace",
"$",
"stack",
"=",
"array_reverse",
"(",
"xdebug_get_function_stack",
"(",
")",
")",
";",
"$",
"trace",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
")",
";",
"$",
"traces",
"=",
"array_diff_key",
"(",
"$",
"stack",
",",
"$",
"trace",
")",
";",
"return",
"$",
"traces",
";",
"}"
]
| Gets the backtrace from an exception.
If xdebug is installed
@param \Throwable $e
@return array | [
"Gets",
"the",
"backtrace",
"from",
"an",
"exception",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Inspector.php#L241-L264 | train |
filp/whoops | src/Whoops/Handler/PrettyPageHandler.php | PrettyPageHandler.getExceptionFrames | protected function getExceptionFrames()
{
$frames = $this->getInspector()->getFrames();
if ($this->getApplicationPaths()) {
foreach ($frames as $frame) {
foreach ($this->getApplicationPaths() as $path) {
if (strpos($frame->getFile(), $path) === 0) {
$frame->setApplication(true);
break;
}
}
}
}
return $frames;
} | php | protected function getExceptionFrames()
{
$frames = $this->getInspector()->getFrames();
if ($this->getApplicationPaths()) {
foreach ($frames as $frame) {
foreach ($this->getApplicationPaths() as $path) {
if (strpos($frame->getFile(), $path) === 0) {
$frame->setApplication(true);
break;
}
}
}
}
return $frames;
} | [
"protected",
"function",
"getExceptionFrames",
"(",
")",
"{",
"$",
"frames",
"=",
"$",
"this",
"->",
"getInspector",
"(",
")",
"->",
"getFrames",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getApplicationPaths",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"frames",
"as",
"$",
"frame",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getApplicationPaths",
"(",
")",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"frame",
"->",
"getFile",
"(",
")",
",",
"$",
"path",
")",
"===",
"0",
")",
"{",
"$",
"frame",
"->",
"setApplication",
"(",
"true",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"frames",
";",
"}"
]
| Get the stack trace frames of the exception that is currently being handled.
@return \Whoops\Exception\FrameCollection; | [
"Get",
"the",
"stack",
"trace",
"frames",
"of",
"the",
"exception",
"that",
"is",
"currently",
"being",
"handled",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PrettyPageHandler.php#L263-L279 | train |
filp/whoops | src/Whoops/Handler/PrettyPageHandler.php | PrettyPageHandler.getExceptionCode | protected function getExceptionCode()
{
$exception = $this->getException();
$code = $exception->getCode();
if ($exception instanceof \ErrorException) {
// ErrorExceptions wrap the php-error types within the 'severity' property
$code = Misc::translateErrorCode($exception->getSeverity());
}
return (string) $code;
} | php | protected function getExceptionCode()
{
$exception = $this->getException();
$code = $exception->getCode();
if ($exception instanceof \ErrorException) {
// ErrorExceptions wrap the php-error types within the 'severity' property
$code = Misc::translateErrorCode($exception->getSeverity());
}
return (string) $code;
} | [
"protected",
"function",
"getExceptionCode",
"(",
")",
"{",
"$",
"exception",
"=",
"$",
"this",
"->",
"getException",
"(",
")",
";",
"$",
"code",
"=",
"$",
"exception",
"->",
"getCode",
"(",
")",
";",
"if",
"(",
"$",
"exception",
"instanceof",
"\\",
"ErrorException",
")",
"{",
"// ErrorExceptions wrap the php-error types within the 'severity' property",
"$",
"code",
"=",
"Misc",
"::",
"translateErrorCode",
"(",
"$",
"exception",
"->",
"getSeverity",
"(",
")",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"code",
";",
"}"
]
| Get the code of the exception that is currently being handled.
@return string | [
"Get",
"the",
"code",
"of",
"the",
"exception",
"that",
"is",
"currently",
"being",
"handled",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PrettyPageHandler.php#L286-L297 | train |
filp/whoops | src/Whoops/Handler/PrettyPageHandler.php | PrettyPageHandler.handleUnconditionally | public function handleUnconditionally($value = null)
{
if (func_num_args() == 0) {
return $this->handleUnconditionally;
}
$this->handleUnconditionally = (bool) $value;
} | php | public function handleUnconditionally($value = null)
{
if (func_num_args() == 0) {
return $this->handleUnconditionally;
}
$this->handleUnconditionally = (bool) $value;
} | [
"public",
"function",
"handleUnconditionally",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"handleUnconditionally",
";",
"}",
"$",
"this",
"->",
"handleUnconditionally",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"}"
]
| Allows to disable all attempts to dynamically decide whether to
handle or return prematurely.
Set this to ensure that the handler will perform no matter what.
@param bool|null $value
@return bool|null | [
"Allows",
"to",
"disable",
"all",
"attempts",
"to",
"dynamically",
"decide",
"whether",
"to",
"handle",
"or",
"return",
"prematurely",
".",
"Set",
"this",
"to",
"ensure",
"that",
"the",
"handler",
"will",
"perform",
"no",
"matter",
"what",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PrettyPageHandler.php#L372-L379 | train |
filp/whoops | src/Whoops/Handler/PrettyPageHandler.php | PrettyPageHandler.getEditorHref | public function getEditorHref($filePath, $line)
{
$editor = $this->getEditor($filePath, $line);
if (empty($editor)) {
return false;
}
// Check that the editor is a string, and replace the
// %line and %file placeholders:
if (!isset($editor['url']) || !is_string($editor['url'])) {
throw new UnexpectedValueException(
__METHOD__ . " should always resolve to a string or a valid editor array; got something else instead."
);
}
$editor['url'] = str_replace("%line", rawurlencode($line), $editor['url']);
$editor['url'] = str_replace("%file", rawurlencode($filePath), $editor['url']);
return $editor['url'];
} | php | public function getEditorHref($filePath, $line)
{
$editor = $this->getEditor($filePath, $line);
if (empty($editor)) {
return false;
}
// Check that the editor is a string, and replace the
// %line and %file placeholders:
if (!isset($editor['url']) || !is_string($editor['url'])) {
throw new UnexpectedValueException(
__METHOD__ . " should always resolve to a string or a valid editor array; got something else instead."
);
}
$editor['url'] = str_replace("%line", rawurlencode($line), $editor['url']);
$editor['url'] = str_replace("%file", rawurlencode($filePath), $editor['url']);
return $editor['url'];
} | [
"public",
"function",
"getEditorHref",
"(",
"$",
"filePath",
",",
"$",
"line",
")",
"{",
"$",
"editor",
"=",
"$",
"this",
"->",
"getEditor",
"(",
"$",
"filePath",
",",
"$",
"line",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"editor",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Check that the editor is a string, and replace the",
"// %line and %file placeholders:",
"if",
"(",
"!",
"isset",
"(",
"$",
"editor",
"[",
"'url'",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"editor",
"[",
"'url'",
"]",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"__METHOD__",
".",
"\" should always resolve to a string or a valid editor array; got something else instead.\"",
")",
";",
"}",
"$",
"editor",
"[",
"'url'",
"]",
"=",
"str_replace",
"(",
"\"%line\"",
",",
"rawurlencode",
"(",
"$",
"line",
")",
",",
"$",
"editor",
"[",
"'url'",
"]",
")",
";",
"$",
"editor",
"[",
"'url'",
"]",
"=",
"str_replace",
"(",
"\"%file\"",
",",
"rawurlencode",
"(",
"$",
"filePath",
")",
",",
"$",
"editor",
"[",
"'url'",
"]",
")",
";",
"return",
"$",
"editor",
"[",
"'url'",
"]",
";",
"}"
]
| Given a string file path, and an integer file line,
executes the editor resolver and returns, if available,
a string that may be used as the href property for that
file reference.
@throws InvalidArgumentException If editor resolver does not return a string
@param string $filePath
@param int $line
@return string|bool | [
"Given",
"a",
"string",
"file",
"path",
"and",
"an",
"integer",
"file",
"line",
"executes",
"the",
"editor",
"resolver",
"and",
"returns",
"if",
"available",
"a",
"string",
"that",
"may",
"be",
"used",
"as",
"the",
"href",
"property",
"for",
"that",
"file",
"reference",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PrettyPageHandler.php#L439-L459 | train |
filp/whoops | src/Whoops/Handler/PrettyPageHandler.php | PrettyPageHandler.getResource | protected function getResource($resource)
{
// If the resource was found before, we can speed things up
// by caching its absolute, resolved path:
if (isset($this->resourceCache[$resource])) {
return $this->resourceCache[$resource];
}
// Search through available search paths, until we find the
// resource we're after:
foreach ($this->searchPaths as $path) {
$fullPath = $path . "/$resource";
if (is_file($fullPath)) {
// Cache the result:
$this->resourceCache[$resource] = $fullPath;
return $fullPath;
}
}
// If we got this far, nothing was found.
throw new RuntimeException(
"Could not find resource '$resource' in any resource paths."
. "(searched: " . join(", ", $this->searchPaths). ")"
);
} | php | protected function getResource($resource)
{
// If the resource was found before, we can speed things up
// by caching its absolute, resolved path:
if (isset($this->resourceCache[$resource])) {
return $this->resourceCache[$resource];
}
// Search through available search paths, until we find the
// resource we're after:
foreach ($this->searchPaths as $path) {
$fullPath = $path . "/$resource";
if (is_file($fullPath)) {
// Cache the result:
$this->resourceCache[$resource] = $fullPath;
return $fullPath;
}
}
// If we got this far, nothing was found.
throw new RuntimeException(
"Could not find resource '$resource' in any resource paths."
. "(searched: " . join(", ", $this->searchPaths). ")"
);
} | [
"protected",
"function",
"getResource",
"(",
"$",
"resource",
")",
"{",
"// If the resource was found before, we can speed things up",
"// by caching its absolute, resolved path:",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"resourceCache",
"[",
"$",
"resource",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resourceCache",
"[",
"$",
"resource",
"]",
";",
"}",
"// Search through available search paths, until we find the",
"// resource we're after:",
"foreach",
"(",
"$",
"this",
"->",
"searchPaths",
"as",
"$",
"path",
")",
"{",
"$",
"fullPath",
"=",
"$",
"path",
".",
"\"/$resource\"",
";",
"if",
"(",
"is_file",
"(",
"$",
"fullPath",
")",
")",
"{",
"// Cache the result:",
"$",
"this",
"->",
"resourceCache",
"[",
"$",
"resource",
"]",
"=",
"$",
"fullPath",
";",
"return",
"$",
"fullPath",
";",
"}",
"}",
"// If we got this far, nothing was found.",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not find resource '$resource' in any resource paths.\"",
".",
"\"(searched: \"",
".",
"join",
"(",
"\", \"",
",",
"$",
"this",
"->",
"searchPaths",
")",
".",
"\")\"",
")",
";",
"}"
]
| Finds a resource, by its relative path, in all available search paths.
The search is performed starting at the last search path, and all the
way back to the first, enabling a cascading-type system of overrides
for all resources.
@throws RuntimeException If resource cannot be found in any of the available paths
@param string $resource
@return string | [
"Finds",
"a",
"resource",
"by",
"its",
"relative",
"path",
"in",
"all",
"available",
"search",
"paths",
".",
"The",
"search",
"is",
"performed",
"starting",
"at",
"the",
"last",
"search",
"path",
"and",
"all",
"the",
"way",
"back",
"to",
"the",
"first",
"enabling",
"a",
"cascading",
"-",
"type",
"system",
"of",
"overrides",
"for",
"all",
"resources",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PrettyPageHandler.php#L600-L625 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.setLogger | public function setLogger($logger = null)
{
if (! (is_null($logger)
|| $logger instanceof LoggerInterface)) {
throw new InvalidArgumentException(
'Argument to ' . __METHOD__ .
" must be a valid Logger Interface (aka. Monolog), " .
get_class($logger) . ' given.'
);
}
$this->logger = $logger;
} | php | public function setLogger($logger = null)
{
if (! (is_null($logger)
|| $logger instanceof LoggerInterface)) {
throw new InvalidArgumentException(
'Argument to ' . __METHOD__ .
" must be a valid Logger Interface (aka. Monolog), " .
get_class($logger) . ' given.'
);
}
$this->logger = $logger;
} | [
"public",
"function",
"setLogger",
"(",
"$",
"logger",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"is_null",
"(",
"$",
"logger",
")",
"||",
"$",
"logger",
"instanceof",
"LoggerInterface",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Argument to '",
".",
"__METHOD__",
".",
"\" must be a valid Logger Interface (aka. Monolog), \"",
".",
"get_class",
"(",
"$",
"logger",
")",
".",
"' given.'",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"=",
"$",
"logger",
";",
"}"
]
| Set the output logger interface.
@throws InvalidArgumentException If argument is not null or a LoggerInterface
@param \Psr\Log\LoggerInterface|null $logger | [
"Set",
"the",
"output",
"logger",
"interface",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L69-L81 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.addTraceToOutput | public function addTraceToOutput($addTraceToOutput = null)
{
if (func_num_args() == 0) {
return $this->addTraceToOutput;
}
$this->addTraceToOutput = (bool) $addTraceToOutput;
return $this;
} | php | public function addTraceToOutput($addTraceToOutput = null)
{
if (func_num_args() == 0) {
return $this->addTraceToOutput;
}
$this->addTraceToOutput = (bool) $addTraceToOutput;
return $this;
} | [
"public",
"function",
"addTraceToOutput",
"(",
"$",
"addTraceToOutput",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"addTraceToOutput",
";",
"}",
"$",
"this",
"->",
"addTraceToOutput",
"=",
"(",
"bool",
")",
"$",
"addTraceToOutput",
";",
"return",
"$",
"this",
";",
"}"
]
| Add error trace to output.
@param bool|null $addTraceToOutput
@return bool|$this | [
"Add",
"error",
"trace",
"to",
"output",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L107-L115 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.addTraceFunctionArgsToOutput | public function addTraceFunctionArgsToOutput($addTraceFunctionArgsToOutput = null)
{
if (func_num_args() == 0) {
return $this->addTraceFunctionArgsToOutput;
}
if (! is_integer($addTraceFunctionArgsToOutput)) {
$this->addTraceFunctionArgsToOutput = (bool) $addTraceFunctionArgsToOutput;
} else {
$this->addTraceFunctionArgsToOutput = $addTraceFunctionArgsToOutput;
}
} | php | public function addTraceFunctionArgsToOutput($addTraceFunctionArgsToOutput = null)
{
if (func_num_args() == 0) {
return $this->addTraceFunctionArgsToOutput;
}
if (! is_integer($addTraceFunctionArgsToOutput)) {
$this->addTraceFunctionArgsToOutput = (bool) $addTraceFunctionArgsToOutput;
} else {
$this->addTraceFunctionArgsToOutput = $addTraceFunctionArgsToOutput;
}
} | [
"public",
"function",
"addTraceFunctionArgsToOutput",
"(",
"$",
"addTraceFunctionArgsToOutput",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"addTraceFunctionArgsToOutput",
";",
"}",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"addTraceFunctionArgsToOutput",
")",
")",
"{",
"$",
"this",
"->",
"addTraceFunctionArgsToOutput",
"=",
"(",
"bool",
")",
"$",
"addTraceFunctionArgsToOutput",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addTraceFunctionArgsToOutput",
"=",
"$",
"addTraceFunctionArgsToOutput",
";",
"}",
"}"
]
| Add error trace function arguments to output.
Set to True for all frame args, or integer for the n first frame args.
@param bool|integer|null $addTraceFunctionArgsToOutput
@return null|bool|integer | [
"Add",
"error",
"trace",
"function",
"arguments",
"to",
"output",
".",
"Set",
"to",
"True",
"for",
"all",
"frame",
"args",
"or",
"integer",
"for",
"the",
"n",
"first",
"frame",
"args",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L123-L134 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.generateResponse | public function generateResponse()
{
$exception = $this->getException();
return sprintf(
"%s: %s in file %s on line %d%s\n",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$this->getTraceOutput()
);
} | php | public function generateResponse()
{
$exception = $this->getException();
return sprintf(
"%s: %s in file %s on line %d%s\n",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$this->getTraceOutput()
);
} | [
"public",
"function",
"generateResponse",
"(",
")",
"{",
"$",
"exception",
"=",
"$",
"this",
"->",
"getException",
"(",
")",
";",
"return",
"sprintf",
"(",
"\"%s: %s in file %s on line %d%s\\n\"",
",",
"get_class",
"(",
"$",
"exception",
")",
",",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"$",
"exception",
"->",
"getLine",
"(",
")",
",",
"$",
"this",
"->",
"getTraceOutput",
"(",
")",
")",
";",
"}"
]
| Create plain text response and return it as a string
@return string | [
"Create",
"plain",
"text",
"response",
"and",
"return",
"it",
"as",
"a",
"string"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L151-L162 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.loggerOnly | public function loggerOnly($loggerOnly = null)
{
if (func_num_args() == 0) {
return $this->loggerOnly;
}
$this->loggerOnly = (bool) $loggerOnly;
} | php | public function loggerOnly($loggerOnly = null)
{
if (func_num_args() == 0) {
return $this->loggerOnly;
}
$this->loggerOnly = (bool) $loggerOnly;
} | [
"public",
"function",
"loggerOnly",
"(",
"$",
"loggerOnly",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"loggerOnly",
";",
"}",
"$",
"this",
"->",
"loggerOnly",
"=",
"(",
"bool",
")",
"$",
"loggerOnly",
";",
"}"
]
| Only output to logger.
@param bool|null $loggerOnly
@return null|bool | [
"Only",
"output",
"to",
"logger",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L180-L187 | train |
filp/whoops | src/Whoops/Handler/PlainTextHandler.php | PlainTextHandler.getTraceOutput | private function getTraceOutput()
{
if (! $this->addTraceToOutput()) {
return '';
}
$inspector = $this->getInspector();
$frames = $inspector->getFrames();
$response = "\nStack trace:";
$line = 1;
foreach ($frames as $frame) {
/** @var Frame $frame */
$class = $frame->getClass();
$template = "\n%3d. %s->%s() %s:%d%s";
if (! $class) {
// Remove method arrow (->) from output.
$template = "\n%3d. %s%s() %s:%d%s";
}
$response .= sprintf(
$template,
$line,
$class,
$frame->getFunction(),
$frame->getFile(),
$frame->getLine(),
$this->getFrameArgsOutput($frame, $line)
);
$line++;
}
return $response;
} | php | private function getTraceOutput()
{
if (! $this->addTraceToOutput()) {
return '';
}
$inspector = $this->getInspector();
$frames = $inspector->getFrames();
$response = "\nStack trace:";
$line = 1;
foreach ($frames as $frame) {
/** @var Frame $frame */
$class = $frame->getClass();
$template = "\n%3d. %s->%s() %s:%d%s";
if (! $class) {
// Remove method arrow (->) from output.
$template = "\n%3d. %s%s() %s:%d%s";
}
$response .= sprintf(
$template,
$line,
$class,
$frame->getFunction(),
$frame->getFile(),
$frame->getLine(),
$this->getFrameArgsOutput($frame, $line)
);
$line++;
}
return $response;
} | [
"private",
"function",
"getTraceOutput",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"addTraceToOutput",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"inspector",
"=",
"$",
"this",
"->",
"getInspector",
"(",
")",
";",
"$",
"frames",
"=",
"$",
"inspector",
"->",
"getFrames",
"(",
")",
";",
"$",
"response",
"=",
"\"\\nStack trace:\"",
";",
"$",
"line",
"=",
"1",
";",
"foreach",
"(",
"$",
"frames",
"as",
"$",
"frame",
")",
"{",
"/** @var Frame $frame */",
"$",
"class",
"=",
"$",
"frame",
"->",
"getClass",
"(",
")",
";",
"$",
"template",
"=",
"\"\\n%3d. %s->%s() %s:%d%s\"",
";",
"if",
"(",
"!",
"$",
"class",
")",
"{",
"// Remove method arrow (->) from output.",
"$",
"template",
"=",
"\"\\n%3d. %s%s() %s:%d%s\"",
";",
"}",
"$",
"response",
".=",
"sprintf",
"(",
"$",
"template",
",",
"$",
"line",
",",
"$",
"class",
",",
"$",
"frame",
"->",
"getFunction",
"(",
")",
",",
"$",
"frame",
"->",
"getFile",
"(",
")",
",",
"$",
"frame",
"->",
"getLine",
"(",
")",
",",
"$",
"this",
"->",
"getFrameArgsOutput",
"(",
"$",
"frame",
",",
"$",
"line",
")",
")",
";",
"$",
"line",
"++",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Get the exception trace as plain text.
@return string | [
"Get",
"the",
"exception",
"trace",
"as",
"plain",
"text",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Handler/PlainTextHandler.php#L250-L285 | train |
filp/whoops | src/Whoops/Exception/FrameCollection.php | FrameCollection.map | public function map($callable)
{
// Contain the map within a higher-order callable
// that enforces type-correctness for the $callable
$this->frames = array_map(function ($frame) use ($callable) {
$frame = call_user_func($callable, $frame);
if (!$frame instanceof Frame) {
throw new UnexpectedValueException(
"Callable to " . __METHOD__ . " must return a Frame object"
);
}
return $frame;
}, $this->frames);
return $this;
} | php | public function map($callable)
{
// Contain the map within a higher-order callable
// that enforces type-correctness for the $callable
$this->frames = array_map(function ($frame) use ($callable) {
$frame = call_user_func($callable, $frame);
if (!$frame instanceof Frame) {
throw new UnexpectedValueException(
"Callable to " . __METHOD__ . " must return a Frame object"
);
}
return $frame;
}, $this->frames);
return $this;
} | [
"public",
"function",
"map",
"(",
"$",
"callable",
")",
"{",
"// Contain the map within a higher-order callable",
"// that enforces type-correctness for the $callable",
"$",
"this",
"->",
"frames",
"=",
"array_map",
"(",
"function",
"(",
"$",
"frame",
")",
"use",
"(",
"$",
"callable",
")",
"{",
"$",
"frame",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"frame",
")",
";",
"if",
"(",
"!",
"$",
"frame",
"instanceof",
"Frame",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Callable to \"",
".",
"__METHOD__",
".",
"\" must return a Frame object\"",
")",
";",
"}",
"return",
"$",
"frame",
";",
"}",
",",
"$",
"this",
"->",
"frames",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Map the collection of frames
@param callable $callable
@return FrameCollection | [
"Map",
"the",
"collection",
"of",
"frames"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/FrameCollection.php#L55-L72 | train |
filp/whoops | src/Whoops/Exception/FrameCollection.php | FrameCollection.topDiff | public function topDiff(FrameCollection $parentFrames)
{
$diff = $this->frames;
$parentFrames = $parentFrames->getArray();
$p = count($parentFrames)-1;
for ($i = count($diff)-1; $i >= 0 && $p >= 0; $i--) {
/** @var Frame $tailFrame */
$tailFrame = $diff[$i];
if ($tailFrame->equals($parentFrames[$p])) {
unset($diff[$i]);
}
$p--;
}
return $diff;
} | php | public function topDiff(FrameCollection $parentFrames)
{
$diff = $this->frames;
$parentFrames = $parentFrames->getArray();
$p = count($parentFrames)-1;
for ($i = count($diff)-1; $i >= 0 && $p >= 0; $i--) {
/** @var Frame $tailFrame */
$tailFrame = $diff[$i];
if ($tailFrame->equals($parentFrames[$p])) {
unset($diff[$i]);
}
$p--;
}
return $diff;
} | [
"public",
"function",
"topDiff",
"(",
"FrameCollection",
"$",
"parentFrames",
")",
"{",
"$",
"diff",
"=",
"$",
"this",
"->",
"frames",
";",
"$",
"parentFrames",
"=",
"$",
"parentFrames",
"->",
"getArray",
"(",
")",
";",
"$",
"p",
"=",
"count",
"(",
"$",
"parentFrames",
")",
"-",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"diff",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
"&&",
"$",
"p",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"/** @var Frame $tailFrame */",
"$",
"tailFrame",
"=",
"$",
"diff",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"tailFrame",
"->",
"equals",
"(",
"$",
"parentFrames",
"[",
"$",
"p",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"diff",
"[",
"$",
"i",
"]",
")",
";",
"}",
"$",
"p",
"--",
";",
"}",
"return",
"$",
"diff",
";",
"}"
]
| Gets the innermost part of stack trace that is not the same as that of outer exception
@param FrameCollection $parentFrames Outer exception frames to compare tail against
@return Frame[] | [
"Gets",
"the",
"innermost",
"part",
"of",
"stack",
"trace",
"that",
"is",
"not",
"the",
"same",
"as",
"that",
"of",
"outer",
"exception"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/FrameCollection.php#L186-L202 | train |
filp/whoops | src/Whoops/Exception/Frame.php | Frame.getComments | public function getComments($filter = null)
{
$comments = $this->comments;
if ($filter !== null) {
$comments = array_filter($comments, function ($c) use ($filter) {
return $c['context'] == $filter;
});
}
return $comments;
} | php | public function getComments($filter = null)
{
$comments = $this->comments;
if ($filter !== null) {
$comments = array_filter($comments, function ($c) use ($filter) {
return $c['context'] == $filter;
});
}
return $comments;
} | [
"public",
"function",
"getComments",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"comments",
"=",
"$",
"this",
"->",
"comments",
";",
"if",
"(",
"$",
"filter",
"!==",
"null",
")",
"{",
"$",
"comments",
"=",
"array_filter",
"(",
"$",
"comments",
",",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"filter",
")",
"{",
"return",
"$",
"c",
"[",
"'context'",
"]",
"==",
"$",
"filter",
";",
"}",
")",
";",
"}",
"return",
"$",
"comments",
";",
"}"
]
| Returns all comments for this frame. Optionally allows
a filter to only retrieve comments from a specific
context.
@param string $filter
@return array[] | [
"Returns",
"all",
"comments",
"for",
"this",
"frame",
".",
"Optionally",
"allows",
"a",
"filter",
"to",
"only",
"retrieve",
"comments",
"from",
"a",
"specific",
"context",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Frame.php#L155-L166 | train |
filp/whoops | src/Whoops/Exception/Frame.php | Frame.getFileLines | public function getFileLines($start = 0, $length = null)
{
if (null !== ($contents = $this->getFileContents())) {
$lines = explode("\n", $contents);
// Get a subset of lines from $start to $end
if ($length !== null) {
$start = (int) $start;
$length = (int) $length;
if ($start < 0) {
$start = 0;
}
if ($length <= 0) {
throw new InvalidArgumentException(
"\$length($length) cannot be lower or equal to 0"
);
}
$lines = array_slice($lines, $start, $length, true);
}
return $lines;
}
} | php | public function getFileLines($start = 0, $length = null)
{
if (null !== ($contents = $this->getFileContents())) {
$lines = explode("\n", $contents);
// Get a subset of lines from $start to $end
if ($length !== null) {
$start = (int) $start;
$length = (int) $length;
if ($start < 0) {
$start = 0;
}
if ($length <= 0) {
throw new InvalidArgumentException(
"\$length($length) cannot be lower or equal to 0"
);
}
$lines = array_slice($lines, $start, $length, true);
}
return $lines;
}
} | [
"public",
"function",
"getFileLines",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"contents",
"=",
"$",
"this",
"->",
"getFileContents",
"(",
")",
")",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"contents",
")",
";",
"// Get a subset of lines from $start to $end",
"if",
"(",
"$",
"length",
"!==",
"null",
")",
"{",
"$",
"start",
"=",
"(",
"int",
")",
"$",
"start",
";",
"$",
"length",
"=",
"(",
"int",
")",
"$",
"length",
";",
"if",
"(",
"$",
"start",
"<",
"0",
")",
"{",
"$",
"start",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"length",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"\\$length($length) cannot be lower or equal to 0\"",
")",
";",
"}",
"$",
"lines",
"=",
"array_slice",
"(",
"$",
"lines",
",",
"$",
"start",
",",
"$",
"length",
",",
"true",
")",
";",
"}",
"return",
"$",
"lines",
";",
"}",
"}"
]
| Returns the contents of the file for this frame as an
array of lines, and optionally as a clamped range of lines.
NOTE: lines are 0-indexed
@example
Get all lines for this file
$frame->getFileLines(); // => array( 0 => '<?php', 1 => '...', ...)
@example
Get one line for this file, starting at line 10 (zero-indexed, remember!)
$frame->getFileLines(9, 1); // array( 10 => '...', 11 => '...')
@throws InvalidArgumentException if $length is less than or equal to 0
@param int $start
@param int $length
@return string[]|null | [
"Returns",
"the",
"contents",
"of",
"the",
"file",
"for",
"this",
"frame",
"as",
"an",
"array",
"of",
"lines",
"and",
"optionally",
"as",
"a",
"clamped",
"range",
"of",
"lines",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Frame.php#L197-L221 | train |
filp/whoops | src/Whoops/Exception/Frame.php | Frame.serialize | public function serialize()
{
$frame = $this->frame;
if (!empty($this->comments)) {
$frame['_comments'] = $this->comments;
}
return serialize($frame);
} | php | public function serialize()
{
$frame = $this->frame;
if (!empty($this->comments)) {
$frame['_comments'] = $this->comments;
}
return serialize($frame);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"frame",
"=",
"$",
"this",
"->",
"frame",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"comments",
")",
")",
"{",
"$",
"frame",
"[",
"'_comments'",
"]",
"=",
"$",
"this",
"->",
"comments",
";",
"}",
"return",
"serialize",
"(",
"$",
"frame",
")",
";",
"}"
]
| Implements the Serializable interface, with special
steps to also save the existing comments.
@see Serializable::serialize
@return string | [
"Implements",
"the",
"Serializable",
"interface",
"with",
"special",
"steps",
"to",
"also",
"save",
"the",
"existing",
"comments",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Frame.php#L230-L238 | train |
filp/whoops | src/Whoops/Exception/Frame.php | Frame.unserialize | public function unserialize($serializedFrame)
{
$frame = unserialize($serializedFrame);
if (!empty($frame['_comments'])) {
$this->comments = $frame['_comments'];
unset($frame['_comments']);
}
$this->frame = $frame;
} | php | public function unserialize($serializedFrame)
{
$frame = unserialize($serializedFrame);
if (!empty($frame['_comments'])) {
$this->comments = $frame['_comments'];
unset($frame['_comments']);
}
$this->frame = $frame;
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serializedFrame",
")",
"{",
"$",
"frame",
"=",
"unserialize",
"(",
"$",
"serializedFrame",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"frame",
"[",
"'_comments'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"comments",
"=",
"$",
"frame",
"[",
"'_comments'",
"]",
";",
"unset",
"(",
"$",
"frame",
"[",
"'_comments'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"frame",
"=",
"$",
"frame",
";",
"}"
]
| Unserializes the frame data, while also preserving
any existing comment data.
@see Serializable::unserialize
@param string $serializedFrame | [
"Unserializes",
"the",
"frame",
"data",
"while",
"also",
"preserving",
"any",
"existing",
"comment",
"data",
"."
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Frame.php#L247-L257 | train |
filp/whoops | src/Whoops/Exception/Frame.php | Frame.equals | public function equals(Frame $frame)
{
if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
return false;
}
return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
} | php | public function equals(Frame $frame)
{
if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
return false;
}
return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
} | [
"public",
"function",
"equals",
"(",
"Frame",
"$",
"frame",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getFile",
"(",
")",
"||",
"$",
"this",
"->",
"getFile",
"(",
")",
"===",
"'Unknown'",
"||",
"!",
"$",
"this",
"->",
"getLine",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"frame",
"->",
"getFile",
"(",
")",
"===",
"$",
"this",
"->",
"getFile",
"(",
")",
"&&",
"$",
"frame",
"->",
"getLine",
"(",
")",
"===",
"$",
"this",
"->",
"getLine",
"(",
")",
";",
"}"
]
| Compares Frame against one another
@param Frame $frame
@return bool | [
"Compares",
"Frame",
"against",
"one",
"another"
]
| 2583ec09af009d02d20d3d14591359c6c48ae960 | https://github.com/filp/whoops/blob/2583ec09af009d02d20d3d14591359c6c48ae960/src/Whoops/Exception/Frame.php#L264-L270 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php | SQLServerSchemaManager.getColumnConstraintSQL | private function getColumnConstraintSQL($table, $column)
{
return "SELECT SysObjects.[Name]
FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab
ON Tab.[ID] = Sysobjects.[Parent_Obj]
INNER JOIN sys.default_constraints DefCons ON DefCons.[object_id] = Sysobjects.[ID]
INNER JOIN SysColumns Col ON Col.[ColID] = DefCons.[parent_column_id] AND Col.[ID] = Tab.[ID]
WHERE Col.[Name] = " . $this->_conn->quote($column) . ' AND Tab.[Name] = ' . $this->_conn->quote($table) . '
ORDER BY Col.[Name]';
} | php | private function getColumnConstraintSQL($table, $column)
{
return "SELECT SysObjects.[Name]
FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab
ON Tab.[ID] = Sysobjects.[Parent_Obj]
INNER JOIN sys.default_constraints DefCons ON DefCons.[object_id] = Sysobjects.[ID]
INNER JOIN SysColumns Col ON Col.[ColID] = DefCons.[parent_column_id] AND Col.[ID] = Tab.[ID]
WHERE Col.[Name] = " . $this->_conn->quote($column) . ' AND Tab.[Name] = ' . $this->_conn->quote($table) . '
ORDER BY Col.[Name]';
} | [
"private",
"function",
"getColumnConstraintSQL",
"(",
"$",
"table",
",",
"$",
"column",
")",
"{",
"return",
"\"SELECT SysObjects.[Name]\n FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab\n ON Tab.[ID] = Sysobjects.[Parent_Obj]\n INNER JOIN sys.default_constraints DefCons ON DefCons.[object_id] = Sysobjects.[ID]\n INNER JOIN SysColumns Col ON Col.[ColID] = DefCons.[parent_column_id] AND Col.[ID] = Tab.[ID]\n WHERE Col.[Name] = \"",
".",
"$",
"this",
"->",
"_conn",
"->",
"quote",
"(",
"$",
"column",
")",
".",
"' AND Tab.[Name] = '",
".",
"$",
"this",
"->",
"_conn",
"->",
"quote",
"(",
"$",
"table",
")",
".",
"'\n ORDER BY Col.[Name]'",
";",
"}"
]
| Returns the SQL to retrieve the constraints for a given column.
@param string $table
@param string $column
@return string | [
"Returns",
"the",
"SQL",
"to",
"retrieve",
"the",
"constraints",
"for",
"a",
"given",
"column",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php#L297-L306 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php | SQLServerSchemaManager.closeActiveDatabaseConnections | private function closeActiveDatabaseConnections($database)
{
$database = new Identifier($database);
$this->_execSql(
sprintf(
'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE',
$database->getQuotedName($this->_platform)
)
);
} | php | private function closeActiveDatabaseConnections($database)
{
$database = new Identifier($database);
$this->_execSql(
sprintf(
'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE',
$database->getQuotedName($this->_platform)
)
);
} | [
"private",
"function",
"closeActiveDatabaseConnections",
"(",
"$",
"database",
")",
"{",
"$",
"database",
"=",
"new",
"Identifier",
"(",
"$",
"database",
")",
";",
"$",
"this",
"->",
"_execSql",
"(",
"sprintf",
"(",
"'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE'",
",",
"$",
"database",
"->",
"getQuotedName",
"(",
"$",
"this",
"->",
"_platform",
")",
")",
")",
";",
"}"
]
| Closes currently active connections on the given database.
This is useful to force DROP DATABASE operations which could fail because of active connections.
@param string $database The name of the database to close currently active connections for.
@return void | [
"Closes",
"currently",
"active",
"connections",
"on",
"the",
"given",
"database",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php#L317-L327 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.getSQL | public function getSQL()
{
if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
return $this->sql;
}
switch ($this->type) {
case self::INSERT:
$sql = $this->getSQLForInsert();
break;
case self::DELETE:
$sql = $this->getSQLForDelete();
break;
case self::UPDATE:
$sql = $this->getSQLForUpdate();
break;
case self::SELECT:
default:
$sql = $this->getSQLForSelect();
break;
}
$this->state = self::STATE_CLEAN;
$this->sql = $sql;
return $sql;
} | php | public function getSQL()
{
if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
return $this->sql;
}
switch ($this->type) {
case self::INSERT:
$sql = $this->getSQLForInsert();
break;
case self::DELETE:
$sql = $this->getSQLForDelete();
break;
case self::UPDATE:
$sql = $this->getSQLForUpdate();
break;
case self::SELECT:
default:
$sql = $this->getSQLForSelect();
break;
}
$this->state = self::STATE_CLEAN;
$this->sql = $sql;
return $sql;
} | [
"public",
"function",
"getSQL",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sql",
"!==",
"null",
"&&",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_CLEAN",
")",
"{",
"return",
"$",
"this",
"->",
"sql",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"INSERT",
":",
"$",
"sql",
"=",
"$",
"this",
"->",
"getSQLForInsert",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"DELETE",
":",
"$",
"sql",
"=",
"$",
"this",
"->",
"getSQLForDelete",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"UPDATE",
":",
"$",
"sql",
"=",
"$",
"this",
"->",
"getSQLForUpdate",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"SELECT",
":",
"default",
":",
"$",
"sql",
"=",
"$",
"this",
"->",
"getSQLForSelect",
"(",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_CLEAN",
";",
"$",
"this",
"->",
"sql",
"=",
"$",
"sql",
";",
"return",
"$",
"sql",
";",
"}"
]
| Gets the complete SQL string formed by the current specifications of this QueryBuilder.
<code>
$qb = $em->createQueryBuilder()
->select('u')
->from('User', 'u')
echo $qb->getSQL(); // SELECT u FROM User u
</code>
@return string The SQL query string. | [
"Gets",
"the",
"complete",
"SQL",
"string",
"formed",
"by",
"the",
"current",
"specifications",
"of",
"this",
"QueryBuilder",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L218-L246 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.setParameter | public function setParameter($key, $value, $type = null)
{
if ($type !== null) {
$this->paramTypes[$key] = $type;
}
$this->params[$key] = $value;
return $this;
} | php | public function setParameter($key, $value, $type = null)
{
if ($type !== null) {
$this->paramTypes[$key] = $type;
}
$this->params[$key] = $value;
return $this;
} | [
"public",
"function",
"setParameter",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"paramTypes",
"[",
"$",
"key",
"]",
"=",
"$",
"type",
";",
"}",
"$",
"this",
"->",
"params",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets a query parameter for the query being constructed.
<code>
$qb = $conn->createQueryBuilder()
->select('u')
->from('users', 'u')
->where('u.id = :user_id')
->setParameter(':user_id', 1);
</code>
@param string|int $key The parameter position or name.
@param mixed $value The parameter value.
@param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
@return $this This QueryBuilder instance. | [
"Sets",
"a",
"query",
"parameter",
"for",
"the",
"query",
"being",
"constructed",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L265-L274 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.setParameters | public function setParameters(array $params, array $types = [])
{
$this->paramTypes = $types;
$this->params = $params;
return $this;
} | php | public function setParameters(array $params, array $types = [])
{
$this->paramTypes = $types;
$this->params = $params;
return $this;
} | [
"public",
"function",
"setParameters",
"(",
"array",
"$",
"params",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"paramTypes",
"=",
"$",
"types",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets a collection of query parameters for the query being constructed.
<code>
$qb = $conn->createQueryBuilder()
->select('u')
->from('users', 'u')
->where('u.id = :user_id1 OR u.id = :user_id2')
->setParameters(array(
':user_id1' => 1,
':user_id2' => 2
));
</code>
@param mixed[] $params The query parameters to set.
@param int[]|string[] $types The query parameters types to set.
@return $this This QueryBuilder instance. | [
"Sets",
"a",
"collection",
"of",
"query",
"parameters",
"for",
"the",
"query",
"being",
"constructed",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L295-L301 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.groupBy | public function groupBy($groupBy)
{
if (empty($groupBy)) {
return $this;
}
$groupBy = is_array($groupBy) ? $groupBy : func_get_args();
return $this->add('groupBy', $groupBy, false);
} | php | public function groupBy($groupBy)
{
if (empty($groupBy)) {
return $this;
}
$groupBy = is_array($groupBy) ? $groupBy : func_get_args();
return $this->add('groupBy', $groupBy, false);
} | [
"public",
"function",
"groupBy",
"(",
"$",
"groupBy",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"groupBy",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"groupBy",
"=",
"is_array",
"(",
"$",
"groupBy",
")",
"?",
"$",
"groupBy",
":",
"func_get_args",
"(",
")",
";",
"return",
"$",
"this",
"->",
"add",
"(",
"'groupBy'",
",",
"$",
"groupBy",
",",
"false",
")",
";",
"}"
]
| Specifies a grouping over the results of the query.
Replaces any previously specified groupings, if any.
<code>
$qb = $conn->createQueryBuilder()
->select('u.name')
->from('users', 'u')
->groupBy('u.id');
</code>
@param mixed $groupBy The grouping expression.
@return $this This QueryBuilder instance. | [
"Specifies",
"a",
"grouping",
"over",
"the",
"results",
"of",
"the",
"query",
".",
"Replaces",
"any",
"previously",
"specified",
"groupings",
"if",
"any",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L858-L867 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.getSQLForInsert | private function getSQLForInsert()
{
return 'INSERT INTO ' . $this->sqlParts['from']['table'] .
' (' . implode(', ', array_keys($this->sqlParts['values'])) . ')' .
' VALUES(' . implode(', ', $this->sqlParts['values']) . ')';
} | php | private function getSQLForInsert()
{
return 'INSERT INTO ' . $this->sqlParts['from']['table'] .
' (' . implode(', ', array_keys($this->sqlParts['values'])) . ')' .
' VALUES(' . implode(', ', $this->sqlParts['values']) . ')';
} | [
"private",
"function",
"getSQLForInsert",
"(",
")",
"{",
"return",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"sqlParts",
"[",
"'from'",
"]",
"[",
"'table'",
"]",
".",
"' ('",
".",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"this",
"->",
"sqlParts",
"[",
"'values'",
"]",
")",
")",
".",
"')'",
".",
"' VALUES('",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"sqlParts",
"[",
"'values'",
"]",
")",
".",
"')'",
";",
"}"
]
| Converts this instance into an INSERT string in SQL.
@return string | [
"Converts",
"this",
"instance",
"into",
"an",
"INSERT",
"string",
"in",
"SQL",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L1175-L1180 | train |
doctrine/dbal | lib/Doctrine/DBAL/Query/QueryBuilder.php | QueryBuilder.createPositionalParameter | public function createPositionalParameter($value, $type = ParameterType::STRING)
{
$this->boundCounter++;
$this->setParameter($this->boundCounter, $value, $type);
return '?';
} | php | public function createPositionalParameter($value, $type = ParameterType::STRING)
{
$this->boundCounter++;
$this->setParameter($this->boundCounter, $value, $type);
return '?';
} | [
"public",
"function",
"createPositionalParameter",
"(",
"$",
"value",
",",
"$",
"type",
"=",
"ParameterType",
"::",
"STRING",
")",
"{",
"$",
"this",
"->",
"boundCounter",
"++",
";",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"this",
"->",
"boundCounter",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"return",
"'?'",
";",
"}"
]
| Creates a new positional parameter and bind the given value to it.
Attention: If you are using positional parameters with the query builder you have
to be very careful to bind all parameters in the order they appear in the SQL
statement , otherwise they get bound in the wrong order which can lead to serious
bugs in your code.
Example:
<code>
$qb = $conn->createQueryBuilder();
$qb->select('u.*')
->from('users', 'u')
->where('u.username = ' . $qb->createPositionalParameter('Foo', ParameterType::STRING))
->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', ParameterType::STRING))
</code>
@param mixed $value
@param int $type
@return string | [
"Creates",
"a",
"new",
"positional",
"parameter",
"and",
"bind",
"the",
"given",
"value",
"to",
"it",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L1280-L1286 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | Driver._constructPdoDsn | protected function _constructPdoDsn(array $params)
{
$dsn = 'sqlite:';
if (isset($params['path'])) {
$dsn .= $params['path'];
} elseif (isset($params['memory'])) {
$dsn .= ':memory:';
}
return $dsn;
} | php | protected function _constructPdoDsn(array $params)
{
$dsn = 'sqlite:';
if (isset($params['path'])) {
$dsn .= $params['path'];
} elseif (isset($params['memory'])) {
$dsn .= ':memory:';
}
return $dsn;
} | [
"protected",
"function",
"_constructPdoDsn",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"dsn",
"=",
"'sqlite:'",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"dsn",
".=",
"$",
"params",
"[",
"'path'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"params",
"[",
"'memory'",
"]",
")",
")",
"{",
"$",
"dsn",
".=",
"':memory:'",
";",
"}",
"return",
"$",
"dsn",
";",
"}"
]
| Constructs the Sqlite PDO DSN.
@param mixed[] $params
@return string The DSN. | [
"Constructs",
"the",
"Sqlite",
"PDO",
"DSN",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php#L62-L72 | train |
doctrine/dbal | lib/Doctrine/DBAL/SQLParserUtils.php | SQLParserUtils.getPlaceholderPositions | public static function getPlaceholderPositions($statement, $isPositional = true)
{
return $isPositional
? self::getPositionalPlaceholderPositions($statement)
: self::getNamedPlaceholderPositions($statement);
} | php | public static function getPlaceholderPositions($statement, $isPositional = true)
{
return $isPositional
? self::getPositionalPlaceholderPositions($statement)
: self::getNamedPlaceholderPositions($statement);
} | [
"public",
"static",
"function",
"getPlaceholderPositions",
"(",
"$",
"statement",
",",
"$",
"isPositional",
"=",
"true",
")",
"{",
"return",
"$",
"isPositional",
"?",
"self",
"::",
"getPositionalPlaceholderPositions",
"(",
"$",
"statement",
")",
":",
"self",
"::",
"getNamedPlaceholderPositions",
"(",
"$",
"statement",
")",
";",
"}"
]
| Gets an array of the placeholders in an sql statements as keys and their positions in the query string.
For a statement with positional parameters, returns a zero-indexed list of placeholder position.
For a statement with named parameters, returns a map of placeholder positions to their parameter names.
@deprecated Will be removed as internal implementation detail.
@param string $statement
@param bool $isPositional
@return int[]|string[] | [
"Gets",
"an",
"array",
"of",
"the",
"placeholders",
"in",
"an",
"sql",
"statements",
"as",
"keys",
"and",
"their",
"positions",
"in",
"the",
"query",
"string",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/SQLParserUtils.php#L54-L59 | train |
doctrine/dbal | lib/Doctrine/DBAL/SQLParserUtils.php | SQLParserUtils.getPositionalPlaceholderPositions | private static function getPositionalPlaceholderPositions(string $statement) : array
{
return self::collectPlaceholders(
$statement,
'?',
self::POSITIONAL_TOKEN,
static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry) : void {
$carry[] = $placeholderPosition + $fragmentPosition;
}
);
} | php | private static function getPositionalPlaceholderPositions(string $statement) : array
{
return self::collectPlaceholders(
$statement,
'?',
self::POSITIONAL_TOKEN,
static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry) : void {
$carry[] = $placeholderPosition + $fragmentPosition;
}
);
} | [
"private",
"static",
"function",
"getPositionalPlaceholderPositions",
"(",
"string",
"$",
"statement",
")",
":",
"array",
"{",
"return",
"self",
"::",
"collectPlaceholders",
"(",
"$",
"statement",
",",
"'?'",
",",
"self",
"::",
"POSITIONAL_TOKEN",
",",
"static",
"function",
"(",
"string",
"$",
"_",
",",
"int",
"$",
"placeholderPosition",
",",
"int",
"$",
"fragmentPosition",
",",
"array",
"&",
"$",
"carry",
")",
":",
"void",
"{",
"$",
"carry",
"[",
"]",
"=",
"$",
"placeholderPosition",
"+",
"$",
"fragmentPosition",
";",
"}",
")",
";",
"}"
]
| Returns a zero-indexed list of placeholder position.
@return int[] | [
"Returns",
"a",
"zero",
"-",
"indexed",
"list",
"of",
"placeholder",
"position",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/SQLParserUtils.php#L66-L76 | train |
doctrine/dbal | lib/Doctrine/DBAL/SQLParserUtils.php | SQLParserUtils.getNamedPlaceholderPositions | private static function getNamedPlaceholderPositions(string $statement) : array
{
return self::collectPlaceholders(
$statement,
':',
self::NAMED_TOKEN,
static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry) : void {
$carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1);
}
);
} | php | private static function getNamedPlaceholderPositions(string $statement) : array
{
return self::collectPlaceholders(
$statement,
':',
self::NAMED_TOKEN,
static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry) : void {
$carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1);
}
);
} | [
"private",
"static",
"function",
"getNamedPlaceholderPositions",
"(",
"string",
"$",
"statement",
")",
":",
"array",
"{",
"return",
"self",
"::",
"collectPlaceholders",
"(",
"$",
"statement",
",",
"':'",
",",
"self",
"::",
"NAMED_TOKEN",
",",
"static",
"function",
"(",
"string",
"$",
"placeholder",
",",
"int",
"$",
"placeholderPosition",
",",
"int",
"$",
"fragmentPosition",
",",
"array",
"&",
"$",
"carry",
")",
":",
"void",
"{",
"$",
"carry",
"[",
"$",
"placeholderPosition",
"+",
"$",
"fragmentPosition",
"]",
"=",
"substr",
"(",
"$",
"placeholder",
",",
"1",
")",
";",
"}",
")",
";",
"}"
]
| Returns a map of placeholder positions to their parameter names.
@return string[] | [
"Returns",
"a",
"map",
"of",
"placeholder",
"positions",
"to",
"their",
"parameter",
"names",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/SQLParserUtils.php#L83-L93 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | PostgreSqlPlatform.isUnchangedBinaryColumn | private function isUnchangedBinaryColumn(ColumnDiff $columnDiff)
{
$columnType = $columnDiff->column->getType();
if (! $columnType instanceof BinaryType && ! $columnType instanceof BlobType) {
return false;
}
$fromColumn = $columnDiff->fromColumn instanceof Column ? $columnDiff->fromColumn : null;
if ($fromColumn) {
$fromColumnType = $fromColumn->getType();
if (! $fromColumnType instanceof BinaryType && ! $fromColumnType instanceof BlobType) {
return false;
}
return count(array_diff($columnDiff->changedProperties, ['type', 'length', 'fixed'])) === 0;
}
if ($columnDiff->hasChanged('type')) {
return false;
}
return count(array_diff($columnDiff->changedProperties, ['length', 'fixed'])) === 0;
} | php | private function isUnchangedBinaryColumn(ColumnDiff $columnDiff)
{
$columnType = $columnDiff->column->getType();
if (! $columnType instanceof BinaryType && ! $columnType instanceof BlobType) {
return false;
}
$fromColumn = $columnDiff->fromColumn instanceof Column ? $columnDiff->fromColumn : null;
if ($fromColumn) {
$fromColumnType = $fromColumn->getType();
if (! $fromColumnType instanceof BinaryType && ! $fromColumnType instanceof BlobType) {
return false;
}
return count(array_diff($columnDiff->changedProperties, ['type', 'length', 'fixed'])) === 0;
}
if ($columnDiff->hasChanged('type')) {
return false;
}
return count(array_diff($columnDiff->changedProperties, ['length', 'fixed'])) === 0;
} | [
"private",
"function",
"isUnchangedBinaryColumn",
"(",
"ColumnDiff",
"$",
"columnDiff",
")",
"{",
"$",
"columnType",
"=",
"$",
"columnDiff",
"->",
"column",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"$",
"columnType",
"instanceof",
"BinaryType",
"&&",
"!",
"$",
"columnType",
"instanceof",
"BlobType",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fromColumn",
"=",
"$",
"columnDiff",
"->",
"fromColumn",
"instanceof",
"Column",
"?",
"$",
"columnDiff",
"->",
"fromColumn",
":",
"null",
";",
"if",
"(",
"$",
"fromColumn",
")",
"{",
"$",
"fromColumnType",
"=",
"$",
"fromColumn",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"$",
"fromColumnType",
"instanceof",
"BinaryType",
"&&",
"!",
"$",
"fromColumnType",
"instanceof",
"BlobType",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"array_diff",
"(",
"$",
"columnDiff",
"->",
"changedProperties",
",",
"[",
"'type'",
",",
"'length'",
",",
"'fixed'",
"]",
")",
")",
"===",
"0",
";",
"}",
"if",
"(",
"$",
"columnDiff",
"->",
"hasChanged",
"(",
"'type'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"array_diff",
"(",
"$",
"columnDiff",
"->",
"changedProperties",
",",
"[",
"'length'",
",",
"'fixed'",
"]",
")",
")",
"===",
"0",
";",
"}"
]
| Checks whether a given column diff is a logically unchanged binary type column.
Used to determine whether a column alteration for a binary type column can be skipped.
Doctrine's {@link \Doctrine\DBAL\Types\BinaryType} and {@link \Doctrine\DBAL\Types\BlobType}
are mapped to the same database column type on this platform as this platform
does not have a native VARBINARY/BINARY column type. Therefore the {@link \Doctrine\DBAL\Schema\Comparator}
might detect differences for binary type columns which do not have to be propagated
to database as there actually is no difference at database level.
@param ColumnDiff $columnDiff The column diff to check against.
@return bool True if the given column diff is an unchanged binary type column, false otherwise. | [
"Checks",
"whether",
"a",
"given",
"column",
"diff",
"is",
"a",
"logically",
"unchanged",
"binary",
"type",
"column",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L651-L676 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | PostgreSqlPlatform.convertSingleBooleanValue | private function convertSingleBooleanValue($value, $callback)
{
if ($value === null) {
return $callback(null);
}
if (is_bool($value) || is_numeric($value)) {
return $callback((bool) $value);
}
if (! is_string($value)) {
return $callback(true);
}
/**
* Better safe than sorry: http://php.net/in_array#106319
*/
if (in_array(strtolower(trim($value)), $this->booleanLiterals['false'], true)) {
return $callback(false);
}
if (in_array(strtolower(trim($value)), $this->booleanLiterals['true'], true)) {
return $callback(true);
}
throw new UnexpectedValueException("Unrecognized boolean literal '${value}'");
} | php | private function convertSingleBooleanValue($value, $callback)
{
if ($value === null) {
return $callback(null);
}
if (is_bool($value) || is_numeric($value)) {
return $callback((bool) $value);
}
if (! is_string($value)) {
return $callback(true);
}
/**
* Better safe than sorry: http://php.net/in_array#106319
*/
if (in_array(strtolower(trim($value)), $this->booleanLiterals['false'], true)) {
return $callback(false);
}
if (in_array(strtolower(trim($value)), $this->booleanLiterals['true'], true)) {
return $callback(true);
}
throw new UnexpectedValueException("Unrecognized boolean literal '${value}'");
} | [
"private",
"function",
"convertSingleBooleanValue",
"(",
"$",
"value",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"callback",
"(",
"null",
")",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
"||",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"callback",
"(",
"(",
"bool",
")",
"$",
"value",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"callback",
"(",
"true",
")",
";",
"}",
"/**\n * Better safe than sorry: http://php.net/in_array#106319\n */",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"value",
")",
")",
",",
"$",
"this",
"->",
"booleanLiterals",
"[",
"'false'",
"]",
",",
"true",
")",
")",
"{",
"return",
"$",
"callback",
"(",
"false",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"value",
")",
")",
",",
"$",
"this",
"->",
"booleanLiterals",
"[",
"'true'",
"]",
",",
"true",
")",
")",
"{",
"return",
"$",
"callback",
"(",
"true",
")",
";",
"}",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Unrecognized boolean literal '${value}'\"",
")",
";",
"}"
]
| Converts a single boolean value.
First converts the value to its native PHP boolean type
and passes it to the given callback function to be reconverted
into any custom representation.
@param mixed $value The value to convert.
@param callable $callback The callback function to use for converting the real boolean value.
@return mixed
@throws UnexpectedValueException | [
"Converts",
"a",
"single",
"boolean",
"value",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L817-L843 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | PostgreSqlPlatform.doConvertBooleans | private function doConvertBooleans($item, $callback)
{
if (is_array($item)) {
foreach ($item as $key => $value) {
$item[$key] = $this->convertSingleBooleanValue($value, $callback);
}
return $item;
}
return $this->convertSingleBooleanValue($item, $callback);
} | php | private function doConvertBooleans($item, $callback)
{
if (is_array($item)) {
foreach ($item as $key => $value) {
$item[$key] = $this->convertSingleBooleanValue($value, $callback);
}
return $item;
}
return $this->convertSingleBooleanValue($item, $callback);
} | [
"private",
"function",
"doConvertBooleans",
"(",
"$",
"item",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"item",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"convertSingleBooleanValue",
"(",
"$",
"value",
",",
"$",
"callback",
")",
";",
"}",
"return",
"$",
"item",
";",
"}",
"return",
"$",
"this",
"->",
"convertSingleBooleanValue",
"(",
"$",
"item",
",",
"$",
"callback",
")",
";",
"}"
]
| Converts one or multiple boolean values.
First converts the value(s) to their native PHP boolean type
and passes them to the given callback function to be reconverted
into any custom representation.
@param mixed $item The value(s) to convert.
@param callable $callback The callback function to use for converting the real boolean value(s).
@return mixed | [
"Converts",
"one",
"or",
"multiple",
"boolean",
"values",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L857-L868 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | PostgreSqlPlatform.typeChangeBreaksDefaultValue | private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool
{
if (! $columnDiff->fromColumn) {
return $columnDiff->hasChanged('type');
}
$oldTypeIsNumeric = $this->isNumericType($columnDiff->fromColumn->getType());
$newTypeIsNumeric = $this->isNumericType($columnDiff->column->getType());
// default should not be changed when switching between numeric types and the default comes from a sequence
return $columnDiff->hasChanged('type')
&& ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement());
} | php | private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool
{
if (! $columnDiff->fromColumn) {
return $columnDiff->hasChanged('type');
}
$oldTypeIsNumeric = $this->isNumericType($columnDiff->fromColumn->getType());
$newTypeIsNumeric = $this->isNumericType($columnDiff->column->getType());
// default should not be changed when switching between numeric types and the default comes from a sequence
return $columnDiff->hasChanged('type')
&& ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement());
} | [
"private",
"function",
"typeChangeBreaksDefaultValue",
"(",
"ColumnDiff",
"$",
"columnDiff",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"columnDiff",
"->",
"fromColumn",
")",
"{",
"return",
"$",
"columnDiff",
"->",
"hasChanged",
"(",
"'type'",
")",
";",
"}",
"$",
"oldTypeIsNumeric",
"=",
"$",
"this",
"->",
"isNumericType",
"(",
"$",
"columnDiff",
"->",
"fromColumn",
"->",
"getType",
"(",
")",
")",
";",
"$",
"newTypeIsNumeric",
"=",
"$",
"this",
"->",
"isNumericType",
"(",
"$",
"columnDiff",
"->",
"column",
"->",
"getType",
"(",
")",
")",
";",
"// default should not be changed when switching between numeric types and the default comes from a sequence",
"return",
"$",
"columnDiff",
"->",
"hasChanged",
"(",
"'type'",
")",
"&&",
"!",
"(",
"$",
"oldTypeIsNumeric",
"&&",
"$",
"newTypeIsNumeric",
"&&",
"$",
"columnDiff",
"->",
"column",
"->",
"getAutoincrement",
"(",
")",
")",
";",
"}"
]
| Check whether the type of a column is changed in a way that invalidates the default value for the column | [
"Check",
"whether",
"the",
"type",
"of",
"a",
"column",
"is",
"changed",
"in",
"a",
"way",
"that",
"invalidates",
"the",
"default",
"value",
"for",
"the",
"column"
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L1232-L1244 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | OCI8Statement.findPlaceholderOrOpeningQuote | private static function findPlaceholderOrOpeningQuote(
$statement,
&$tokenOffset,
&$fragmentOffset,
&$fragments,
&$currentLiteralDelimiter,
&$paramMap
) {
$token = self::findToken($statement, $tokenOffset, '/[?\'"]/');
if (! $token) {
return false;
}
if ($token === '?') {
$position = count($paramMap) + 1;
$param = ':param' . $position;
$fragments[] = substr($statement, $fragmentOffset, $tokenOffset - $fragmentOffset);
$fragments[] = $param;
$paramMap[$position] = $param;
$tokenOffset += 1;
$fragmentOffset = $tokenOffset;
return true;
}
$currentLiteralDelimiter = $token;
++$tokenOffset;
return true;
} | php | private static function findPlaceholderOrOpeningQuote(
$statement,
&$tokenOffset,
&$fragmentOffset,
&$fragments,
&$currentLiteralDelimiter,
&$paramMap
) {
$token = self::findToken($statement, $tokenOffset, '/[?\'"]/');
if (! $token) {
return false;
}
if ($token === '?') {
$position = count($paramMap) + 1;
$param = ':param' . $position;
$fragments[] = substr($statement, $fragmentOffset, $tokenOffset - $fragmentOffset);
$fragments[] = $param;
$paramMap[$position] = $param;
$tokenOffset += 1;
$fragmentOffset = $tokenOffset;
return true;
}
$currentLiteralDelimiter = $token;
++$tokenOffset;
return true;
} | [
"private",
"static",
"function",
"findPlaceholderOrOpeningQuote",
"(",
"$",
"statement",
",",
"&",
"$",
"tokenOffset",
",",
"&",
"$",
"fragmentOffset",
",",
"&",
"$",
"fragments",
",",
"&",
"$",
"currentLiteralDelimiter",
",",
"&",
"$",
"paramMap",
")",
"{",
"$",
"token",
"=",
"self",
"::",
"findToken",
"(",
"$",
"statement",
",",
"$",
"tokenOffset",
",",
"'/[?\\'\"]/'",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"token",
"===",
"'?'",
")",
"{",
"$",
"position",
"=",
"count",
"(",
"$",
"paramMap",
")",
"+",
"1",
";",
"$",
"param",
"=",
"':param'",
".",
"$",
"position",
";",
"$",
"fragments",
"[",
"]",
"=",
"substr",
"(",
"$",
"statement",
",",
"$",
"fragmentOffset",
",",
"$",
"tokenOffset",
"-",
"$",
"fragmentOffset",
")",
";",
"$",
"fragments",
"[",
"]",
"=",
"$",
"param",
";",
"$",
"paramMap",
"[",
"$",
"position",
"]",
"=",
"$",
"param",
";",
"$",
"tokenOffset",
"+=",
"1",
";",
"$",
"fragmentOffset",
"=",
"$",
"tokenOffset",
";",
"return",
"true",
";",
"}",
"$",
"currentLiteralDelimiter",
"=",
"$",
"token",
";",
"++",
"$",
"tokenOffset",
";",
"return",
"true",
";",
"}"
]
| Finds next placeholder or opening quote.
@param string $statement The SQL statement to parse
@param string $tokenOffset The offset to start searching from
@param int $fragmentOffset The offset to build the next fragment from
@param string[] $fragments Fragments of the original statement not containing placeholders
@param string|null $currentLiteralDelimiter The delimiter of the current string literal
or NULL if not currently in a literal
@param array<int, string> $paramMap Mapping of the original parameter positions to their named replacements
@return bool Whether the token was found | [
"Finds",
"next",
"placeholder",
"or",
"opening",
"quote",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php#L181-L211 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | OCI8Statement.findClosingQuote | private static function findClosingQuote(
$statement,
&$tokenOffset,
&$currentLiteralDelimiter
) {
$token = self::findToken(
$statement,
$tokenOffset,
'/' . preg_quote($currentLiteralDelimiter, '/') . '/'
);
if (! $token) {
return false;
}
$currentLiteralDelimiter = false;
++$tokenOffset;
return true;
} | php | private static function findClosingQuote(
$statement,
&$tokenOffset,
&$currentLiteralDelimiter
) {
$token = self::findToken(
$statement,
$tokenOffset,
'/' . preg_quote($currentLiteralDelimiter, '/') . '/'
);
if (! $token) {
return false;
}
$currentLiteralDelimiter = false;
++$tokenOffset;
return true;
} | [
"private",
"static",
"function",
"findClosingQuote",
"(",
"$",
"statement",
",",
"&",
"$",
"tokenOffset",
",",
"&",
"$",
"currentLiteralDelimiter",
")",
"{",
"$",
"token",
"=",
"self",
"::",
"findToken",
"(",
"$",
"statement",
",",
"$",
"tokenOffset",
",",
"'/'",
".",
"preg_quote",
"(",
"$",
"currentLiteralDelimiter",
",",
"'/'",
")",
".",
"'/'",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"return",
"false",
";",
"}",
"$",
"currentLiteralDelimiter",
"=",
"false",
";",
"++",
"$",
"tokenOffset",
";",
"return",
"true",
";",
"}"
]
| Finds closing quote
@param string $statement The SQL statement to parse
@param string $tokenOffset The offset to start searching from
@param string $currentLiteralDelimiter The delimiter of the current string literal
@return bool Whether the token was found | [
"Finds",
"closing",
"quote"
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php#L222-L241 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | OCI8Statement.findToken | private static function findToken($statement, &$offset, $regex)
{
if (preg_match($regex, $statement, $matches, PREG_OFFSET_CAPTURE, $offset)) {
$offset = $matches[0][1];
return $matches[0][0];
}
return null;
} | php | private static function findToken($statement, &$offset, $regex)
{
if (preg_match($regex, $statement, $matches, PREG_OFFSET_CAPTURE, $offset)) {
$offset = $matches[0][1];
return $matches[0][0];
}
return null;
} | [
"private",
"static",
"function",
"findToken",
"(",
"$",
"statement",
",",
"&",
"$",
"offset",
",",
"$",
"regex",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"statement",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
",",
"$",
"offset",
")",
")",
"{",
"$",
"offset",
"=",
"$",
"matches",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"return",
"$",
"matches",
"[",
"0",
"]",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
]
| Finds the token described by regex starting from the given offset. Updates the offset with the position
where the token was found.
@param string $statement The SQL statement to parse
@param int $offset The offset to start searching from
@param string $regex The regex containing token pattern
@return string|null Token or NULL if not found | [
"Finds",
"the",
"token",
"described",
"by",
"regex",
"starting",
"from",
"the",
"given",
"offset",
".",
"Updates",
"the",
"offset",
"with",
"the",
"position",
"where",
"the",
"token",
"was",
"found",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php#L253-L262 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | OCI8Statement.convertParameterType | private function convertParameterType(int $type) : int
{
switch ($type) {
case ParameterType::BINARY:
return OCI_B_BIN;
case ParameterType::LARGE_OBJECT:
return OCI_B_BLOB;
default:
return SQLT_CHR;
}
} | php | private function convertParameterType(int $type) : int
{
switch ($type) {
case ParameterType::BINARY:
return OCI_B_BIN;
case ParameterType::LARGE_OBJECT:
return OCI_B_BLOB;
default:
return SQLT_CHR;
}
} | [
"private",
"function",
"convertParameterType",
"(",
"int",
"$",
"type",
")",
":",
"int",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"ParameterType",
"::",
"BINARY",
":",
"return",
"OCI_B_BIN",
";",
"case",
"ParameterType",
"::",
"LARGE_OBJECT",
":",
"return",
"OCI_B_BLOB",
";",
"default",
":",
"return",
"SQLT_CHR",
";",
"}",
"}"
]
| Converts DBAL parameter type to oci8 parameter type | [
"Converts",
"DBAL",
"parameter",
"type",
"to",
"oci8",
"parameter",
"type"
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php#L304-L316 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php | ForeignKeyConstraint.getQuotedLocalColumns | public function getQuotedLocalColumns(AbstractPlatform $platform)
{
$columns = [];
foreach ($this->_localColumnNames as $column) {
$columns[] = $column->getQuotedName($platform);
}
return $columns;
} | php | public function getQuotedLocalColumns(AbstractPlatform $platform)
{
$columns = [];
foreach ($this->_localColumnNames as $column) {
$columns[] = $column->getQuotedName($platform);
}
return $columns;
} | [
"public",
"function",
"getQuotedLocalColumns",
"(",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_localColumnNames",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"platform",
")",
";",
"}",
"return",
"$",
"columns",
";",
"}"
]
| Returns the quoted representation of the referencing table column names
the foreign key constraint is associated with.
But only if they were defined with one or the referencing table column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inserted is returned.
@param AbstractPlatform $platform The platform to use for quotation.
@return string[] | [
"Returns",
"the",
"quoted",
"representation",
"of",
"the",
"referencing",
"table",
"column",
"names",
"the",
"foreign",
"key",
"constraint",
"is",
"associated",
"with",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php#L154-L163 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php | ForeignKeyConstraint.getUnqualifiedForeignTableName | public function getUnqualifiedForeignTableName()
{
$name = $this->_foreignTableName->getName();
$position = strrpos($name, '.');
if ($position !== false) {
$name = substr($name, $position);
}
return strtolower($name);
} | php | public function getUnqualifiedForeignTableName()
{
$name = $this->_foreignTableName->getName();
$position = strrpos($name, '.');
if ($position !== false) {
$name = substr($name, $position);
}
return strtolower($name);
} | [
"public",
"function",
"getUnqualifiedForeignTableName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_foreignTableName",
"->",
"getName",
"(",
")",
";",
"$",
"position",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'.'",
")",
";",
"if",
"(",
"$",
"position",
"!==",
"false",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"$",
"position",
")",
";",
"}",
"return",
"strtolower",
"(",
"$",
"name",
")",
";",
"}"
]
| Returns the non-schema qualified foreign table name.
@return string | [
"Returns",
"the",
"non",
"-",
"schema",
"qualified",
"foreign",
"table",
"name",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php#L230-L240 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php | ForeignKeyConstraint.getQuotedForeignColumns | public function getQuotedForeignColumns(AbstractPlatform $platform)
{
$columns = [];
foreach ($this->_foreignColumnNames as $column) {
$columns[] = $column->getQuotedName($platform);
}
return $columns;
} | php | public function getQuotedForeignColumns(AbstractPlatform $platform)
{
$columns = [];
foreach ($this->_foreignColumnNames as $column) {
$columns[] = $column->getQuotedName($platform);
}
return $columns;
} | [
"public",
"function",
"getQuotedForeignColumns",
"(",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_foreignColumnNames",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"platform",
")",
";",
"}",
"return",
"$",
"columns",
";",
"}"
]
| Returns the quoted representation of the referenced table column names
the foreign key constraint is associated with.
But only if they were defined with one or the referenced table column name
is a keyword reserved by the platform.
Otherwise the plain unquoted value as inserted is returned.
@param AbstractPlatform $platform The platform to use for quotation.
@return string[] | [
"Returns",
"the",
"quoted",
"representation",
"of",
"the",
"referenced",
"table",
"column",
"names",
"the",
"foreign",
"key",
"constraint",
"is",
"associated",
"with",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php#L282-L291 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php | ForeignKeyConstraint.onEvent | private function onEvent($event)
{
if (isset($this->_options[$event])) {
$onEvent = strtoupper($this->_options[$event]);
if (! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) {
return $onEvent;
}
}
return false;
} | php | private function onEvent($event)
{
if (isset($this->_options[$event])) {
$onEvent = strtoupper($this->_options[$event]);
if (! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) {
return $onEvent;
}
}
return false;
} | [
"private",
"function",
"onEvent",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_options",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"onEvent",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"_options",
"[",
"$",
"event",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"onEvent",
",",
"[",
"'NO ACTION'",
",",
"'RESTRICT'",
"]",
")",
")",
"{",
"return",
"$",
"onEvent",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Returns the referential action for a given database operation
on the referenced table the foreign key constraint is associated with.
@param string $event Name of the database operation/event to return the referential action for.
@return string|null | [
"Returns",
"the",
"referential",
"action",
"for",
"a",
"given",
"database",
"operation",
"on",
"the",
"referenced",
"table",
"the",
"foreign",
"key",
"constraint",
"is",
"associated",
"with",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php#L358-L369 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php | ForeignKeyConstraint.intersectsIndexColumns | public function intersectsIndexColumns(Index $index)
{
foreach ($index->getColumns() as $indexColumn) {
foreach ($this->_localColumnNames as $localColumn) {
if (strtolower($indexColumn) === strtolower($localColumn->getName())) {
return true;
}
}
}
return false;
} | php | public function intersectsIndexColumns(Index $index)
{
foreach ($index->getColumns() as $indexColumn) {
foreach ($this->_localColumnNames as $localColumn) {
if (strtolower($indexColumn) === strtolower($localColumn->getName())) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"intersectsIndexColumns",
"(",
"Index",
"$",
"index",
")",
"{",
"foreach",
"(",
"$",
"index",
"->",
"getColumns",
"(",
")",
"as",
"$",
"indexColumn",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_localColumnNames",
"as",
"$",
"localColumn",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"indexColumn",
")",
"===",
"strtolower",
"(",
"$",
"localColumn",
"->",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks whether this foreign key constraint intersects the given index columns.
Returns `true` if at least one of this foreign key's local columns
matches one of the given index's columns, `false` otherwise.
@param Index $index The index to be checked against.
@return bool | [
"Checks",
"whether",
"this",
"foreign",
"key",
"constraint",
"intersects",
"the",
"given",
"index",
"columns",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php#L381-L392 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php | SQLAnywhereSchemaManager.startDatabase | public function startDatabase($database)
{
assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStartDatabaseSQL($database));
} | php | public function startDatabase($database)
{
assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStartDatabaseSQL($database));
} | [
"public",
"function",
"startDatabase",
"(",
"$",
"database",
")",
"{",
"assert",
"(",
"$",
"this",
"->",
"_platform",
"instanceof",
"SQLAnywherePlatform",
")",
";",
"$",
"this",
"->",
"_execSql",
"(",
"$",
"this",
"->",
"_platform",
"->",
"getStartDatabaseSQL",
"(",
"$",
"database",
")",
")",
";",
"}"
]
| Starts a database.
@param string $database The name of the database to start. | [
"Starts",
"a",
"database",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php#L51-L55 | train |
doctrine/dbal | lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php | SQLAnywhereSchemaManager.stopDatabase | public function stopDatabase($database)
{
assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStopDatabaseSQL($database));
} | php | public function stopDatabase($database)
{
assert($this->_platform instanceof SQLAnywherePlatform);
$this->_execSql($this->_platform->getStopDatabaseSQL($database));
} | [
"public",
"function",
"stopDatabase",
"(",
"$",
"database",
")",
"{",
"assert",
"(",
"$",
"this",
"->",
"_platform",
"instanceof",
"SQLAnywherePlatform",
")",
";",
"$",
"this",
"->",
"_execSql",
"(",
"$",
"this",
"->",
"_platform",
"->",
"getStopDatabaseSQL",
"(",
"$",
"database",
")",
")",
";",
"}"
]
| Stops a database.
@param string $database The name of the database to stop. | [
"Stops",
"a",
"database",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php#L62-L66 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | Driver.constructPdoDsn | private function constructPdoDsn(array $params)
{
$dsn = 'oci:dbname=' . $this->getEasyConnectString($params);
if (isset($params['charset'])) {
$dsn .= ';charset=' . $params['charset'];
}
return $dsn;
} | php | private function constructPdoDsn(array $params)
{
$dsn = 'oci:dbname=' . $this->getEasyConnectString($params);
if (isset($params['charset'])) {
$dsn .= ';charset=' . $params['charset'];
}
return $dsn;
} | [
"private",
"function",
"constructPdoDsn",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"dsn",
"=",
"'oci:dbname='",
".",
"$",
"this",
"->",
"getEasyConnectString",
"(",
"$",
"params",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'charset'",
"]",
")",
")",
"{",
"$",
"dsn",
".=",
"';charset='",
".",
"$",
"params",
"[",
"'charset'",
"]",
";",
"}",
"return",
"$",
"dsn",
";",
"}"
]
| Constructs the Oracle PDO DSN.
@param mixed[] $params
@return string The DSN. | [
"Constructs",
"the",
"Oracle",
"PDO",
"DSN",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php#L44-L53 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php | AbstractMySQLDriver.getOracleMysqlVersionNumber | private function getOracleMysqlVersionNumber(string $versionString) : string
{
if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionString,
$versionParts
)) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'<major_version>.<minor_version>.<patch_version>'
);
}
$majorVersion = $versionParts['major'];
$minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? null;
if ($majorVersion === '5' && $minorVersion === '7' && $patchVersion === null) {
$patchVersion = '9';
}
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
} | php | private function getOracleMysqlVersionNumber(string $versionString) : string
{
if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionString,
$versionParts
)) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'<major_version>.<minor_version>.<patch_version>'
);
}
$majorVersion = $versionParts['major'];
$minorVersion = $versionParts['minor'] ?? 0;
$patchVersion = $versionParts['patch'] ?? null;
if ($majorVersion === '5' && $minorVersion === '7' && $patchVersion === null) {
$patchVersion = '9';
}
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
} | [
"private",
"function",
"getOracleMysqlVersionNumber",
"(",
"string",
"$",
"versionString",
")",
":",
"string",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(?P<major>\\d+)(?:\\.(?P<minor>\\d+)(?:\\.(?P<patch>\\d+))?)?/'",
",",
"$",
"versionString",
",",
"$",
"versionParts",
")",
")",
"{",
"throw",
"DBALException",
"::",
"invalidPlatformVersionSpecified",
"(",
"$",
"versionString",
",",
"'<major_version>.<minor_version>.<patch_version>'",
")",
";",
"}",
"$",
"majorVersion",
"=",
"$",
"versionParts",
"[",
"'major'",
"]",
";",
"$",
"minorVersion",
"=",
"$",
"versionParts",
"[",
"'minor'",
"]",
"??",
"0",
";",
"$",
"patchVersion",
"=",
"$",
"versionParts",
"[",
"'patch'",
"]",
"??",
"null",
";",
"if",
"(",
"$",
"majorVersion",
"===",
"'5'",
"&&",
"$",
"minorVersion",
"===",
"'7'",
"&&",
"$",
"patchVersion",
"===",
"null",
")",
"{",
"$",
"patchVersion",
"=",
"'9'",
";",
"}",
"return",
"$",
"majorVersion",
".",
"'.'",
".",
"$",
"minorVersion",
".",
"'.'",
".",
"$",
"patchVersion",
";",
"}"
]
| Get a normalized 'version number' from the server string
returned by Oracle MySQL servers.
@param string $versionString Version string returned by the driver, i.e. '5.7.10'
@throws DBALException | [
"Get",
"a",
"normalized",
"version",
"number",
"from",
"the",
"server",
"string",
"returned",
"by",
"Oracle",
"MySQL",
"servers",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php#L142-L163 | train |
doctrine/dbal | lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php | AbstractMySQLDriver.getMariaDbMysqlVersionNumber | private function getMariaDbMysqlVersionNumber(string $versionString) : string
{
if (! preg_match(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString,
$versionParts
)) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
);
}
return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch'];
} | php | private function getMariaDbMysqlVersionNumber(string $versionString) : string
{
if (! preg_match(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString,
$versionParts
)) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
);
}
return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch'];
} | [
"private",
"function",
"getMariaDbMysqlVersionNumber",
"(",
"string",
"$",
"versionString",
")",
":",
"string",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(?:5\\.5\\.5-)?(mariadb-)?(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)/i'",
",",
"$",
"versionString",
",",
"$",
"versionParts",
")",
")",
"{",
"throw",
"DBALException",
"::",
"invalidPlatformVersionSpecified",
"(",
"$",
"versionString",
",",
"'^(?:5\\.5\\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'",
")",
";",
"}",
"return",
"$",
"versionParts",
"[",
"'major'",
"]",
".",
"'.'",
".",
"$",
"versionParts",
"[",
"'minor'",
"]",
".",
"'.'",
".",
"$",
"versionParts",
"[",
"'patch'",
"]",
";",
"}"
]
| Detect MariaDB server version, including hack for some mariadb distributions
that starts with the prefix '5.5.5-'
@param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial'
@throws DBALException | [
"Detect",
"MariaDB",
"server",
"version",
"including",
"hack",
"for",
"some",
"mariadb",
"distributions",
"that",
"starts",
"with",
"the",
"prefix",
"5",
".",
"5",
".",
"5",
"-"
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php#L173-L187 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SqlitePlatform.php | SqlitePlatform.getNonAutoincrementPrimaryKeyDefinition | private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string
{
if (empty($options['primary'])) {
return '';
}
$keyColumns = array_unique(array_values($options['primary']));
foreach ($keyColumns as $keyColumn) {
if (! empty($columns[$keyColumn]['autoincrement'])) {
return '';
}
}
return ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
} | php | private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string
{
if (empty($options['primary'])) {
return '';
}
$keyColumns = array_unique(array_values($options['primary']));
foreach ($keyColumns as $keyColumn) {
if (! empty($columns[$keyColumn]['autoincrement'])) {
return '';
}
}
return ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
} | [
"private",
"function",
"getNonAutoincrementPrimaryKeyDefinition",
"(",
"array",
"$",
"columns",
",",
"array",
"$",
"options",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'primary'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"keyColumns",
"=",
"array_unique",
"(",
"array_values",
"(",
"$",
"options",
"[",
"'primary'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"keyColumns",
"as",
"$",
"keyColumn",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"columns",
"[",
"$",
"keyColumn",
"]",
"[",
"'autoincrement'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"}",
"return",
"', PRIMARY KEY('",
".",
"implode",
"(",
"', '",
",",
"$",
"keyColumns",
")",
".",
"')'",
";",
"}"
]
| Generate a PRIMARY KEY definition if no autoincrement value is used
@param mixed[][] $columns
@param mixed[] $options | [
"Generate",
"a",
"PRIMARY",
"KEY",
"definition",
"if",
"no",
"autoincrement",
"value",
"is",
"used"
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php#L362-L377 | train |
doctrine/dbal | lib/Doctrine/DBAL/Statement.php | Statement.bindValue | public function bindValue($name, $value, $type = ParameterType::STRING)
{
$this->params[$name] = $value;
$this->types[$name] = $type;
if ($type !== null) {
if (is_string($type)) {
$type = Type::getType($type);
}
if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->platform);
$bindingType = $type->getBindingType();
} else {
$bindingType = $type;
}
return $this->stmt->bindValue($name, $value, $bindingType);
}
return $this->stmt->bindValue($name, $value);
} | php | public function bindValue($name, $value, $type = ParameterType::STRING)
{
$this->params[$name] = $value;
$this->types[$name] = $type;
if ($type !== null) {
if (is_string($type)) {
$type = Type::getType($type);
}
if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->platform);
$bindingType = $type->getBindingType();
} else {
$bindingType = $type;
}
return $this->stmt->bindValue($name, $value, $bindingType);
}
return $this->stmt->bindValue($name, $value);
} | [
"public",
"function",
"bindValue",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"type",
"=",
"ParameterType",
"::",
"STRING",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"types",
"[",
"$",
"name",
"]",
"=",
"$",
"type",
";",
"if",
"(",
"$",
"type",
"!==",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"Type",
"::",
"getType",
"(",
"$",
"type",
")",
";",
"}",
"if",
"(",
"$",
"type",
"instanceof",
"Type",
")",
"{",
"$",
"value",
"=",
"$",
"type",
"->",
"convertToDatabaseValue",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"platform",
")",
";",
"$",
"bindingType",
"=",
"$",
"type",
"->",
"getBindingType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"bindingType",
"=",
"$",
"type",
";",
"}",
"return",
"$",
"this",
"->",
"stmt",
"->",
"bindValue",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"bindingType",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stmt",
"->",
"bindValue",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
]
| Binds a parameter value to the statement.
The value can optionally be bound with a PDO binding type or a DBAL mapping type.
If bound with a DBAL mapping type, the binding type is derived from the mapping
type and the value undergoes the conversion routines of the mapping type before
being bound.
@param string|int $name The name or position of the parameter.
@param mixed $value The value of the parameter.
@param mixed $type Either a PDO binding type or a DBAL mapping type name or instance.
@return bool TRUE on success, FALSE on failure. | [
"Binds",
"a",
"parameter",
"value",
"to",
"the",
"statement",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Statement.php#L90-L109 | train |
doctrine/dbal | lib/Doctrine/DBAL/Statement.php | Statement.bindParam | public function bindParam($name, &$var, $type = ParameterType::STRING, $length = null)
{
$this->params[$name] = $var;
$this->types[$name] = $type;
return $this->stmt->bindParam($name, $var, $type, $length);
} | php | public function bindParam($name, &$var, $type = ParameterType::STRING, $length = null)
{
$this->params[$name] = $var;
$this->types[$name] = $type;
return $this->stmt->bindParam($name, $var, $type, $length);
} | [
"public",
"function",
"bindParam",
"(",
"$",
"name",
",",
"&",
"$",
"var",
",",
"$",
"type",
"=",
"ParameterType",
"::",
"STRING",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
"=",
"$",
"var",
";",
"$",
"this",
"->",
"types",
"[",
"$",
"name",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
"->",
"stmt",
"->",
"bindParam",
"(",
"$",
"name",
",",
"$",
"var",
",",
"$",
"type",
",",
"$",
"length",
")",
";",
"}"
]
| Binds a parameter to a value by reference.
Binding a parameter by reference does not support DBAL mapping types.
@param string|int $name The name or position of the parameter.
@param mixed $var The reference to the variable to bind.
@param int $type The PDO binding type.
@param int|null $length Must be specified when using an OUT bind
so that PHP allocates enough memory to hold the returned value.
@return bool TRUE on success, FALSE on failure. | [
"Binds",
"a",
"parameter",
"to",
"a",
"value",
"by",
"reference",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Statement.php#L124-L130 | train |
doctrine/dbal | lib/Doctrine/DBAL/Statement.php | Statement.execute | public function execute($params = null)
{
if (is_array($params)) {
$this->params = $params;
}
$logger = $this->conn->getConfiguration()->getSQLLogger();
if ($logger) {
$logger->startQuery($this->sql, $this->params, $this->types);
}
try {
$stmt = $this->stmt->execute($params);
} catch (Throwable $ex) {
if ($logger) {
$logger->stopQuery();
}
throw DBALException::driverExceptionDuringQuery(
$this->conn->getDriver(),
$ex,
$this->sql,
$this->conn->resolveParams($this->params, $this->types)
);
}
if ($logger) {
$logger->stopQuery();
}
$this->params = [];
$this->types = [];
return $stmt;
} | php | public function execute($params = null)
{
if (is_array($params)) {
$this->params = $params;
}
$logger = $this->conn->getConfiguration()->getSQLLogger();
if ($logger) {
$logger->startQuery($this->sql, $this->params, $this->types);
}
try {
$stmt = $this->stmt->execute($params);
} catch (Throwable $ex) {
if ($logger) {
$logger->stopQuery();
}
throw DBALException::driverExceptionDuringQuery(
$this->conn->getDriver(),
$ex,
$this->sql,
$this->conn->resolveParams($this->params, $this->types)
);
}
if ($logger) {
$logger->stopQuery();
}
$this->params = [];
$this->types = [];
return $stmt;
} | [
"public",
"function",
"execute",
"(",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"}",
"$",
"logger",
"=",
"$",
"this",
"->",
"conn",
"->",
"getConfiguration",
"(",
")",
"->",
"getSQLLogger",
"(",
")",
";",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"startQuery",
"(",
"$",
"this",
"->",
"sql",
",",
"$",
"this",
"->",
"params",
",",
"$",
"this",
"->",
"types",
")",
";",
"}",
"try",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"stmt",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"ex",
")",
"{",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"stopQuery",
"(",
")",
";",
"}",
"throw",
"DBALException",
"::",
"driverExceptionDuringQuery",
"(",
"$",
"this",
"->",
"conn",
"->",
"getDriver",
"(",
")",
",",
"$",
"ex",
",",
"$",
"this",
"->",
"sql",
",",
"$",
"this",
"->",
"conn",
"->",
"resolveParams",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"this",
"->",
"types",
")",
")",
";",
"}",
"if",
"(",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"stopQuery",
"(",
")",
";",
"}",
"$",
"this",
"->",
"params",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"types",
"=",
"[",
"]",
";",
"return",
"$",
"stmt",
";",
"}"
]
| Executes the statement with the currently bound parameters.
@param mixed[]|null $params
@return bool TRUE on success, FALSE on failure.
@throws DBALException | [
"Executes",
"the",
"statement",
"with",
"the",
"currently",
"bound",
"parameters",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Statement.php#L141-L173 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getAlterTableAddColumnClause | protected function getAlterTableAddColumnClause(Column $column)
{
return 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
} | php | protected function getAlterTableAddColumnClause(Column $column)
{
return 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
} | [
"protected",
"function",
"getAlterTableAddColumnClause",
"(",
"Column",
"$",
"column",
")",
"{",
"return",
"'ADD '",
".",
"$",
"this",
"->",
"getColumnDeclarationSQL",
"(",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
",",
"$",
"column",
"->",
"toArray",
"(",
")",
")",
";",
"}"
]
| Returns the SQL clause for creating a column in a table alteration.
@param Column $column The column to add.
@return string | [
"Returns",
"the",
"SQL",
"clause",
"for",
"creating",
"a",
"column",
"in",
"a",
"table",
"alteration",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L211-L214 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getAlterTableRenameColumnClause | protected function getAlterTableRenameColumnClause($oldColumnName, Column $column)
{
$oldColumnName = new Identifier($oldColumnName);
return 'RENAME ' . $oldColumnName->getQuotedName($this) . ' TO ' . $column->getQuotedName($this);
} | php | protected function getAlterTableRenameColumnClause($oldColumnName, Column $column)
{
$oldColumnName = new Identifier($oldColumnName);
return 'RENAME ' . $oldColumnName->getQuotedName($this) . ' TO ' . $column->getQuotedName($this);
} | [
"protected",
"function",
"getAlterTableRenameColumnClause",
"(",
"$",
"oldColumnName",
",",
"Column",
"$",
"column",
")",
"{",
"$",
"oldColumnName",
"=",
"new",
"Identifier",
"(",
"$",
"oldColumnName",
")",
";",
"return",
"'RENAME '",
".",
"$",
"oldColumnName",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
".",
"' TO '",
".",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
";",
"}"
]
| Returns the SQL clause for renaming a column in a table alteration.
@param string $oldColumnName The quoted name of the column to rename.
@param Column $column The column to rename to.
@return string | [
"Returns",
"the",
"SQL",
"clause",
"for",
"renaming",
"a",
"column",
"in",
"a",
"table",
"alteration",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L248-L253 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getAlterTableChangeColumnClause | protected function getAlterTableChangeColumnClause(ColumnDiff $columnDiff)
{
$column = $columnDiff->column;
// Do not return alter clause if only comment has changed.
if (! ($columnDiff->hasChanged('comment') && count($columnDiff->changedProperties) === 1)) {
$columnAlterationClause = 'ALTER ' .
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
if ($columnDiff->hasChanged('default') && $column->getDefault() === null) {
$columnAlterationClause .= ', ALTER ' . $column->getQuotedName($this) . ' DROP DEFAULT';
}
return $columnAlterationClause;
}
return null;
} | php | protected function getAlterTableChangeColumnClause(ColumnDiff $columnDiff)
{
$column = $columnDiff->column;
// Do not return alter clause if only comment has changed.
if (! ($columnDiff->hasChanged('comment') && count($columnDiff->changedProperties) === 1)) {
$columnAlterationClause = 'ALTER ' .
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
if ($columnDiff->hasChanged('default') && $column->getDefault() === null) {
$columnAlterationClause .= ', ALTER ' . $column->getQuotedName($this) . ' DROP DEFAULT';
}
return $columnAlterationClause;
}
return null;
} | [
"protected",
"function",
"getAlterTableChangeColumnClause",
"(",
"ColumnDiff",
"$",
"columnDiff",
")",
"{",
"$",
"column",
"=",
"$",
"columnDiff",
"->",
"column",
";",
"// Do not return alter clause if only comment has changed.",
"if",
"(",
"!",
"(",
"$",
"columnDiff",
"->",
"hasChanged",
"(",
"'comment'",
")",
"&&",
"count",
"(",
"$",
"columnDiff",
"->",
"changedProperties",
")",
"===",
"1",
")",
")",
"{",
"$",
"columnAlterationClause",
"=",
"'ALTER '",
".",
"$",
"this",
"->",
"getColumnDeclarationSQL",
"(",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
",",
"$",
"column",
"->",
"toArray",
"(",
")",
")",
";",
"if",
"(",
"$",
"columnDiff",
"->",
"hasChanged",
"(",
"'default'",
")",
"&&",
"$",
"column",
"->",
"getDefault",
"(",
")",
"===",
"null",
")",
"{",
"$",
"columnAlterationClause",
".=",
"', ALTER '",
".",
"$",
"column",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
".",
"' DROP DEFAULT'",
";",
"}",
"return",
"$",
"columnAlterationClause",
";",
"}",
"return",
"null",
";",
"}"
]
| Returns the SQL clause for altering a column in a table alteration.
This method returns null in case that only the column comment has changed.
Changes in column comments have to be handled differently.
@param ColumnDiff $columnDiff The diff of the column to alter.
@return string|null | [
"Returns",
"the",
"SQL",
"clause",
"for",
"altering",
"a",
"column",
"in",
"a",
"table",
"alteration",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L277-L294 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getForeignKeyMatchClauseSQL | public function getForeignKeyMatchClauseSQL($type)
{
switch ((int) $type) {
case self::FOREIGN_KEY_MATCH_SIMPLE:
return 'SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL:
return 'FULL';
break;
case self::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE:
return 'UNIQUE SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
return 'UNIQUE FULL';
default:
throw new InvalidArgumentException('Invalid foreign key match type: ' . $type);
}
} | php | public function getForeignKeyMatchClauseSQL($type)
{
switch ((int) $type) {
case self::FOREIGN_KEY_MATCH_SIMPLE:
return 'SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL:
return 'FULL';
break;
case self::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE:
return 'UNIQUE SIMPLE';
break;
case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
return 'UNIQUE FULL';
default:
throw new InvalidArgumentException('Invalid foreign key match type: ' . $type);
}
} | [
"public",
"function",
"getForeignKeyMatchClauseSQL",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"(",
"int",
")",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"FOREIGN_KEY_MATCH_SIMPLE",
":",
"return",
"'SIMPLE'",
";",
"break",
";",
"case",
"self",
"::",
"FOREIGN_KEY_MATCH_FULL",
":",
"return",
"'FULL'",
";",
"break",
";",
"case",
"self",
"::",
"FOREIGN_KEY_MATCH_SIMPLE_UNIQUE",
":",
"return",
"'UNIQUE SIMPLE'",
";",
"break",
";",
"case",
"self",
"::",
"FOREIGN_KEY_MATCH_FULL_UNIQUE",
":",
"return",
"'UNIQUE FULL'",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid foreign key match type: '",
".",
"$",
"type",
")",
";",
"}",
"}"
]
| Returns foreign key MATCH clause for given type.
@param int $type The foreign key match type
@return string
@throws InvalidArgumentException If unknown match type given. | [
"Returns",
"foreign",
"key",
"MATCH",
"clause",
"for",
"given",
"type",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L625-L645 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getPrimaryKeyDeclarationSQL | public function getPrimaryKeyDeclarationSQL(Index $index, $name = null)
{
if (! $index->isPrimary()) {
throw new InvalidArgumentException(
'Can only create primary key declarations with getPrimaryKeyDeclarationSQL()'
);
}
return $this->getTableConstraintDeclarationSQL($index, $name);
} | php | public function getPrimaryKeyDeclarationSQL(Index $index, $name = null)
{
if (! $index->isPrimary()) {
throw new InvalidArgumentException(
'Can only create primary key declarations with getPrimaryKeyDeclarationSQL()'
);
}
return $this->getTableConstraintDeclarationSQL($index, $name);
} | [
"public",
"function",
"getPrimaryKeyDeclarationSQL",
"(",
"Index",
"$",
"index",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"index",
"->",
"isPrimary",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Can only create primary key declarations with getPrimaryKeyDeclarationSQL()'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getTableConstraintDeclarationSQL",
"(",
"$",
"index",
",",
"$",
"name",
")",
";",
"}"
]
| Obtain DBMS specific SQL code portion needed to set a primary key
declaration to be used in statements like ALTER TABLE.
@param Index $index Index definition
@param string $name Name of the primary key
@return string DBMS specific SQL code portion needed to set a primary key
@throws InvalidArgumentException If the given index is not a primary key. | [
"Obtain",
"DBMS",
"specific",
"SQL",
"code",
"portion",
"needed",
"to",
"set",
"a",
"primary",
"key",
"declaration",
"to",
"be",
"used",
"in",
"statements",
"like",
"ALTER",
"TABLE",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L1020-L1029 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getAdvancedIndexOptionsSQL | protected function getAdvancedIndexOptionsSQL(Index $index)
{
$sql = '';
if (! $index->isPrimary() && $index->hasFlag('for_olap_workload')) {
$sql .= ' FOR OLAP WORKLOAD';
}
return $sql;
} | php | protected function getAdvancedIndexOptionsSQL(Index $index)
{
$sql = '';
if (! $index->isPrimary() && $index->hasFlag('for_olap_workload')) {
$sql .= ' FOR OLAP WORKLOAD';
}
return $sql;
} | [
"protected",
"function",
"getAdvancedIndexOptionsSQL",
"(",
"Index",
"$",
"index",
")",
"{",
"$",
"sql",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"index",
"->",
"isPrimary",
"(",
")",
"&&",
"$",
"index",
"->",
"hasFlag",
"(",
"'for_olap_workload'",
")",
")",
"{",
"$",
"sql",
".=",
"' FOR OLAP WORKLOAD'",
";",
"}",
"return",
"$",
"sql",
";",
"}"
]
| Return the INDEX query section dealing with non-standard
SQL Anywhere options.
@param Index $index Index definition
@return string | [
"Return",
"the",
"INDEX",
"query",
"section",
"dealing",
"with",
"non",
"-",
"standard",
"SQL",
"Anywhere",
"options",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L1346-L1355 | train |
doctrine/dbal | lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php | SQLAnywherePlatform.getTableConstraintDeclarationSQL | protected function getTableConstraintDeclarationSQL(Constraint $constraint, $name = null)
{
if ($constraint instanceof ForeignKeyConstraint) {
return $this->getForeignKeyDeclarationSQL($constraint);
}
if (! $constraint instanceof Index) {
throw new InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
}
if (! $constraint->isPrimary() && ! $constraint->isUnique()) {
throw new InvalidArgumentException(
'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' .
'with getTableConstraintDeclarationSQL().'
);
}
$constraintColumns = $constraint->getQuotedColumns($this);
if (empty($constraintColumns)) {
throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$sql = '';
$flags = '';
if (! empty($name)) {
$name = new Identifier($name);
$sql .= 'CONSTRAINT ' . $name->getQuotedName($this) . ' ';
}
if ($constraint->hasFlag('clustered')) {
$flags = 'CLUSTERED ';
}
if ($constraint->isPrimary()) {
return $sql . 'PRIMARY KEY ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
}
return $sql . 'UNIQUE ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
} | php | protected function getTableConstraintDeclarationSQL(Constraint $constraint, $name = null)
{
if ($constraint instanceof ForeignKeyConstraint) {
return $this->getForeignKeyDeclarationSQL($constraint);
}
if (! $constraint instanceof Index) {
throw new InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
}
if (! $constraint->isPrimary() && ! $constraint->isUnique()) {
throw new InvalidArgumentException(
'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' .
'with getTableConstraintDeclarationSQL().'
);
}
$constraintColumns = $constraint->getQuotedColumns($this);
if (empty($constraintColumns)) {
throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$sql = '';
$flags = '';
if (! empty($name)) {
$name = new Identifier($name);
$sql .= 'CONSTRAINT ' . $name->getQuotedName($this) . ' ';
}
if ($constraint->hasFlag('clustered')) {
$flags = 'CLUSTERED ';
}
if ($constraint->isPrimary()) {
return $sql . 'PRIMARY KEY ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
}
return $sql . 'UNIQUE ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
} | [
"protected",
"function",
"getTableConstraintDeclarationSQL",
"(",
"Constraint",
"$",
"constraint",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"constraint",
"instanceof",
"ForeignKeyConstraint",
")",
"{",
"return",
"$",
"this",
"->",
"getForeignKeyDeclarationSQL",
"(",
"$",
"constraint",
")",
";",
"}",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Index",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unsupported constraint type: '",
".",
"get_class",
"(",
"$",
"constraint",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"constraint",
"->",
"isPrimary",
"(",
")",
"&&",
"!",
"$",
"constraint",
"->",
"isUnique",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Can only create primary, unique or foreign key constraint declarations, no common index declarations '",
".",
"'with getTableConstraintDeclarationSQL().'",
")",
";",
"}",
"$",
"constraintColumns",
"=",
"$",
"constraint",
"->",
"getQuotedColumns",
"(",
"$",
"this",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"constraintColumns",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Incomplete definition. 'columns' required.\"",
")",
";",
"}",
"$",
"sql",
"=",
"''",
";",
"$",
"flags",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"new",
"Identifier",
"(",
"$",
"name",
")",
";",
"$",
"sql",
".=",
"'CONSTRAINT '",
".",
"$",
"name",
"->",
"getQuotedName",
"(",
"$",
"this",
")",
".",
"' '",
";",
"}",
"if",
"(",
"$",
"constraint",
"->",
"hasFlag",
"(",
"'clustered'",
")",
")",
"{",
"$",
"flags",
"=",
"'CLUSTERED '",
";",
"}",
"if",
"(",
"$",
"constraint",
"->",
"isPrimary",
"(",
")",
")",
"{",
"return",
"$",
"sql",
".",
"'PRIMARY KEY '",
".",
"$",
"flags",
".",
"'('",
".",
"$",
"this",
"->",
"getIndexFieldDeclarationListSQL",
"(",
"$",
"constraintColumns",
")",
".",
"')'",
";",
"}",
"return",
"$",
"sql",
".",
"'UNIQUE '",
".",
"$",
"flags",
".",
"'('",
".",
"$",
"this",
"->",
"getIndexFieldDeclarationListSQL",
"(",
"$",
"constraintColumns",
")",
".",
"')'",
";",
"}"
]
| Returns the SQL snippet for creating a table constraint.
@param Constraint $constraint The table constraint to create the SQL snippet for.
@param string|null $name The table constraint name to use if any.
@return string
@throws InvalidArgumentException If the given table constraint type is not supported by this method. | [
"Returns",
"the",
"SQL",
"snippet",
"for",
"creating",
"a",
"table",
"constraint",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php#L1377-L1417 | train |
doctrine/dbal | lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php | SQLAzureShardManager.splitFederation | public function splitFederation($splitDistributionValue)
{
$type = Type::getType($this->distributionType);
$sql = 'ALTER FEDERATION ' . $this->getFederationName() . ' ' .
'SPLIT AT (' . $this->getDistributionKey() . ' = ' .
$this->conn->quote($splitDistributionValue, $type->getBindingType()) . ')';
$this->conn->exec($sql);
} | php | public function splitFederation($splitDistributionValue)
{
$type = Type::getType($this->distributionType);
$sql = 'ALTER FEDERATION ' . $this->getFederationName() . ' ' .
'SPLIT AT (' . $this->getDistributionKey() . ' = ' .
$this->conn->quote($splitDistributionValue, $type->getBindingType()) . ')';
$this->conn->exec($sql);
} | [
"public",
"function",
"splitFederation",
"(",
"$",
"splitDistributionValue",
")",
"{",
"$",
"type",
"=",
"Type",
"::",
"getType",
"(",
"$",
"this",
"->",
"distributionType",
")",
";",
"$",
"sql",
"=",
"'ALTER FEDERATION '",
".",
"$",
"this",
"->",
"getFederationName",
"(",
")",
".",
"' '",
".",
"'SPLIT AT ('",
".",
"$",
"this",
"->",
"getDistributionKey",
"(",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"conn",
"->",
"quote",
"(",
"$",
"splitDistributionValue",
",",
"$",
"type",
"->",
"getBindingType",
"(",
")",
")",
".",
"')'",
";",
"$",
"this",
"->",
"conn",
"->",
"exec",
"(",
"$",
"sql",
")",
";",
"}"
]
| Splits Federation at a given distribution value.
@param mixed $splitDistributionValue
@return void | [
"Splits",
"Federation",
"at",
"a",
"given",
"distribution",
"value",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php#L199-L207 | train |
doctrine/dbal | lib/Doctrine/DBAL/Version.php | Version.compare | public static function compare($version)
{
$currentVersion = str_replace(' ', '', strtolower(self::VERSION));
$version = str_replace(' ', '', $version);
return version_compare($version, $currentVersion);
} | php | public static function compare($version)
{
$currentVersion = str_replace(' ', '', strtolower(self::VERSION));
$version = str_replace(' ', '', $version);
return version_compare($version, $currentVersion);
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"version",
")",
"{",
"$",
"currentVersion",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"strtolower",
"(",
"self",
"::",
"VERSION",
")",
")",
";",
"$",
"version",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"version",
")",
";",
"return",
"version_compare",
"(",
"$",
"version",
",",
"$",
"currentVersion",
")",
";",
"}"
]
| Compares a Doctrine version with the current one.
@param string $version The Doctrine version to compare to.
@return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer. | [
"Compares",
"a",
"Doctrine",
"version",
"with",
"the",
"current",
"one",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Version.php#L26-L32 | train |
doctrine/dbal | lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php | PoolingShardConnection.connect | public function connect($shardId = null)
{
if ($shardId === null && $this->_conn) {
return false;
}
if ($shardId !== null && $shardId === $this->activeShardId) {
return false;
}
if ($this->getTransactionNestingLevel() > 0) {
throw new ShardingException('Cannot switch shard when transaction is active.');
}
$activeShardId = $this->activeShardId = (int) $shardId;
if (isset($this->activeConnections[$activeShardId])) {
$this->_conn = $this->activeConnections[$activeShardId];
return false;
}
$this->_conn = $this->activeConnections[$activeShardId] = $this->connectTo($activeShardId);
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new ConnectionEventArgs($this);
$this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);
}
return true;
} | php | public function connect($shardId = null)
{
if ($shardId === null && $this->_conn) {
return false;
}
if ($shardId !== null && $shardId === $this->activeShardId) {
return false;
}
if ($this->getTransactionNestingLevel() > 0) {
throw new ShardingException('Cannot switch shard when transaction is active.');
}
$activeShardId = $this->activeShardId = (int) $shardId;
if (isset($this->activeConnections[$activeShardId])) {
$this->_conn = $this->activeConnections[$activeShardId];
return false;
}
$this->_conn = $this->activeConnections[$activeShardId] = $this->connectTo($activeShardId);
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new ConnectionEventArgs($this);
$this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);
}
return true;
} | [
"public",
"function",
"connect",
"(",
"$",
"shardId",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"shardId",
"===",
"null",
"&&",
"$",
"this",
"->",
"_conn",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"shardId",
"!==",
"null",
"&&",
"$",
"shardId",
"===",
"$",
"this",
"->",
"activeShardId",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getTransactionNestingLevel",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"ShardingException",
"(",
"'Cannot switch shard when transaction is active.'",
")",
";",
"}",
"$",
"activeShardId",
"=",
"$",
"this",
"->",
"activeShardId",
"=",
"(",
"int",
")",
"$",
"shardId",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"activeConnections",
"[",
"$",
"activeShardId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_conn",
"=",
"$",
"this",
"->",
"activeConnections",
"[",
"$",
"activeShardId",
"]",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_conn",
"=",
"$",
"this",
"->",
"activeConnections",
"[",
"$",
"activeShardId",
"]",
"=",
"$",
"this",
"->",
"connectTo",
"(",
"$",
"activeShardId",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"postConnect",
")",
")",
"{",
"$",
"eventArgs",
"=",
"new",
"ConnectionEventArgs",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"_eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postConnect",
",",
"$",
"eventArgs",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Connects to a given shard.
@param string|int|null $shardId
@return bool
@throws ShardingException | [
"Connects",
"to",
"a",
"given",
"shard",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php#L173-L203 | train |
doctrine/dbal | lib/Doctrine/DBAL/Connection.php | Connection.connect | public function connect()
{
if ($this->isConnected) {
return false;
}
$driverOptions = $this->params['driverOptions'] ?? [];
$user = $this->params['user'] ?? null;
$password = $this->params['password'] ?? null;
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);
$this->isConnected = true;
if ($this->autoCommit === false) {
$this->beginTransaction();
}
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new Event\ConnectionEventArgs($this);
$this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);
}
return true;
} | php | public function connect()
{
if ($this->isConnected) {
return false;
}
$driverOptions = $this->params['driverOptions'] ?? [];
$user = $this->params['user'] ?? null;
$password = $this->params['password'] ?? null;
$this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions);
$this->isConnected = true;
if ($this->autoCommit === false) {
$this->beginTransaction();
}
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new Event\ConnectionEventArgs($this);
$this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);
}
return true;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isConnected",
")",
"{",
"return",
"false",
";",
"}",
"$",
"driverOptions",
"=",
"$",
"this",
"->",
"params",
"[",
"'driverOptions'",
"]",
"??",
"[",
"]",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"params",
"[",
"'user'",
"]",
"??",
"null",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"params",
"[",
"'password'",
"]",
"??",
"null",
";",
"$",
"this",
"->",
"_conn",
"=",
"$",
"this",
"->",
"_driver",
"->",
"connect",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"user",
",",
"$",
"password",
",",
"$",
"driverOptions",
")",
";",
"$",
"this",
"->",
"isConnected",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"autoCommit",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"postConnect",
")",
")",
"{",
"$",
"eventArgs",
"=",
"new",
"Event",
"\\",
"ConnectionEventArgs",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"_eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postConnect",
",",
"$",
"eventArgs",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Establishes the connection with the database.
@return bool TRUE if the connection was successfully established, FALSE if
the connection is already open. | [
"Establishes",
"the",
"connection",
"with",
"the",
"database",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Connection.php#L344-L367 | train |
doctrine/dbal | lib/Doctrine/DBAL/Connection.php | Connection.detectDatabasePlatform | private function detectDatabasePlatform()
{
$version = $this->getDatabasePlatformVersion();
if ($version !== null) {
assert($this->_driver instanceof VersionAwarePlatformDriver);
$this->platform = $this->_driver->createDatabasePlatformForVersion($version);
} else {
$this->platform = $this->_driver->getDatabasePlatform();
}
$this->platform->setEventManager($this->_eventManager);
} | php | private function detectDatabasePlatform()
{
$version = $this->getDatabasePlatformVersion();
if ($version !== null) {
assert($this->_driver instanceof VersionAwarePlatformDriver);
$this->platform = $this->_driver->createDatabasePlatformForVersion($version);
} else {
$this->platform = $this->_driver->getDatabasePlatform();
}
$this->platform->setEventManager($this->_eventManager);
} | [
"private",
"function",
"detectDatabasePlatform",
"(",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getDatabasePlatformVersion",
"(",
")",
";",
"if",
"(",
"$",
"version",
"!==",
"null",
")",
"{",
"assert",
"(",
"$",
"this",
"->",
"_driver",
"instanceof",
"VersionAwarePlatformDriver",
")",
";",
"$",
"this",
"->",
"platform",
"=",
"$",
"this",
"->",
"_driver",
"->",
"createDatabasePlatformForVersion",
"(",
"$",
"version",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"platform",
"=",
"$",
"this",
"->",
"_driver",
"->",
"getDatabasePlatform",
"(",
")",
";",
"}",
"$",
"this",
"->",
"platform",
"->",
"setEventManager",
"(",
"$",
"this",
"->",
"_eventManager",
")",
";",
"}"
]
| Detects and sets the database platform.
Evaluates custom platform class and version in order to set the correct platform.
@throws DBALException If an invalid platform was specified for this connection. | [
"Detects",
"and",
"sets",
"the",
"database",
"platform",
"."
]
| e4978c2299d4d8e4f39da94f4d567e698e9bdbeb | https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Connection.php#L376-L389 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.