_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q14800
WP_CLI.do_hook
train
public static function do_hook( $when ) { $args = func_num_args() > 1 ? array_slice( func_get_args(), 1 ) : array(); self::$hooks_passed[ $when ] = $args; if ( ! isset( self::$hooks[ $when ] ) ) { return; } self::debug( sprintf( 'Processing hook "%s" with %d callbacks', $when, count( self::$hooks[ $when ] ) ), 'hooks' ); foreach ( self::$hooks[ $when ] as $callback ) { self::debug( sprintf( 'On hook "%s": %s', $when, Utils\describe_callable( $callback ) ), 'hooks' ); call_user_func_array( $callback, $args ); } }
php
{ "resource": "" }
q14801
WP_CLI.add_wp_hook
train
public static function add_wp_hook( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { global $wp_filter, $merged_filters; if ( function_exists( 'add_filter' ) ) { add_filter( $tag, $function_to_add, $priority, $accepted_args ); } else { $idx = self::wp_hook_build_unique_id( $tag, $function_to_add, $priority ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- This is intentional & the purpose of this function. $wp_filter[ $tag ][ $priority ][ $idx ] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args, ); unset( $merged_filters[ $tag ] ); } return true; }
php
{ "resource": "" }
q14802
WP_CLI.defer_command_addition
train
private static function defer_command_addition( $name, $parent, $callable, $args = array() ) { $args['is_deferred'] = true; self::$deferred_additions[ $name ] = array( 'parent' => $parent, 'callable' => $callable, 'args' => $args, ); self::add_hook( "after_add_command:$parent", function () use ( $name ) { $deferred_additions = WP_CLI::get_deferred_additions(); if ( ! array_key_exists( $name, $deferred_additions ) ) { return; } $callable = $deferred_additions[ $name ]['callable']; $args = $deferred_additions[ $name ]['args']; WP_CLI::remove_deferred_addition( $name ); WP_CLI::add_command( $name, $callable, $args ); } ); }
php
{ "resource": "" }
q14803
WP_CLI.remove_deferred_addition
train
public static function remove_deferred_addition( $name ) { if ( ! array_key_exists( $name, self::$deferred_additions ) ) { self::warning( "Trying to remove a non-existent command addition '{$name}'." ); } unset( self::$deferred_additions[ $name ] ); }
php
{ "resource": "" }
q14804
WP_CLI.error_multi_line
train
public static function error_multi_line( $message_lines ) { if ( ! isset( self::get_runner()->assoc_args['completions'] ) && is_array( $message_lines ) ) { self::$logger->error_multi_line( array_map( array( __CLASS__, 'error_to_string' ), $message_lines ) ); } }
php
{ "resource": "" }
q14805
WP_CLI.confirm
train
public static function confirm( $question, $assoc_args = array() ) { if ( ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'yes' ) ) { fwrite( STDOUT, $question . ' [y/n] ' ); $answer = strtolower( trim( fgets( STDIN ) ) ); if ( 'y' !== $answer ) { exit; } } }
php
{ "resource": "" }
q14806
WP_CLI.get_value_from_arg_or_stdin
train
public static function get_value_from_arg_or_stdin( $args, $index ) { if ( isset( $args[ $index ] ) ) { $raw_value = $args[ $index ]; } else { // We don't use file_get_contents() here because it doesn't handle // Ctrl-D properly, when typing in the value interactively. $raw_value = ''; while ( false !== ( $line = fgets( STDIN ) ) ) { $raw_value .= $line; } } return $raw_value; }
php
{ "resource": "" }
q14807
WP_CLI.read_value
train
public static function read_value( $raw_value, $assoc_args = array() ) { if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) { $value = json_decode( $raw_value, true ); if ( null === $value ) { self::error( sprintf( 'Invalid JSON: %s', $raw_value ) ); } } else { $value = $raw_value; } return $value; }
php
{ "resource": "" }
q14808
WP_CLI.print_value
train
public static function print_value( $value, $assoc_args = array() ) { if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) { $value = json_encode( $value ); } elseif ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) { $value = Spyc::YAMLDump( $value, 2, 0 ); } elseif ( is_array( $value ) || is_object( $value ) ) { $value = var_export( $value, true ); } echo $value . "\n"; }
php
{ "resource": "" }
q14809
WP_CLI.error_to_string
train
public static function error_to_string( $errors ) { if ( is_string( $errors ) ) { return $errors; } // Only json_encode() the data when it needs it $render_data = function( $data ) { if ( is_array( $data ) || is_object( $data ) ) { return json_encode( $data ); } return '"' . $data . '"'; }; if ( is_object( $errors ) && is_a( $errors, 'WP_Error' ) ) { foreach ( $errors->get_error_messages() as $message ) { if ( $errors->get_error_data() ) { return $message . ' ' . $render_data( $errors->get_error_data() ); } return $message; } } }
php
{ "resource": "" }
q14810
WP_CLI.launch_self
train
public static function launch_self( $command, $args = array(), $assoc_args = array(), $exit_on_error = true, $return_detailed = false, $runtime_args = array() ) { $reused_runtime_args = array( 'path', 'url', 'user', 'allow-root', ); foreach ( $reused_runtime_args as $key ) { if ( isset( $runtime_args[ $key ] ) ) { $assoc_args[ $key ] = $runtime_args[ $key ]; continue; } $value = self::get_runner()->config[ $key ]; if ( $value ) { $assoc_args[ $key ] = $value; } } $php_bin = escapeshellarg( Utils\get_php_binary() ); $script_path = $GLOBALS['argv'][0]; if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) { $config_path = getenv( 'WP_CLI_CONFIG_PATH' ); } else { $config_path = Utils\get_home_dir() . '/.wp-cli/config.yml'; } $config_path = escapeshellarg( $config_path ); $args = implode( ' ', array_map( 'escapeshellarg', $args ) ); $assoc_args = \WP_CLI\Utils\assoc_args_to_str( $assoc_args ); $full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$command} {$args} {$assoc_args}"; return self::launch( $full_command, $exit_on_error, $return_detailed ); }
php
{ "resource": "" }
q14811
WP_CLI.get_config
train
public static function get_config( $key = null ) { if ( null === $key ) { return self::get_runner()->config; } if ( ! isset( self::get_runner()->config[ $key ] ) ) { self::warning( "Unknown config option '$key'." ); return null; } return self::get_runner()->config[ $key ]; }
php
{ "resource": "" }
q14812
SynopsisParser.render
train
public static function render( &$synopsis ) { if ( ! is_array( $synopsis ) ) { return ''; } $bits = [ 'positional' => '', 'assoc' => '', 'generic' => '', 'flag' => '', ]; $reordered_synopsis = [ 'positional' => [], 'assoc' => [], 'generic' => [], 'flag' => [], ]; foreach ( $bits as $key => &$value ) { foreach ( $synopsis as $arg ) { if ( empty( $arg['type'] ) || $key !== $arg['type'] ) { continue; } if ( empty( $arg['name'] ) && 'generic' !== $arg['type'] ) { continue; } if ( 'positional' === $key ) { $rendered_arg = "<{$arg['name']}>"; $reordered_synopsis['positional'] [] = $arg; } elseif ( 'assoc' === $key ) { $arg_value = isset( $arg['value']['name'] ) ? $arg['value']['name'] : $arg['name']; $rendered_arg = "--{$arg['name']}=<{$arg_value}>"; $reordered_synopsis['assoc'] [] = $arg; } elseif ( 'generic' === $key ) { $rendered_arg = '--<field>=<value>'; $reordered_synopsis['generic'] [] = $arg; } elseif ( 'flag' === $key ) { $rendered_arg = "--{$arg['name']}"; $reordered_synopsis['flag'] [] = $arg; } if ( ! empty( $arg['repeating'] ) ) { $rendered_arg = "{$rendered_arg}..."; } if ( ! empty( $arg['optional'] ) ) { $rendered_arg = "[{$rendered_arg}]"; } $value .= "{$rendered_arg} "; } } $rendered = ''; foreach ( $bits as $v ) { if ( ! empty( $v ) ) { $rendered .= $v; } } $synopsis = array_merge( $reordered_synopsis['positional'], $reordered_synopsis['assoc'], $reordered_synopsis['generic'], $reordered_synopsis['flag'] ); return rtrim( $rendered, ' ' ); }
php
{ "resource": "" }
q14813
SynopsisParser.classify_token
train
private static function classify_token( $token ) { $param = array(); list( $param['optional'], $token ) = self::is_optional( $token ); list( $param['repeating'], $token ) = self::is_repeating( $token ); $p_name = '([a-z-_0-9]+)'; $p_value = '([a-zA-Z-_|,0-9]+)'; if ( '--<field>=<value>' === $token ) { $param['type'] = 'generic'; } elseif ( preg_match( "/^<($p_value)>$/", $token, $matches ) ) { $param['type'] = 'positional'; $param['name'] = $matches[1]; } elseif ( preg_match( "/^--(?:\\[no-\\])?$p_name/", $token, $matches ) ) { $param['name'] = $matches[1]; $value = substr( $token, strlen( $matches[0] ) ); // substr returns false <= PHP 5.6, and '' PHP 7+ if ( false === $value || '' === $value ) { $param['type'] = 'flag'; } else { $param['type'] = 'assoc'; list( $param['value']['optional'], $value ) = self::is_optional( $value ); if ( preg_match( "/^=<$p_value>$/", $value, $matches ) ) { $param['value']['name'] = $matches[1]; } else { $param = array( 'type' => 'unknown', ); } } } else { $param['type'] = 'unknown'; } return $param; }
php
{ "resource": "" }
q14814
SynopsisParser.is_optional
train
private static function is_optional( $token ) { if ( '[' === substr( $token, 0, 1 ) && ']' === substr( $token, -1 ) ) { return array( true, substr( $token, 1, -1 ) ); } return array( false, $token ); }
php
{ "resource": "" }
q14815
StatusMessage.setRefersTo
train
public function setRefersTo($var) { GPBUtil::checkEnum($var, \Google\Cloud\Debugger\V2\StatusMessage_Reference::class); $this->refers_to = $var; return $this; }
php
{ "resource": "" }
q14816
StatusMessage.setDescription
train
public function setDescription($var) { GPBUtil::checkMessage($var, \Google\Cloud\Debugger\V2\FormatMessage::class); $this->description = $var; return $this; }
php
{ "resource": "" }
q14817
ExportAssetsRequest.setContentType
train
public function setContentType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Asset\V1\ContentType::class); $this->content_type = $var; return $this; }
php
{ "resource": "" }
q14818
ListDataSourcesResponse.setDataSources
train
public function setDataSources($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BigQuery\DataTransfer\V1\DataSource::class); $this->data_sources = $arr; return $this; }
php
{ "resource": "" }
q14819
TimeSeries.setPoints
train
public function setPoints($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\Point::class); $this->points = $arr; return $this; }
php
{ "resource": "" }
q14820
Date.createFromValues
train
public static function createFromValues($year, $month, $day) { $value = sprintf('%s-%s-%s', $year, $month, $day); $dt = \DateTimeImmutable::createFromFormat(self::FORMAT, $value); return new static($dt); }
php
{ "resource": "" }
q14821
BatchJob.flush
train
public function flush(array $items = []) { if (! $this->callFunc($items)) { $this->handleFailure($this->id, $items); return false; } return true; }
php
{ "resource": "" }
q14822
CreateIndexRequest.setIndex
train
public function setIndex($var) { GPBUtil::checkMessage($var, \Google\Cloud\Firestore\Admin\V1\Index::class); $this->index = $var; return $this; }
php
{ "resource": "" }
q14823
InstanceAdminGrpcClient.GetInstance
train
public function GetInstance(\Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/google.spanner.admin.instance.v1.InstanceAdmin/GetInstance', $argument, ['\Google\Cloud\Spanner\Admin\Instance\V1\Instance', 'decode'], $metadata, $options); }
php
{ "resource": "" }
q14824
InstanceAdminGrpcClient.DeleteInstance
train
public function DeleteInstance(\Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstance', $argument, ['\Google\Protobuf\GPBEmpty', 'decode'], $metadata, $options); }
php
{ "resource": "" }
q14825
DatastoreKey.setEntityKey
train
public function setEntityKey($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Key::class); $this->entity_key = $var; return $this; }
php
{ "resource": "" }
q14826
WorkflowMetadata.setCreateCluster
train
public function setCreateCluster($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\ClusterOperation::class); $this->create_cluster = $var; return $this; }
php
{ "resource": "" }
q14827
WorkflowMetadata.setGraph
train
public function setGraph($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\WorkflowGraph::class); $this->graph = $var; return $this; }
php
{ "resource": "" }
q14828
WorkflowMetadata.setParameters
train
public function setParameters($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); $this->parameters = $arr; return $this; }
php
{ "resource": "" }
q14829
CommitRequest.setWrites
train
public function setWrites($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Firestore\V1beta1\Write::class); $this->writes = $arr; return $this; }
php
{ "resource": "" }
q14830
ListTopicSubscriptionsResponse.setSubscriptions
train
public function setSubscriptions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->subscriptions = $arr; return $this; }
php
{ "resource": "" }
q14831
UpdateDocumentRequest.setMask
train
public function setMask($var) { GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\DocumentMask::class); $this->mask = $var; return $this; }
php
{ "resource": "" }
q14832
UpdateDocumentRequest.setCurrentDocument
train
public function setCurrentDocument($var) { GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1\Precondition::class); $this->current_document = $var; return $this; }
php
{ "resource": "" }
q14833
Entity.setMetadata
train
public function setMetadata($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); $this->metadata = $arr; return $this; }
php
{ "resource": "" }
q14834
Entity.setMentions
train
public function setMentions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1beta2\EntityMention::class); $this->mentions = $arr; return $this; }
php
{ "resource": "" }
q14835
WriteLogEntriesPartialErrors.setLogEntryErrors
train
public function setLogEntryErrors($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::INT32, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\Status::class); $this->log_entry_errors = $arr; return $this; }
php
{ "resource": "" }
q14836
DeidentifyContentResponse.setItem
train
public function setItem($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\ContentItem::class); $this->item = $var; return $this; }
php
{ "resource": "" }
q14837
DeidentifyContentResponse.setOverview
train
public function setOverview($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\TransformationOverview::class); $this->overview = $var; return $this; }
php
{ "resource": "" }
q14838
IntentBatch.setIntents
train
public function setIntents($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent::class); $this->intents = $arr; return $this; }
php
{ "resource": "" }
q14839
CreateDeviceRegistryRequest.setDeviceRegistry
train
public function setDeviceRegistry($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iot\V1\DeviceRegistry::class); $this->device_registry = $var; return $this; }
php
{ "resource": "" }
q14840
CloudWorkspaceId.setRepoId
train
public function setRepoId($var) { GPBUtil::checkMessage($var, \Google\Cloud\DevTools\Source\V1\RepoId::class); $this->repo_id = $var; return $this; }
php
{ "resource": "" }
q14841
Breakpoint.setAction
train
public function setAction($var) { GPBUtil::checkEnum($var, \Google\Cloud\Debugger\V2\Breakpoint_Action::class); $this->action = $var; return $this; }
php
{ "resource": "" }
q14842
Breakpoint.setLocation
train
public function setLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Debugger\V2\SourceLocation::class); $this->location = $var; return $this; }
php
{ "resource": "" }
q14843
Breakpoint.setExpressions
train
public function setExpressions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->expressions = $arr; return $this; }
php
{ "resource": "" }
q14844
Breakpoint.setLogLevel
train
public function setLogLevel($var) { GPBUtil::checkEnum($var, \Google\Cloud\Debugger\V2\Breakpoint_LogLevel::class); $this->log_level = $var; return $this; }
php
{ "resource": "" }
q14845
Breakpoint.setEvaluatedExpressions
train
public function setEvaluatedExpressions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Variable::class); $this->evaluated_expressions = $arr; return $this; }
php
{ "resource": "" }
q14846
Breakpoint.setVariableTable
train
public function setVariableTable($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Debugger\V2\Variable::class); $this->variable_table = $arr; return $this; }
php
{ "resource": "" }
q14847
Breakpoint.setLabels
train
public function setLabels($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); $this->labels = $arr; return $this; }
php
{ "resource": "" }
q14848
Finding.setState
train
public function setState($var) { GPBUtil::checkEnum($var, \Google\Cloud\SecurityCenter\V1\Finding_State::class); $this->state = $var; return $this; }
php
{ "resource": "" }
q14849
Finding.setSourceProperties
train
public function setSourceProperties($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); $this->source_properties = $arr; return $this; }
php
{ "resource": "" }
q14850
Finding.setSecurityMarks
train
public function setSecurityMarks($var) { GPBUtil::checkMessage($var, \Google\Cloud\SecurityCenter\V1\SecurityMarks::class); $this->security_marks = $var; return $this; }
php
{ "resource": "" }
q14851
MatchingFileIterator.accept
train
public function accept() { $candidate = $this->getInnerIterator()->current(); // Check that the candidate file (a full file path) ends in the pattern we are searching for. return strrpos($candidate, $this->file) === strlen($candidate) - strlen($this->file); }
php
{ "resource": "" }
q14852
CreateGroupRequest.setGroup
train
public function setGroup($var) { GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Group::class); $this->group = $var; return $this; }
php
{ "resource": "" }
q14853
ContentLocation.setRecordLocation
train
public function setRecordLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\RecordLocation::class); $this->writeOneof(2, $var); return $this; }
php
{ "resource": "" }
q14854
ContentLocation.setImageLocation
train
public function setImageLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\ImageLocation::class); $this->writeOneof(3, $var); return $this; }
php
{ "resource": "" }
q14855
ContentLocation.setDocumentLocation
train
public function setDocumentLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\DocumentLocation::class); $this->writeOneof(5, $var); return $this; }
php
{ "resource": "" }
q14856
SysvProcessor.submit
train
public function submit($item, $idNum) { if (!array_key_exists($idNum, $this->sysvQs)) { $this->sysvQs[$idNum] = msg_get_queue($this->getSysvKey($idNum)); } $result = @msg_send( $this->sysvQs[$idNum], self::$typeDirect, $item ); if ($result === false) { // Try to put the content in a temp file and send the filename. $tempFile = tempnam(sys_get_temp_dir(), 'Item'); $result = file_put_contents($tempFile, serialize($item)); if ($result === false) { throw new \RuntimeException( "Failed to write to $tempFile while submiting the item" ); } $result = @msg_send( $this->sysvQs[$idNum], self::$typeFile, $tempFile ); if ($result === false) { @unlink($tempFile); throw new \RuntimeException( "Failed to submit the filename: $tempFile" ); } } }
php
{ "resource": "" }
q14857
ClusterUpdate.setDesiredAddonsConfig
train
public function setDesiredAddonsConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\AddonsConfig::class); $this->desired_addons_config = $var; return $this; }
php
{ "resource": "" }
q14858
ClusterUpdate.setDesiredNodePoolAutoscaling
train
public function setDesiredNodePoolAutoscaling($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\NodePoolAutoscaling::class); $this->desired_node_pool_autoscaling = $var; return $this; }
php
{ "resource": "" }
q14859
ClusterUpdate.setDesiredMasterAuthorizedNetworksConfig
train
public function setDesiredMasterAuthorizedNetworksConfig($var) { GPBUtil::checkMessage($var, \Google\Cloud\Container\V1\MasterAuthorizedNetworksConfig::class); $this->desired_master_authorized_networks_config = $var; return $this; }
php
{ "resource": "" }
q14860
StreamingRecognitionResult.setMessageType
train
public function setMessageType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\StreamingRecognitionResult_MessageType::class); $this->message_type = $var; return $this; }
php
{ "resource": "" }
q14861
AnnotationPayload.setTranslation
train
public function setTranslation($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TranslationAnnotation::class); $this->writeOneof(2, $var); return $this; }
php
{ "resource": "" }
q14862
AnnotationPayload.setClassification
train
public function setClassification($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\ClassificationAnnotation::class); $this->writeOneof(3, $var); return $this; }
php
{ "resource": "" }
q14863
DeltaPresenceEstimationConfig.setAuxiliaryTables
train
public function setAuxiliaryTables($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\StatisticalTable::class); $this->auxiliary_tables = $arr; return $this; }
php
{ "resource": "" }
q14864
ListDeviceRegistriesResponse.setDeviceRegistries
train
public function setDeviceRegistries($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iot\V1\DeviceRegistry::class); $this->device_registries = $arr; return $this; }
php
{ "resource": "" }
q14865
InstantiateInlineWorkflowTemplateRequest.setTemplate
train
public function setTemplate($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\WorkflowTemplate::class); $this->template = $var; return $this; }
php
{ "resource": "" }
q14866
TranslationAnnotation.setTranslatedContent
train
public function setTranslatedContent($var) { GPBUtil::checkMessage($var, \Google\Cloud\AutoMl\V1beta1\TextSnippet::class); $this->translated_content = $var; return $this; }
php
{ "resource": "" }
q14867
AttributeTrait.addAttributes
train
public function addAttributes(array $attributes) { foreach ($attributes as $key => $value) { $this->addAttribute($key, $value); } }
php
{ "resource": "" }
q14868
AttributeTrait.addAttribute
train
public function addAttribute($key, $value) { if (!$this->attributes) { $this->attributes = new Attributes(); } $this->attributes[$key] = $value; }
php
{ "resource": "" }
q14869
ValueMapper.encodeValuesAsSimpleType
train
public function encodeValuesAsSimpleType(array $values, $allowMixedArrayType = false) { $res = []; foreach ($values as $value) { $type = null; $definition = null; if (is_array($value) && (empty($value) || !$this->isAssoc($value))) { $type = Database::TYPE_ARRAY; $definition = new ArrayType(null); } $res[] = $this->paramType($value, $type, $definition, $allowMixedArrayType)[0]; } return $res; }
php
{ "resource": "" }
q14870
ValueMapper.resolveTypeDefinition
train
private function resolveTypeDefinition($type, $key = null) { $definition = null; if (is_array($type)) { $type += [ 1 => null, 2 => null ]; $definition = new ArrayType($type[1], $type[2]); $type = Database::TYPE_ARRAY; } elseif ($type instanceof ArrayType) { $definition = $type; $type = Database::TYPE_ARRAY; } elseif ($type instanceof StructType) { $definition = $type; $type = Database::TYPE_STRUCT; } return [$type, $definition]; }
php
{ "resource": "" }
q14871
ValueMapper.decodeValue
train
private function decodeValue($value, array $type) { if ($value === null || $value === '') { return $value; } switch ($type['code']) { case self::TYPE_INT64: $value = $this->returnInt64AsObject ? new Int64($value) : (int) $value; break; case self::TYPE_TIMESTAMP: $value = $this->parseTimeString($value); $value = new Timestamp($value[0], $value[1]); break; case self::TYPE_DATE: $value = new Date(new \DateTimeImmutable($value)); break; case self::TYPE_BYTES: $value = new Bytes(base64_decode($value)); break; case self::TYPE_ARRAY: $res = []; foreach ($value as $item) { $res[] = $this->decodeValue($item, $type['arrayElementType']); } $value = $res; break; case self::TYPE_STRUCT: $fields = isset($type['structType']['fields']) ? $type['structType']['fields'] : []; $value = $this->decodeValues($fields, $value, Result::RETURN_ASSOCIATIVE); break; case self::TYPE_FLOAT64: // NaN, Infinite and -Infinite are possible FLOAT64 values, // but when the gRPC response is decoded, they are represented // as strings. This conditional checks for a string, converts to // an equivalent double value, or dies if something really weird // happens. if (is_string($value)) { switch ($value) { case 'NaN': $value = NAN; break; case 'Infinity': $value = INF; break; case '-Infinity': $value = -INF; break; default: throw new \RuntimeException(sprintf( 'Unexpected string value %s encountered in FLOAT64 field.', $value )); } } break; } return $value; }
php
{ "resource": "" }
q14872
ValueMapper.paramType
train
private function paramType( $value, $givenType = null, $definition = null, $allowMixedArrayType = false ) { $valueType = gettype($value); // If a definition is provided, the type is set to `array` to force // the value to be interpreted as an array or a struct, even if null. if ($definition !== null) { $valueType = 'array'; } switch ($valueType) { case 'boolean': $type = $this->typeObject($givenType ?: self::TYPE_BOOL); break; case 'integer': $value = (string) $value; $type = $this->typeObject($givenType ?: self::TYPE_INT64); break; case 'double': $type = $this->typeObject($givenType ?: self::TYPE_FLOAT64); switch ($value) { case INF: $value = 'Infinity'; break; case -INF: $value = '-Infinity'; break; } if (!is_string($value) && is_nan($value)) { $value = 'NaN'; } break; case 'string': $type = $this->typeObject($givenType ?: self::TYPE_STRING); break; case 'resource': $type = $this->typeObject($givenType ?: self::TYPE_BYTES); $value = base64_encode(stream_get_contents($value)); break; case 'object': list ($type, $value) = $this->objectParam($value); break; case 'array': if ($givenType === Database::TYPE_STRUCT) { if (!($definition instanceof StructType)) { throw new \InvalidArgumentException( 'Struct parameter types must be declared explicitly, and must '. 'be an instance of Google\Cloud\Spanner\StructType.' ); } if ($value instanceof \stdClass) { $value = (array) $value; } list ($value, $type) = $this->structParam($value, $definition); } else { if (!($definition instanceof ArrayType)) { throw new \InvalidArgumentException( 'Array parameter types must be an instance of Google\Cloud\Spanner\ArrayType.' ); } list ($value, $type) = $this->arrayParam($value, $definition, $allowMixedArrayType); } break; case 'NULL': $type = $this->typeObject($givenType); break; default: throw new \InvalidArgumentException(sprintf( 'Unrecognized value type %s. ' . 'Please ensure you are using the latest version of google/cloud or google/cloud-spanner.', get_class($value) )); break; } return [$value, $type]; }
php
{ "resource": "" }
q14873
ValueMapper.arrayParam
train
private function arrayParam($value, ArrayType $arrayType, $allowMixedArrayType = false) { if (!is_array($value) && $value !== null) { throw new \InvalidArgumentException('Array value must be an array or null.'); } $inferredTypes = []; $res = null; if ($value !== null) { $res = []; foreach ($value as $element) { $type = $this->paramType( $element, $arrayType->type() === Database::TYPE_STRUCT ? $arrayType->type() : null, $arrayType->structType() ); $res[] = $type[0]; if (isset($type[1]['code'])) { $inferredTypes[] = $type[1]['code']; } } } if (!$allowMixedArrayType && count(array_unique($inferredTypes)) > 1) { throw new \InvalidArgumentException('Array values may not be of mixed type'); } $nested = $arrayType->structType(); $arrayType = $arrayType->type(); if (!empty($value) && $arrayType && $arrayType !== $inferredTypes[0]) { throw new \InvalidArgumentException('Array data does not match given array parameter type.'); } $typeCode = $arrayType === null && $inferredTypes ? $inferredTypes[0] : $arrayType; if ($nested) { $nestedDefType = $this->resolveTypeDefinition($nested); $nestedDef = $this->paramType(null, $nestedDefType[0], $nestedDefType[1]); $typeObject = $nestedDef[1]; } else { $typeObject = $this->typeObject($typeCode); } $type = $this->typeObject( self::TYPE_ARRAY, $typeObject, 'arrayElementType' ); return [$res, $type]; }
php
{ "resource": "" }
q14874
ValueMapper.objectParam
train
private function objectParam($value) { if ($value instanceof \stdClass) { throw new \InvalidArgumentException( 'Values of type `\stdClass` are interpreted as structs and must define their types.' ); } if ($value instanceof ValueInterface) { return [ $this->typeObject($value->type()), $value->formatAsString() ]; } if ($value instanceof Int64) { return [ $this->typeObject(self::TYPE_INT64), $value->get() ]; } throw new \InvalidArgumentException(sprintf( 'Unrecognized value type %s. ' . 'Please ensure you are using the latest version of google/cloud or google/cloud-spanner.', get_class($value) )); }
php
{ "resource": "" }
q14875
ValueMapper.getColumnName
train
private function getColumnName($columns, $index) { return (isset($columns[$index]['name']) && $columns[$index]['name']) ? $columns[$index]['name'] : $index; }
php
{ "resource": "" }
q14876
GcRule.setIntersection
train
public function setIntersection($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\GcRule_Intersection::class); $this->writeOneof(3, $var); return $this; }
php
{ "resource": "" }
q14877
GcRule.setUnion
train
public function setUnion($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\GcRule_Union::class); $this->writeOneof(4, $var); return $this; }
php
{ "resource": "" }
q14878
SpeechClient.recognize
train
public function recognize($audio, array $options = []) { $results = []; $response = $this->connection->recognize( $this->formatRequest($audio, $options) ); if (!isset($response['results'])) { return $results; } foreach ($response['results'] as $result) { $results[] = new Result($result); } return $results; }
php
{ "resource": "" }
q14879
SpeechClient.beginRecognizeOperation
train
public function beginRecognizeOperation($audio, array $options = []) { $response = $this->connection->longRunningRecognize( $this->formatRequest($audio, $options) ); return new Operation( $this->connection, $response['name'], $response ); }
php
{ "resource": "" }
q14880
PlanNode.setChildLinks
train
public function setChildLinks($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\PlanNode\ChildLink::class); $this->child_links = $arr; return $this; }
php
{ "resource": "" }
q14881
Dataset.exists
train
public function exists() { try { $this->connection->getDataset($this->identity + ['fields' => 'datasetReference']); } catch (NotFoundException $ex) { return false; } return true; }
php
{ "resource": "" }
q14882
Dataset.tables
train
public function tables(array $options = []) { $resultLimit = $this->pluck('resultLimit', $options, false); return new ItemIterator( new PageIterator( function (array $table) { return new Table( $this->connection, $table['tableReference']['tableId'], $this->identity['datasetId'], $this->identity['projectId'], $this->mapper, $table ); }, [$this->connection, 'listTables'], $options + $this->identity, [ 'itemsKey' => 'tables', 'resultLimit' => $resultLimit ] ) ); }
php
{ "resource": "" }
q14883
Dataset.reload
train
public function reload(array $options = []) { return $this->info = $this->connection->getDataset($options + $this->identity); }
php
{ "resource": "" }
q14884
RecordLocation.setRecordKey
train
public function setRecordKey($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\RecordKey::class); $this->record_key = $var; return $this; }
php
{ "resource": "" }
q14885
RecordLocation.setFieldId
train
public function setFieldId($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\FieldId::class); $this->field_id = $var; return $this; }
php
{ "resource": "" }
q14886
RecordLocation.setTableLocation
train
public function setTableLocation($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\TableLocation::class); $this->table_location = $var; return $this; }
php
{ "resource": "" }
q14887
Field.setType
train
public function setType($var) { GPBUtil::checkMessage($var, \Google\Cloud\Spanner\V1\Type::class); $this->type = $var; return $this; }
php
{ "resource": "" }
q14888
BatchClient.snapshot
train
public function snapshot(array $options = []) { $options += [ 'transactionOptions' => [], ]; // Single Use transactions are not supported in batch mode. $options['transactionOptions']['singleUse'] = false; $transactionOptions = $this->pluck('transactionOptions', $options); $transactionOptions['returnReadTimestamp'] = true; $transactionOptions = $this->configureSnapshotOptions($transactionOptions); $session = $this->operation->createSession( $this->databaseName, $this->pluck('sessionOptions', $options, false) ?: [] ); return $this->operation->snapshot($session, [ 'className' => BatchSnapshot::class, 'transactionOptions' => $transactionOptions ] + $options); }
php
{ "resource": "" }
q14889
VideoAnnotationResults.setFrameLabelAnnotations
train
public function setFrameLabelAnnotations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\LabelAnnotation::class); $this->frame_label_annotations = $arr; return $this; }
php
{ "resource": "" }
q14890
VideoAnnotationResults.setFaceAnnotations
train
public function setFaceAnnotations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\FaceAnnotation::class); $this->face_annotations = $arr; return $this; }
php
{ "resource": "" }
q14891
VideoAnnotationResults.setShotAnnotations
train
public function setShotAnnotations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\VideoSegment::class); $this->shot_annotations = $arr; return $this; }
php
{ "resource": "" }
q14892
VideoAnnotationResults.setExplicitAnnotation
train
public function setExplicitAnnotation($var) { GPBUtil::checkMessage($var, \Google\Cloud\VideoIntelligence\V1\ExplicitContentAnnotation::class); $this->explicit_annotation = $var; return $this; }
php
{ "resource": "" }
q14893
VideoAnnotationResults.setSpeechTranscriptions
train
public function setSpeechTranscriptions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\SpeechTranscription::class); $this->speech_transcriptions = $arr; return $this; }
php
{ "resource": "" }
q14894
VideoAnnotationResults.setTextAnnotations
train
public function setTextAnnotations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\TextAnnotation::class); $this->text_annotations = $arr; return $this; }
php
{ "resource": "" }
q14895
VideoAnnotationResults.setObjectAnnotations
train
public function setObjectAnnotations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\VideoIntelligence\V1\ObjectTrackingAnnotation::class); $this->object_annotations = $arr; return $this; }
php
{ "resource": "" }
q14896
ExplicitContentFrame.setPornographyLikelihood
train
public function setPornographyLikelihood($var) { GPBUtil::checkEnum($var, \Google\Cloud\VideoIntelligence\V1\Likelihood::class); $this->pornography_likelihood = $var; return $this; }
php
{ "resource": "" }
q14897
CreateTableFromSnapshotMetadata.setOriginalRequest
train
public function setOriginalRequest($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotRequest::class); $this->original_request = $var; return $this; }
php
{ "resource": "" }
q14898
QueryResult.setFulfillmentMessages
train
public function setFulfillmentMessages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\Message::class); $this->fulfillment_messages = $arr; return $this; }
php
{ "resource": "" }
q14899
QueryResult.setSentimentAnalysisResult
train
public function setSentimentAnalysisResult($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\SentimentAnalysisResult::class); $this->sentiment_analysis_result = $var; return $this; }
php
{ "resource": "" }