_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q16200
WriteBatch.validatePrecondition
train
private function validatePrecondition(array &$options) { $precondition = isset($options['precondition']) ? $options['precondition'] : null; if (!$precondition) { return; } if (isset($precondition['exists'])) { return $precondition; ...
php
{ "resource": "" }
q16201
WriteBatch.createDatabaseWriteOperation
train
private function createDatabaseWriteOperation($type, $document, array $options = []) { switch ($type) { case self::TYPE_UPDATE: return [ 'update' => [ 'name' => $document, 'fields' => $this->pluck('fields', $opti...
php
{ "resource": "" }
q16202
WriteBatch.formatPrecondition
train
private function formatPrecondition(array $options, $mustExist = false) { if (!isset($options['precondition']) && !$mustExist) { return $options; } $precondition = isset($options['precondition']) ? $options['precondition'] : [];
php
{ "resource": "" }
q16203
WriteBatch.checkPrefixes
train
private function checkPrefixes(array $paths) { sort($paths); for ($i = 1; $i < count($paths); $i++) { $prefix = $paths[$i-1]; $suffix = $paths[$i]; $prefix = explode('.', $prefix); $suffix = explode('.', $suffix); $isPrefix = count($pref...
php
{ "resource": "" }
q16204
NetworkPolicy.setProvider
train
public function setProvider($var) { GPBUtil::checkEnum($var, \Google\Cloud\Container\V1\NetworkPolicy_Provider::class);
php
{ "resource": "" }
q16205
CreateNotificationChannelRequest.setNotificationChannel
train
public function setNotificationChannel($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\NotificationChannel::class);
php
{ "resource": "" }
q16206
UnaryFilter.setOp
train
public function setOp($var) { GPBUtil::checkEnum($var, \Google\Cloud\Firestore\V1\StructuredQuery_Una
php
{ "resource": "" }
q16207
ListInspectTemplatesResponse.setInspectTemplates
train
public function setInspectTemplates($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16208
SetMasterAuthRequest.setAction
train
public function setAction($var) { GPBUtil::checkEnum($var, \Google\Cloud\Container\V1\SetMasterAuthRequest_Action::class);
php
{ "resource": "" }
q16209
SetMasterAuthRequest.setUpdate
train
public function setUpdate($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\MasterAuth::class);
php
{ "resource": "" }
q16210
EducationRecord.setStructuredDegree
train
public function setStructuredDegree($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16211
Variable.setMembers
train
public function setMembers($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16212
Intent.setWebhookState
train
public function setWebhookState($var) { GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\Intent_WebhookState::class);
php
{ "resource": "" }
q16213
Intent.setEvents
train
public function setEvents($var) { $arr = GPBUtil::checkRepeatedField($var,
php
{ "resource": "" }
q16214
Intent.setTrainingPhrases
train
public function setTrainingPhrases($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16215
Intent.setMessages
train
public function setMessages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16216
Intent.setFollowupIntentInfo
train
public function setFollowupIntentInfo($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16217
InsertResponse.failedRows
train
public function failedRows() { $rows = []; if ($this->isSuccessful()) { return $rows; } foreach ($this->info['insertErrors'] as $error) { $rows[] = $error + [
php
{ "resource": "" }
q16218
ListDlpJobsResponse.setJobs
train
public function setJobs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16219
RecordKey.setIdValues
train
public function setIdValues($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
php
{ "resource": "" }
q16220
BigtableClient.table
train
public function table($instanceId, $tableId, array $options = []) { return new Table( $this->gapicClient,
php
{ "resource": "" }
q16221
ErrorGroupServiceGrpcClient.UpdateGroup
train
public function UpdateGroup(\Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup',
php
{ "resource": "" }
q16222
Family.setColumns
train
public function setColumns($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16223
ClusterOperationMetadata.setWarnings
train
public function setWarnings($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
php
{ "resource": "" }
q16224
RequestMetadata.setDeviceInfo
train
public function setDeviceInfo($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16225
ListSubscriptionsResponse.setSubscriptions
train
public function setSubscriptions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16226
ListGroupStatsResponse.setErrorGroupStats
train
public function setErrorGroupStats($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16227
Mutation.setSetCell
train
public function setSetCell($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_SetCell::class);
php
{ "resource": "" }
q16228
Mutation.setDeleteFromColumn
train
public function setDeleteFromColumn($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16229
Mutation.setDeleteFromFamily
train
public function setDeleteFromFamily($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16230
Mutation.setDeleteFromRow
train
public function setDeleteFromRow($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromRow::class);
php
{ "resource": "" }
q16231
Annotation.setDescription
train
public function setDescription($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16232
Error.setTimestamps
train
public function setTimestamps($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16233
EmulatorTrait.emulatorGapicConfig
train
private function emulatorGapicConfig($emulatorHost) { // Strip the URL scheme from the input, if it was provided. if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { $search = $scheme . '://'; $emulatorHost = str_replace($search, '', $emulatorHost); } r...
php
{ "resource": "" }
q16234
EmulatorTrait.emulatorBaseUri
train
private function emulatorBaseUri($emulatorHost) { $emulatorUriComponents = parse_url($emulatorHost); $emulatorUriComponents = array_merge(['scheme' => 'http', 'port' => ''], $emulatorUriComponents);
php
{ "resource": "" }
q16235
EmulatorTrait.getEmulatorBaseUri
train
public function getEmulatorBaseUri($baseUri, $emulatorHost = null) { if ($emulatorHost)
php
{ "resource": "" }
q16236
ImportSshPublicKeyResponse.setLoginProfile
train
public function setLoginProfile($var) { GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1\LoginProfile::class);
php
{ "resource": "" }
q16237
BatchSnapshot.executePartition
train
public function executePartition(PartitionInterface $partition, array $options = []) { if ($partition instanceof QueryPartition) { return $this->executeQuery($partition); } elseif ($partition instanceof ReadPartition) {
php
{ "resource": "" }
q16238
BatchSnapshot.serialize
train
public function serialize() { return base64_encode(json_encode([ 'sessionName' => $this->session->name(), 'transactionId' => $this->transactionId,
php
{ "resource": "" }
q16239
BatchSnapshot.executeQuery
train
private function executeQuery(QueryPartition $partition) { return $this->execute($partition->sql(), [
php
{ "resource": "" }
q16240
BatchSnapshot.executeRead
train
private function executeRead(ReadPartition $partition) { return $this->read($partition->table(), $partition->keySet(),
php
{ "resource": "" }
q16241
CreateClusterRequest.setCluster
train
public function setCluster($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\Cluster::class);
php
{ "resource": "" }
q16242
UpdateTopicRequest.setTopic
train
public function setTopic($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16243
CloudTasksGapicClient.queueName
train
public static function queueName($project, $location, $queue) { return self::getQueueNameTemplate()->render([ 'project' => $project,
php
{ "resource": "" }
q16244
CloudTasksGapicClient.taskName
train
public static function taskName($project, $location, $queue, $task) { return self::getTaskNameTemplate()->render([ 'project' => $project,
php
{ "resource": "" }
q16245
OrderedJob.setHadoopJob
train
public function setHadoopJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\HadoopJob::class);
php
{ "resource": "" }
q16246
OrderedJob.setSparkJob
train
public function setSparkJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\SparkJob::class);
php
{ "resource": "" }
q16247
Bucket.setMin
train
public function setMin($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16248
Bucket.setMax
train
public function setMax($var) { GPBUtil::checkMessage($var,
php
{ "resource": "" }
q16249
Bucket.setReplacementValue
train
public function setReplacementValue($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class);
php
{ "resource": "" }
q16250
DeviceInfo.setDeviceType
train
public function setDeviceType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DeviceInfo_DeviceType::class);
php
{ "resource": "" }
q16251
BigtableTableAdminGapicClient.snapshotName
train
public static function snapshotName($project, $instance, $cluster, $snapshot) { return self::getSnapshotNameTemplate()->render([ 'project' => $project,
php
{ "resource": "" }
q16252
RequestedOptions.setSnapshotInspectTemplate
train
public function setSnapshotInspectTemplate($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectTemplate::class);
php
{ "resource": "" }
q16253
AudioConfig.setAudioEncoding
train
public function setAudioEncoding($var) { GPBUtil::checkEnum($var, \Google\Cloud\TextToSpeech\V1\AudioEncoding::class);
php
{ "resource": "" }
q16254
Row.setFamilies
train
public function setFamilies($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE,
php
{ "resource": "" }
q16255
OperationResponseTrait.operationToArray
train
private function operationToArray($operation, $serializer, array $lroMappers) { $response = $operation->getLastProtoResponse(); if (is_null($response)) { return null; } $response = $serializer->encodeMessage($response); $result = null; if ($operation->is...
php
{ "resource": "" }
q16256
OperationResponseTrait.deserializeResult
train
private function deserializeResult($operation, $type, $serializer, array $mappers) { $mappers = array_filter($mappers, function ($mapper) use ($type) { return $mapper['typeUrl'] === $type; }); if (count($mappers) === 0) { throw new \RuntimeException(sprintf('No mappe...
php
{ "resource": "" }
q16257
CurlPost.submit
train
public function submit(RequestParameters $params) { $handle = $this->curl->init($this->siteVerifyUrl); $options = array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $params->toQueryString(), CURLOPT_HTTPHEADER => array( 'Content-Type: application/...
php
{ "resource": "" }
q16258
ReCaptcha.verify
train
public function verify($response, $remoteIp = null) { // Discard empty solution submissions if (empty($response)) { $recaptchaResponse = new Response(false, array(self::E_MISSING_INPUT_RESPONSE)); return $recaptchaResponse; } $params = new RequestParameters($...
php
{ "resource": "" }
q16259
MakeCommand.createSettingsFile
train
protected function createSettingsFile($format, $options) { $SettingsClass = ($format === 'json') ? JsonSettings::class : YamlSettings::class; $filename = $this->exampleSettingsExists($format) ? "{$this->basePath}/Homestead.{$format}.example" : __DIR__."/../resources/Homestea...
php
{ "resource": "" }
q16260
HomesteadSettings.update
train
public function update($attributes) { $this->attributes = array_merge($this->attributes, array_filter($attributes,
php
{ "resource": "" }
q16261
HomesteadSettings.configureSites
train
public function configureSites($projectName, $projectDirectory) { $sites = [ [ 'map' => "{$projectName}.test", 'to' => "/home/vagrant/{$projectDirectory}/public", ], ]; if (isset($this->attributes['sites']) && ! empty($this->attributes...
php
{ "resource": "" }
q16262
HomesteadSettings.configureSharedFolders
train
public function configureSharedFolders($projectPath, $projectDirectory) { $folders = [ [ 'map' => $projectPath, 'to' => "/home/vagrant/{$projectDirectory}", ], ]; if (isset($this->attributes['folders']) && ! empty($this->attributes['fo...
php
{ "resource": "" }
q16263
AbstractAnnotation.mergeProperties
train
public function mergeProperties($object) { $defaultValues = get_class_vars(get_class($this)); $currentValues = get_object_vars($this); foreach ($object as $property => $value) { if ($property === '_context') { continue; } if ($currentValues...
php
{ "resource": "" }
q16264
AbstractAnnotation._validate
train
private static function _validate($fields, $parents, $skip, $baseRef) { $valid = true; $blacklist = []; if (is_object($fields)) { if (in_array($fields, $skip, true)) { return true; } $skip[] = $fields; $blacklist = property_exis...
php
{ "resource": "" }
q16265
AbstractAnnotation.validateType
train
private function validateType($type, $value): bool { if (substr($type, 0, 1) === '[' && substr($type, -1) === ']') { // Array of a specified type? if ($this->validateType('array', $value) === false) { return false; } $itemType = substr($type, 1, -1); ...
php
{ "resource": "" }
q16266
AbstractAnnotation.validateDefaultTypes
train
private function validateDefaultTypes($type, $value): bool { switch ($type) { case 'string': return is_string($value); case 'boolean': return is_bool($value); case 'integer': return is_int($value); case 'number':...
php
{ "resource": "" }
q16267
AbstractAnnotation.validateArrayType
train
private function validateArrayType($value): bool { if (is_array($value) === false) { return false; } $count = 0; foreach ($value as $i => $item) { //not a array, but a hash/map
php
{ "resource": "" }
q16268
AbstractAnnotation.nested
train
private function nested($annotation, $nestedContext) { if (property_exists($annotation, '_context') &&
php
{ "resource": "" }
q16269
InheritProperties.addAllOfProperty
train
private function addAllOfProperty(Schema $childSchema, Schema $parentSchema) { $currentSchema = new Schema(['_context' => $childSchema->_context]); $currentSchema->mergeProperties($childSchema); $defaultValues = get_class_vars(Schema::class); foreach (get_object_vars($currentSchem...
php
{ "resource": "" }
q16270
Analyser.fromComment
train
public function fromComment($comment, $context = null) { if ($context === null) { $context = new Context(['comment' => $comment]); } else { $context->comment = $comment; } try { self::$context = $context; if ($context->is('annotations')...
php
{ "resource": "" }
q16271
Serializer.deserialize
train
public function deserialize($jsonString, $className) { if (!$this->isValidClassName($className)) { throw new \Exception($className.' is not defined in OpenApi PHP Annotations');
php
{ "resource": "" }
q16272
Serializer.deserializeFile
train
public function deserializeFile($filename, $className = 'OpenApi\Annotations\OpenApi') { if (!$this->isValidClassName($className)) {
php
{ "resource": "" }
q16273
Serializer.doDeserialize
train
private function doDeserialize(\stdClass $c, $class) { $annotation = new $class([]); foreach ($c as $property => $value) { if ($property === '$ref') { $property = 'ref'; } if (substr($property, 0, 2) === 'x-') { if ($annotation->x ...
php
{ "resource": "" }
q16274
Serializer.doDeserializeProperty
train
private function doDeserializeProperty(Annotations\AbstractAnnotation $annotation, $property, $value) { // property is primitive type if (array_key_exists($property, $annotation::$_types)) { return $this->doDeserializeBaseProperty($annotation::$_types[$property], $value); } ...
php
{ "resource": "" }
q16275
Serializer.doDeserializeBaseProperty
train
private function doDeserializeBaseProperty($type, $value) { $isAnnotationClass = is_string($type) && is_subclass_of(trim($type, '[]'), AbstractAnnotation::class); if ($isAnnotationClass) { $isArray = strpos($type, '[') === 0 && substr($type, -1) === ']'; if ($isArray) { ...
php
{ "resource": "" }
q16276
Context.with
train
public function with($property) { if (property_exists($this, $property)) { return
php
{ "resource": "" }
q16277
Context.getDebugLocation
train
public function getDebugLocation() { $location = ''; if ($this->class && ($this->method || $this->property)) { $location .= $this->fullyQualifiedName($this->class); if ($this->method) { $location .= ($this->static ? '::' : '->') . $this->method . '()'; ...
php
{ "resource": "" }
q16278
Context.phpdocSummary
train
public function phpdocSummary() { $content = $this->phpdocContent(); if (!$content) { return UNDEFINED; } $lines = preg_split('/(\n|\r\n)/', $content); $summary = '';
php
{ "resource": "" }
q16279
Context.detect
train
public static function detect($index = 0) { $context = new Context(); $backtrace = debug_backtrace(); $position = $backtrace[$index]; if (isset($position['file'])) { $context->filename = $position['file']; } if (isset($position['line'])) { $con...
php
{ "resource": "" }
q16280
Context.fullyQualifiedName
train
public function fullyQualifiedName($class) { if ($this->namespace) { $namespace = str_replace('\\\\', '\\', '\\' . $this->namespace . '\\'); } else { $namespace = '\\'; // global namespace } if ($this->class === null) { $this->class = ''; ...
php
{ "resource": "" }
q16281
Analysis.getTraitsOfClass
train
public function getTraitsOfClass($class) { $definitions = []; // in case there is a hierarchy of classes $classes = $this->getSuperClasses($class); if (is_array($classes)) { foreach ($classes as $subClass) { if (isset($subClass['traits'])) { ...
php
{ "resource": "" }
q16282
Analysis.merged
train
public function merged() { if (!$this->openapi) { throw new Exception('No openapi target set. Run the MergeIntoOpenApi processor'); } $unmerged = $this->openapi->_unmerged; $this->openapi->_unmerged = [];
php
{ "resource": "" }
q16283
Analysis.split
train
public function split() { $result = new stdClass(); $result->merged = $this->merged(); $result->unmerged = new Analysis(); foreach ($this->annotations as $annotation) { if ($result->merged->annotations->contains($annotation) === false) {
php
{ "resource": "" }
q16284
Analysis.&
train
public static function &processors() { if (!self::$processors) { // Add default processors. self::$processors = [ new MergeIntoOpenApi(), new MergeIntoComponents(), new ImportTraits(), new AugmentSchemas(), ...
php
{ "resource": "" }
q16285
Analysis.unregisterProcessor
train
public static function unregisterProcessor($processor) { $processors = &self::processors(); $key = array_search($processor, $processors, true); if ($key === false) {
php
{ "resource": "" }
q16286
StaticAnalyser.fromFile
train
public function fromFile($filename) { if (function_exists('opcache_get_status') && function_exists('opcache_get_configuration')) { if (empty($GLOBALS['openapi_opcache_warning'])) { $GLOBALS['openapi_opcache_warning'] = true; $status = opcache_get_status(); ...
php
{ "resource": "" }
q16287
StaticAnalyser.fromCode
train
public function fromCode($code, $context) { $tokens = token_get_all($code);
php
{ "resource": "" }
q16288
StaticAnalyser.nextToken
train
private function nextToken(&$tokens, $context) { while (true) { $token = next($tokens); if ($token[0] === T_WHITESPACE) { continue; } if ($token[0] === T_COMMENT) { $pos = strpos($token[1], '@OA\\'); if ($pos) { ...
php
{ "resource": "" }
q16289
OpenApi.saveAs
train
public function saveAs($filename, $format = 'auto') { if ($format === 'auto') { $format = strtolower(substr($filename, -5)) === '.json' ? 'json' : 'yaml'; } if (strtolower($format) === 'json') { $content = $this->toJson(); } else {
php
{ "resource": "" }
q16290
Util.removePrefix
train
private static function removePrefix($str, $prefix) { if (substr($str, 0, strlen($prefix)) == $prefix) { return
php
{ "resource": "" }
q16291
ItemMenu.route
train
public function route(string $name, array $parameters = [], bool $absolute = true): self { $this->route = route($name, $parameters, $absolute);
php
{ "resource": "" }
q16292
Picture.targetId
train
public function targetId(): self { $this->set('target', 'id'); $this->addBeforeRender(function () { $value = (string) $this->get('value'); if (! ctype_digit($value)) {
php
{ "resource": "" }
q16293
Menu.add
train
public function add(string $place, ItemMenu $itemMenu) { $arg = get_object_vars($itemMenu); if (array_key_exists('show', $arg) && ! $arg['show']) { return $this; } $this->location = $place;
php
{ "resource": "" }
q16294
Menu.render
train
public function render(string $location, string $template = 'platform::partials.mainMenu'): string { $this->checkAccess(); return $this->findAllChildren($location) ->sortBy('sort')
php
{ "resource": "" }
q16295
ResourceController.show
train
public function show(string $package, string $path, Dashboard $dashboard) { $dir = $dashboard ->getPublicDirectory() ->get($package); abort_if(is_null($dir), 404); $resources = (new Finder()) ->ignoreUnreadableDirs() ->followLinks() ...
php
{ "resource": "" }
q16296
Post.getEntityObject
train
public function getEntityObject($slug = null) { if (! is_null($this->entity)) {
php
{ "resource": "" }
q16297
TaxonomyBuilder.slug
train
public function slug($slug = null): self { if (! empty($slug)) { // set this slug to be used in with callback $this->slug = $slug; // exception to filter on specific slug $exception = function ($query) {
php
{ "resource": "" }
q16298
DateTimer.noCalendar
train
public function noCalendar(bool $noCalendar = true) : self { $this->enableTime();
php
{ "resource": "" }
q16299
Many.getFilters
train
public function getFilters(): Collection { $filters = collect(); foreach ($this->filters() as $filter) { $filter = new
php
{ "resource": "" }