_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q246000
MailerTransformer.transformTemplate
validation
protected function transformTemplate(Template $template) { return array( 'template' => $template->getTemplate(), 'engine' => $template->getEngine(), 'vars' => $this->transform($template->getVars()), 'streamable' => $this->transformBoolean($template->isStreamable()), ); }
php
{ "resource": "" }
q246001
StatsD.updateStats
validation
public function updateStats($stats, $delta = 1, $sampleRate = 1) { if (!is_array($stats)) { $stats = array($stats); } $data = array(); foreach ($stats as $stat) { $data[$stat] = "$delta|c"; } $this->queue($data, $sampleRate); }
php
{ "resource": "" }
q246002
StatsD.flush
validation
public function flush() { if ($this->doNotTrack) { return; } if (empty($this->queue)) { return; } if ($this->mergePackets) { $this->send(implode("\n", $this->queue)); } else { foreach ($this->queue as $data) { $this->send($data); } } $this->queue = array(); $this->queueSize = 0; }
php
{ "resource": "" }
q246003
StatsD.send
validation
protected function send($data) { if ($this->doNotTrack) { return; } // Wrap this in a try/catch - failures in any of this should be silently ignored try { $fp = fsockopen("udp://$this->host", $this->port, $errno, $errstr); if (!$fp) { return; } fwrite($fp, $data); fclose($fp); } catch (\Exception $e) { } }
php
{ "resource": "" }
q246004
UserComponent.createUser
validation
public function createUser() { if (false == $this->validateRegistrationOptin()) { //show error message on submit but not on page reload. if ($this->getRequestParameter('stoken')) { \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('OEGDPROPTIN_CONFIRM_USER_REGISTRATION_OPTIN', false, true); \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('OEGDPROPTIN_CONFIRM_USER_REGISTRATION_OPTIN', false, true, 'oegdproptin_userregistration'); } } else { return parent::createUser(); } }
php
{ "resource": "" }
q246005
UserComponent.validateDeliveryAddressOptIn
validation
protected function validateDeliveryAddressOptIn() { $return = true; $optin = (int) $this->getRequestParameter('oegdproptin_deliveryaddress'); $changeExistigAddress = (int) $this->getRequestParameter('oegdproptin_changeDelAddress'); $addressId = $this->getRequestParameter('oxaddressid'); $deliveryAddressData = $this->_getDelAddressData(); if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blOeGdprOptinDeliveryAddress') && ((null == $addressId) || ('-1' == $addressId) || (1 == $changeExistigAddress)) && !empty($deliveryAddressData) && (1 !== $optin) ) { $return = false; } return $return; }
php
{ "resource": "" }
q246006
UserComponent.validateRegistrationOptin
validation
protected function validateRegistrationOptin() { $return = true; $optin = (int) $this->getRequestParameter('oegdproptin_userregistration'); //1 is for guest buy, 3 for account creation $registrationOption = (int) $this->getRequestParameter('option'); if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blOeGdprOptinUserRegistration') && (3 == $registrationOption) && (1 !== $optin)) { $return = false; } return $return; }
php
{ "resource": "" }
q246007
UserComponent.validateInvoiceAddressOptIn
validation
protected function validateInvoiceAddressOptIn() { $return = true; $optin = (int) $this->getRequestParameter('oegdproptin_invoiceaddress'); $changeExistigAddress = (int) $this->getRequestParameter('oegdproptin_changeInvAddress'); if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blOeGdprOptinInvoiceAddress') && (1 == $changeExistigAddress) && (1 !== $optin) ) { $return = false; } return $return; }
php
{ "resource": "" }
q246008
OP_API.convertXmlToPhpObj
validation
public static function convertXmlToPhpObj ($node) { $ret = array(); if (is_object($node) && $node->hasChildNodes()) { foreach ($node->childNodes as $child) { $name = self::decode($child->nodeName); if ($child->nodeType == XML_TEXT_NODE) { $ret = self::decode($child->nodeValue); } else { if ('array' === $name) { return self::parseArray($child); } else { $ret[$name] = self::convertXmlToPhpObj($child); } } } } return !empty($ret) ? $ret : null; }
php
{ "resource": "" }
q246009
OP_API.convertPhpObjToDom
validation
public static function convertPhpObjToDom ($arr, $node, $dom) { if (is_array($arr)) { /** * If arr has integer keys, this php-array must be converted in * xml-array representation (<array><item>..</item>..</array>) */ $arrayParam = array(); foreach ($arr as $k => $v) { if (is_integer($k)) { $arrayParam[] = $v; } } if (0 < count($arrayParam)) { $node->appendChild($arrayDom = $dom->createElement("array")); foreach ($arrayParam as $key => $val) { $new = $arrayDom->appendChild($dom->createElement('item')); self::convertPhpObjToDom($val, $new, $dom); } } else { foreach ($arr as $key => $val) { $new = $node->appendChild( $dom->createElement(self::encode($key)) ); self::convertPhpObjToDom($val, $new, $dom); } } } elseif (!is_object($arr)) { $node->appendChild($dom->createTextNode(self::encode($arr))); } }
php
{ "resource": "" }
q246010
Plugin.run
validation
public function run() { if ( ! $this->is_debug() || ! $this->is_debug_display() ) { return; } /** @var Run $run */ $run = $this['run']; $run->register(); ob_start(); // Or we are going to be spitting out WP markup before whoops. }
php
{ "resource": "" }
q246011
WidgetExtension.renderWidget
validation
public function renderWidget(string $widgetGroup = '', array $widgetId = []) { $widgets = $this->widgetBuilder->build($this->widgets->getWidgets(), $widgetGroup, $widgetId); return $this->engine->render($widgets); }
php
{ "resource": "" }
q246012
WidgetController.status
validation
public function status(Request $request, WidgetInterface $widget, string $widgetId, bool $status = true) { // Build Widget $widgets = $widget->getWidgets(); if (isset($widgets[$widgetId])) { // Get User Widgets $widgetConfig = $this->getDoctrine() ->getRepository('PdWidgetBundle:WidgetUser') ->findOneBy(['owner' => $this->getUser()]) ?? (new WidgetUser())->setOwner($this->getUser()); // Add Config Parameters $widgetConfig->addWidgetConfig($widgetId, ['status' => $status]); // Save $em = $this->getDoctrine()->getManager(); $em->persist($widgetConfig); $em->flush(); } // Response return $this->redirect($request->headers->get('referer') ?? $this->generateUrl($this->getParameter('pd_widget.return_route'))); }
php
{ "resource": "" }
q246013
WidgetController.configs
validation
public function configs(Request $request, WidgetInterface $widget, CacheInterface $cache, string $widgetId) { // Build Widget $widgets = $widget->getWidgets(); if (isset($widgets[$widgetId])) { // Get User Widgets $widgetConfig = $this->getDoctrine() ->getRepository('PdWidgetBundle:WidgetUser') ->findOneBy(['owner' => $this->getUser()]) ?? (new WidgetUser())->setOwner($this->getUser()); // Add or Remove Config Parameters if ($request->get('remove')) { $widgetConfig->removeWidgetConfig($widgetId, $widgets[$widgetId]->getConfigProcess($request) ?? []); } else { $widgetConfig->addWidgetConfig($widgetId, $widgets[$widgetId]->getConfigProcess($request) ?? []); } // Save $em = $this->getDoctrine()->getManager(); $em->persist($widgetConfig); $em->flush(); // Flush Widget Cache $cache->delete($widgetId.$this->getUser()->getId()); } // Response return $this->redirect($request->headers->get('referer') ?? $this->generateUrl($this->getParameter('pd_widget.return_route'))); }
php
{ "resource": "" }
q246014
WidgetController.order
validation
public function order(Request $request, WidgetInterface $widget, string $widgetId, int $order) { // Build Widget $widgets = $widget->getWidgets(); if (isset($widgets[$widgetId])) { // Get User Widgets $widgetConfig = $this->getDoctrine() ->getRepository('PdWidgetBundle:WidgetUser') ->findOneBy(['owner' => $this->getUser()]) ?? (new WidgetUser())->setOwner($this->getUser()); // Add Config Parameters $widgetConfig->addWidgetConfig($widgetId, ['order' => $order]); // Save $em = $this->getDoctrine()->getManager(); $em->persist($widgetConfig); $em->flush(); } // Response return $this->json([ 'result' => 'success', ]); }
php
{ "resource": "" }
q246015
WidgetBuilder.build
validation
public function build($widgets, string $widgetGroup = '', array $widgetId = []) { // Without Widgets if (!$widgets) { return $widgets; } // Load User Widget Configuration $this->loadUserConfig(); // Output Widgets $outputWidget = []; // Custom Items if ($widgetId) { foreach ($widgetId as $id) { if (isset($widgets[$id])) { // Activate $widgets[$id]->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false); // Set Widget Config $widgets[$id]->setConfig($this->widgetConfig[$widget->getId()] ?? []); $outputWidget[] = $widgets[$id]; } } return $outputWidget; } foreach ($widgets as $widget) { if ('' !== $widgetGroup && $widget->getGroup() !== $widgetGroup) { continue; } // Set Custom Order if (isset($this->widgetConfig[$widget->getId()]['order'])) { $widget->setOrder($this->widgetConfig[$widget->getId()]['order']); } // Order if (null !== $widget->getOrder()) { while (isset($outputWidget[$widget->getOrder()])) { $widget->setOrder($widget->getOrder() + 1); } $outputWidget[$widget->getOrder()] = $widget; } else { $outputWidget[] = $widget; } // Activate $widget->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false); // Set Widget Config $widget->setConfig($this->widgetConfig[$widget->getId()] ?? []); } // Sort ksort($outputWidget); return $outputWidget; }
php
{ "resource": "" }
q246016
WidgetBuilder.loadUserConfig
validation
private function loadUserConfig() { if (!$this->widgetConfig) { $this->widgetConfig = $this->entityManager ->getRepository('PdWidgetBundle:WidgetUser') ->findOneBy([ 'owner' => $this->tokenStorage->getToken()->getUser(), ]); if (null !== $this->widgetConfig) { $this->widgetConfig = $this->widgetConfig->getConfig(); } } }
php
{ "resource": "" }
q246017
TwigRender.render
validation
public function render($widgets, bool $base = true) { if (!$widgets) { return false; } // Output Storage $output = ''; // Get User ID $userId = $this->tokenStorage->getToken()->getUser()->getId(); foreach ($widgets as $widget) { if ($widget->isActive()) { $output .= $this->getOutput($widget, $userId); } } // Render Base if ($base) { $output = $this->engine->render($this->baseTemplate, ['widgets' => $output]); } return $output; }
php
{ "resource": "" }
q246018
TwigRender.getOutput
validation
public function getOutput(ItemInterface $item, $userId) { if ($item->getCacheTime()) { // Get Cache Item $cache = $this->cache->getItem($item->getId().$userId); // Set Cache Expires $cache->expiresAfter($item->getCacheTime()); // Save if (false === $cache->isHit()) { $cache->set($item->getTemplate() ? $this->engine->render($item->getTemplate(), ['widget' => $item]) : $item->getContent()); $this->cache->save($cache); } return $cache->get(); } return $item->getTemplate() ? $this->engine->render($item->getTemplate(), ['widget' => $item]) : $item->getContent(); }
php
{ "resource": "" }
q246019
Widget.addWidget
validation
public function addWidget(ItemInterface $item) { // Check Security if ($this->checkRole) { if ($item->getRole() && !$this->security->isGranted($item->getRole())) { return $this; } } // Add $this->widgets[$item->getId()] = $item; return $this; }
php
{ "resource": "" }
q246020
Widget.removeWidget
validation
public function removeWidget(string $widgetId) { if (isset($this->widgets[$widgetId])) { unset($this->widgets[$widgetId]); } return $this; }
php
{ "resource": "" }
q246021
Widget.clearWidgetCache
validation
public function clearWidgetCache() { // Get Widgets $widgets = $this->getWidgets(false); $userId = $this->token->getToken()->getUser()->getId(); // Clear Cache foreach ($widgets as $widget) { $this->cache->deleteItem($widget->getId().$userId); } }
php
{ "resource": "" }
q246022
WidgetUser.addWidgetConfig
validation
public function addWidgetConfig(string $widgetId, array $config = []) { $this->config[$widgetId] = array_merge($this->config[$widgetId] ?? [], $config); return $this; }
php
{ "resource": "" }
q246023
WidgetUser.removeWidgetConfig
validation
public function removeWidgetConfig(string $widgetId, array $config = []) { foreach ($config as $id => $content) { if (isset($this->config[$widgetId][$id])) { unset($this->config[$widgetId][$id]); } } return $this; }
php
{ "resource": "" }
q246024
GetModuleTrait.getModule
validation
public function getModule() { if (!is_object($this->_module)) { $this->_module = Yii::$app->getModule($this->_module); } return $this->_module; }
php
{ "resource": "" }
q246025
PublishesUnhandledMessages.handle
validation
public function handle($message, callable $next) { try { $next($message); } catch (UndefinedCallable $exception) { $this->logger->log( $this->logLevel, 'No message handler found, trying to handle it asynchronously', [ 'type' => get_class($message) ] ); $this->publisher->publish($message); } }
php
{ "resource": "" }
q246026
NotORM_Row.offsetExists
validation
function offsetExists($key) { $this->access($key); $return = array_key_exists($key, $this->row); if (!$return) { $this->access($key, true); } return $return; }
php
{ "resource": "" }
q246027
NotORM_Row.offsetGet
validation
function offsetGet($key) { $this->access($key); if (!array_key_exists($key, $this->row)) { $this->access($key, true); } return $this->row[$key]; }
php
{ "resource": "" }
q246028
NotORM_Row.offsetSet
validation
function offsetSet($key, $value) { $this->row[$key] = $value; $this->modified[$key] = $value; }
php
{ "resource": "" }
q246029
NotORM_Result.insert
validation
function insert($data){ $rows = func_get_args(); $return = $this->insert_multi($rows); if(!$return){ return false; } if(!is_array($data)){ return $return; } // #56 postgresql无法获取新增数据的主键ID @ clov4r-连友 201608 if ($this->notORM->driver == "pgsql") { if (!isset($data[$this->primary])) { //获取序列名称 $pgss = $this->query("SELECT pg_get_serial_sequence('" . $this->table . "', '" . $this->primary . "') pgss", $this->parameters)->fetch(); if (isset($pgss['pgss'])) { $rs = $this->query("select last_value id from " . $pgss['pgss'], $this->parameters)->fetch(); $data[$this->primary] = $rs['id']; $this->sequence = $rs['id']; } } } else { if (!isset($data[$this->primary]) && ($id = $this->notORM->connection->lastInsertId($this->notORM->structure->getSequence($this->table)))) { $data[$this->primary] = $id; } } return new $this->notORM->rowClass($data, $this); }
php
{ "resource": "" }
q246030
NotORM_Result.update
validation
function update(array $data){ if($this->notORM->freeze){ return false; } if(!$data){ return 0; } $values = array(); $parameters = array(); $quoteChar = $this->getQuoteChar(); foreach($data as $key => $val){ // doesn't use binding because $this->parameters can be filled by ? or :name $values[] = "{$quoteChar}{$key}{$quoteChar} = " . $this->quote($val); if($val instanceof NotORM_Literal && $val->parameters){ $parameters = array_merge($parameters, $val->parameters); } } if($this->parameters){ $parameters = array_merge($parameters, $this->parameters); } // joins in UPDATE are supported only in MySQL $return = $this->query("UPDATE" . $this->topString($this->limit) . " $this->table SET " . implode(", ", $values) . $this->whereString(), $parameters); if(!$return){ return false; } return $return->rowCount(); }
php
{ "resource": "" }
q246031
NotORM_Result.insert_update
validation
function insert_update(array $unique, array $insert, array $update = array()){ if(!$update){ $update = $insert; } $insert = $unique + $insert; $values = "(" . implode(", ", array_keys($insert)) . ") VALUES " . $this->quote($insert); //! parameters if($this->notORM->driver == "mysql"){ $set = array(); if(!$update){ $update = $unique; } $quoteChar = $this->getQuoteChar(); foreach($update as $key => $val){ $set[] = "{$quoteChar}{$key}{$quoteChar} = " . $this->quote($val); //! parameters } return $this->insert("$values ON DUPLICATE KEY UPDATE " . implode(", ", $set)); }else{ $connection = $this->notORM->connection; $errorMode = $connection->getAttribute(PDO::ATTR_ERRMODE); $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try{ $return = $this->insert($values); $connection->setAttribute(PDO::ATTR_ERRMODE, $errorMode); return $return; } catch(PDOException $e){ $connection->setAttribute(PDO::ATTR_ERRMODE, $errorMode); if($e->getCode() == "23000" || $e->getCode() == "23505"){ // "23000" - duplicate key, "23505" unique constraint pgsql if(!$update){ return 0; } $clone = clone $this; $return = $clone->where($unique)->update($update); return ($return ? $return + 1 : $return); } if($errorMode == PDO::ERRMODE_EXCEPTION){ throw $e; }elseif($errorMode == PDO::ERRMODE_WARNING){ trigger_error("PDOStatement::execute(): " . $e->getMessage(), E_USER_WARNING); // E_WARNING is unusable } } } return 0; }
php
{ "resource": "" }
q246032
NotORM_Result.delete
validation
function delete(){ if($this->notORM->freeze){ return false; } //防止误删,禁止全表的删除 //@dogstar - 2014-10-24 $where = $this->whereString(); if(empty($where)){ throw new Exception('sorry, you can not delete the whole table --dogstar'); } $return = $this->query("DELETE" . $this->topString($this->limit) . " FROM $this->table" . $where, $this->parameters); if(!$return){ return false; } return $return->rowCount(); }
php
{ "resource": "" }
q246033
NotORM_Result.select
validation
function select($columns){ $this->__destruct(); if($columns != ""){ foreach(func_get_args() as $columns){ $this->select[] = $columns; } }else{ $this->select = array(); } return $this; }
php
{ "resource": "" }
q246034
NotORM_Result.order
validation
function order($columns){ $this->rows = null; if($columns != ""){ foreach(func_get_args() as $columns){ if($this->union){ $this->unionOrder[] = $columns; }else{ $this->order[] = $columns; } } }elseif($this->union){ $this->unionOrder = array(); }else{ $this->order = array(); } return $this; }
php
{ "resource": "" }
q246035
NotORM_Result.group
validation
function group($columns, $having = ""){ $this->__destruct(); $this->group = $columns; $this->having = $having; return $this; }
php
{ "resource": "" }
q246036
NotORM_Result.aggregation
validation
function aggregation($function){ $join = $this->createJoins(implode(",", $this->conditions) . ",$function"); $query = "SELECT $function FROM $this->table" . implode($join); if($this->where){ $query .= " WHERE " . implode($this->where); } foreach($this->query($query, $this->parameters)->fetch() as $return){ return $return; } }
php
{ "resource": "" }
q246037
NotORM_Result.execute
validation
protected function execute(){ if(!isset($this->rows)){ $result = false; $exception = null; $parameters = array(); foreach(array_merge($this->select, array( $this, $this->group, $this->having ), $this->order, $this->unionOrder) as $val){ if(($val instanceof NotORM_Literal || $val instanceof self) && $val->parameters){ $parameters = array_merge($parameters, $val->parameters); } } try{ $result = $this->query($this->__toString(), $parameters); } catch(PDOException $exception){ // handled later } if(!$result){ if(!$this->select && $this->accessed){ $this->accessed = ''; $this->access = array(); $result = $this->query($this->__toString(), $parameters); }elseif($exception){ throw $exception; } } $this->rows = array(); if($result){ $result->setFetchMode(PDO::FETCH_ASSOC); foreach($result as $key => $row){ if(isset($row[$this->primary])){ $key = $row[$this->primary]; if(!is_string($this->access)){ $this->access[$this->primary] = true; } } //$this->rows[$key] = new $this->notORM->rowClass($row, $this); if ($this->notORM->isKeepPrimaryKeyIndex) { //@dogstar 采用主键作为下标 2015-12-30 $this->rows[$key] = $row; } else { //@dogstar 改用返回数组 2014-11-01 $this->rows[] = $row; } } } $this->data = $this->rows; } }
php
{ "resource": "" }
q246038
NotORM_Result.fetch
validation
function fetch($column = ''){ // no $this->select($column) because next calls can access different columns $this->execute(); $return = current($this->data); next($this->data); if($return && $column != ''){ return $return[$column]; } return $return; }
php
{ "resource": "" }
q246039
NotORM_Result.offsetGet
validation
function offsetGet($key){ if($this->single && !isset($this->data)){ $clone = clone $this; if(is_array($key)){ $clone->where($key)->limit(1); }else{ $clone->where($this->primary, $key); } $return = $clone->fetch(); if($return){ return $return; } }else{ $this->execute(); if(is_array($key)){ foreach($this->data as $row){ foreach($key as $k => $v){ if((isset($v) && $row[$k] !== null ? $row[$k] != $v : $row[$k] !== $v)){ continue 2; } } return $row; } }elseif(isset($this->data[$key])){ return $this->data[$key]; } } return NULL; }
php
{ "resource": "" }
q246040
NotORM_Result.exec
validation
function exec($query) { $conn = $this->getConn(); $sql = $conn->quote($query); return $conn->exec($sql); }
php
{ "resource": "" }
q246041
NotORM_MultiResult.via
validation
function via($column) { $this->column = $column; $this->conditions[0] = "$this->table.$column AND"; $this->where[0] = "(" . $this->whereIn("$this->table.$column", array_keys((array) $this->result->rows)) . ")"; return $this; }
php
{ "resource": "" }
q246042
SqlQuery.injectSpecialBindings
validation
public function injectSpecialBindings( string $sql, array $bindings ):string { foreach(self::SPECIAL_BINDINGS as $special) { $specialPlaceholder = ":" . $special; if(!array_key_exists($special, $bindings)) { continue; } $replacement = $this->escapeSpecialBinding( $bindings[$special], $special ); $sql = str_replace( $specialPlaceholder, $replacement, $sql ); unset($bindings[$special]); } foreach($bindings as $key => $value) { if(is_array($value)) { $inString = ""; foreach($value as $i => $innerValue) { $newKey = $key . "__" . $i; $keyParamString = ":$newKey"; $inString .= "$keyParamString, "; } $inString = rtrim($inString, " ,"); $sql = str_replace( ":$key", $inString, $sql ); } } return $sql; }
php
{ "resource": "" }
q246043
QueryCollectionFactory.locateDirectory
validation
protected function locateDirectory(string $name):?string { $parts = [$name]; foreach(Database::COLLECTION_SEPARATOR_CHARACTERS as $char) { if(!strstr($name, $char)) { continue; } $parts = explode($char, $name); break; } return $this->recurseLocateDirectory($parts); }
php
{ "resource": "" }
q246044
Tx_HappyFeet_Service_Rendering.renderRichText
validation
public function renderRichText($richText) { if (strlen($richText) < 1) { return ''; } $templatePath = $this->getTemplatePathAndFilename('RichText'); $view = $this->createView($templatePath); $view->assign('richText', $richText); return $view->render($templatePath); }
php
{ "resource": "" }
q246045
Tx_HappyFeet_Service_Rendering.getTemplatePath
validation
private function getTemplatePath() { /** * @var $tsfe TypoScriptFrontendController */ $tsfe = $GLOBALS['TSFE']; if (isset($tsfe->tmpl->setup['lib.']['plugins.']['tx_happyfeet.']['view.']['template'])) { $templateFile = GeneralUtility::getFileAbsFileName( $tsfe->tmpl->setup['lib.']['plugins.']['tx_happyfeet.']['view.']['template'] ); if (is_file($templateFile)) { return $tsfe->tmpl->setup['lib.']['plugins.']['tx_happyfeet.']['view.']['template']; } } return $this->getTemplatePathAndFilename($this->defaultTemplate); }
php
{ "resource": "" }
q246046
Tx_HappyFeet_Domain_Repository_FootnoteRepository.getLowestFreeIndexNumber
validation
public function getLowestFreeIndexNumber() { $query = $this->createQuery(); $query->statement('SELECT index_number from ' . strtolower($this->objectType) . ' WHERE deleted=0'); $index = 1; $results = $query->execute(true); if (false === is_array($results) || sizeof($results) < 1) { return $index; } $indexes = array(); foreach ($results as $result) { $indexes[] = (integer)$result['index_number']; } for ($index = 1; $index <= sizeof($indexes) + 1; $index++) { if (false === in_array($index, $indexes)) { break; } } return $index; }
php
{ "resource": "" }
q246047
InlineVariableCommentSniff.processMemberVar
validation
protected function processMemberVar( File $phpcsFile, $stackPtr ) { $tokens = $phpcsFile->getTokens(); $commentToken = [ T_COMMENT, T_DOC_COMMENT_CLOSE_TAG, ]; $commentEnd = $phpcsFile->findPrevious($commentToken, $stackPtr); $commentStart = $tokens[$commentEnd]['comment_opener']; if ($tokens[$commentEnd]['line'] === $tokens[$commentStart]['line']) { $phpcsFile->addError('Member variable comment should not be inline', $stackPtr, static::ERROR_CODE); } }
php
{ "resource": "" }
q246048
CronPlus.schedule_event
validation
public function schedule_event() { if ( $this->is_scheduled( $this->args[ 'name' ] ) ) { return; } if ( $this->args[ 'run_on_creation' ] ) { call_user_func( $this->args[ 'cb' ], $this->args[ 'args' ] ); } if ( $this->args[ 'schedule' ] === 'schedule' ) { wp_schedule_event( $this->args[ 'time' ], $this->args[ 'recurrence' ], $this->args[ 'name' ], $this->args[ 'args' ] ); } elseif ( $this->args[ 'schedule' ] === 'single' ) { wp_schedule_single_event( $this->args[ 'recurrence' ], $this->args[ 'name' ], $this->args[ 'args' ] ); } // Save all the site ids where is the corn for the deactivation if ( is_multisite() && !wp_is_large_network() ) { $sites = ( array ) get_site_option( $this->args[ 'name' ] . '_sites', array() ); $sites[] = get_current_blog_id(); update_site_option( $this->args[ 'name' ] . '_sites', $sites ); } return true; }
php
{ "resource": "" }
q246049
CronPlus.unschedule_specific_event
validation
public function unschedule_specific_event( $timestamp = '' ) { if ( empty( $timestamp ) ) { $timestamp = wp_next_scheduled( $this->args[ 'name' ], $this->args[ 'args' ] ); } wp_unschedule_event( $timestamp, $this->args[ 'name' ], $this->args[ 'args' ] ); }
php
{ "resource": "" }
q246050
CronPlus.deactivate
validation
public function deactivate() { $this->clear_schedule(); if ( !is_multisite() || wp_is_large_network() ) { return; } $sites = ( array ) get_site_option( $this->args[ 'name' ] . '_sites', array() ); $sites and $sites = array_diff( $sites, [ get_current_blog_id() ] ); foreach ( $sites as $site ) { switch_to_blog( $site ); $this->clear_schedule(); } restore_current_blog(); delete_site_option( $this->args[ 'name' ] . '_sites' ); }
php
{ "resource": "" }
q246051
CronPlus.is_scheduled
validation
private function is_scheduled( $name ) { $crons = _get_cron_array(); if ( empty( $crons ) ) { return false; } foreach ( $crons as $cron ) { if ( isset( $cron[ $name ] ) ) { return true; } } return false; }
php
{ "resource": "" }
q246052
ExpressionLanguageFactory.create
validation
public function create() { $language = new ExpressionLanguage(); foreach ($this->providers as $provider) { $language->registerProvider($provider); } return $language; }
php
{ "resource": "" }
q246053
Context.add
validation
public function add($name, $value) { if (array_key_exists($name, $this->storage)) { throw new AlreadyDefinedException(sprintf('Context value with key `%s` already defined', $name)); } $this->storage[$name] = $value; }
php
{ "resource": "" }
q246054
Context.get
validation
public function get($name, $default = null) { return array_key_exists($name, $this->storage) ? $this->storage[$name] : $default; }
php
{ "resource": "" }
q246055
AnyDataset.createFrom
validation
private function createFrom($filepath) { if (file_exists($filepath)) { $anyDataSet = XmlUtil::createXmlDocumentFromFile($filepath); $this->collection = array(); $rows = $anyDataSet->getElementsByTagName("row"); foreach ($rows as $row) { $sr = new Row(); $fields = $row->getElementsByTagName("field"); foreach ($fields as $field) { $attr = $field->attributes->getNamedItem("name"); if (is_null($attr)) { throw new \InvalidArgumentException('Malformed anydataset file ' . basename($filepath)); } $sr->addField($attr->nodeValue, $field->nodeValue); } $sr->acceptChanges(); $this->collection[] = $sr; } $this->currentRow = count($this->collection) - 1; } }
php
{ "resource": "" }
q246056
AnyDataset.getAsDom
validation
public function getAsDom() { $anyDataSet = XmlUtil::createXmlDocumentFromStr("<anydataset></anydataset>"); $nodeRoot = $anyDataSet->getElementsByTagName("anydataset")->item(0); foreach ($this->collection as $sr) { $row = $sr->getAsDom(); $nodeRow = $row->getElementsByTagName("row")->item(0); $newRow = XmlUtil::createChild($nodeRoot, "row"); XmlUtil::addNodeFromNode($newRow, $nodeRow); } return $anyDataSet; }
php
{ "resource": "" }
q246057
AnyDataset.appendRow
validation
public function appendRow($singleRow = null) { if (!is_null($singleRow)) { if ($singleRow instanceof Row) { $this->collection[] = $singleRow; $singleRow->acceptChanges(); } elseif (is_array($singleRow)) { $this->collection[] = new Row($singleRow); } else { throw new InvalidArgumentException("You must pass an array or a Row object"); } } else { $singleRow = new Row(); $this->collection[] = $singleRow; $singleRow->acceptChanges(); } $this->currentRow = count($this->collection) - 1; }
php
{ "resource": "" }
q246058
AnyDataset.insertRowBefore
validation
public function insertRowBefore($rowNumber, $row = null) { if ($rowNumber > count($this->collection)) { $this->appendRow($row); } else { $singleRow = $row; if (!($row instanceof Row)) { $singleRow = new Row($row); } array_splice($this->collection, $rowNumber, 0, ''); $this->collection[$rowNumber] = $singleRow; } }
php
{ "resource": "" }
q246059
AnyDataset.addField
validation
public function addField($name, $value) { if ($this->currentRow < 0) { $this->appendRow(); } $this->collection[$this->currentRow]->addField($name, $value); }
php
{ "resource": "" }
q246060
AnyDataset.getIterator
validation
public function getIterator(IteratorFilter $itf = null) { if (is_null($itf)) { return new AnyIterator($this->collection); } return new AnyIterator($itf->match($this->collection)); }
php
{ "resource": "" }
q246061
Row.addField
validation
public function addField($name, $value) { if (!array_key_exists($name, $this->row)) { $this->row[$name] = $value; } elseif (is_array($this->row[$name])) { $this->row[$name][] = $value; } else { $this->row[$name] = array($this->row[$name], $value); } $this->informChanges(); }
php
{ "resource": "" }
q246062
Row.getAsArray
validation
public function getAsArray($fieldName) { if (!array_key_exists($fieldName, $this->row)) { return []; } $result = $this->row[$fieldName]; if (empty($result)) { return []; } return (array)$result; }
php
{ "resource": "" }
q246063
Row.set
validation
public function set($name, $value) { if (!array_key_exists($name, $this->row)) { $this->addField($name, $value); } else { $this->row[$name] = $value; } $this->informChanges(); }
php
{ "resource": "" }
q246064
Row.removeField
validation
public function removeField($fieldName) { if (array_key_exists($fieldName, $this->row)) { unset($this->row[$fieldName]); $this->informChanges(); } }
php
{ "resource": "" }
q246065
Row.removeValue
validation
public function removeValue($fieldName, $value) { $result = $this->row[$fieldName]; if (!is_array($result)) { if ($value == $result) { unset($this->row[$fieldName]); $this->informChanges(); } } else { $qty = count($result); for ($i = 0; $i < $qty; $i++) { if ($result[$i] == $value) { unset($result[$i]); $this->informChanges(); } } $this->row[$fieldName] = array_values($result); } }
php
{ "resource": "" }
q246066
Row.replaceValue
validation
public function replaceValue($fieldName, $oldvalue, $newvalue) { $result = $this->row[$fieldName]; if (!is_array($result)) { if ($oldvalue == $result) { $this->row[$fieldName] = $newvalue; $this->informChanges(); } } else { for ($i = count($result) - 1; $i >= 0; $i--) { if ($result[$i] == $oldvalue) { $this->row[$fieldName][$i] = $newvalue; $this->informChanges(); } } } }
php
{ "resource": "" }
q246067
Row.getAsDom
validation
public function getAsDom() { if (is_null($this->node)) { $this->node = XmlUtil::createXmlDocumentFromStr("<row></row>"); $root = $this->node->getElementsByTagName("row")->item(0); foreach ($this->row as $key => $value) { if (!is_array($value)) { $field = XmlUtil::createChild($root, "field", $value); XmlUtil::addAttribute($field, "name", $key); } else { foreach ($value as $valueItem) { $field = XmlUtil::createChild($root, "field", $valueItem); XmlUtil::addAttribute($field, "name", $key); } } } } return $this->node; }
php
{ "resource": "" }
q246068
GoCardless_PreAuthorization.find
validation
public static function find($id) { $endpoint = self::$endpoint . '/' . $id; return new self(GoCardless::$client, GoCardless::$client->request('get', $endpoint)); }
php
{ "resource": "" }
q246069
GoCardless_PreAuthorization.create_bill
validation
public function create_bill($attrs) { if ( ! isset($attrs['amount'])) { throw new GoCardless_ArgumentsException('Amount required'); } $params = array( 'bill' => array( 'amount' => $attrs['amount'], 'pre_authorization_id' => $this->id ) ); if (isset($attrs['name'])) { $params['bill']['name'] = $attrs['name']; } if (isset($attrs['description'])) { $params['bill']['description'] = $attrs['description']; } if (isset($attrs['charge_customer_at'])) { $params['bill']['charge_customer_at'] = $attrs['charge_customer_at']; } $endpoint = GoCardless_Bill::$endpoint; return new GoCardless_Bill($this->client, $this->client->request('post', $endpoint, $params)); }
php
{ "resource": "" }
q246070
GoCardless_PreAuthorization.cancel
validation
public function cancel() { $endpoint = self::$endpoint . '/' . $this->id . '/cancel'; return new self($this->client, $this->client->request('put', $endpoint)); }
php
{ "resource": "" }
q246071
GoCardless_Merchant.find
validation
public static function find($id) { $client = GoCardless::$client; return new self($client, $client->request('get', self::$endpoint . '/' . $id)); }
php
{ "resource": "" }
q246072
GoCardless_Bill.retry
validation
public function retry() { $endpoint = self::$endpoint . '/' . $this->id . '/retry'; return new self($this->client, $this->client->request('post', $endpoint)); }
php
{ "resource": "" }
q246073
GoCardless_Bill.payout
validation
public function payout() { if (!$this->payout_id) { throw new GoCardless_ClientException("Cannot fetch payout for a bill that has not been paid out"); } return GoCardless_Payout::find_with_client($this->client, $this->payout_id); }
php
{ "resource": "" }
q246074
GoCardless_Client.authorize_url
validation
public function authorize_url($options = null) { if ( ! isset($options['redirect_uri'])) { throw new GoCardless_ArgumentsException('redirect_uri required'); } $required_options = array( "client_id" => $this->account_details['app_id'], "scope" => "manage_merchant", "response_type" => "code" ); $params = array_merge($required_options, $options); $request = GoCardless_Utils::generate_query_string($params); return $this->base_url . "/oauth/authorize/?" . $request; }
php
{ "resource": "" }
q246075
GoCardless_Client.fetch_access_token
validation
public function fetch_access_token($params) { if ( ! isset($params['redirect_uri'])) { throw new GoCardless_ArgumentsException('redirect_uri required'); } $params['http_authorization'] = $this->account_details['app_id'] . ':' . $this->account_details['app_secret']; $response = $this->request('post', '/oauth/access_token', $params); $merchant = explode(':', $response['scope']); $merchant_id = isset($merchant[1]) ? $merchant[1] : null; $access_token = $response['access_token']; return array( 'merchant_id' => $merchant_id, 'access_token' => $access_token ); }
php
{ "resource": "" }
q246076
GoCardless_Client.merchant
validation
public function merchant($id = null) { if ($id == null) { $id = $this->account_details['merchant_id']; } return GoCardless_Merchant::find_with_client($this, $id); }
php
{ "resource": "" }
q246077
GoCardless_Client.create_bill
validation
public function create_bill($params) { if ( ! isset($params['pre_authorization_id'])) { throw new GoCardless_ArgumentsException('pre_authorization_id missing'); } $pre_auth = new GoCardless_PreAuthorization($this, array( 'id' => $params['pre_authorization_id'] )); return $pre_auth->create_bill(array('amount' => $params['amount'])); }
php
{ "resource": "" }
q246078
GoCardless_Client.confirm_resource
validation
public function confirm_resource($params) { // Define confirm endpoint $endpoint = '/confirm'; // First validate signature // Then send confirm request // List of required params $required_params = array( 'resource_id', 'resource_type' ); // Loop through required params // Add to $data or throw exception if missing foreach ($required_params as $key => $value) { if ( ! isset($params[$value])) { throw new GoCardless_ArgumentsException("$value missing"); } $data[$value] = $params[$value]; } // state is optional if (isset($params['state'])) { $data['state'] = $params['state']; } // resource_uri is optional if (isset($params['resource_uri'])) { $data['resource_uri'] = $params['resource_uri']; } $sig_validation_data = array( 'data' => $data, 'secret' => $this->account_details['app_secret'], 'signature' => $params['signature'] ); if ($this->validate_signature($sig_validation_data) == false) { throw new GoCardless_SignatureException(); } // Sig valid, now send confirm request $confirm_params = array( 'resource_id' => $params['resource_id'], 'resource_type' => $params['resource_type'] ); // Use HTTP Basic Authorization $confirm_params['http_authorization'] = $this->account_details['app_id'] . ':' . $this->account_details['app_secret']; // If no method-specific redirect sent, use class level if available if ( ! isset($params['redirect_uri']) && isset($this->redirect_uri)) { $confirm_params['redirect_uri'] = $this->redirect_uri; } // Do query $response = $this->request('post', $endpoint, $confirm_params); if ($response['success'] == true) { $endpoint = '/' . $params['resource_type'] . 's/' . $params['resource_id']; $class_name = 'GoCardless_' . GoCardless_Utils::camelize($params['resource_type']); return new $class_name($this, $this->request('get', $endpoint)); } else { throw new GoCardless_ClientException('Failed to fetch the confirmed resource.'); } }
php
{ "resource": "" }
q246079
GoCardless_Client.new_limit_url
validation
public function new_limit_url($type, $params) { // $params are passed in // Optional $params are saved in $request and removed from $params // $params now only contains params for the payments // $payment_params is created containing sub-object named after $type // Merge $payment_params, $request and mandatory params // Sign // Generate query string // Return resulting url // Declare empty array $request = array(); // Add in merchant id $params['merchant_id'] = $this->account_details['merchant_id']; // Define optional parameters $opt_params = array( 'redirect_uri', 'cancel_uri', 'state' ); // Loop through optional parameters foreach ($opt_params as $opt_param) { if (isset($params[$opt_param])) { $request[$opt_param] = $params[$opt_param]; unset($params[$opt_param]); } } // If no method-specific redirect submitted then // use class level if available if ( ! isset($request['redirect_uri']) && isset($this->redirect_uri)) { $request['redirect_uri'] = $this->redirect_uri; } // Create array of payment params $payment_params = array($type => $params); // Put together all the bits: passed params inc payment params & mandatory $request = array_merge($request, $payment_params, $this->generate_mandatory_params()); // Generate signature $request['signature'] = GoCardless_Utils::generate_signature($request, $this->account_details['app_secret']); // Generate query string from all parameters $query_string = GoCardless_Utils::generate_query_string($request); // Generate url NB. Pluralises resource return $this->base_url . '/connect/' . $type . 's/new?' . $query_string; }
php
{ "resource": "" }
q246080
GoCardless_Client.request
validation
public function request($method, $endpoint, $params = array()) { // If there is no http_authorization, try checking for access_token if ( ! isset($params['http_authorization'])) { // No http_authorization and no access_token? Fail if ( ! isset($this->account_details['access_token'])) { throw new GoCardless_ClientException('Access token missing'); } // access_token found so set Authorization header to contain bearer $params['http_bearer'] = $this->account_details['access_token']; } // Set application specific user agent suffix if found if (isset($this->account_details['ua_tag'])) { $params['ua_tag'] = $this->account_details['ua_tag']; } if (substr($endpoint, 0, 6) == '/oauth') { // OAuth API calls don't require /api/v1 base $url = $this->base_url . $endpoint; } else { // http://sandbox.gocardless.com | /api/v1 | /test $url = $this->base_url . self::$api_path . $endpoint; } // Call Request class (might be aliased for testing) with URL & params return call_user_func(GoCardless::getClass('Request').'::'.$method, $url, $params); }
php
{ "resource": "" }
q246081
GoCardless_Client.validate_webhook
validation
public function validate_webhook($params) { $sig = $params['signature']; unset($params['signature']); if ( ! isset($sig)) { return false; } $data = array( 'data' => $params, 'secret' => $this->account_details['app_secret'], 'signature' => $sig ); return $this->validate_signature($data); }
php
{ "resource": "" }
q246082
GoCardless_Resource.fetch_sub_resource
validation
public function fetch_sub_resource($type, $params = array()) { // Generate subresource endpoint by snipping out the // right part of the sub_resource_uri $endpoint = preg_replace('/api\/v[0-9]+\//', '', parse_url($this->sub_resource_uris[$type], PHP_URL_PATH)); $sub_resource_params = array(); // Extract params from subresource uri if available and create // sub_resource_params array if ($param_string = parse_url($this->sub_resource_uris[$type], PHP_URL_QUERY)) { $split_params = explode('&', $param_string); foreach ($split_params as $split_param) { $parts = explode('=', $split_param); $sub_resource_params[$parts[0]] = $parts[1]; } } // Overwrite params from subresource uri with passed params, if found $params = array_merge($params, $sub_resource_params); // Get class name $class = 'GoCardless_' . GoCardless_Utils::camelize(GoCardless_Utils::singularize($type)); $objects = array(); // Create an array of objects foreach ($this->client->request('get', $endpoint, $params) as $value) { $objects[] = new $class($this->client, $value); } // Return the array of objects return $objects; }
php
{ "resource": "" }
q246083
GoCardless_Utils.generate_query_string
validation
public static function generate_query_string($params, &$pairs = array(), $namespace = null) { if (is_array($params)) { foreach ($params as $k => $v) { if (is_int($k)) { GoCardless_Utils::generate_query_string($v, $pairs, $namespace . '[]'); } else { GoCardless_Utils::generate_query_string($v, $pairs, $namespace !== null ? $namespace . "[$k]" : $k); } } if ($namespace !== null) { return $pairs; } if (empty($pairs)) { return ''; } usort($pairs, array(__CLASS__, 'sortPairs')); $strs = array(); foreach ($pairs as $pair) { $strs[] = $pair[0] . '=' . $pair[1]; } return implode('&', $strs); } else { $pairs[] = array(rawurlencode($namespace), rawurlencode($params)); } }
php
{ "resource": "" }
q246084
GoCardless_Utils.sortPairs
validation
public static function sortPairs($a, $b) { $keys = strcmp($a[0], $b[0]); if ($keys !== 0) { return $keys; } return strcmp($a[1], $b[1]); }
php
{ "resource": "" }
q246085
GoCardless_Utils.singularize
validation
public static function singularize($string) { if (substr($string, -1) == 's') { return substr($string, 0, -1); } elseif (substr($string, -1) == 'i') { return substr($string, 0, -1) . 'us'; } else { return $string; } }
php
{ "resource": "" }
q246086
GoCardless_Request.call
validation
protected static function call($method, $url, $params = array()) { // Initialize curl $ch = curl_init(); // Default curl options, including library & version number $curl_options = array( CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'gocardless-php/v' . GoCardless::VERSION, ); // Set application specific user agent suffix if found if (isset($params['ua_tag'])) { // Set the user agent header $curl_options[CURLOPT_USERAGENT] .= ' ' . $params['ua_tag']; // Remove ua_tag from $params as $params are used later unset($params['ua_tag']); } // Request format $curl_options[CURLOPT_HTTPHEADER][] = 'Accept: application/json'; // Enable SSL certificate validation. // This is true by default since libcurl 7.1. $curl_options[CURLOPT_SSL_VERIFYPEER] = true; // Debug - DO NOT USE THIS IN PRODUCTION FOR SECURITY REASONS // // This fixes a problem in some environments with connecting to HTTPS-enabled servers. // Sometimes, Curl has no list of valid CAs, and so won't connect. With this fix, it // doesn't verify and just connects anyway, instead of throwing an exception. // //$curl_options[CURLOPT_SSL_VERIFYPEER] = false; // HTTP Authentication (for confirming new payments) if (isset($params['http_authorization'])) { // Set HTTP Basic Authorization header $curl_options[CURLOPT_USERPWD] = $params['http_authorization']; // Unset http basic param as params are used later unset($params['http_authorization']); } else { // Throw an exception if access token is missing if ( ! isset($params['http_bearer'])) { throw new GoCardless_ClientException('Access token missing'); } // Set the authorization header $curl_options[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $params['http_bearer']; // Unset http_bearer param as params are used later unset($params['http_bearer']); } if ($method == 'post') { // Curl options for POSt $curl_options[CURLOPT_POST] = 1; if ( ! empty($params)) { $curl_options[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&'); } } elseif ($method == 'get') { // Curl options for GET $curl_options[CURLOPT_HTTPGET] = 1; if ( ! empty($params)) { $url .= '?' . http_build_query($params, null, '&'); } } elseif ($method == 'put') { // Curl options for PUT $curl_options[CURLOPT_PUT] = 1; // Receiving the following Curl error?: // "cannot represent a stream of type MEMORY as a STDIO FILE*" // Try changing the first parameter of fopen() to `php://temp` $fh = fopen('php://memory', 'rw+'); $curl_options[CURLOPT_INFILE] = $fh; $curl_options[CURLOPT_INFILESIZE] = 0; } // Set the url to query curl_setopt($ch, CURLOPT_URL, $url); // Debug //echo "<pre>\nCurl " . strtoupper($method) . " request to: $url\n"; //if (isset($curl_options[CURLOPT_POSTFIELDS])) { // echo "Post vars:\n"; // echo htmlspecialchars(print_r($curl_options[CURLOPT_POSTFIELDS], true)); // echo "\n"; //} //echo "Curl request config:\n"; //print_r($curl_options); //echo '</pre>'; // Set curl options curl_setopt_array($ch, $curl_options); // Send the request $result = curl_exec($ch); $error = curl_errno($ch); if ($error == CURLE_SSL_PEER_CERTIFICATE || $error == CURLE_SSL_CACERT || $error == 77) { curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cert-bundle.crt'); $result = curl_exec($ch); } // Debug //echo "<pre>\nCurl result config:\n"; //print_r(curl_getinfo($ch)); //echo "Curl result:\n"; //echo htmlspecialchars($result) . "\n"; //echo "</pre>"; // Grab the response code and throw an exception if it's not good $http_response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_response_code < 200 || $http_response_code > 300) { // Create a string $message = print_r(json_decode($result, true), true); // Throw an exception with the error message throw new GoCardless_ApiException($message, $http_response_code, $result); } // Close the connection curl_close($ch); // Close the $fh handle used by PUT if (isset($fh)) { fclose($fh); } // Return the response as an array return json_decode($result, true); }
php
{ "resource": "" }
q246087
ClassAliaser.register
validation
public static function register(array $aliases) { if (!$aliases) { return; } if (!isset(self::$autoloadFn)) { $classAliases = &self::$aliases; self::$autoloadFn = function ($className) use (&$classAliases) { if (isset($classAliases[$className])) { if (strtolower($classAliases[$className]) === strtolower($className)) { throw new \LogicException("Class alias is referencing the alias itself"); } $facadeClass = $classAliases[$className]; class_alias($facadeClass, $className); } }; spl_autoload_register(self::$autoloadFn); } self::$aliases = array_merge(self::$aliases, $aliases); }
php
{ "resource": "" }
q246088
ClassAliaser.unregister
validation
public static function unregister() { if (isset(self::$autoloadFn)) { spl_autoload_unregister(self::$autoloadFn); self::$autoloadFn = null; } self::$aliases = []; }
php
{ "resource": "" }
q246089
PathFinder.destinationsFor
validation
public function destinationsFor(string $filePath): array { $filePath = Path::canonicalize($filePath); $source = $this->matchingSource($filePath); return $this->resolveDestinations($filePath, $source); }
php
{ "resource": "" }
q246090
DriverCreator.createDriver
validation
protected function createDriver($driverClass): Driver\DriverInterface { return isset($this->container) ? $this->container->get($driverClass) : new $driverClass(); }
php
{ "resource": "" }
q246091
PrepareCounter.prepare
validation
public function prepare($value) { /** @var Importer $importer */ $importer = $this->getVariably()->get('importer'); $table = $importer->getCurrentTable(); if (!isset($this->counter[$table])) { $db = $importer->getDb(); $counter = $db->fetchOne('SELECT MAX(DISTINCT counter) AS counter FROM ' . $table); $this->counter[$table] = $counter['counter'] + 1; } return $this->counter[$table]; }
php
{ "resource": "" }
q246092
Importer.applyId
validation
protected function applyId(& $row, $id, $identifierField) { $ids = (array) $id; $findId = function ($row) use ($ids, $identifierField) { foreach ($ids as $id) { // Foton == FOTON $bool = true; $identifierField = $this->flatten($identifierField); foreach ($identifierField as $identifier) { $bool = $bool && (mb_strtolower($id[$identifier]) === mb_strtolower($row[$identifier])); } if ($bool) { return $id['id']; } } return 0; }; $isDeep = $this->isDeep($row); if ($isDeep) { foreach ($row as $i => & $r) { $r['id'] = $findId($r); } } else { $row['id'] = $findId($row); } }
php
{ "resource": "" }
q246093
Importer.getDriver
validation
public function getDriver($configTask, $source) { $driverFactory = $this->getDriverCreator(); /** @var DriverInterface $driver */ $driver = $driverFactory->create($configTask); $driver->source($source); if (method_exists($driver, 'getLogger') && $driver instanceof LoggerAwareInterface) { $this->logger = $driver->getLogger(); } return $driver; }
php
{ "resource": "" }
q246094
Importer.getCurrentRealRows
validation
public function getCurrentRealRows($table = null) { $table = $table ?: $this->getCurrentTable(); if (!isset($this->currentRealRows[$table]) || !$this->currentRealRows[$table]) { $fields = $this->getPreparedFields()[$table]; $this->currentRealRows[$table] = $this->getRealRow($fields, $table); } return $this->currentRealRows[$table]; }
php
{ "resource": "" }
q246095
Importer.profiling
validation
protected function profiling($signal = true) { static $timeStart; if ($signal) { $timeStart = microtime(true); } if (!$signal) { $this->timeExecution = (microtime(true) - $timeStart) / 60; return $this->timeExecution; } }
php
{ "resource": "" }
q246096
Importer.log
validation
public function log($level, $message, array $context = []) { static $counter = []; !$this->logger || $this->logger->log($level, $message, $context); // If message is exception convert it to string $message = is_object($message) ? $message->__toString() : $message; // Group identical messages with add suffix number if (isset($this->messages[$level][$hash = md5($message)])) { $this->messages[$level][$hash] = '(' . ++$counter[$hash] . ') ' . $message; } else { $counter[$hash] = 1; $this->messages[$level][$hash] = $message; } }
php
{ "resource": "" }
q246097
PaginationParams.setParams
validation
public function setParams($namespace, $params) { $session = new Container($namespace); $session->params = $params; unset($session->list); return $this; }
php
{ "resource": "" }
q246098
PaginationParams.getParams
validation
public function getParams($namespace, $defaults, $params = null) { $session = new Container($namespace); $sessionParams = $session->params ?: array(); $params = $params ?: clone $this->getController()->getRequest()->getQuery(); if ($params->get('clear')) { $sessionParams = array(); unset($params['clear']); } $changed = false; foreach ($defaults as $key => $default) { if (is_numeric($key)) { $key = $default; $default = null; } $value = $params->get($key); if (null === $value) { if (isset($sessionParams[$key])) { $params->set($key, $sessionParams[$key]); } elseif (null !== $default) { $params->set($key, $default); $sessionParams[$key] = $default; $changed = true; } } else { if (!isset($sessionParams[$key]) || $sessionParams[$key] != $value) { $changed = true; $sessionParams[$key] = $value; } } } if ($changed) { unset($session->list); $session->params = $sessionParams; } return $params; }
php
{ "resource": "" }
q246099
PaginationParams.getList
validation
public function getList($namespace, $callback) { $session = new Container($namespace); $params = $session->params?:array(); if (!$session->list) { $session->list = is_array($callback) ? call_user_func($callback, $session->params) : $callback->getPaginationList($session->params); } return $session->list; }
php
{ "resource": "" }