_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q22700
Selector.find
train
public function find(AbstractNode $node): Collection { $results = new Collection; foreach ($this->selectors as $selector) { $nodes = [$node]; if (count($selector) == 0) { continue; } $options = []; foreach ($selector as $ru...
php
{ "resource": "" }
q22701
Selector.flattenOptions
train
protected function flattenOptions(array $optionsArray) { $options = []; foreach ($optionsArray as $optionArray)
php
{ "resource": "" }
q22702
Selector.getNextChild
train
protected function getNextChild(AbstractNode $node, AbstractNode $currentChild) { try { // get next child $child = $node->nextChild($currentChild->id());
php
{ "resource": "" }
q22703
Selector.checkTag
train
protected function checkTag(array $rule, AbstractNode $node): bool { if ( ! empty($rule['tag']) && $rule['tag'] != $node->getTag()->name() && $rule['tag']
php
{ "resource": "" }
q22704
Selector.checkKey
train
protected function checkKey(array $rule, AbstractNode $node): bool { if ($rule['noKey']) { if ( ! is_null($node->getAttribute($rule['key']))) { return false; }
php
{ "resource": "" }
q22705
Selector.checkComparison
train
public function checkComparison(array $rule, AbstractNode $node): bool { if ($rule['key'] == 'plaintext') { // plaintext search $nodeValue = $node->text(); } else { // normal search $nodeValue = $node->getAttribute($rule['key']); } $ch...
php
{ "resource": "" }
q22706
Options.setOptions
train
public function setOptions(array $options): Options { foreach ($options as
php
{ "resource": "" }
q22707
Collection.offsetGet
train
public function offsetGet($offset) { return isset($this->collection[$offset]) ?
php
{ "resource": "" }
q22708
Collection.each
train
public function each(callable $callback) { foreach ($this->collection as $key => $value) {
php
{ "resource": "" }
q22709
Parser.parseSelectorString
train
public function parseSelectorString(string $selector): array { $selectors = []; $matches = []; preg_match_all($this->pattern, trim($selector).' ', $matches, PREG_SET_ORDER); // skip tbody $result = []; foreach ($matches as $match) { // default values ...
php
{ "resource": "" }
q22710
AbstractNode.propagateEncoding
train
public function propagateEncoding(Encode $encode) { $this->encode = $encode;
php
{ "resource": "" }
q22711
AbstractNode.isAncestor
train
public function isAncestor(int $id): Bool { if ( ! is_null($this->getAncestor($id))) {
php
{ "resource": "" }
q22712
AbstractNode.hasNextSibling
train
public function hasNextSibling(): bool { try { $this->nextSibling(); // sibling found, return true; return true; } catch (ParentNotFoundException $e) {
php
{ "resource": "" }
q22713
AbstractNode.setAttribute
train
public function setAttribute(string $key, $value): AbstractNode { $this->tag->setAttribute($key, $value);
php
{ "resource": "" }
q22714
AbstractNode.removeAttribute
train
public function removeAttribute(string $key): void { $this->tag->removeAttribute($key);
php
{ "resource": "" }
q22715
UsBankAccountVerificationGateway.confirmMicroTransferAmounts
train
public function confirmMicroTransferAmounts($token, $amounts) { try { $path = $this->_config->merchantPath() . '/us_bank_account_verifications/' . $token . '/confirm_micro_transfer_amounts'; $response = $this->_http->put($path, [ "us_bank_account_verification" => ["de...
php
{ "resource": "" }
q22716
PaymentMethodGateway.find
train
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; $response = $this->_http->get($path); return PaymentMethodParser::parsePaymentMethod($response);
php
{ "resource": "" }
q22717
PaymentMethodGateway._doDelete
train
public function _doDelete($subPath) { $fullPath = $this->_config->merchantPath() . $subPath;
php
{ "resource": "" }
q22718
DocumentUploadGateway.create
train
public function create($params) { Util::verifyKeys(self::createSignature(), $params); $file = $params['file']; if (!is_resource($file)) { throw new InvalidArgumentException('file must be a stream resource'); } $payload = [ 'document_upload[kind]' =>...
php
{ "resource": "" }
q22719
AddressGateway.delete
train
public function delete($customerOrId = null, $addressId = null) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId);
php
{ "resource": "" }
q22720
AddressGateway.find
train
public function find($customerOrId, $addressId) { $customerId = $this->_determineCustomerId($customerOrId); $this->_validateId($addressId); try { $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_h...
php
{ "resource": "" }
q22721
AddressGateway.update
train
public function update($customerOrId, $addressId, $attributes) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); Util::verifyKeys(self::updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/customers/' . $customerId .
php
{ "resource": "" }
q22722
AddressGateway.updateNoValidate
train
public function updateNoValidate($customerOrId, $addressId, $attributes) { $result = $this->update($customerOrId, $addressId, $attributes);
php
{ "resource": "" }
q22723
AddressGateway._validateCustomerId
train
private function _validateCustomerId($id = null) { if (empty($id) || trim($id) == "") { throw new InvalidArgumentException( 'expected customer id to be set' ); }
php
{ "resource": "" }
q22724
AddressGateway._determineCustomerId
train
private function _determineCustomerId($customerOrId) { $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId;
php
{ "resource": "" }
q22725
AddressGateway._doCreate
train
private function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath;
php
{ "resource": "" }
q22726
TransactionGateway.saleNoValidate
train
public function saleNoValidate($attribs) { $result = $this->sale($attribs); return
php
{ "resource": "" }
q22727
SettlementBatchSummary.generate
train
public static function generate($settlement_date, $groupByCustomField = NULL) { return
php
{ "resource": "" }
q22728
ResourceCollection._getPage
train
private function _getPage($ids) { $object = $this->_pager['object']; $method = $this->_pager['method']; $methodArgs = []; foreach ($this->_pager['methodArgs'] as
php
{ "resource": "" }
q22729
IdealPaymentGateway.find
train
public function find($idealPaymentId) { try { $path = $this->_config->merchantPath() . '/ideal_payments/' . $idealPaymentId; $response = $this->_http->get($path); return IdealPayment::factory($response['idealPayment']); } catch (Exception\NotFound $e) {
php
{ "resource": "" }
q22730
Parser.arrayFromXml
train
public static function arrayFromXml($xml) { $document = new DOMDocument('1.0', 'UTF-8'); $document->loadXML($xml); $root = $document->documentElement->nodeName;
php
{ "resource": "" }
q22731
Parser._nodeToArray
train
private static function _nodeToArray($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'array': $array = []; foreach ($node->childNodes as $child) { $value...
php
{ "resource": "" }
q22732
Parser._nodeToValue
train
private static function _nodeToValue($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'datetime': return self::_timestampToUTC((string) $node->nodeValue); case 'date': ...
php
{ "resource": "" }
q22733
Parser._timestampToUTC
train
private static function _timestampToUTC($timestamp) { $tz = new DateTimeZone('UTC');
php
{ "resource": "" }
q22734
TransparentRedirectGateway.init
train
public static function init() { self::$_createCustomerSignature = [ self::$_transparentRedirectKeys, ['customer' => CustomerGateway::createSignature()], ]; self::$_updateCustomerSignature = [ self::$_transparentRedirectKeys, 'customerId', ...
php
{ "resource": "" }
q22735
TransparentRedirectGateway.createCreditCardData
train
public function createCreditCardData($params) { Util::verifyKeys( self::$_createCreditCardSignature, $params );
php
{ "resource": "" }
q22736
TransparentRedirectGateway.createCustomerData
train
public function createCustomerData($params) { Util::verifyKeys( self::$_createCustomerSignature, $params );
php
{ "resource": "" }
q22737
TransparentRedirectGateway.transactionData
train
public function transactionData($params) { Util::verifyKeys( self::$_transactionSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_TRANSACTION; $transactionType = isset($params['transaction']['type']) ? $params['tra...
php
{ "resource": "" }
q22738
TransparentRedirectGateway.updateCreditCardData
train
public function updateCreditCardData($params) { Util::verifyKeys( self::$_updateCreditCardSignature, $params ); if (!isset($params['paymentMethodToken'])) { throw new InvalidArgumentException( 'expected
php
{ "resource": "" }
q22739
TransparentRedirectGateway.updateCustomerData
train
public function updateCustomerData($params) { Util::verifyKeys( self::$_updateCustomerSignature, $params ); if (!isset($params['customerId'])) { throw new InvalidArgumentException( 'expected
php
{ "resource": "" }
q22740
Collection.set
train
public function set($index, $value) { if($index >= $this->count())
php
{ "resource": "" }
q22741
Collection.remove
train
public function remove($index) { if($index >= $this->count()) throw new OutOfRangeException('Index
php
{ "resource": "" }
q22742
Address.isEqual
train
public function isEqual($other) { return !($other instanceof self) ? false :
php
{ "resource": "" }
q22743
PayPalAccountGateway.find
train
public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; $response = $this->_http->get($path); return PayPalAccount::factory($response['paypalAccount']);
php
{ "resource": "" }
q22744
PayPalAccountGateway.update
train
public function update($token, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($token); return
php
{ "resource": "" }
q22745
PayPalAccountGateway.sale
train
public function sale($token, $transactionAttribs) { $this->_validateId($token); return Transaction::sale( array_merge(
php
{ "resource": "" }
q22746
PayPalAccountGateway._validateId
train
private function _validateId($identifier = null, $identifierType = 'token') { if (empty($identifier)) { throw new InvalidArgumentException( 'expected paypal account id to be set' ); }
php
{ "resource": "" }
q22747
DisputeGateway.addFileEvidence
train
public function addFileEvidence($disputeId, $documentIdOrRequest) { $request = is_array($documentIdOrRequest) ? $documentIdOrRequest : ['documentId' => $documentIdOrRequest]; if (trim($disputeId) == "") { throw new Exception\NotFound('dispute with id "' . $disputeId . '" not found'); ...
php
{ "resource": "" }
q22748
DisputeGateway.addTextEvidence
train
public function addTextEvidence($id, $contentOrRequest) { $request = is_array($contentOrRequest) ? $contentOrRequest : ['content' => $contentOrRequest]; if (trim($request['content']) == "") { throw new InvalidArgumentException('content cannot be blank'); } try { ...
php
{ "resource": "" }
q22749
DisputeGateway.finalize
train
public function finalize($id) { try { if (trim($id) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $id . '/finalize'; $response = $this->_http->put($path); if (isset($response['a...
php
{ "resource": "" }
q22750
DisputeGateway.find
train
public function find($id) { if (trim($id) == "") { throw new Exception\NotFound('dispute with id "' . $id . '" not found'); } try { $path = $this->_config->merchantPath() . '/disputes/'
php
{ "resource": "" }
q22751
DisputeGateway.removeEvidence
train
public function removeEvidence($disputeId, $evidenceId) { try { if (trim($disputeId) == "" || trim($evidenceId) == "") { throw new Exception\NotFound(); } $path = $this->_config->merchantPath() . '/disputes/' . $disputeId . '/evidence/' . $evidenceId; ...
php
{ "resource": "" }
q22752
DisputeGateway.search
train
public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $pager = [ 'object' => $this,
php
{ "resource": "" }
q22753
PaginatedCollection.rewind
train
public function rewind() { $this->_index = 0; $this->_currentPage = 0; $this->_pageSize = 0;
php
{ "resource": "" }
q22754
Configuration.timeout
train
public static function timeout($value=null) { if (empty($value)) { return self::$global->getTimeout();
php
{ "resource": "" }
q22755
Configuration.proxyHost
train
public static function proxyHost($value = null) { if (empty($value)) { return self::$global->getProxyHost();
php
{ "resource": "" }
q22756
Configuration.proxyPort
train
public static function proxyPort($value = null) { if (empty($value)) { return self::$global->getProxyPort();
php
{ "resource": "" }
q22757
Configuration.proxyType
train
public static function proxyType($value = null) { if (empty($value)) { return self::$global->getProxyType();
php
{ "resource": "" }
q22758
Configuration.isUsingProxy
train
public static function isUsingProxy() { $proxyHost = self::$global->getProxyHost(); $proxyPort
php
{ "resource": "" }
q22759
Configuration.isAuthenticatedProxy
train
public static function isAuthenticatedProxy() { $proxyUser = self::$global->getProxyUser(); $proxyPwd
php
{ "resource": "" }
q22760
Configuration.acceptGzipEncoding
train
public static function acceptGzipEncoding($value = null) { if (is_null($value)) { return self::$global->getAcceptGzipEncoding();
php
{ "resource": "" }
q22761
Configuration.caFile
train
public function caFile($sslPath = NULL) { $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'ssl' . DIRECTORY_SEPARATOR; $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt';
php
{ "resource": "" }
q22762
PdoStorage.getSqlQuery
train
protected function getSqlQuery($name, array $vars = array()) { $sql = $this->sqlQueries[$name]; $vars = array_merge(array('tablename'
php
{ "resource": "" }
q22763
ExceptionsCollector.addThrowable
train
public function addThrowable($e) { $this->exceptions[] = $e; if ($this->chainExceptions && $previous =
php
{ "resource": "" }
q22764
ExceptionsCollector.formatThrowableData
train
public function formatThrowableData($e) { $filePath = $e->getFile(); if ($filePath && file_exists($filePath)) { $lines = file($filePath); $start = $e->getLine() - 4; $lines = array_slice($lines, $start < 0 ? 0 : $start, 7); } else { $lines = ar...
php
{ "resource": "" }
q22765
MemcachedStorage.memcachedGetMulti
train
protected function memcachedGetMulti($keys, $flags) { if ($this->newGetMultiSignature === null) { $this->newGetMultiSignature = (new ReflectionMethod('Memcached', 'getMulti'))->getNumberOfParameters() === 2;
php
{ "resource": "" }
q22766
PDOCollector.setRenderSqlWithParams
train
public function setRenderSqlWithParams($enabled = true, $quotationChar = '<>')
php
{ "resource": "" }
q22767
PDOCollector.addConnection
train
public function addConnection(TraceablePDO $pdo, $name = null) { if ($name === null) { $name =
php
{ "resource": "" }
q22768
PDOCollector.collectPDO
train
protected function collectPDO(TraceablePDO $pdo, TimeDataCollector $timeCollector = null, $connectionName = null) { if (empty($connectionName) || $connectionName == 'default') { $connectionName = 'pdo'; } else { $connectionName = 'pdo ' . $connectionName; } $s...
php
{ "resource": "" }
q22769
DebugBarVarDumper.getCloner
train
protected function getCloner() { if (!$this->cloner) { $clonerOptions = $this->getClonerOptions(); if (isset($clonerOptions['casters'])) { $this->cloner = new VarCloner($clonerOptions['casters']); } else { $this->cloner = new VarCloner(); ...
php
{ "resource": "" }
q22770
DebugBarVarDumper.getDumper
train
protected function getDumper() { if (!$this->dumper) { $this->dumper = new DebugBarHtmlDumper(); $dumperOptions = $this->getDumperOptions();
php
{ "resource": "" }
q22771
DebugBarVarDumper.getClonerOptions
train
public function getClonerOptions() { if ($this->clonerOptions === null) {
php
{ "resource": "" }
q22772
DebugBarVarDumper.mergeClonerOptions
train
public function mergeClonerOptions($options) { $this->clonerOptions
php
{ "resource": "" }
q22773
DebugBarVarDumper.resetClonerOptions
train
public function resetClonerOptions($options = null) { $this->clonerOptions = ($options ?: array())
php
{ "resource": "" }
q22774
DebugBarVarDumper.getDumperOptions
train
public function getDumperOptions() { if ($this->dumperOptions === null) {
php
{ "resource": "" }
q22775
DebugBarVarDumper.mergeDumperOptions
train
public function mergeDumperOptions($options) { $this->dumperOptions
php
{ "resource": "" }
q22776
DebugBarVarDumper.resetDumperOptions
train
public function resetDumperOptions($options = null) { $this->dumperOptions = ($options ?: array())
php
{ "resource": "" }
q22777
DebugBarVarDumper.getDisplayOptions
train
protected function getDisplayOptions() { $displayOptions = array(); $dumperOptions = $this->getDumperOptions(); // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['expanded_depth'])) { $displayOptions['maxDepth'] = $dumperOptions['expanded_depth'];
php
{ "resource": "" }
q22778
DebugBarVarDumper.renderCapturedVar
train
public function renderCapturedVar($capturedData, $seekPath = array()) { $data = unserialize($capturedData); // The seek method was added in Symfony 3.2; emulate the behavior via SeekingData for older // Symfony versions. if (!method_exists($data, 'seek')) {
php
{ "resource": "" }
q22779
DebugBarVarDumper.dump
train
protected function dump(Data $data) { $dumper = $this->getDumper(); $output = fopen('php://memory', 'r+b'); $dumper->setOutput($output); $dumper->setDumpHeader(''); // we don't actually want a dump header // NOTE: Symfony 3.2 added the third $extraDisplayOptions parameter. ...
php
{ "resource": "" }
q22780
MessagesCollector.getVarDumper
train
public function getVarDumper() { if ($this->varDumper === null) {
php
{ "resource": "" }
q22781
AggregatedCollector.sort
train
protected function sort($data) { if (is_string($this->sort)) { $p = $this->sort; usort($data, function ($a, $b) use ($p) { if ($a[$p] == $b[$p]) { return 0; } return $a[$p] < $b[$p] ?
php
{ "resource": "" }
q22782
JavascriptRenderer.setOptions
train
public function setOptions(array $options) { if (array_key_exists('base_path', $options)) { $this->setBasePath($options['base_path']); } if (array_key_exists('base_url', $options)) { $this->setBaseUrl($options['base_url']); } if (array_key_exists('incl...
php
{ "resource": "" }
q22783
JavascriptRenderer.setIncludeVendors
train
public function setIncludeVendors($enabled = true) { if (is_string($enabled)) { $enabled = array($enabled); } $this->includeVendors = $enabled;
php
{ "resource": "" }
q22784
JavascriptRenderer.disableVendor
train
public function disableVendor($name) { if (array_key_exists($name, $this->cssVendors)) { unset($this->cssVendors[$name]); }
php
{ "resource": "" }
q22785
JavascriptRenderer.addControl
train
public function addControl($name, array $options) { if (count(array_intersect(array_keys($options), array('icon', 'widget', 'tab', 'indicator'))) === 0) { throw
php
{ "resource": "" }
q22786
JavascriptRenderer.addAssets
train
public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null) { $this->additionalAssets[] = array( 'base_path' => $basePath, 'base_url' => $baseUrl,
php
{ "resource": "" }
q22787
JavascriptRenderer.addInlineAssets
train
public function addInlineAssets($inlineCss, $inlineJs, $inlineHead) { $this->additionalAssets[] = array( 'inline_css' => (array) $inlineCss,
php
{ "resource": "" }
q22788
JavascriptRenderer.getRelativeRoot
train
protected function getRelativeRoot($relativeTo, $basePath, $baseUrl) { if ($relativeTo === self::RELATIVE_PATH) {
php
{ "resource": "" }
q22789
JavascriptRenderer.createAsseticCollection
train
protected function createAsseticCollection($files = null, $content = null) { $assets = array(); if ($files) { foreach ($files as $file) { $assets[] = new \Assetic\Asset\FileAsset($file);
php
{ "resource": "" }
q22790
JavascriptRenderer.dumpCssAssets
train
public function dumpCssAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('css'),
php
{ "resource": "" }
q22791
JavascriptRenderer.dumpJsAssets
train
public function dumpJsAssets($targetFilename = null) { $this->dumpAssets($this->getAssets('js'),
php
{ "resource": "" }
q22792
JavascriptRenderer.renderOnShutdown
train
public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true, $head = false) { register_shutdown_function(array($this, "replaceTagInBuffer"),
php
{ "resource": "" }
q22793
JavascriptRenderer.render
train
public function render($initialize = true, $renderStackedData = true) { $js = ''; if ($initialize) { $js = $this->getJsInitializationCode(); } if ($renderStackedData && $this->debugBar->hasStackedData()) { foreach ($this->debugBar->getStackedData() as $id =>...
php
{ "resource": "" }
q22794
JavascriptRenderer.getJsControlsDefinitionCode
train
protected function getJsControlsDefinitionCode($varname) { $js = ''; $dataMap = array(); $excludedOptions = array('indicator', 'tab', 'map', 'default', 'widget', 'position'); // finds controls provided by collectors $widgets = array(); foreach ($this->debugBar->getCo...
php
{ "resource": "" }
q22795
JavascriptRenderer.getAddDatasetCode
train
protected function getAddDatasetCode($requestId, $data, $suffix = null) { $js = sprintf("%s.addDataSet(%s, \"%s\"%s);\n", $this->variableName, json_encode($data),
php
{ "resource": "" }
q22796
PropelCollector.enablePropelProfiling
train
public static function enablePropelProfiling(PropelConfiguration $config = null) { if ($config === null) { $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); } $config->setParameter('debugpdo.logging.details.method.enabled', true); $config->setParameter...
php
{ "resource": "" }
q22797
OpenHandler.handle
train
public function handle($request = null, $echo = true, $sendHeader = true) { if ($request === null) { $request = $_REQUEST; } $op = 'find'; if (isset($request['op'])) { $op = $request['op']; if (!in_array($op, array('find', 'get', 'clear'))) { ...
php
{ "resource": "" }
q22798
DataCollector.getVarDumper
train
public function getVarDumper() { if ($this->varDumper === null) {
php
{ "resource": "" }
q22799
DebugBar.getCollector
train
public function getCollector($name) { if (!isset($this->collectors[$name])) {
php
{ "resource": "" }